get_order.py 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. if start:
  62. start = start if start > '2021-07-09' else '2021-07-09'
  63. logging.info('国风订单数据拉取,开始')
  64. if start is None:
  65. start = end = du.getNow()
  66. accounts = get_account("国风") if new is None else get_new_account('国风')
  67. if len(accounts) == 0:
  68. return
  69. else:
  70. logging.info(f'国风有账号{len(accounts)}个')
  71. for account in accounts:
  72. get_gf_order_task(start, end, account)
  73. logging.info('国风订单数据拉取,结束')
  74. @DingTalkDecorators("掌读")
  75. def zhangdu(start=None, end=None, new=None):
  76. logging.info('掌读订单数据拉取,开始')
  77. if start is None:
  78. start = end = du.getNow()
  79. accounts = get_account("掌读")
  80. if len(accounts) == 0:
  81. return
  82. else:
  83. logging.info(f'掌读有账号{len(accounts)}个')
  84. for account in accounts:
  85. get_zd_order_task(start, end, account)
  86. logging.info('掌读订单数据拉取,结束')
  87. @DingTalkDecorators("掌中云")
  88. def zhangzhongyun(start=None, end=None, new=None):
  89. logging.info('掌中云订单数据拉取,开始')
  90. if start is None:
  91. start = du.getNow()
  92. end = du.get_n_days(1)
  93. executor = ThreadPoolExecutor(max_workers=5)
  94. accounts = get_account("掌中云")
  95. if len(accounts) == 0:
  96. return
  97. else:
  98. logging.info(f'掌中云有账号{len(accounts)}个')
  99. for account in accounts:
  100. executor.submit(get_zzy_order_task, start, end, account)
  101. executor.shutdown()
  102. logging.info('掌中云订单数据拉取,结束')
  103. @DingTalkDecorators("阅文")
  104. def yueweng(start=None, end=None):
  105. logging.info('阅文订单数据拉取,开始')
  106. if start is None:
  107. start = end = du.getNow()
  108. executor = ThreadPoolExecutor(max_workers=5)
  109. accounts = get_account("阅文")
  110. if len(accounts) == 0:
  111. return
  112. else:
  113. logging.info(f'阅文有账号{len(accounts)}个')
  114. for account in accounts:
  115. executor.submit(get_yuewen_order_task, start, end, account)
  116. executor.shutdown()
  117. logging.info('阅文订单数据拉取,结束')
  118. @DingTalkDecorators("七悦有声")
  119. def qiyueyousheng(start=None, end=None):
  120. logging.info('七悦有声订单数据拉取,开始')
  121. if start is None:
  122. start = end = du.getNow()
  123. accounts = get_account("七悦有声")
  124. if len(accounts) == 0:
  125. return
  126. else:
  127. logging.info(f'七悦有声有账号{len(accounts)}个')
  128. for account in accounts:
  129. AudioQiyue().get_order(start, end, account)
  130. logging.info('七悦有声订单数据拉取,结束')
  131. @DingTalkDecorators("悠书阁")
  132. def youshuge(start=None, end=None):
  133. logging.info('悠书阁订单数据拉取,开始')
  134. if start is None:
  135. start = end = du.getNow()
  136. executor = ThreadPoolExecutor(max_workers=5)
  137. accounts = get_account("悠书阁")
  138. if len(accounts) == 0:
  139. return
  140. else:
  141. logging.info(f'悠书阁有账号{len(accounts)}个')
  142. for account in accounts:
  143. executor.submit(get_youshuge_order_task, start, end, account)
  144. executor.shutdown()
  145. logging.info('悠书阁订单数据拉取,结束')
  146. def yestoday():
  147. st = et = du.get_n_days(-1)
  148. huasheng(st, et)
  149. qiyue(st, et)
  150. qiyueyousheng(st, et)
  151. wending(st, et)
  152. zhangdu(st, et)
  153. zhangzhongyun(st, et)
  154. yueweng(st, et)
  155. youshuge(st, et)
  156. yangguang(st, et)
  157. if __name__ == '__main__':
  158. # zhangzhongyun()
  159. # yangguang()
  160. # huasheng("2021-04-12",'2021-05-10')
  161. # yueweng("2021-05-11", '2021-05-11')
  162. qiyue('2020-11-01', '2021-06-03')