get_order.py 5.9 KB

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