示例#1
0
def get_rst_bankcard_list(rst_id):
    arg_spec = {
        'status': Arg(int, allow_missing=True),
        'type_code': Arg(int, allow_missing=True),
        'page_size': Arg(int, allow_missing=True),
        'page_no': Arg(int, allow_missing=True)
    }
    args = args_parser.parse(arg_spec)
    status = args.get('status')
    type_code = args.get('type_code')
    page_no, page_size = get_paging_params()
    offset = (page_no - 1) * page_size
    limit = page_size
    rst_bankcard_list = bankcard_base \
        .query_bankcard(rst_id, status=status, limit=limit, offset=offset)
    rst_bankcard_list_new = [model2dict(m) for m in rst_bankcard_list]
    return {
        'bankcard_list':
        rst_bankcard_list_new,
        'total_num':
        bankcard_base.get_bankcard_count([
            rst_id,
        ],
                                         status=status,
                                         type_code=type_code)
    }
示例#2
0
def get_all_bankcard_list():
    arg_spec = {
        'search_text': Arg(),
        'status': Arg(int, allow_missing=True),
        'type_code': Arg(int, allow_missing=True),
    }
    args = args_parser.parse(arg_spec)
    search_text = args.pop('search_text')

    rst_ids = _filter_ids(search_text)

    args['rst_ids'] = rst_ids
    page_no, page_size = get_paging_params(paging_size=50)
    offset = (page_no - 1) * page_size
    limit = page_size
    args.update({"offset": offset, "limit": limit})
    bankcard_list = bankcard_base.query_by_status(**args)

    if not bankcard_list:
        return {
            'bankcard_list': [],
            'total_num': 0,
        }

    bankcard_list_new = []
    rst_set_ids = set()
    for bankcard in bankcard_list:
        bankcard_list_new.append(model2dict(bankcard))
        rst_set_ids.add(bankcard.rst_id)

    rst_map = rst_base.get_map(rst_set_ids)
    for bankcard in bankcard_list_new:
        bankcard.update({
            "restaurant_name": rst_map[bankcard['rst_id']].name,
        })

    return {
        'bankcard_list': bankcard_list_new,
        'total_num':
            bankcard_base.get_bankcard_count(
                rst_ids=rst_ids,
                status=args.get("status"),
                type_code=args.get("type_code")),
    }
示例#3
0
def get_all_bankcard_list():
    arg_spec = {
        'search_text': Arg(),
        'status': Arg(int, allow_missing=True),
        'type_code': Arg(int, allow_missing=True),
    }
    args = args_parser.parse(arg_spec)
    search_text = args.pop('search_text')

    rst_ids = _filter_ids(search_text)

    args['rst_ids'] = rst_ids
    page_no, page_size = get_paging_params(paging_size=50)
    offset = (page_no - 1) * page_size
    limit = page_size
    args.update({"offset": offset, "limit": limit})
    bankcard_list = bankcard_base.query_by_status(**args)

    if not bankcard_list:
        return {
            'bankcard_list': [],
            'total_num': 0,
        }

    bankcard_list_new = []
    rst_set_ids = set()
    for bankcard in bankcard_list:
        bankcard_list_new.append(model2dict(bankcard))
        rst_set_ids.add(bankcard.rst_id)

    rst_map = rst_base.get_map(rst_set_ids)
    for bankcard in bankcard_list_new:
        bankcard.update({
            "restaurant_name": rst_map[bankcard['rst_id']].name,
        })

    return {
        'bankcard_list':
        bankcard_list_new,
        'total_num':
        bankcard_base.get_bankcard_count(rst_ids=rst_ids,
                                         status=args.get("status"),
                                         type_code=args.get("type_code")),
    }
示例#4
0
def get_rst_bankcard_list(rst_id):
    arg_spec = {
        'status': Arg(int, allow_missing=True),
        'type_code': Arg(int, allow_missing=True),
        'page_size': Arg(int, allow_missing=True),
        'page_no': Arg(int, allow_missing=True)
    }
    args = args_parser.parse(arg_spec)
    status = args.get('status')
    type_code = args.get('type_code')
    page_no, page_size = get_paging_params()
    offset = (page_no - 1) * page_size
    limit = page_size
    rst_bankcard_list = bankcard_base \
        .query_bankcard(rst_id, status=status, limit=limit, offset=offset)
    rst_bankcard_list_new = [model2dict(m) for m in rst_bankcard_list]
    return {
        'bankcard_list': rst_bankcard_list_new,
        'total_num':
            bankcard_base.get_bankcard_count([rst_id, ],
                                             status=status,
                                             type_code=type_code)
    }