yangguang.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. from app.api_data.platform_order.order_util import *
  2. from model.DataBaseUtils import MysqlUtils
  3. from model.DingTalkUtils import DingTalkDecorators,DingTalkUtils
  4. from model.DateUtils import DateUtils
  5. db = MysqlUtils()
  6. du = DateUtils()
  7. @DingTalkDecorators("阳光")
  8. def yangguang(start=None, end=None):
  9. accounts = get_account("阳光")
  10. if start:
  11. start = start + ' 00:00:00'
  12. end = end + ' 23:59:59'
  13. else:
  14. start = du.getTodayOrYestoday() + ' 00:00:00'
  15. end = du.get_n_hours_ago(0)
  16. client_id = 10008097
  17. token = '2xa1d55tTPBjeEA8Ho'
  18. if accounts.__len__() == 0:
  19. return
  20. else:
  21. print(f"阳光账号数:{accounts.__len__()}")
  22. for i in accounts:
  23. stage = i[0]
  24. vip_id = i[1]
  25. print(vip_id)
  26. # get_yg_vip_channel(stage, vip_id, client_id, token)
  27. get_yg_data(stage, vip_id, client_id, token, start, end)
  28. print(check())
  29. parse_data()
  30. def get_channel_info():
  31. accounts = get_account("阳光")
  32. client_id = 10008097
  33. token = '2xa1d55tTPBjeEA8Ho'
  34. for i in accounts:
  35. stage = i[0]
  36. vip_id = i[1]
  37. print(vip_id)
  38. get_yg_vip_channel(stage, vip_id, client_id, token)
  39. def parse_data():
  40. print(111)
  41. accounts = get_account("阳光")
  42. for i in accounts:
  43. # print(i)
  44. vip_id = i[1]
  45. stage = i[0]
  46. parse_yg_data(vip_id, stage)
  47. def check():
  48. x = 1
  49. while True:
  50. a = db.quchen_text.getOne("select count(1) from yangguang_path where type ='order' and path is null")
  51. print(f" 回调接口 待处理数量 {a} ")
  52. if a == 0:
  53. info = '回调完成'
  54. break
  55. time.sleep(60)
  56. x += 1
  57. if x > 10:
  58. DingTalkUtils.send('阳光订单回调延时10min', '18860455786')
  59. info = '回调未完成'
  60. break
  61. return info
  62. def get_account(plactform, id=None):
  63. op = f" and id={id} " if id else ''
  64. data = db.quchen_text.getData(f"select text from order_account_text where platform='{plactform}' {op}")
  65. new_data = []
  66. for i in data:
  67. new_data.append(i[0].replace('\n', '').split(","))
  68. return new_data
  69. def daily_yg():
  70. st = du.get_n_days(-10)
  71. et = du.get_n_days(-1)
  72. yangguang(st, et)
  73. if __name__ == '__main__':
  74. # get_channel_info()
  75. # exit(0)
  76. # yangguang('2020-09-20','2020-10-01')
  77. # exit(0)
  78. for i in du.split_date2('2020-06-28','2020-11-03',30):
  79. print(i)
  80. yangguang(i[0], i[1])