get_order.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import requests
  2. import time
  3. import hashlib
  4. import json
  5. from app.api_data.order_util import *
  6. from model.DataBaseUtils import MysqlUtils
  7. from model.DateUtils import DateUtils
  8. from concurrent.futures import ProcessPoolExecutor,ThreadPoolExecutor
  9. db=MysqlUtils()
  10. def get_account(plactform):
  11. data = db.quchen_text.getData(f"select text from order_account_text where platform='{plactform}'")
  12. new_data = []
  13. for i in data:
  14. new_data.append(i[0].replace('\n', '').split(","))
  15. return new_data
  16. def yangguang(start=None, end=None):
  17. if start:
  18. start = start+' 00:00:00'
  19. end = end+' 23:59:59'
  20. else:
  21. start = du.getTodayOrYestoday() + ' 00:00:00'
  22. end = du.get_n_hours_ago(0)
  23. client_id = 10008097
  24. token = '2xa1d55tTPBjeEA8Ho'
  25. accounts=get_account("阳光")
  26. for i in accounts:
  27. stage = i[0]
  28. vip_id = i[1]
  29. print(vip_id)
  30. get_yg_vip_channel(stage, vip_id, client_id, token)
  31. get_yg_data(stage, vip_id, client_id, token, start, end)
  32. while True:
  33. a = db.quchen_text.getOne("select count(1) from yangguang_path where update_time is null")
  34. print(f" vip 待处理数量 {a} 正在等待数据回调")
  35. if a == 0:
  36. break
  37. time.sleep(60)
  38. for i in accounts:
  39. vip_id = i[1]
  40. parse_yg_data(vip_id)
  41. def huasheng(start=None,end=None):
  42. if start is None:
  43. start = end = du.getTodayOrYestoday()
  44. executor = ThreadPoolExecutor(max_workers=5)
  45. accounts = get_account("花生")
  46. li = []
  47. for account in accounts:
  48. channel_data = get_hs_channel(account)
  49. if not channel_data:
  50. continue
  51. for merchant in channel_data:
  52. executor.submit(get_huasheng_order_task, start, end, account, merchant,li)
  53. executor.shutdown(True)
  54. save_hs_data(li)
  55. if __name__ == '__main__':
  56. # yangguang('2021-01-16','2021-01-18')
  57. huasheng('2021-01-18','2021-01-18')
  58. """要是只跑一个账号 把 get_yg_acccount() 里面的sql where 条件加上 id=xxx"""