|
@@ -107,7 +107,7 @@ def parse_yg_data(vip_id,stage):
|
|
|
"user_id,order_time,reg_time,amount,from_novel,order_id) values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",tuple(insert_data))
|
|
|
|
|
|
|
|
|
-def get_hs_channel(account):
|
|
|
+def get_hs_order_task(start, end, account):
|
|
|
url = 'https://vip.rlcps.cn/api/getMerchants'
|
|
|
apiKey = str(account[0])
|
|
|
apiSecurity = account[1]
|
|
@@ -122,11 +122,25 @@ def get_hs_channel(account):
|
|
|
response_result_json = requests.post(url, params).json()
|
|
|
if 'data' not in response_result_json.keys():
|
|
|
print('花生账号【{apiKey}】本次请求数据异常,响应报文【{result}】'.format(apiKey=apiKey, result=response_result_json))
|
|
|
- return
|
|
|
- return response_result_json['data']
|
|
|
|
|
|
-def get_huasheng_order_task(start,end, account, merchant,li):
|
|
|
- count=0
|
|
|
+ channel_data = response_result_json['data']
|
|
|
+
|
|
|
+ print(f"花生账号:{account[2]} 有channel{len(channel_data)}个:{str([i['merchant_name'] for i in channel_data])}")
|
|
|
+
|
|
|
+ li = []
|
|
|
+ for merchant in channel_data:
|
|
|
+ get_huasheng_order(start, end, account, merchant, li)
|
|
|
+
|
|
|
+ if len(li) > 0:
|
|
|
+ print(f"花生账号:{account[2]} 有order{len(li)}个")
|
|
|
+ # print(li)
|
|
|
+ db.quchen_text.executeMany("replace into ods_order values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",li)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+def get_huasheng_order(start,end, account, merchant,li):
|
|
|
+
|
|
|
apiKey = str(account[0])
|
|
|
apiSecurity = account[1]
|
|
|
stage = account[2]
|
|
@@ -154,6 +168,7 @@ def get_huasheng_order_task(start,end, account, merchant,li):
|
|
|
}
|
|
|
r = requests.post(order_url, order_params)
|
|
|
# print(r.text)
|
|
|
+
|
|
|
response_result_json = r.json()
|
|
|
|
|
|
if 'data' not in response_result_json.keys():
|
|
@@ -165,39 +180,36 @@ def get_huasheng_order_task(start,end, account, merchant,li):
|
|
|
if len(response_result_json['data']) == 0:
|
|
|
break
|
|
|
|
|
|
- total_count = response_result_json['count']
|
|
|
order_item_list = response_result_json['data']
|
|
|
+ if len(order_item_list) == 0:
|
|
|
+ break
|
|
|
|
|
|
- for order_item in order_item_list:
|
|
|
- if order_item['order_status'] == 1: # 1为已支付
|
|
|
- order = {}
|
|
|
- order['user_id'] = order_item['openid']
|
|
|
- order['order_id'] = order_item['trans_id']
|
|
|
- order['order_time'] = order_item['pay_at']
|
|
|
- order['reg_time'] = order_item['join_at']
|
|
|
- order['channel'] = merchant_name
|
|
|
- order['channel_id'] = merchant_id
|
|
|
- order['platform'] = '花生'
|
|
|
- order['stage'] = stage
|
|
|
- order['from_novel'] = order_item['book_name']
|
|
|
- order['amount'] = order_item['amount']
|
|
|
- order["date"]=int(time.mktime(time.strptime(order_item['pay_at'][:10],"%Y-%m-%d")))
|
|
|
- order = sorted(order.items(), key=lambda item: item[0])
|
|
|
- order = dict(order)
|
|
|
- order = tuple(order.values())
|
|
|
- if order.__len__()>0:
|
|
|
- li.append(order)
|
|
|
- count+=1
|
|
|
-
|
|
|
- if int(page) >= math.ceil(total_count / int(limit)):
|
|
|
+ for i in order_item_list:
|
|
|
+ li.append(
|
|
|
+ (i['request_at'][:10],
|
|
|
+ stage,
|
|
|
+ '花生',
|
|
|
+ merchant_name,
|
|
|
+ merchant_id,
|
|
|
+ i['openid'],
|
|
|
+ i['request_at'],
|
|
|
+ i['join_at'],
|
|
|
+ i['amount'],
|
|
|
+ i['book_name'],
|
|
|
+ i['trans_id'] if i['trans_id'] != '' else i['order_num'],
|
|
|
+ 2 if i['order_status'] == 1 else 1
|
|
|
+ )
|
|
|
+ )
|
|
|
+
|
|
|
+ if len(order_item_list) < limit:
|
|
|
break
|
|
|
- page = page + 1
|
|
|
- print(f"[{merchant_name}] 订单数: {count}")
|
|
|
+ else:
|
|
|
+ page = page + 1
|
|
|
+
|
|
|
|
|
|
|
|
|
def save_hs_data(data):
|
|
|
- sql = 'replace INTO quchen_text.`order` ' \
|
|
|
- '(amount,channel,channel_id,date,from_novel,order_id,order_time,platform,reg_time,stage,user_id)' \
|
|
|
+ sql = 'replace INTO quchen_text.ods_order ' \
|
|
|
' VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);'
|
|
|
db.quchen_text.executeMany(sql,data)
|
|
|
|
|
@@ -576,7 +588,9 @@ def get_zzy_channel_order(start, end, account, channel):
|
|
|
|
|
|
|
|
|
|
|
|
+if __name__ == '__main__':
|
|
|
+ account = "347347942,e0c361b54a35a55c2b6296b5a80867ce,趣程小程序"
|
|
|
+ get_hs_order_task('2021-05-01','2021-05-07',account.split(","))
|
|
|
|
|
|
|
|
|
-if __name__ == '__main__':
|
|
|
- get_qiyue_order_task('2021-02-01','2021-02-19',['趣程15期','eyJpdiI6ImluVWxoRUl3VTR6QU5hamlYOFBvXC9BPT0iLCJ2YWx1ZSI6Ik5IZ0N4dm5GcmJ0Zklsd0tNZ1JVSVE9PSIsIm1hYyI6IjJjODUzMjdlZTc2ODI2ZjFmY2QyYmU5MGViYTkzOGU4MDEwZTIyODIxOTE4NzgzYTNhOGQ1YWM4OGJkMDAzMmIifQ=='])
|
|
|
+ # get_qiyue_order_task('2021-02-01','2021-02-19',['趣程15期','eyJpdiI6ImluVWxoRUl3VTR6QU5hamlYOFBvXC9BPT0iLCJ2YWx1ZSI6Ik5IZ0N4dm5GcmJ0Zklsd0tNZ1JVSVE9PSIsIm1hYyI6IjJjODUzMjdlZTc2ODI2ZjFmY2QyYmU5MGViYTkzOGU4MDEwZTIyODIxOTE4NzgzYTNhOGQ1YWM4OGJkMDAzMmIifQ=='])
|