platform_order_api_util.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. __title__ = '各个平台的订单API接口'
  5. @Time : 2020/9/30 12:33
  6. @Author : Kenny-PC
  7. @Software: PyCharm
  8. # code is far away from bugs with the god animal protecting
  9. I love animals. They taste delicious.
  10. ┏┓ ┏┓
  11. ┏┛┻━━━┛┻┓
  12. ┃ ☃ ┃
  13. ┃ ┳┛ ┗┳ ┃
  14. ┃ ┻ ┃
  15. ┗━┓ ┏━┛
  16. ┃ ┗━━━┓
  17. ┃ 神兽保佑 ┣┓
  18. ┃ 永无BUG! ┏┛
  19. ┗┓┓┏━┳┓┏┛
  20. ┃┫┫ ┃┫┫
  21. ┗┻┛ ┗┻┛
  22. """
  23. import datetime
  24. import hashlib
  25. import math
  26. import time
  27. from concurrent.futures import ProcessPoolExecutor
  28. from urllib import parse
  29. import requests
  30. import account_list_zwg as al
  31. from util import date_util
  32. from util import platform_config_util
  33. from util import robust_util
  34. # md5加密,使用utf-8编码
  35. def md5(s):
  36. md5 = hashlib.md5()
  37. md5.update(s.encode("utf-8"))
  38. return md5.hexdigest()
  39. # 阅文
  40. @robust_util.catch_exception
  41. def get_yuewen_order(st, et):
  42. start_exec_seconds = date_util.getCurrentSecondTime()
  43. total_order_list = ()
  44. account_list = platform_config_util.get_yuewen_account_list()
  45. executor = ProcessPoolExecutor(max_workers=5)
  46. futures = []
  47. for account in account_list:
  48. future = executor.submit(get_yuewen_order_task, st, et, account)
  49. futures.append(future)
  50. executor.shutdown(True)
  51. for future in futures:
  52. order_list = future.result()
  53. if len(order_list) > 0:
  54. total_order_list = order_list + total_order_list
  55. print('阅文订单数量:', len(total_order_list), '执行时长(秒):', date_util.getCurrentSecondTime() - start_exec_seconds)
  56. return total_order_list
  57. def get_yuewen_order_task(st, et, account):
  58. order_list = ()
  59. email = account[0]
  60. appsecert = account[1]
  61. url = 'https://open.yuewen.com/cpapi/wxRecharge/querychargelog'
  62. version = 1
  63. order_status = 2 # 已支付
  64. page_count = 100 # 每页100条数据
  65. start_time = st
  66. for i in range((et - st) // 86400 + 1):
  67. page = 1
  68. last_min_id = ''
  69. last_max_id = ''
  70. total_count = ''
  71. last_page = ''
  72. while True:
  73. if start_time == et:
  74. break
  75. end_time = min(start_time + 86400, et)
  76. timestamp = int(time.time())
  77. params = {
  78. 'email': email,
  79. 'version': version,
  80. 'timestamp': timestamp,
  81. 'start_time': start_time,
  82. 'end_time': end_time,
  83. 'page': page,
  84. 'order_status': order_status
  85. }
  86. if page > 1:
  87. params['last_min_id'] = last_min_id
  88. params['last_max_id'] = last_max_id
  89. params['total_count'] = total_count
  90. params['last_page'] = last_page
  91. sorted_data = sorted(params.items())
  92. str_params = ''
  93. for k, v in sorted_data:
  94. str_params = str_params + str(k) + str(v)
  95. sign = md5(appsecert + str_params).upper()
  96. # 放入签名
  97. params['sign'] = sign
  98. response_result_json = requests.get(url=url, params=params).json()
  99. code = response_result_json['code']
  100. ## 此接口有调用频率限制,相同查询条件每分钟仅能请求一次
  101. if code != 0:
  102. print('阅文查询充值接口异常:', response_result_json, '参数', params)
  103. break
  104. # if code == 10408:
  105. # if fail_count > 0:
  106. # break
  107. #
  108. # sleep_seconds = random.randint(60, 70)
  109. # print('阅文获取订单数据线程休眠【{sleep_seconds}】秒,因为该接口有一分钟的限制'.format(sleep_seconds=sleep_seconds))
  110. # time.sleep(sleep_seconds)
  111. #
  112. # print('重试一次')
  113. # fail_count = fail_count + 1
  114. # get_yuewen_order_task(st, et, account, fail_count)
  115. response_data = response_result_json['data']
  116. total_count = response_data['total_count']
  117. if total_count == 0:
  118. continue
  119. last_min_id = response_data['min_id']
  120. last_max_id = response_data['max_id']
  121. last_page = response_data['page']
  122. order_item_list = response_data['list']
  123. for order_item in order_item_list:
  124. order_time = order_item['order_time']
  125. dtime = datetime.datetime.strptime(order_time, "%Y-%m-%d %H:%M:%S")
  126. order_time_unix = int(time.mktime(dtime.timetuple()))
  127. order_id = order_item['order_id']
  128. if date_util.checkInterval(start_time, end_time, order_time_unix) == False:
  129. print('阅文账号【{key}】, 查询时间【{start_time} - {end_time}】,有不符合该时间范围的订单,订单Id【{order_id}】的时间为【{order_time}】'
  130. .format(key=email, start_time=date_util.getSecondsToDatetime(start_time),
  131. end_time=date_util.getSecondsToDatetime(end_time), order_id=order_id,
  132. order_time=order_time))
  133. continue
  134. order = {}
  135. order['date'] = ((order_time_unix + 8 * 3600) // 86400) * 86400 - 8 * 3600
  136. order['platform'] = '阅文'
  137. order['channel'] = order_item['app_name']
  138. order['from_novel'] = order_item['book_name']
  139. order['user_id'] = order_item['openid']
  140. order['stage'] = ''
  141. order['channel_id'] = 0
  142. order['order_time'] = order_time
  143. order['amount'] = order_item['amount']
  144. order['reg_time'] = order_item['reg_time']
  145. order['order_id'] = order_id
  146. order = sorted(order.items(), key=lambda item: item[0])
  147. order = dict(order)
  148. order = tuple(order.values())
  149. order_list = order_list + ((order),)
  150. # print('阅文账号【{key}】, 查询时间【{start_time} - {end_time}】,当前页【{page}】,本次查询订单数量【{total_count}】'
  151. # .format(key=email, start_time=date_util.getSecondsToDatetime(start_time),
  152. # end_time=date_util.getSecondsToDatetime(end_time),page=page, total_count=total_count))
  153. if int(page) >= math.ceil(total_count / int(page_count)):
  154. break
  155. page = page + 1
  156. start_time = start_time + 86400 # 天数加1
  157. # sleep_seconds = random.randint(60, 70)
  158. # print('阅文获取订单数据线程休眠【{sleep_seconds}】秒,因为该接口有一分钟的限制'.format(sleep_seconds=sleep_seconds))
  159. # time.sleep(sleep_seconds)
  160. return order_list
  161. # 掌读
  162. @robust_util.catch_exception
  163. def get_zhangdu_order(st, et):
  164. start_exec_seconds = date_util.getCurrentSecondTime()
  165. total_order_list = ()
  166. account_list = platform_config_util.get_zhangdu_account_list()
  167. executor = ProcessPoolExecutor(max_workers=5)
  168. futures = []
  169. for account in account_list:
  170. future = executor.submit(get_zhangdu_order_task, st, et, account)
  171. futures.append(future)
  172. executor.shutdown(True)
  173. for future in futures:
  174. order_list = future.result()
  175. if len(order_list) > 0:
  176. total_order_list = order_list + total_order_list
  177. print('掌读订单数量:', len(total_order_list), '执行时长(秒):', date_util.getCurrentSecondTime() - start_exec_seconds)
  178. return total_order_list
  179. def get_zhangdu_order_task(st, et, account):
  180. order_list = ()
  181. url = 'https://api.zhangdu520.com/channel/getorder'
  182. uid = account[0]
  183. appsecert = account[1]
  184. channel = account[2]
  185. timestamp = int(time.time())
  186. sign = md5(str(uid) + '&' + appsecert + '&' + str(timestamp))
  187. starttime = st
  188. timespace = 90 * 3600 * 24
  189. endtime = min(et, st + timespace)
  190. for x in range((et - st) // timespace + 1): # 分时段
  191. if x > 0:
  192. print('掌读跨天数查询:', x)
  193. params = {
  194. 'uid': uid,
  195. 'timestamp': timestamp,
  196. 'sign': sign,
  197. 'starttime': starttime,
  198. 'endtime': endtime
  199. }
  200. response_result_json = requests.get(url=url, params=params).json()
  201. pageCount = response_result_json['data']['pageCount']
  202. if pageCount == 0:
  203. continue
  204. for page in range(1, pageCount + 1): # 分页
  205. params = {
  206. 'uid': uid,
  207. 'timestamp': timestamp,
  208. 'sign': sign,
  209. 'starttime': starttime,
  210. 'endtime': endtime,
  211. 'page': page
  212. }
  213. list2 = requests.get(url=url, params=params).json()
  214. if 'data' in list2.keys():
  215. for b in list2['data']['list']:
  216. if b['status'] == '1':
  217. c = {}
  218. c['amount'] = b['amount']
  219. c['channel_id'] = uid
  220. c['order_id'] = str(b['orderno'])
  221. c['order_time'] = b['ctime']
  222. c['user_id'] = b['openid']
  223. c['platform'] = '掌读'
  224. c['channel'] = channel
  225. c['reg_time'] = b['regtime']
  226. c['from_novel'] = ''
  227. c['stage'] = ''
  228. c['date'] = ((int(b['ctime']) + 8 * 3600) // 86400) * 86400 - 8 * 3600
  229. x = sorted(c.items(), key=lambda item: item[0])
  230. x = dict(x)
  231. x = tuple(x.values())
  232. order_list = order_list + ((x),)
  233. starttime = starttime + timespace
  234. endtime = min(et, starttime + timespace)
  235. return order_list
  236. # 花生
  237. @robust_util.catch_exception
  238. def get_huasheng_order(st, et):
  239. start_exec_seconds = date_util.getCurrentSecondTime()
  240. total_order_list = ()
  241. account_list = platform_config_util.get_huasheng_account_list()
  242. executor = ProcessPoolExecutor(max_workers=5)
  243. futures = []
  244. for account in account_list:
  245. url = 'https://vip.rlcps.cn/api/getMerchants'
  246. apiKey = str(account[0])
  247. apiSecurity = account[1]
  248. timestamp = str(int(time.time()))
  249. sign = md5(apiKey + timestamp + apiSecurity).upper()
  250. params = {
  251. 'apiKey': apiKey,
  252. 'apiSecurity': apiSecurity,
  253. 'timestamp': timestamp,
  254. 'sign': sign
  255. }
  256. response_result_json = requests.post(url, params).json()
  257. if 'data' not in response_result_json.keys():
  258. # print('花生账号【{apiKey}】本次请求数据为空,响应报文【{result}】'.format(apiKey=apiKey, result=response_result_json))
  259. continue
  260. for merchant in response_result_json['data']:
  261. future = executor.submit(get_huasheng_order_task, st, et, account, merchant)
  262. futures.append(future)
  263. executor.shutdown(True)
  264. for future in futures:
  265. order_list = future.result()
  266. if len(order_list) > 0:
  267. total_order_list = order_list + total_order_list
  268. print('花生订单数量:', len(total_order_list), '执行时长(秒):', date_util.getCurrentSecondTime() - start_exec_seconds)
  269. return total_order_list
  270. def get_huasheng_order_task(st, et, account, merchant):
  271. order_list = ()
  272. apiKey = str(account[0])
  273. apiSecurity = account[1]
  274. stage = account[2]
  275. timestamp = str(int(time.time()))
  276. order_url = 'https://vip.rlcps.cn/api/orderList'
  277. merchant_id = merchant['merchant_id']
  278. merchant_name = merchant['merchant_name']
  279. start_time = st
  280. limit = 500
  281. for i in range((et - st) // 86400 + 1):
  282. page = 1
  283. while True:
  284. date = time.strftime("%Y-%m-%d", time.localtime(start_time))
  285. sign = md5(apiKey + date + str(merchant_id) + timestamp + apiSecurity).upper()
  286. order_params = {
  287. 'apiKey': apiKey,
  288. 'apiSecurity': apiSecurity,
  289. 'timestamp': timestamp,
  290. 'date': date,
  291. 'merchant_id': merchant_id,
  292. 'sign': sign,
  293. 'page': page,
  294. 'limit': limit
  295. }
  296. response_result_json = requests.post(order_url, order_params).json()
  297. if 'data' not in response_result_json.keys() or len(response_result_json['data']) == 0:
  298. # print('花生账号【{key}】, 渠道【{merchant_id}:{merchant_name}】本次请求数据为空,响应报文【{result}】'
  299. # .format(key=apiKey, merchant_id=merchant_id, merchant_name=merchant_name,
  300. # result=response_result_json))
  301. break
  302. total_count = response_result_json['count']
  303. order_item_list = response_result_json['data']
  304. for order_item in order_item_list:
  305. if order_item['order_status'] == 1: # 1为已支付
  306. order = {}
  307. ##dtime = datetime.datetime.strptime(order_item['pay_at'],"%Y-%m-%d")
  308. ##order['date']= ((int(time.mktime(dtime.timetuple()))+8*3600)//86400)*86400-8*3600
  309. order['user_id'] = order_item['openid']
  310. order['order_id'] = order_item['trans_id']
  311. order['order_time'] = order_item['pay_at']
  312. order['reg_time'] = order_item['join_at']
  313. # TODO 花生的时间需要统一
  314. order['date'] = (start_time + 8 * 3600) // 86400 * 86400 - 8 * 3600
  315. order['channel'] = merchant_name
  316. order['channel_id'] = merchant_id
  317. order['platform'] = '花生'
  318. order['stage'] = stage
  319. order['from_novel'] = order_item['book_name']
  320. order['amount'] = order_item['amount']
  321. order = sorted(order.items(), key=lambda item: item[0])
  322. order = dict(order)
  323. order = tuple(order.values())
  324. order_list = order_list + ((order),)
  325. if int(page) >= math.ceil(total_count / int(limit)):
  326. break
  327. # print('花生账号【{key}】, 渠道【{merchant_id}:{merchant_name}】当前页【{page}】,本次查询订单数【{total_count}】,即将查询下一页'
  328. # .format(key=apiKey, merchant_id=merchant_id, merchant_name=merchant_name, page=page, total_count=total_count))
  329. page = page + 1
  330. start_time = start_time + 86400 # 天数加1
  331. return order_list
  332. # 掌中云
  333. @robust_util.catch_exception
  334. def get_zhangzhongyun_order(st, et):
  335. start_exec_seconds = date_util.getCurrentSecondTime()
  336. total_order_list = ()
  337. account_list = al.zzy_account_list
  338. # account_list = platform_util.get_zhangzhongyun_account_list()
  339. # account_list = [['1108701f1d6','0f9c0f8429d1a16a8a78c2306e7a4db3','清勇7月']]
  340. # account_list = [['1109295d56c','9bb955186597882ac473e86ba4576158','趣程20期']]
  341. executor = ProcessPoolExecutor(max_workers=5)
  342. futures = []
  343. for account in account_list:
  344. url = 'https://openapi.818tu.com/partners/channel/channels/list?'
  345. key = account[0]
  346. secert = account[1]
  347. sign = md5(secert + 'key=' + key)
  348. params = 'key=' + key + '&sign=' + sign
  349. response_result_json = requests.get(url + params).json() # 获取子渠道列表
  350. if 'data' not in response_result_json.keys():
  351. # print('掌中云账号【{key}】本次请求数据为空,响应报文【{result}】'.format(key=key, result=response_result_json))
  352. continue
  353. items = response_result_json['data']['items']
  354. for channel in items:
  355. # 获取channel_id 后逐个拉取历史orders
  356. future = executor.submit(get_zhangzhongyun_order_task, st, et, account, channel)
  357. futures.append(future)
  358. executor.shutdown(True)
  359. for future in futures:
  360. order_list = future.result()
  361. if len(order_list) > 0:
  362. total_order_list = order_list + total_order_list
  363. print('掌中云订单数量:', len(total_order_list), '执行时长(秒):', date_util.getCurrentSecondTime() - start_exec_seconds)
  364. return total_order_list
  365. def get_zhangzhongyun_order_task(st, et, account, channel):
  366. # 掌中云的时间格式比较特殊,转换下
  367. st = platform_config_util.get_zhangzhongyun_format_time(st)
  368. et = platform_config_util.get_zhangzhongyun_format_time(et)
  369. order_list = ()
  370. key = account[0]
  371. secert = account[1]
  372. stage = account[2]
  373. order_url = 'https://openapi.818tu.com/partners/channel/orders/list?'
  374. channel_id = channel['id']
  375. channel_name = channel['nickname']
  376. status = str(1)
  377. page = str(1)
  378. per_page = str(1000)
  379. get_time = st
  380. limit_time = et
  381. gte = parse.urlencode({'created_at[gte]': get_time}) # gte就是ge 大于等于开始时间
  382. lt = parse.urlencode({'created_at[lt]': limit_time}) # 小于 结束时间
  383. while True:
  384. sign = md5(secert + 'channel_id=' + str(
  385. channel_id) + '&created_at[gte]=' + get_time + '&created_at[lt]=' + limit_time + '&key=' + key + '&page=' + str(
  386. page) + '&per_page=' + per_page + '&status=' + status)
  387. params = 'channel_id=' + str(channel_id) + '&' + gte + '&' + lt + '&page=' + str(
  388. page) + '&per_page=' + per_page + '&status=' + status + '&key=' + key + '&sign=' + sign
  389. response_result_json = requests.get(order_url + params).json()
  390. if 'data' not in response_result_json.keys():
  391. # print('掌中云账号【{key}】, 渠道【{channel_id}:{channel_name}】本次请求数据为空,响应报文【{result}】'
  392. # .format(key=key, channel_id=channel_id, channel_name=channel_name, result=response_result_json))
  393. break
  394. total_count = response_result_json['data']['count'] # 总数量
  395. order_item_list = response_result_json['data']['items'] # 订单列表
  396. for order_item in order_item_list:
  397. order = {}
  398. order['user_id'] = str(order_item['member']['openid'])
  399. order['channel'] = channel_name
  400. order['reg_time'] = order_item['member']['created_at']
  401. order['channel_id'] = channel_id
  402. order['amount'] = round(order_item['price'] / 100, 2)
  403. order['order_id'] = str(order_item['id'])
  404. order['order_time'] = order_item['created_at']
  405. order['platform'] = '掌中云'
  406. order['stage'] = stage
  407. dtime = datetime.datetime.strptime(order_item['created_at'][0:10], "%Y-%m-%d")
  408. order['date'] = ((int(time.mktime(dtime.timetuple())) + 8 * 3600) // 86400) * 86400 - 8 * 3600
  409. if str(order_item['from_novel_id']) != 'None':
  410. order['from_novel'] = order_item['from_novel']['title']
  411. else:
  412. order['from_novel'] = 'None'
  413. x = sorted(order.items(), key=lambda item: item[0])
  414. x = dict(x)
  415. x = tuple(x.values())
  416. order_list = order_list + ((x),)
  417. if int(page) >= math.ceil(total_count / int(per_page)):
  418. break
  419. # print('掌中云账号【{key}】, 渠道【{channel_id}:{channel_name}】当前页【{page}】,本次查询订单数【{total_count}】,即将查询下一页'
  420. # .format(key=key, channel_id=channel_id, channel_name=channel_name, page=page, total_count=total_count))
  421. page = int(page) + 1
  422. return order_list
  423. # 悠书阁
  424. @robust_util.catch_exception
  425. def get_youshuge_order(st, et):
  426. start_exec_seconds = date_util.getCurrentSecondTime()
  427. total_order_list = ()
  428. account_list = platform_config_util.get_youshuge_account_list()
  429. executor = ProcessPoolExecutor(max_workers=5)
  430. futures = []
  431. for account in account_list:
  432. future = executor.submit(get_youshuge_order_task, st, et, account)
  433. futures.append(future)
  434. executor.shutdown(True)
  435. for future in futures:
  436. order_list = future.result()
  437. if len(order_list) > 0:
  438. total_order_list = order_list + total_order_list
  439. print('悠书阁订单数量:', len(total_order_list), '执行时长(秒):', date_util.getCurrentSecondTime() - start_exec_seconds)
  440. return total_order_list
  441. def get_youshuge_order_task(st, et, account):
  442. order_list = ()
  443. url = 'https://novel.youshuge.com/v2/open/orders'
  444. # 超过100条就需要分页,别问我为什么知道,看代码看出来的
  445. max_page_size = 100
  446. host_name = account[0]
  447. channel_id = int(account[1])
  448. secert_key = account[2]
  449. channel = account[3]
  450. stage = account[4]
  451. timestamp = int(time.time())
  452. start_date = time.strftime("%Y-%m-%d", time.localtime(st))
  453. end_date = time.strftime("%Y-%m-%d", time.localtime(et))
  454. page = 1
  455. str1 = 'channel_id=' + str(channel_id) + '&end_date=' + end_date + '&host_name=' + host_name + '&page=' + str(
  456. page) + '&pay_status=1' + '&start_date=' + start_date + '&time=' + str(timestamp) + '&key=' + secert_key
  457. sign = md5(str1).upper()
  458. data = {
  459. 'sign': sign,
  460. 'host_name': host_name,
  461. 'time': timestamp,
  462. 'channel_id': channel_id,
  463. 'page': page,
  464. 'pay_status': 1,
  465. 'start_date': start_date,
  466. 'end_date': end_date
  467. }
  468. respone = requests.post(url, data)
  469. if respone.status_code == 400:
  470. print('respone', respone)
  471. result_json = respone.json()
  472. first_page_order = build_ysg_order_data(channel, channel_id, result_json, stage)
  473. order_list = order_list + first_page_order
  474. if len(first_page_order) == 0:
  475. return order_list
  476. total_count = result_json['data'][0]['count']
  477. if total_count > max_page_size:
  478. for i in range((total_count - 1) // max_page_size + 1):
  479. timestamp = int(time.time())
  480. str1 = 'channel_id=' + str(
  481. channel_id) + '&end_date=' + end_date + '&host_name=' + host_name + '&page=' + str(
  482. page) + '&pay_status=1' + '&start_date=' + start_date + '&time=' + str(timestamp) + '&key=' + secert_key
  483. sign = md5(str1).upper()
  484. data2 = {
  485. 'sign': sign,
  486. 'host_name': host_name,
  487. 'time': timestamp,
  488. 'channel_id': channel_id,
  489. 'page': page,
  490. 'pay_status': 1,
  491. 'start_date': start_date,
  492. 'end_date': end_date
  493. }
  494. r2 = requests.post(url, data2).json()
  495. order_list = order_list + build_ysg_order_data(channel, channel_id, r2, stage)
  496. page = page + 1
  497. return order_list
  498. def build_ysg_order_data(channel, channel_id, result_json, stage):
  499. order_list = ()
  500. if 'data' in result_json.keys():
  501. data = result_json['data']
  502. if len(data) > 0:
  503. for x in data:
  504. y = {}
  505. dtime = datetime.datetime.strptime(x['create_time'][0:10], "%Y-%m-%d")
  506. y['date'] = ((int(
  507. time.mktime(dtime.timetuple())) + 8 * 3600) // 86400) * 86400 - 8 * 3600
  508. y['order_id'] = x['order_num']
  509. y['amount'] = round(int(x['price']) / 100, 2)
  510. y['order_time'] = x['create_time']
  511. y['channel'] = channel
  512. y['from_novel'] = x['book_name']
  513. y['stage'] = stage
  514. y['user_id'] = x['openid']
  515. y['channel_id'] = channel_id
  516. y['platform'] = '悠书阁'
  517. y['reg_time'] = x['reg_time']
  518. y = sorted(y.items(), key=lambda item: item[0])
  519. y = dict(y)
  520. y = tuple(y.values())
  521. order_list = order_list + ((y),)
  522. return order_list
  523. @robust_util.catch_exception
  524. def nor():
  525. return 1
  526. @robust_util.catch_exception
  527. def throw_exception():
  528. return 5 / 0