get_order.py 4.6 KB

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