|
@@ -0,0 +1,117 @@
|
|
|
+import time
|
|
|
+from model.DateUtils import DateUtils
|
|
|
+from model.ComUtils import md5
|
|
|
+import requests
|
|
|
+from model.ComUtils import split_int
|
|
|
+from app.api_data.platform_order.order_util import save_order
|
|
|
+from model.DingTalkUtils import DingTalkUtils
|
|
|
+
|
|
|
+ut = DateUtils()
|
|
|
+
|
|
|
+
|
|
|
+def get_yuewen_fast_app_order_task(st, et, account):
|
|
|
+ """相同参数一分钟只能调用一次"""
|
|
|
+ email = account[0]
|
|
|
+ appsecert = account[1]
|
|
|
+
|
|
|
+ url = 'https://open.yuewen.com/cpapi/wxRecharge/quickappchargelog'
|
|
|
+
|
|
|
+ start_time = DateUtils.str_to_stamp(st)
|
|
|
+ # 结束时间不能超过当前的时间戳
|
|
|
+ if et == ut.getNow():
|
|
|
+ end_time = DateUtils.str_to_stamp(ut.get_n_minutes_ago(), "%Y-%m-%d %H:%M:%S")
|
|
|
+ else:
|
|
|
+ end_time = DateUtils.str_to_stamp(et) + 86399
|
|
|
+
|
|
|
+ for i in split_int(start_time, end_time, 10000):
|
|
|
+ print(i)
|
|
|
+ start = i[0]
|
|
|
+ end = i[1]
|
|
|
+
|
|
|
+ page = 1
|
|
|
+ last_min_id = ''
|
|
|
+ last_max_id = ''
|
|
|
+ total_count = ''
|
|
|
+ last_page = ''
|
|
|
+
|
|
|
+ li = []
|
|
|
+ while True:
|
|
|
+
|
|
|
+ params = {
|
|
|
+ 'email': email,
|
|
|
+ 'coop_type': 11,
|
|
|
+ 'timestamp': int(time.time()),
|
|
|
+ 'start_time': start,
|
|
|
+ 'end_time': end,
|
|
|
+ 'version': 1
|
|
|
+ }
|
|
|
+
|
|
|
+ if page > 1:
|
|
|
+ params['last_min_id'] = last_min_id
|
|
|
+ params['last_max_id'] = last_max_id
|
|
|
+ params['total_count'] = total_count
|
|
|
+ params['last_page'] = last_page
|
|
|
+
|
|
|
+ sorted_data = sorted(params.items())
|
|
|
+ str_params = ''
|
|
|
+ for k, v in sorted_data:
|
|
|
+ str_params = str_params + str(k) + str(v)
|
|
|
+ sign = md5(appsecert + str_params).upper()
|
|
|
+
|
|
|
+ # 放入签名
|
|
|
+ params['sign'] = sign
|
|
|
+ # print(params)
|
|
|
+ rsp = requests.get(url=url, params=params)
|
|
|
+ print(rsp.text)
|
|
|
+ response_result_json=rsp.json()
|
|
|
+ print(response_result_json)
|
|
|
+ print(len(response_result_json["data"]["list"]))
|
|
|
+ if not response_result_json.get('data'):
|
|
|
+ DingTalkUtils().send('阅文订单拉取失败')
|
|
|
+
|
|
|
+ response_data = response_result_json['data']
|
|
|
+ total_count = response_data['total_count']
|
|
|
+
|
|
|
+ last_min_id = response_data['min_id']
|
|
|
+ last_max_id = response_data['max_id']
|
|
|
+ last_page = response_data['page']
|
|
|
+ order_item_list = response_data['list']
|
|
|
+
|
|
|
+ if len(order_item_list) == 0:
|
|
|
+ break
|
|
|
+
|
|
|
+ for i in order_item_list:
|
|
|
+ order_time = i["order_time"]
|
|
|
+ li.append((order_time[:10],
|
|
|
+ '',
|
|
|
+ '阅文快应用',
|
|
|
+ 'fast_app_'+i['app_name'],
|
|
|
+ '',
|
|
|
+ i['openid'], # 这部分可能要修改,openid对应的微信相关id
|
|
|
+ i['order_time'],
|
|
|
+ i['reg_time'],
|
|
|
+ i['amount'],
|
|
|
+ i['book_name'],
|
|
|
+ i['order_id'],
|
|
|
+ i['order_status']
|
|
|
+
|
|
|
+ ))
|
|
|
+
|
|
|
+ if len(order_item_list) < 100:
|
|
|
+ break
|
|
|
+ else:
|
|
|
+ page += 1
|
|
|
+ print(li)
|
|
|
+ if len(li) > 0:
|
|
|
+ print(f"{email} 有订单{len(li)}")
|
|
|
+ save_order(li)
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ a = "guangzhouliuqi2@sina.com,10ce1dd6ccb330a82b73701d1e78f518"
|
|
|
+ b = "mqud82950@163.com,74ca754515fa253c8ab790603cebc2ee"
|
|
|
+ {"version": "1", "app_secret": "74ca754515fa253c8ab790603cebc2ee", "email": "mqud82950@163.com"}
|
|
|
+ a = 'mqud82950@163.com,74ca754515fa253c8ab790603cebc2ee'
|
|
|
+ a = 'qucheng66qi@163.com,21a8345b00ef9e062c940887e0dbedb3'
|
|
|
+
|
|
|
+ get_yuewen_fast_app_order_task('2021-09-16', '2021-09-25', a.split(','))
|