Esempio n. 1
0
def get_saler_list():
    u'''
    获取自己所在渠道、及管理的区分的促销人员信息 
    '''
    args = request.args
    if request.method == 'POST':
        args = request.form
    q = args.get('q')
    sales_depart_id = _int(args.get('sales_depart_id', ''))
    page = _int(args.get('page', ''))
    page = page if page else None
    page_size = _int(args.get('page_size', ''))
    page_size = page_size if page_size > 0 else None
    mobile = args.get('mobile', '')
    deleted = args.get('deleted', '')
    deleted = None if not deleted.isdigit() else _int(deleted)
    user = request.environ['user']
    channel_id = user.user_info['channel_id']
    charge_departs = user.user_info['charge_departs']
    if sales_depart_id:
        ids = [sales_depart_id] if sales_depart_id in charge_departs else []
    else:
        ids = charge_departs
    rows = salersvc.get_saler_list(q=q,
                                   channel_id=channel_id,
                                   deleted=deleted,
                                   sales_depart_ids=ids,
                                   page=page,
                                   page_size=page_size,
                                   mobile=mobile)
    return {
        'salers': rows,
    }
Esempio n. 2
0
def plan_audit():
    args = request.args
    if request.method == 'POST':
        args = request.form
    user = request.environ['user']
    channel_id = user.user_info['channel_id']
    charge_departs = user.user_info['charge_departs']
    selected_plan = args.get('selectedPlan', '')
    status = args.get('status', '')
    cnt, msg = 0, ''
    try:
        selected_plan = selected_plan.split(',')
        for s in range(len(selected_plan)):
            selected_plan[s] = _int(selected_plan[s])
        status_id = _int(status)
        if status_id == 2:
            status = [1, 4]
        elif status_id == 4:
            status = [1, 2]
        else:
            raise Abort(u'请求的状态错误')
        cnt = plansvc.plan_audit(status_id=status_id,
                                 status=status,
                                 channel_id=channel_id,
                                 charge_departs=charge_departs,
                                 selected_plan=selected_plan)
        msg = '提交' + str(len(selected_plan)) + '行,成功' + str(cnt) + '行。'
    except ValueError:
        msg = u'请求的数据错误'
    except Abort, e:
        msg = e.msg
Esempio n. 3
0
def admin_set_info():
    u'''
    管理员设置渠道
    '''
    args = request.args
    if request.method == 'POST':
        args = request.form
    channel_id = _int(args.get('channel_id', ''))
    sales_depart_id = _int(args.get('sales_depart_id', ''))
    user = request.environ['user']
    result, msg = False, ''
    try:
        if not channel_id or not sales_depart_id:
            raise Abort(u'无效渠道id或区分id')
        channels = usersvc.get_channels(top=True)
        _channel = [c for c in channels if c['channel_id'] == channel_id]
        if not _channel:
            raise Abort(u'设置的渠道不存在')
        _depart = [
            d for d in _channel[0]['departs']
            if d['sales_depart_id'] == sales_depart_id
        ]
        if not _depart:
            raise Abort(u'设置的渠道和区分错误')
        result = usersvc.set_user_sales_info(user.user_id, channel_id,
                                             sales_depart_id)
        if result:
            user.user_info = usersvc.get_user_local_info(user.user_id)
            user.save_to_session()
    except Abort, e:
        msg = e.msg
Esempio n. 4
0
def pos_audit():
    args = request.args
    if request.method == 'POST':
        args = request.form
    user = request.environ['user']
    channel_id = user.user_info['channel_id']
    charge_departs = user.user_info['charge_departs']
    selectedPoi = args.get('selectedPoi', '')
    status = _int(args.get('status', ''))
    queryStatus = []
    if status == 2:
        queryStatus = [1, 4]
    elif status == 4:
        queryStatus = [1, 2]
    cnt, msg = 0, ''
    if selectedPoi and isinstance(selectedPoi, unicode):
        selectedPoi = selectedPoi.encode().split(',')
        try:
            for s in range(len(selectedPoi)):
                selectedPoi[s] = _int(selectedPoi[s])
            cnt = possvc.pos_audit(selectedPoi=selectedPoi,
                                   status=status,
                                   queryStatus=queryStatus)
            msg = '提交' + str(len(selectedPoi)) + '行,成功' + str(cnt) + '行。'
        except ValueError:
            msg = u'请提供正确的促销点ID'
    else:
        msg = u'促销点Id不符合要求'
    return {'cnt': cnt, 'msg': msg}
