get_order.py 4.8 KB

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