示例#1
0
文件: user.py 项目: liuzelei/walis
def get_user_by_phone(mobile):
    user_type = None
    result = {'user_type': CSEvent.USER_TYPE_OTHERS}
    rst = rst_base.get_by_mobile(mobile)
    if rst:
        user_type = CSEvent.USER_TYPE_MERCHANT
        result = {
            'user_type': user_type,
            'restaurant_id': rst.id,
            'restaurant_name': rst.name,
            'phone': rst.phone
        }

    user = user_base.get_by_mobile(mobile)
    if not user:
        return result

    result.update({'user_id': user.id, 'user_name': user.username})
    if user_type == CSEvent.USER_TYPE_MERCHANT:
        return result

    is_marketing = user_base.has_groups(
        user.id,
        ['region_director', 'city_director', 'entry_director']
    )
    if is_marketing:
        result.update({'user_type': CSEvent.USER_TYPE_MARKETING})
    else:
        result.update({'user_type': CSEvent.USER_TYPE_USER})

    return result
示例#2
0
def get_user_by_mobile():
    args = {
        'mobile':Arg(),
    }
    arg_spec = args_parser.parse(args)
    user = user_base.get_by_mobile(arg_spec['mobile'])
    return user or {}
示例#3
0
def get_user_by_phone(mobile):
    user_type = None
    result = {'user_type': CSEvent.USER_TYPE_OTHERS}
    rst = rst_base.get_by_mobile(mobile)
    if rst:
        user_type = CSEvent.USER_TYPE_MERCHANT
        result = {
            'user_type': user_type,
            'restaurant_id': rst.id,
            'restaurant_name': rst.name,
            'phone': rst.phone
        }

    user = user_base.get_by_mobile(mobile)
    if not user:
        return result

    result.update({'user_id': user.id, 'user_name': user.username})
    if user_type == CSEvent.USER_TYPE_MERCHANT:
        return result

    is_marketing = user_base.has_groups(
        user.id, ['region_director', 'city_director', 'entry_director'])
    if is_marketing:
        result.update({'user_type': CSEvent.USER_TYPE_MARKETING})
    else:
        result.update({'user_type': CSEvent.USER_TYPE_USER})

    return result