Esempio n. 5
0
def update_pos():
    u'''
    可以用作删除
    更新 keys 里的字段
    只能更新数据权限范围内的数据
    渠道不能更改
    区分只能改到自己权限范围内 
    '''
    keys = (
        'pos_type',
        'sales_id',
        'pos_name',
        'pos_address',
        #'channel_id',
        'sales_depart_id',
        'deleted',
        'pos_man',
        'pos_man_mobile',
        'pos_unit',
        'pos_code',
        'geo_data',
    )
    args = request.args
    if request.method == 'POST':
        args = request.form
    pos_id = _int(args.get('pos_id', ''))
    result, msg = False, ''
    user = request.environ['user']
    try:
        if not pos_id:
            raise Abort(u'pos_id invalid.')
        items = {}
        for k in keys:
            val = args.get(k, '')
            if val:
                if k in ('sales_depart_id', ):
                    val = _int(val)
                if not val:
                    raise Abort(u'%s invalid' % k)
                items[k] = val
        if not len(items.keys()):
            raise Abort(u'请指定更新字段.')
        mobile = items.get('pos_man_mobile')
        if mobile and (len(mobile) != 11 or not mobile.isdigit()):
            raise Abort(u'手机号码不正确.')
        pos, cnt = possvc.get_pos_list(pos_id=pos_id)
        if not pos:
            raise Abort(u'更新项不存在.')
        pos = pos[0]
        if pos['channel_id'] != user.user_info['channel_id'] or\
            pos['sales_depart_id'] not in user.user_info['charge_departs']\
            or ('sales_depart_id' in items and items['sales_depart_id']\
                not in user.user_info['charge_departs']) :
            raise Abort(u'无权更新.')
        items['update_user_id'] = user.user_id
        items['pos_id'] = pos_id
        result = possvc.update_pos(items)
    except Abort, e:
        msg = e.msg
Esempio n. 6
0
def audit():
    args = request.args
    if request.method == 'POST':
        args = request.form
    plan_id = _int(args.get('plan_id', ''))
    status = _int(args.get('status', ''))
    result, msg = False, u''
    user = request.environ['user']
    try:
        if not plan_id or not status:
            raise Abort(u'')
        update_info = {
            'plan_id': plan_id,
            'status': status,
            'audit_user_id': user.user_id
        }
        result = plansvc.update_plan(update_info)
    except Abort, e:
        msg = e.msg
Esempio n. 7
0
def update_saler():
    u'''
    更新, 各渠道只能更新各渠道的数据
    区分也限定
    '''
    args = request.args
    if request.method == 'POST':
        args = request.form
    user = request.environ['user']
    mobile = args.get('mobile', '')
    channel_id = args.get('channel_id', '')
    channel_id = _int(channel_id) if channel_id else ''
    sales_depart_id = args.get('sales_depart_id', '')
    sales_depart_id = _int(sales_depart_id) if sales_depart_id else ''
    saler_name = args.get('saler_name', '')
    unit = args.get('unit', '')
    deleted = args.get('deleted', '')
    deleted = _int(deleted) if deleted else ''
    update_user_id = user.user_id
    result, msg = False, ''
    try:
        print sales_depart_id, user.user_info['charge_departs']
        if sales_depart_id and channel_id:
            depart_info = get_depart_list(sales_depart_id=sales_depart_id)
            if depart_info[0]['channel_id'] != channel_id:
                raise Abort(u'设置的渠道与区分不符合')

        elif sales_depart_id:
            if sales_depart_id not in user.user_info['charge_departs']:
                raise Abort(u'设置的区分不符合')

        result = salersvc.update_saler(mobile=mobile,
                                       channel_id=channel_id,
                                       sales_depart_id=sales_depart_id,
                                       saler_name=saler_name,
                                       unit=unit,
                                       deleted=deleted,
                                       update_user_id=update_user_id)
    except Abort, e:
        msg = e.msg
