123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- from app.api_data.order_util import *
- from model.DataBaseUtils import MysqlUtils
- from concurrent.futures import ThreadPoolExecutor
- from model.DingTalkUtils import DingTalkDecorators
- from app.api_data.platform_order.audio_qiyue import AudioQiyue
- from app.api_data.platform_order.youshuge import get_youshuge_order_task
- from app.api_data.platform_order.yuewen import get_yuewen_order_task
- from app.api_data.platform_order.yangguang import yangguang
- from multiprocessing import Process
- db = MysqlUtils()
- def get_account(plactform, id=None):
- op = f" and id={id} " if id else ''
- data = db.quchen_text.getData(f"select text from order_account_text where platform='{plactform}' {op}")
- new_data = []
- for i in data:
- new_data.append(i[0].replace('\n', '').split(","))
- return new_data
- def get_new_account(plactform):
- data = db.quchen_text.getData(
- f"select text from order_account_text where platform='{plactform}' and create_time>='{du.get_n_days(-1)}'")
- new_data = []
- for i in data:
- new_data.append(i[0].replace('\n', '').split(","))
- return new_data
- @DingTalkDecorators("花生")
- def huasheng(start=None, end=None):
- if start is None:
- start = end = du.getNow()
- accounts = get_account("花生")
- if len(accounts) == 0:
- return
- else:
- print(f'花生有账号{len(accounts)}个')
- # 花生有请求限制 不用多线程
- for account in accounts:
- get_hs_order_task(start, end, account)
- @DingTalkDecorators("七悦")
- def qiyue(start=None, end=None, new=None):
- if start is None:
- start = end = du.getNow()
- accounts = get_account("七悦") if new is None else get_new_account('七悦')
- if len(accounts) == 0:
- return
- else:
- print(f'七悦有账号{len(accounts)}个')
- for account in accounts:
- get_qiyue_order_task(start, end, account)
- @DingTalkDecorators("文鼎")
- def wending(start=None, end=None, new=None):
- if start is None:
- start = end = du.getNow()
- accounts = get_account("文鼎") if new is None else get_new_account('文鼎')
- if len(accounts) == 0:
- return
- else:
- print(f'文鼎有账号{len(accounts)}个')
- for account in accounts:
- get_wd_order_task(start, end, account)
- @DingTalkDecorators("掌读")
- def zhangdu(start=None, end=None, new=None):
- if start is None:
- start = end = du.getNow()
- accounts = get_account("掌读")
- if len(accounts) == 0:
- return
- else:
- print(f'掌读有账号{len(accounts)}个')
- for account in accounts:
- get_zd_order_task(start, end, account)
- @DingTalkDecorators("掌中云")
- def zhangzhongyun(start=None, end=None, new=None):
- if start is None:
- start = du.getNow()
- end = du.get_n_days(1)
- executor = ThreadPoolExecutor(max_workers=5)
- accounts = get_account("掌中云")
- if len(accounts) == 0:
- return
- else:
- print(f'掌中云有账号{len(accounts)}个')
- for account in accounts:
- executor.submit(get_zzy_order_task, start, end, account)
- executor.shutdown()
- @DingTalkDecorators("阅文")
- def yueweng(start=None, end=None):
- if start is None:
- start = end = du.getNow()
- executor = ThreadPoolExecutor(max_workers=5)
- accounts = get_account("阅文")
- if len(accounts) == 0:
- return
- else:
- print(f'阅文有账号{len(accounts)}个')
- for account in accounts:
- executor.submit(get_yuewen_order_task, start, end, account)
- executor.shutdown()
- @DingTalkDecorators("七悦有声")
- def qiyueyousheng(start=None, end=None):
- if start is None:
- start = end = du.getNow()
- accounts = get_account("七悦有声")
- if len(accounts) == 0:
- return
- else:
- print(f'七悦有声有账号{len(accounts)}个')
- for account in accounts:
- AudioQiyue().get_order(start, end, account)
- @DingTalkDecorators("悠书阁")
- def youshuge(start=None, end=None):
- if start is None:
- start = end = du.getNow()
- executor = ThreadPoolExecutor(max_workers=5)
- accounts = get_account("悠书阁")
- if len(accounts) == 0:
- return
- else:
- print(f'悠书阁有账号{len(accounts)}个')
- for account in accounts:
- executor.submit(get_youshuge_order_task, start, end, account)
- executor.shutdown()
- def yestoday():
- st = et = du.get_n_days(-1)
- huasheng(st, et)
- qiyue(st, et)
- qiyueyousheng(st, et)
- wending(st, et)
- zhangdu(st, et)
- zhangzhongyun(st, et)
- yueweng(st, et)
- youshuge(st, et)
- yangguang(st, et)
- if __name__ == '__main__':
- # zhangzhongyun()
- yangguang()
- # huasheng("2021-04-12",'2021-05-10')
- # yueweng("2021-05-11", '2021-05-11')
|