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})
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}})