Esempio n. 8
0
def add_pos():
    u'''
    添加,  
    todo: 负责人信息
    '''
    keys = (
        'pos_type',
        'sales_id',
        'pos_name',
        'pos_address',
        'pos_man',
        'pos_man_mobile',
        #'channel_id', 'deleted',
        'sales_depart_id',
        'pos_unit',
        'pos_code',
        'geo_data',
    )
    args = request.args
    if request.method == 'POST':
        args = request.form
    user = request.environ['user']
    channel_id = user.user_info['channel_id']
    charge_departs = user.user_info['charge_departs']
    items = {'channel_id': channel_id, 'create_user_id': user.user_id}
    for k in keys:
        val = args.get(k, '')
        if not val:
            continue
        items[k] = val
    result, msg, pos_id = False, '', None
    try:
        if not items.get('pos_name'):
            raise Abort(u'促销点名称不能为空.')
        if not items.get('pos_man'):
            raise Abort(u'促销负责任不能为空.')
        mobile = items.get('pos_man_mobile')
        if not mobile or len(mobile) != 11 or not mobile.isdigit():
            raise Abort(u'请提供正确的手机号.')
        name_check, _ = possvc.get_pos_list(pos_name=items.get('pos_name'))
        if name_check:
            raise Abort(u'促销点名称已存在.')
        items['sales_depart_id'] = _int(items.get('sales_depart_id', ''))
        if not items['sales_depart_id']:
            raise Abort(u'请指定正确的区分信息.')
        if items['sales_depart_id'] not in charge_departs:
            raise Abort(u'无权添加改区分的促销点信息.')
        pos_id = possvc.add_pos(items)
        result = True if pos_id else False
    except Abort, e:
        msg = e.msg
Esempio n. 9
0
def admin_get_user():
    args = request.args
    if request.method == 'POST':
        args = request.form
    sales_depart_id = _int(args.get('sales_depart_id', ''))
    query = args.get('query')
    user = request.environ["user"]
    channel_id = user.user_info['channel_id']
    charge_departs = user.user_info["charge_departs"]
    charge_departs = tuple(charge_departs)  #后台直接限制查询范围
    return {
        "users":
        usersvc.get_users(channel_id, charge_departs, sales_depart_id, query)
    }
Esempio n. 10
0
def get_pos_list():
    u'''
    查的数据权限限定在自己所在的渠道、负责的区分
    '''
    args = request.args
    if request.method == 'POST':
        args = request.form
    user = request.environ['user']
    q = args.get('query', '')
    pos_id = _int(args.get('pos_id', ''))
    pos_type = args.get('pos_type', '')
    pos_name = args.get('pos_name', '')
    sales_depart_id = _int(args.get('sales_depart_id', ''))
    deleted = args.get('deleted', '')
    pageCurrent = args.get('pageCurrent', '')
    pageSize = args.get('pageSize', '')
    pageSize = None if not pageSize else _int(pageSize)
    pageCurrent = None if not pageCurrent else _int(pageCurrent)
    deleted = -1 if not deleted.isdigit() else _int(deleted)
    channel_id = user.user_info['channel_id']
    charge_departs = user.user_info['charge_departs']
    located = args.get('located', '')
    located = _int(located) if located else None
    is_charge = args.get('is_charge', '')
    if is_charge:
        if _int(is_charge) == 0:
            is_charge = '无租金'
        elif _int(is_charge) == 1:
            is_charge = '有租金'
        else:
            is_charge = None
    if sales_depart_id:
        ids = [sales_depart_id] if sales_depart_id in charge_departs else []
    else:
        ids = charge_departs
    rows, cnt = possvc.get_pos_list(q=q,
                                    channel_id=channel_id,
                                    pos_id=pos_id,
                                    pos_type=pos_type,
                                    pos_name=pos_name,
                                    sales_depart_ids=ids,
                                    deleted=deleted,
                                    pageCurrent=pageCurrent,
                                    pageSize=pageSize,
                                    located=located,
                                    is_charge=is_charge)
    return {'rows': rows, 'cnt': cnt}
Esempio n. 11
0
def pos_audit_list():
    args = request.args
    if request.method == 'POST':
        args = request.form
    user = request.environ['user']
    channel_id = user.user_info["channel_id"]
    charge_departs = user.user_info["charge_departs"]
    pageCurrent = args.get('pageCurrent', '')
    pageSize = args.get('pageSize', '')
    sales_depart_id = _int(args.get('sales_depart_id', ''))
    selectedTag = args.get('selectedTag', '')
    status_id = _int(args.get('status_id', ''))
    queryPoi = args.get('queryPoi', '')
    queryMan = args.get('queryMan', '')
    if pageCurrent and pageSize:
        try:
            pageCurrent = _int(pageCurrent)
            pageSize = _int(pageSize)
        except ValueError:
            msg = u'分页内容应为整数'
    else:
        pageCurrent = None
        pageSize = None
    rows, cnt, result, msg = [], 0, False, ''
    try:
        rows, cnt = possvc.get_audit_list(channel_id=channel_id,
                                          charge_departs=charge_departs,
                                          pageCurrent=pageCurrent,
                                          pageSize=pageSize,
                                          sales_depart_id=sales_depart_id,
                                          selectedTag=selectedTag,
                                          status_id=status_id,
                                          queryPoi=queryPoi,
                                          queryMan=queryMan)

    except Abort, e:
        msg = e.msg
