get_order.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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 zhangdu(start=None, end=None, new=None):
  54. if start is None:
  55. start = end = du.getNow()
  56. accounts = get_account("掌读")
  57. if len(accounts) == 0:
  58. return
  59. else:
  60. print(f'掌读有账号{len(accounts)}个')
  61. for account in accounts:
  62. get_zd_order_task(start, end, account)
  63. @DingTalkDecorators("掌中云")
  64. def zhangzhongyun(start=None, end=None, new=None):
  65. if start is None:
  66. start = du.getNow()
  67. end = du.get_n_days(1)
  68. executor = ThreadPoolExecutor(max_workers=5)
  69. accounts = get_account("掌中云")
  70. if len(accounts) == 0:
  71. return
  72. else:
  73. print(f'掌中云有账号{len(accounts)}个')
  74. for account in accounts:
  75. executor.submit(get_zzy_order_task, start, end, account)
  76. executor.shutdown()
  77. @DingTalkDecorators("阅文")
  78. def yueweng(start=None, end=None):
  79. if start is None:
  80. start = end = du.getNow()
  81. executor = ThreadPoolExecutor(max_workers=5)
  82. accounts = get_account("阅文")
  83. if len(accounts) == 0:
  84. return
  85. else:
  86. print(f'阅文有账号{len(accounts)}个')
  87. for account in accounts:
  88. executor.submit(get_yuewen_order_task, start, end, account)
  89. executor.shutdown()
  90. @DingTalkDecorators("七悦有声")
  91. def qiyueyousheng(start=None, end=None):
  92. if start is None:
  93. start = end = du.getNow()
  94. accounts = get_account("七悦有声")
  95. if len(accounts) == 0:
  96. return
  97. else:
  98. print(f'七悦有声有账号{len(accounts)}个')
  99. for account in accounts:
  100. AudioQiyue().get_order(start, end, account)
  101. @DingTalkDecorators("悠书阁")
  102. def youshuge(start=None, end=None):
  103. if start is None:
  104. start = end = du.getNow()
  105. executor = ThreadPoolExecutor(max_workers=5)
  106. accounts = get_account("悠书阁")
  107. if len(accounts) == 0:
  108. return
  109. else:
  110. print(f'悠书阁有账号{len(accounts)}个')
  111. for account in accounts:
  112. executor.submit(get_youshuge_order_task, start, end, account)
  113. executor.shutdown()
  114. def yestoday():
  115. st = et = du.get_n_days(-1)
  116. huasheng(st, et)
  117. qiyue(st, et)
  118. qiyueyousheng(st, et)
  119. wending(st, et)
  120. zhangdu(st, et)
  121. zhangzhongyun(st, et)
  122. yueweng(st, et)
  123. youshuge(st, et)
  124. yangguang(st, et)
  125. if __name__ == '__main__':
  126. # zhangzhongyun()
  127. # yangguang()
  128. # huasheng("2021-04-12",'2021-05-10')
  129. # yueweng("2021-05-11", '2021-05-11')
  130. qiyue('2020-11-01','2021-06-03')