get_order.py 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. from app.api_data.platform_order.order_util import *
  2. from model.DataBaseUtils import MysqlUtils
  3. from concurrent.futures import ThreadPoolExecutor
  4. from model.DingTalkUtils import DingTalkDecorators
  5. from app.api_data.platform_order.audio_qiyue import AudioQiyue
  6. from app.api_data.platform_order.youshuge import get_youshuge_order_task
  7. from app.api_data.platform_order.yuewen import get_yuewen_order_task
  8. from app.api_data.platform_order.yuewen_fast_app import get_yuewen_fast_app_order_task
  9. from app.api_data.platform_order.yangguang import yangguang
  10. from app.api_data.platform_order.QiYue import get_qiyue_order_task
  11. from app.api_data.platform_order.wandu import get_wandu_order, get_all_channel
  12. import logging
  13. db = MysqlUtils()
  14. def get_new_account(plactform):
  15. data = db.quchen_text.getData(
  16. f"select text from order_account_text where platform='{plactform}' and create_time>='{du.get_n_days(-1)}'")
  17. new_data = []
  18. for i in data:
  19. new_data.append(i[0].replace('\n', '').split(","))
  20. return new_data
  21. @DingTalkDecorators("花生")
  22. def huasheng(start=None, end=None):
  23. logging.info('花生订单数据拉取,开始')
  24. if start is None:
  25. start = end = du.getNow()
  26. accounts = get_account("花生")
  27. if len(accounts) == 0:
  28. return
  29. else:
  30. logging.info(f'花生有账号{len(accounts)}个')
  31. # 花生有请求限制 不用多线程
  32. for account in accounts:
  33. get_hs_order_task(start, end, account)
  34. logging.info('花生订单数据拉取,结束')
  35. @DingTalkDecorators("七悦")
  36. def qiyue(start=None, end=None, new=None):
  37. logging.info('七悦订单数据拉取,开始')
  38. if start is None:
  39. start = end = du.getNow()
  40. accounts = get_account("七悦")
  41. if len(accounts) == 0:
  42. return
  43. else:
  44. logging.info(f'七悦有账号{len(accounts)}个')
  45. for account in accounts:
  46. get_qiyue_order_task(start, end, account)
  47. logging.info('七悦订单数据拉取,结束')
  48. @DingTalkDecorators("万读")
  49. def wandu(start=None, end=None, new=None):
  50. logging.info('万读订单数据拉取,开始')
  51. if start is None:
  52. start = end = du.getNow()
  53. accounts = get_account("万读")
  54. if len(accounts) == 0:
  55. return
  56. else:
  57. logging.info(f'万读有账号{len(accounts)}个')
  58. channel_info = get_all_channel()
  59. for account in accounts:
  60. get_wandu_order(start, end, account, channel_info)
  61. logging.info('万读订单数据拉取,结束')
  62. @DingTalkDecorators("文鼎")
  63. def wending(start=None, end=None, new=None):
  64. logging.info('文鼎订单数据拉取,开始')
  65. if start is None:
  66. start = end = du.getNow()
  67. accounts = get_account("文鼎") if new is None else get_new_account('文鼎')
  68. if len(accounts) == 0:
  69. return
  70. else:
  71. logging.info(f'文鼎有账号{len(accounts)}个')
  72. for account in accounts:
  73. get_wd_order_task(start, end, account)
  74. logging.info('文鼎订单数据拉取,结束')
  75. @DingTalkDecorators("国风")
  76. def guofeng(start=None, end=None, new=None):
  77. if start:
  78. start = start if start > '2021-07-09' else '2021-07-09'
  79. logging.info('国风订单数据拉取,开始')
  80. if start is None:
  81. start = end = du.getNow()
  82. accounts = get_account("国风") if new is None else get_new_account('国风')
  83. if len(accounts) == 0:
  84. return
  85. else:
  86. logging.info(f'国风有账号{len(accounts)}个')
  87. for account in accounts:
  88. get_gf_order_task(start, end, account)
  89. logging.info('国风订单数据拉取,结束')
  90. @DingTalkDecorators("掌读")
  91. def zhangdu(start=None, end=None, new=None):
  92. logging.info('掌读订单数据拉取,开始')
  93. if start is None:
  94. start = end = du.getNow()
  95. accounts = get_account("掌读")
  96. if len(accounts) == 0:
  97. return
  98. else:
  99. logging.info(f'掌读有账号{len(accounts)}个')
  100. for account in accounts:
  101. get_zd_order_task(start, end, account)
  102. logging.info('掌读订单数据拉取,结束')
  103. @DingTalkDecorators("掌中云")
  104. def zhangzhongyun(start=None, end=None, new=None):
  105. logging.info('掌中云订单数据拉取,开始')
  106. if start is None:
  107. start = du.getNow()
  108. end = du.get_n_days(1)
  109. executor = ThreadPoolExecutor(max_workers=5)
  110. accounts = get_account("掌中云")
  111. if len(accounts) == 0:
  112. return
  113. else:
  114. logging.info(f'掌中云有账号{len(accounts)}个')
  115. for account in accounts:
  116. executor.submit(
  117. get_zzy_order_task, start, end, account)
  118. executor.shutdown()
  119. logging.info('掌中云订单数据拉取,结束')
  120. @DingTalkDecorators("阅文")
  121. def yueweng(start=None, end=None):
  122. logging.info('阅文订单数据拉取,开始')
  123. if start is None:
  124. start = end = du.getNow()
  125. executor = ThreadPoolExecutor(max_workers=5)
  126. accounts = get_account("阅文")
  127. if len(accounts) == 0:
  128. return
  129. else:
  130. logging.info(f'阅文有账号{len(accounts)}个')
  131. for account in accounts:
  132. executor.submit(get_yuewen_order_task, start, end, account)
  133. executor.shutdown()
  134. logging.info('阅文订单数据拉取,结束')
  135. @DingTalkDecorators("阅文快应用")
  136. def yueweng_fastapp(start=None, end=None):
  137. logging.info('阅文快应用订单数据拉取,开始')
  138. if start is None:
  139. start = end = du.getNow()
  140. executor = ThreadPoolExecutor(max_workers=5)
  141. accounts = get_account("阅文快应用")
  142. if len(accounts) == 0:
  143. return
  144. else:
  145. logging.info(f'阅文快应用有账号{len(accounts)}个')
  146. for account in accounts:
  147. executor.submit(get_yuewen_fast_app_order_task, start, end, account)
  148. executor.shutdown()
  149. logging.info('阅文快应用订单数据拉取,结束')
  150. @DingTalkDecorators("七悦有声")
  151. def qiyueyousheng(start=None, end=None):
  152. logging.info('七悦有声订单数据拉取,开始')
  153. if start is None:
  154. start = end = du.getNow()
  155. accounts = get_account("七悦有声")
  156. if len(accounts) == 0:
  157. return
  158. else:
  159. logging.info(f'七悦有声有账号{len(accounts)}个')
  160. for account in accounts:
  161. AudioQiyue().get_order(start, end, account)
  162. logging.info('七悦有声订单数据拉取,结束')
  163. @DingTalkDecorators("悠书阁")
  164. def youshuge(start=None, end=None):
  165. logging.info('悠书阁订单数据拉取,开始')
  166. if start is None:
  167. start = end = du.getNow()
  168. executor = ThreadPoolExecutor(max_workers=5)
  169. accounts = get_account("悠书阁")
  170. if len(accounts) == 0:
  171. return
  172. else:
  173. logging.info(f'悠书阁有账号{len(accounts)}个')
  174. for account in accounts:
  175. executor.submit(get_youshuge_order_task, start, end, account)
  176. executor.shutdown()
  177. logging.info('悠书阁订单数据拉取,结束')
  178. def yestoday():
  179. st = et = du.get_n_days(-1)
  180. huasheng(st, et)
  181. qiyue(st, et)
  182. qiyueyousheng(st, et)
  183. wending(st, et)
  184. zhangdu(st, et)
  185. zhangzhongyun(st, et)
  186. yueweng(st, et)
  187. youshuge(st, et)
  188. yangguang(st, et)
  189. if __name__ == '__main__':
  190. # zhangzhongyun()
  191. # yangguang()
  192. # huasheng("2021-04-12",'2021-05-10')
  193. yueweng(du.get_n_days(-3), du.get_n_days(0))
  194. # qiyue('2020-11-01', '2021-06-03')