Esempio n. 12
0
def set_sales_info():
    u'''
    第一次登入需要设置 渠道, 区分信息
    市公司管理不能通过此接口设置 
    '''
    args = request.args
    if request.method == 'POST':
        args = request.form
    channel_id = _int(args.get('channel_id', ''))
    sales_depart_id = _int(args.get('sales_depart_id', ''))
    user = request.environ['user']
    result, msg = False, ''
    try:
        if not channel_id or not sales_depart_id:
            raise Abort(u'无效渠道id或区分id')
        # 检查是否已设置过
        user_info = usersvc.get_user_local_info(user.user_id)
        if user_info['channel_id'] or user_info['sales_depart_id']:
            raise Abort(u'已设置过渠道和区分信息(修改请联系管理人员)')
        # 检查渠道和区分对应关系
        channels = usersvc.get_channels()
        _channel = [c for c in channels if c['channel_id'] == channel_id]
        if not _channel:
            raise Abort(u'设置的渠道不存在')
        _depart = [
            d for d in _channel[0]['departs']
            if d['sales_depart_id'] == sales_depart_id
        ]
        if not _depart:
            raise Abort(u'设置的渠道和区分错误')
        result = usersvc.set_user_sales_info(user.user_id, channel_id,
                                             sales_depart_id)
        if result:
            user.user_info = usersvc.get_user_local_info(user.user_id)
            user.save_to_session()
    except Abort, e:
        msg = e.msg
Esempio n. 13
0
def get_plan_list():
    args = request.args
    if request.method == 'POST':
        args = request.form
    user = request.environ['user']
    channel_id = user.user_info['channel_id']
    charge_departs = tuple(user.user_info['charge_departs'])
    pageCurrent = _int(args.get('pageCurrent', ''))
    pageSize = _int(args.get('pageSize', ''))
    sales_dates = args.get('sales_dates', '')
    status_id = args.get('status_id', '')
    status_id = None if not status_id else status_id.encode().split(',')
    if status_id:
        for s in range(len(status_id)):
            status_id[s] = _int(status_id[s])
    sales_dates = None if not sales_dates else sales_dates.encode().split(',')
    sales_depart_id = _int(args.get('sales_depart_id', ''))
    pos_type = args.get('pos_type', '')
    pos_type = None if not pos_type else pos_type
    is_charge = args.get('is_charge')
    is_charge = None if not is_charge else is_charge
    queryPos = args.get('queryPos')
    queryPos = None if not queryPos else queryPos
    rows, cnt = plansvc.get_plan_list(
        status=status_id,
        channel_id=channel_id,
        page=pageCurrent,
        page_size=pageSize,
        sales_date=sales_dates,
        charge_departs=charge_departs,
        sales_depart_id=sales_depart_id,
        pos_type=pos_type,
        is_charge=is_charge,
        queryPos=queryPos,
    )
    return {'rows': rows, 'count': cnt}
Esempio n. 14
0
def pos_import():
    args = request.args
    if request.method == 'POST':
        args = request.form
    user = request.environ['user']
    channel_id = user.user_info['channel_id']
    charge_departs = user.user_info['charge_departs']

    rows = args.get('rows', '')
    sales_depart_id = _int(args.get('sales_depart_id', ''))
    pos_type = args.get('pos_type', '')
    result, msg, cnt, result_sms_users = False, '', 0, 0
    # 单元	促销点ID	代码点	门店名称	门店地址	负责人姓名	负责人电话
    try:
        if not pos_type:
            raise Abort(u'请指定类型.')
        rows = json.loads(rows)
        _check(rows)
        rows = filter(lambda r: r.get('status') == 3, rows)
        datas = [r['data'][:9] for r in rows]
        keys = [
            'sales_depart_id', 'pos_unit', 'sales_id', 'pos_code', 'pos_name',
            'pos_address', 'pos_man', 'pos_man_mobile', 'is_charge'
        ]
        datas = [dict(zip(keys, d)) for d in datas]
        update_sms_users = []
        for d in datas:
            d['create_user_id'] = user.user_id
            d['channel_id'] = channel_id
            d['pos_type'] = pos_type
            match = False
            for u in update_sms_users:
                if u.has_key('pos_man_mobile'
                             ) and u['pos_man_mobile'] == d['pos_man_mobile']:
                    match = True
                    break
            if not match:
                update_sms_users.append(d)
        result = possvc.pos_import(datas)
        result_sms_users = possvc.sms_user_import(update_sms_users)
    except ValueError, e:
        msg = u'请提供JSON格式数据.(loads error) '
