|
@@ -28,7 +28,7 @@ import datetime
|
|
import hashlib
|
|
import hashlib
|
|
import math
|
|
import math
|
|
import time
|
|
import time
|
|
-from concurrent.futures import ProcessPoolExecutor
|
|
|
|
|
|
+from concurrent.futures import ProcessPoolExecutor,ThreadPoolExecutor
|
|
from urllib import parse
|
|
from urllib import parse
|
|
|
|
|
|
import requests
|
|
import requests
|
|
@@ -407,39 +407,45 @@ def get_huasheng_order_task(st, et, account, merchant):
|
|
return order_list
|
|
return order_list
|
|
|
|
|
|
|
|
|
|
-# 掌中云
|
|
|
|
-@robust_util.catch_exception
|
|
|
|
-def get_zhangzhongyun_order(st, et, account_list):
|
|
|
|
- start_exec_seconds = date_util.getCurrentSecondTime()
|
|
|
|
- total_order_list = ()
|
|
|
|
|
|
+def get_zzy(account,st,et,total_order_list):
|
|
|
|
+ url = 'https://inovel.818tu.com/partners/channel/channels/list?'
|
|
|
|
|
|
- executor = ProcessPoolExecutor(max_workers=5)
|
|
|
|
|
|
+ key = account[0]
|
|
|
|
+ secert = account[1]
|
|
|
|
+ sign = md5(secert + 'key=' + key)
|
|
|
|
+ params = 'key=' + key + '&sign=' + sign
|
|
|
|
+ response_result_json = requests.get(url + params).json() # 获取子渠道列表
|
|
|
|
|
|
- futures = []
|
|
|
|
- for account in account_list:
|
|
|
|
- url = 'https://inovel.818tu.com/partners/channel/channels/list?'
|
|
|
|
- key = account[0]
|
|
|
|
- secert = account[1]
|
|
|
|
- sign = md5(secert + 'key=' + key)
|
|
|
|
- params = 'key=' + key + '&sign=' + sign
|
|
|
|
- response_result_json = requests.get(url + params).json() # 获取子渠道列表
|
|
|
|
|
|
+ if 'data' not in response_result_json.keys():
|
|
|
|
+ print('掌中云账号【{key}】本次请求数据异常,响应报文【{result}】'.format(key=key, result=response_result_json))
|
|
|
|
+ return
|
|
|
|
|
|
- if 'data' not in response_result_json.keys():
|
|
|
|
- print('掌中云账号【{key}】本次请求数据异常,响应报文【{result}】'.format(key=key, result=response_result_json))
|
|
|
|
- continue
|
|
|
|
|
|
+ items = response_result_json['data']['items']
|
|
|
|
+ # print(f'VIP{account[0]} 有公众号{len(items)} ')
|
|
|
|
+ for channel in items:
|
|
|
|
+ # 获取channel_id 后逐个拉取历史orders
|
|
|
|
+ order_list = get_zhangzhongyun_order_task(st, et, account, channel)
|
|
|
|
+ for i in order_list:
|
|
|
|
+ total_order_list.append(i)
|
|
|
|
|
|
- items = response_result_json['data']['items']
|
|
|
|
- for channel in items:
|
|
|
|
- # 获取channel_id 后逐个拉取历史orders
|
|
|
|
- future = executor.submit(get_zhangzhongyun_order_task, st, et, account, channel)
|
|
|
|
- futures.append(future)
|
|
|
|
|
|
|
|
- executor.shutdown(True)
|
|
|
|
|
|
|
|
- for future in futures:
|
|
|
|
- order_list = future.result()
|
|
|
|
- if len(order_list) > 0:
|
|
|
|
- total_order_list = order_list + total_order_list
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+# 掌中云
|
|
|
|
+
|
|
|
|
+def get_zhangzhongyun_order(st, et, account_list):
|
|
|
|
+ start_exec_seconds = date_util.getCurrentSecondTime()
|
|
|
|
+ total_order_list = []
|
|
|
|
+ executor = ThreadPoolExecutor(max_workers=5)
|
|
|
|
+
|
|
|
|
+ for account in account_list:
|
|
|
|
+ # get_zzy(account,st,et,total_order_list)
|
|
|
|
+ # 列表线程间通信 进程不行
|
|
|
|
+ executor.submit(get_zzy,account,st,et,total_order_list)
|
|
|
|
+ executor.shutdown()
|
|
|
|
|
|
print('掌中云订单数量:', len(total_order_list), '执行时长(秒):', date_util.getCurrentSecondTime() - start_exec_seconds)
|
|
print('掌中云订单数量:', len(total_order_list), '执行时长(秒):', date_util.getCurrentSecondTime() - start_exec_seconds)
|
|
return total_order_list
|
|
return total_order_list
|
|
@@ -449,6 +455,7 @@ def get_zhangzhongyun_order_task(st, et, account, channel):
|
|
# 掌中云的时间格式比较特殊,转换下
|
|
# 掌中云的时间格式比较特殊,转换下
|
|
get_time=datetime.datetime.strptime(date_util.stamp_to_str(st),"%Y-%m-%d %H:%M:%S").strftime("%Y-%m-%dT%H:%M:%S+08:00")
|
|
get_time=datetime.datetime.strptime(date_util.stamp_to_str(st),"%Y-%m-%d %H:%M:%S").strftime("%Y-%m-%dT%H:%M:%S+08:00")
|
|
limit_time=datetime.datetime.strptime(date_util.stamp_to_str(et),"%Y-%m-%d %H:%M:%S").strftime("%Y-%m-%dT%H:%M:%S+08:00")
|
|
limit_time=datetime.datetime.strptime(date_util.stamp_to_str(et),"%Y-%m-%d %H:%M:%S").strftime("%Y-%m-%dT%H:%M:%S+08:00")
|
|
|
|
+
|
|
order_list = ()
|
|
order_list = ()
|
|
key = account[0]
|
|
key = account[0]
|
|
secert = account[1]
|
|
secert = account[1]
|
|
@@ -476,8 +483,8 @@ def get_zhangzhongyun_order_task(st, et, account, channel):
|
|
response_result_json = r.json()
|
|
response_result_json = r.json()
|
|
break
|
|
break
|
|
else:
|
|
else:
|
|
- time.sleep(1)
|
|
|
|
- print("掌中云接口调用sleep 1s...")
|
|
|
|
|
|
+ time.sleep(61)
|
|
|
|
+ print("掌中云接口调用sleep 61s...")
|
|
|
|
|
|
|
|
|
|
if 'data' not in response_result_json.keys():
|
|
if 'data' not in response_result_json.keys():
|
|
@@ -517,7 +524,7 @@ def get_zhangzhongyun_order_task(st, et, account, channel):
|
|
if int(page) >= math.ceil(total_count / int(per_page)):
|
|
if int(page) >= math.ceil(total_count / int(per_page)):
|
|
break
|
|
break
|
|
page = int(page) + 1
|
|
page = int(page) + 1
|
|
-
|
|
|
|
|
|
+ print(f"{channel_name}获取订单:{order_list.__len__()}")
|
|
return order_list
|
|
return order_list
|
|
|
|
|
|
|
|
|