def order(table): sql = "select DISTINCT user_id, orderno, order_sn, amount, order_type, pay_url, status from {}" \ " where create_time BETWEEN '{}' and '{}' ".format(table, today, end_time) result_list = db_query(sql) for result in result_list: if result[6] == 0: status = '已失效' elif result[6] == 1: status = '待支付' elif result[6] == 2: status = '待发货' else: status = '已评价' if status == '已评价': evalute = '是' else: evalute = '否' data = { "name": result[0], "orderno": result[1], "order_sn": result[2], "amount": result[3], "order_type": result[4], "pay_url": result[5], "status": status, "evalute": evalute } url = 'http://127.0.0.1:8000/api/order/' response = requests.post(url, json=data) print(response.json())
def order_down(table): if table == 't_pdd_order': sql = "select DISTINCT user_id, amount, accesstoken, goods_url,order_number, orderno, notifyurl, sign, goods_id, callbackurl,extends, is_use from {}" \ " where create_time BETWEEN '{}' and '{}' ".format(table, today, end_time) else: sql = "select DISTINCT user_id, amount, kdtsessionid, goods_url,order_number, orderno, notifyurl, sign, goods_id, callbackurl,extends, is_use from {}" \ " where create_time BETWEEN '{}' and '{}' ".format(table, today, end_time) result_list = db_query(sql) for result in result_list: if result[11] == 0: is_use = '否' else: is_use = '是' data = { "name": result[0], "amount": result[1], "token": result[2], "goods_url": result[3], "goods_number": result[4], "orderno": result[5], "notifyurl": result[6], "sign": result[7], "order": is_use, "goods_id": result[8], "callbackurl": result[9], "extends": result[10] } url = 'http://127.0.0.1:8000/api/orderdown/' response = requests.post(url, json=data) print(response.json())
def evaluate(table): sql = "select distinct user_id, goods_id, goods_url, order_sn from {} where status=3 and create_time BETWEEN '{}' and '{}' ".format( table, today, end_time) result_list = db_query(sql) for result in result_list: data = { "name": result[0], "goods_id": result[1], "goods_url": result[2], "order_sn": result[3], "content": "商品太好了,买了几百次", "over": '是' } url = 'http://127.0.0.1:8000/api/evaluate/' response = requests.post(url, json=data) print(response.json())
def yz_pass_date(**kwargs): res = '' for k, v in kwargs.items(): res += v + '|' where_r = res.rstrip('|') q_sql = "select kdtsessionid, amount, goods_url, goods_id, orderno, order_number, user_id, notifyurl, callbackurl," \ " extends, sign, order_type, pay_url, order_sn, status, is_query, memberid, cookie, is_use, create_time, update_time from t_yz_order" \ " where create_time BETWEEN '{}' and '{}' ".format(where_r.split('|')[0], where_r.split('|')[1]) result_list = db_query(q_sql) # 将满足条件的数据删除 # d_sql = "delete from t_yz_order where create_time BETWEEN '{}' and '{}' ".format(where_r.split('|')[0], # where_r.split('|')[1]) # db_insert(d_sql) for result in result_list: r_result = r_dict(result) yz_rec.put(r_result) print(r_result)
def pdd_pass_field(**kwargs): res = '' for k, v in kwargs.items(): res += k + '=' + str(v) + " and " where_r = res.rstrip(' and ') # 查出满足条件的数据 q_sql = "select accesstoken, amount, goods_url, goods_id, orderno, order_number, user_id, notifyurl, callbackurl," \ " extends, sign, order_type, pay_url, order_sn, status, is_query, memberid, passid, is_use, create_time, update_time from t_pdd_order where {}".format( where_r) result_list = db_query(q_sql) # 将满足条件的数据删除 # d_sql = "delete from t_pdd_order where {}".format(where_r) # db_insert(d_sql) for result in result_list: r_result = r_dict(result) pdd_rec.put(r_result) print(r_result)
def pdd_pass_query(pdduid=None, orderno=None, order_sn=None): today = datetime.datetime.now().strftime('%Y-%m-%d') end_time = today + ' 23:59:59' if pdduid is None and orderno is None and order_sn is None: sql = "select orderno, status from t_pdd_order where create_time BETWEEN '{}' and '{}' ".format( today, end_time) elif pdduid is None and orderno is None and order_sn is not None: sql = "select orderno, status from t_pdd_order where order_sn='{}'".format( order_sn) elif pdduid is None and orderno is not None and order_sn is None: sql = "select orderno, status from t_pdd_order where orderno='{}'".format( orderno) elif pdduid is not None and orderno is None and order_sn is None: sql = "select orderno, status from t_pdd_order where user_id='{}'".format( pdduid) elif pdduid is not None and orderno is not None and order_sn is None: sql = "select orderno, status from t_pdd_order where user_id='{}' and orderno='{}'".format( pdduid, orderno) elif pdduid is not None and orderno is None and order_sn is not None: sql = "select orderno, status from t_pdd_order where user_id='{}' and order_sn='{}'".format( pdduid, order_sn) elif pdduid is None and orderno is not None and order_sn is not None: sql = "select orderno, status from t_pdd_order where orderno='{}' and order_sn='{}'".format( orderno, order_sn) else: sql = "select orderno, status from t_pdd_order where user_id='{}' and orderno='{}' and order_sn='{}'".format( pdduid, orderno, order_sn) try: q_result = db_query(sql) result = [] for j in q_result: result_dict = {} result_dict['code'] = 1 result_dict['orderno'] = j[0] result_dict['status'] = j[1] result.append(result_dict) if len(result) == 0: result = {'code': 0, 'msg': '未找到满足条件的订单!'} return result except: return {'code': 0, 'msg': '查询错误!'}