def put_order_info(): detail_ordid = request.args.get('uid', type=int) dorder = DetailOrder().query.filter_by(detailed_orderID=detail_ordid).first() status = request.args.get('status', type=str) if dorder == None or status == None: return jsonify({'status': 'fail'}) else: dorder.status = status db_app.session.commit() return jsonify({'status': 'success'})
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_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}})
def get_type(): args_dic = {} type1 = request.args.get('type1') type2 = request.args.get('type2') sellerid = request.args.get('sellerid', type=int) if type1: args_dic['type1'] = type1 if type2: args_dic['type2'] = type2 if sellerid: args_dic['oid'] = sellerid print(args_dic) type_list = Type.get_type(args_dic) print(len(type_list)) args_dic['types'] = [types['typeid'] for types in type_list] products = Product.get_product(args_dic) print(len(products)) args_dic['pid_list'] = [prod['uid'] for prod in products] products = DetailOrder.get_type_product(args_dic) print(len(products)) totals = 0 totaln = 0 for product in products: totals += product['totalprice'] totaln += product['totalnumber'] return jsonify({'data': {'totalsum': totals, 'totalnumber': totaln}})