def get_topuser():
    args_dic = {}
    args_dic['start'] = request.args.get('start')
    args_dic['end'] = request.args.get('end')

    orders = Order.get_period_order(args_dic)
    args_dic['orderid_list'] = [order['orderid'] for order in orders]

    users = Order.get_user_sta(args_dic)

    return jsonify({'data': users})
def get_topseller():
    args_dic = {}
    args_dic['start'] = request.args.get('start')
    args_dic['end'] = request.args.get('end')

    orders = Order.get_period_order(args_dic)
    args_dic['orderid_list'] = [order['orderid'] for order in orders]

    args_dic['top_flag'] = True
    sellers = DetailOrder.get_seller_sta(args_dic)

    return jsonify({'data': sellers})
def get_seller_sta():
    args_dic = {}
    args_dic['start'] = request.args.get('start')
    args_dic['end'] = request.args.get('end')

    sellerid = request.args.get('sellerid', type=int)
    if sellerid:
        args_dic['oid'] = sellerid

    orders = Order.get_period_order(args_dic)
    args_dic['orderid_list'] = [order['orderid'] for order in orders]

    sellers = DetailOrder.get_seller_sta(args_dic)

    return jsonify({'data': sellers})
def get_total():
    args_dic = {}
    args_dic['start'] = request.args.get('start')
    args_dic['end'] = request.args.get('end')

    orders = Order.get_period_order(args_dic)
    args_dic['oid_list'] = [order['orderid'] for order in orders]

    detail_orders = DetailOrder.get_detail_order(args_dic)
    totals = 0
    totaln = 0
    for detail_order in detail_orders:
        totals += detail_order['price']
        totaln += detail_order['number']

    return jsonify({'data': {'totalsum': totals, 'totalnumber': totaln}})
def get_month():
    args_dic = {}
    args_dic['year'] = request.args.get('year', type=int)

    orders_list = Order.get_year_order(args_dic)
    mon_list = [
        'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
        'Nov', 'Dec'
    ]
    result_list = []
    for i, orders in enumerate(orders_list):
        return_dic = {}
        return_dic['month'] = mon_list[i]
        return_dic['ordernumber'] = len(orders)
        return_dic['totalprice'] = 0
        for order in orders:
            return_dic['totalprice'] += order['price']
        result_list.append(return_dic)

    return jsonify({'data': result_list})
Пример #6
0
def get_order_info():
    args_dic = {}
    sellerid = request.args.get('sellerid', type=int)
    orderid = request.args.get('orderid', type=int)
    userid = request.args.get('userid', type=int)
    if sellerid != None:
        args_dic['oid'] = sellerid
    if orderid != None:
        args_dic['orderid'] = orderid
    if userid != None:
        args_dic['uid'] = userid

    return_list = []
    orders = Order.get_order(args_dic)
    if sellerid != None:
        ordid_list = [x['orderid'] for x in orders]
        args_dic['oid_list'] = ordid_list
        return_list = DetailOrder.get_detail_order(args_dic)

    else:
        orderid_list = []
        for order in orders:
            orderid_list.append(order['orderid'])
        detail_orders = DetailOrder.get_detail_order({'oid_list': orderid_list})
        detail_orders_dic = {}
        for detail_order in detail_orders:
            order_id = detail_order.get('order_id')
            if detail_orders_dic.get(order_id) == None:
                detail_orders_dic[order_id] = [detail_order]
            else:
                detail_orders_dic[order_id].append(detail_order)
        for order in orders:
            order['detailorders'] = detail_orders_dic[order['orderid']]
            return_list.append(order)

    return jsonify({'data': return_list})