Esempio n. 15
0
def add_saler():
    u'''
    更新, 各渠道只能更新各渠道的数据
    区分也限定
    '''
    args = request.args
    if request.method == 'POST':
        args = request.form
    keys = (
        'mobile',
        'saler_name',  #'channel_id',
        'sales_depart_id',
        'unit',  #'create_user_id'
    )
    user = request.environ['user']
    channel_id = user.user_info['channel_id']  # 限定只能添加自己渠道的
    charge_departs = user.user_info['charge_departs']
    saler = {'channel_id': channel_id, 'create_user_id': user.user_id}
    for k in keys:
        val = args.get(k, '')
        saler[k] = val
    sales_depart_id = _int(saler['sales_depart_id'])
    saler['sales_depart_id'] = sales_depart_id
    result, msg = False, ''
    try:
        mobile = saler['mobile']
        if not mobile.isdigit() or len(mobile) != 11:
            raise Abort(u'请提供正确的手机号')
        if not saler['saler_name']:
            raise Abort(u'促销人员姓名不能为空')
        if not saler['sales_depart_id']:
            raise Abort(u'促销人员区分不能为空')
        if saler['sales_depart_id'] not in charge_departs:
            raise Abort(u'无权添加人员到该区分')
        check = salersvc.get_saler_list(mobile=mobile)
        if len(check):
            msg = u'手机号码已存在请作更新操作(若无法查询到该记录请联系管理员)'
            raise Abort(msg)
        result = salersvc.add_saler(saler)
    except Abort, e:
        msg = e.msg
Esempio n. 16
0
def admin_alter_user():
    args = request.args
    if request.method == 'POST':
        args = request.form
    result, msg = False, ''
    try:
        user_id = args.get('user_id', '')
        SetUser = usersvc.get_user_local_info(user_id)
        privs = copy.copy(SetUser['privs'] if SetUser['privs'] else [])
        AdminUser = request.environ['user']
        if not user_id or not SetUser:
            raise Abort(u'设置的用户不存在')
        if 'PRIV_ADMIN_SUPER' in privs or \
                ('PRIV_ADMIN_SUPER' not in AdminUser.user_info['privs'] and 'PRIV_ADMIN' in privs) :
            raise Abort(u'不能越级更改系统管理员的信息')

        channel_id = args.get('channel_id', '')
        channel_id = _int(channel_id) if channel_id else None
        channel_id = channel_id if channel_id != SetUser['channel_id'] else None
        sales_depart_id = args.get('sales_depart_id', None)
        sales_depart_id = _int(sales_depart_id) if sales_depart_id else None
        sales_depart_id = sales_depart_id if sales_depart_id != SetUser[
            'sales_depart_id'] else None
        user_name = args.get('user_name', None)
        user_name = user_name if user_name != SetUser['user_name'] else None
        if channel_id and 'PRIV_ADMIN_SUPER' not in AdminUser.user_info[
                'privs'] and channel_id != AdminUser.user_info['channel_id']:
            raise Abort(u'非超级管理员不能更改渠道')
        if sales_depart_id and 'PRIV_ADMIN_SUPER' not in AdminUser.user_info[
                'privs'] and sales_depart_id not in AdminUser.user_info[
                    'charge_departs']:
            raise Abort(u'非超级管理员不能夸越渠道变更区分')
        if sales_depart_id and channel_id:
            depart_info = usersvc.get_depart_list(
                sales_depart_id=sales_depart_id)
            if depart_info[0]['channel_id'] != channel_id:
                raise Abort(u'设置的渠道与区分不符合')

        PRIV_ADMIN = args.get('PRIV_ADMIN', None)
        if PRIV_ADMIN: privs = privsUpdate(privs, 'PRIV_ADMIN', PRIV_ADMIN)
        PRIV_ADMIN_POS = args.get('PRIV_ADMIN_POS', None)
        if PRIV_ADMIN_POS:
            privs = privsUpdate(privs, 'PRIV_ADMIN_POS', PRIV_ADMIN_POS)
        PRIV_ADMIN_SALE = args.get('PRIV_ADMIN_SALE', None)
        if PRIV_ADMIN_SALE:
            privs = privsUpdate(privs, 'PRIV_ADMIN_SALE', PRIV_ADMIN_SALE)
        PRIV_PLAN = args.get('PRIV_PLAN', None)
        if PRIV_PLAN: privs = privsUpdate(privs, 'PRIV_PLAN', PRIV_PLAN)
        PRIV_ADMIN_DATA = args.get('PRIV_ADMIN_DATA', None)
        if PRIV_ADMIN_DATA:
            privs = privsUpdate(privs, 'PRIV_ADMIN_DATA', PRIV_ADMIN_DATA)
        PRIV_PLAN_AUDIT = args.get('PRIV_PLAN_AUDIT', None)
        if PRIV_PLAN_AUDIT:
            privs = privsUpdate(privs, 'PRIV_PLAN_AUDIT', PRIV_PLAN_AUDIT)
        privs = '{' + ','.join(
            privs) + '}' if privs != SetUser['privs'] else None

        tags = copy.copy(SetUser['tags'] if SetUser['tags'] else [])
        TAG_1 = args.get(u'1', None)
        if TAG_1 == 'true' and 1 not in tags:
            tags.append(1)
        elif TAG_1 == 'false' and 1 in tags:
            tags.remove(1)
        TAG_2 = args.get(u'2', None)
        if TAG_2 == 'true' and 2 not in tags:
            tags.append(2)
        elif TAG_2 == 'false' and 2 in tags:
            tags.remove(2)
        tags = '{' + ','.join(map(
            str, tags)) + '}' if tags != SetUser['tags'] else None
        if channel_id or sales_depart_id or user_name or privs or tags:
            usersvc.set_user_all(
                user_id=user_id,
                adminuser_id=AdminUser.user_info['user_id'],
                channel_id=channel_id,
                sales_depart_id=sales_depart_id,
                user_name=user_name,
                privs=privs,
                tags=tags,
            )
            result = True
        else:
            raise Abort(u'没有更新的内容')
    except Abort, e:
        msg = e.msg
