|
@@ -13,7 +13,7 @@ from model.DateUtils import DateUtils
|
|
|
import logging
|
|
|
from urllib import parse
|
|
|
from model.DingTalkUtils import DingTalkUtils
|
|
|
-from .order_util import save_order2
|
|
|
+from app.api_data.platform_order.order_util import *
|
|
|
|
|
|
logging.getLogger().setLevel(logging.WARNING)
|
|
|
db = MysqlUtils()
|
|
@@ -23,7 +23,7 @@ du = DateUtils()
|
|
|
# 获取七悦订单数据
|
|
|
def get_qiyue_order_task(start, end, account):
|
|
|
"""一分钟请求60次的限制"""
|
|
|
-
|
|
|
+ order_list = []
|
|
|
# 参数
|
|
|
order_url = "https://api.zhangwenwenhua.com" + "/v1/orders"
|
|
|
stage = account[0]
|
|
@@ -31,7 +31,7 @@ def get_qiyue_order_task(start, end, account):
|
|
|
size = 50
|
|
|
freq = 0
|
|
|
for date in du.getDateLists(start, end):
|
|
|
- order_list = []
|
|
|
+
|
|
|
page = 1
|
|
|
while True:
|
|
|
timestamp = int(time.time())
|
|
@@ -62,6 +62,7 @@ def get_qiyue_order_task(start, end, account):
|
|
|
for x in order_item_list:
|
|
|
create_time = DateUtils.stamp_to_str(x['create_time'], '%Y-%m-%d %H:%M:%S')
|
|
|
reg_time = DateUtils.stamp_to_str(x['user_create_time'], '%Y-%m-%d %H:%M:%S')
|
|
|
+
|
|
|
order_list.append((
|
|
|
create_time[:10],
|
|
|
stage,
|
|
@@ -73,30 +74,64 @@ def get_qiyue_order_task(start, end, account):
|
|
|
reg_time, # 用户注册时间
|
|
|
x['money'],
|
|
|
x['book_name'],
|
|
|
- x['transaction_no'] if x['transaction_no'] != 0 else x['trade_no'], # 订单id
|
|
|
+ x['id'],
|
|
|
x['state'],
|
|
|
x['id'],
|
|
|
x['user_id'],
|
|
|
x['wechat_app_id'],
|
|
|
x['book_keywords'],
|
|
|
- x['type']
|
|
|
+ x['type'],
|
|
|
+ x['trade_no'],
|
|
|
+ x['transaction_no']
|
|
|
)
|
|
|
)
|
|
|
-
|
|
|
next_page_url = result_data['next_page_url']
|
|
|
if next_page_url is None:
|
|
|
break
|
|
|
page += 1
|
|
|
# print(len(order_list))
|
|
|
- print(f'{stage} [{date}] 有订单{order_list.__len__()}')
|
|
|
+ print(f'{stage} [{start}-{end}] 有订单{order_list.__len__()}')
|
|
|
# print(order_list)
|
|
|
- if order_list.__len__() > 0:
|
|
|
-
|
|
|
- db.quchen_text.execute(f'DELETE from ods_order where platform="七悦" and date="{date}"')
|
|
|
- save_order2(order_list)
|
|
|
+ if order_list.__len__() > 0:
|
|
|
+ save_order2(order_list)
|
|
|
|
|
|
|
|
|
|
|
|
# 获取七悦用户信息
|
|
|
-def get_qiyue_user_info():
|
|
|
- pass
|
|
|
+def get_qiyue_user_info(account):
|
|
|
+ order_url = "https://api.zhangwenwenhua.com" + "/v1/users"
|
|
|
+ stage = account[0]
|
|
|
+ token = account[1]
|
|
|
+ page = 1
|
|
|
+ size = 50
|
|
|
+ freq = 0
|
|
|
+ li = []
|
|
|
+ while True:
|
|
|
+ timestamp = int(time.time())
|
|
|
+ url = order_url + "?" + "token=" + str(token) + "×tamp=" + str(timestamp) + "&page=" + str(
|
|
|
+ page) + "&size=" + str(size) + "&date="
|
|
|
+ r = requests.get(url=url).json()
|
|
|
+ print(r)
|
|
|
+ if r['code'] != 0:
|
|
|
+ DingTalkUtils.send('七悦用户拉取接口错误'+r['msg'])
|
|
|
+ else:
|
|
|
+ continue
|
|
|
+ i = r['data']['data']
|
|
|
+ li.append(('七悦',
|
|
|
+ i['id'],
|
|
|
+ i['openid'],
|
|
|
+ i['channel_id'],
|
|
|
+ i['wechat_app_name'],
|
|
|
+ i['wechat_app_id'],
|
|
|
+
|
|
|
+ ))
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+
|
|
|
+ for account in get_account("七悦"):
|
|
|
+ get_qiyue_order_task('2021-06-03','2021-06-03',account)
|
|
|
+ # get_qiyue_user_info(account)
|