Esempio n. 17
0
def _check(rows):
    user = request.environ['user']
    channel_id = user.user_info['channel_id']
    charge_departs = user.user_info['charge_departs']
    for row in rows:
        pos_id = row.get('pos_id')
        mobiles = row.get('saler_mobiles')
        sales_date = row.get('sales_date')
        sale_hour = row.get('sale_hour')
        if _int(sales_date) < _int(dt.now().strftime('%Y%m%d')):
            row['msg'] = u'排产日期不能小于当前时间'
            row['status'] = 4
            continue
        plans, _ = plansvc.get_plan_list(sales_date=sales_date,
                                         pos_id=pos_id,
                                         status=[1, 2])
        if plans:
            plan = plans[0]
            if plan['status'] == 1:
                row['msg'] = '已排产(继续将删除之前排产)'
            if plan['status'] == 2:
                row['msg'] = '已排产并审核通过.'
                row['status'] = 4
                continue
        saler_cnt = row.get('saler_cnt')
        if not pos_id or not mobiles or not sales_date\
                        or not saler_cnt:
            row['msg'] = '数据不完整'
            row['status'] = 4
            continue
        _pos, _ = possvc.get_pos_list(channel_id=channel_id,
                                      sales_depart_ids=charge_departs,
                                      pos_id=pos_id,
                                      deleted=0)
        salers = salersvc.get_saler_list(channel_id=channel_id,
                                         sales_depart_ids=charge_departs,
                                         deleted=0,
                                         mobiles=mobiles)
        row['salers'] = salers
        if not _pos:
            row['msg'] = '促销点不存在.'
            row['status'] = 4
            continue
        row['pos'] = _pos[0]
        if not salers or len(salers) != len(mobiles):
            row['msg'] = '促销人员不存在.'
            row['status'] = 4
            continue
        row['status'] = 3
        if sale_hour and len(sale_hour) < 100:
            sale_hour = sale_hour.split(',')
            for h in range(len(sale_hour)):
                if sale_hour[h] in sale_hour[h + 1:]:
                    row['msg'] = '促销时间重复'
                    row['status'] = 4
                try:
                    s = int(sale_hour[h])
                except:
                    s = 0
                    row['msg'] = '促销时间不是整数'
                    row['status'] = 4
                if s not in range(0, 24):
                    row['msg'] = '促销时间范围超出0-23'
                    row['status'] = 4
        else:
            row['msg'] = '促销时间错误!'
            row['status'] = 4
    return rows