123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- from app.api_data.platform_order.order_util import *
- from model.DataBaseUtils import MysqlUtils
- from model.DingTalkUtils import DingTalkDecorators,DingTalkUtils
- from model.DateUtils import DateUtils
- db = MysqlUtils()
- du = DateUtils()
- @DingTalkDecorators("阳光")
- def yangguang(start=None, end=None):
- accounts = get_account("阳光")
- if start:
- start = start + ' 00:00:00'
- end = end + ' 23:59:59'
- else:
- start = du.getTodayOrYestoday() + ' 00:00:00'
- end = du.get_n_hours_ago(0)
- client_id = 10008097
- token = '2xa1d55tTPBjeEA8Ho'
- if accounts.__len__() == 0:
- return
- else:
- print(f"阳光账号数:{accounts.__len__()}")
- for i in accounts:
- stage = i[0]
- vip_id = i[1]
- print(vip_id)
- # get_yg_vip_channel(stage, vip_id, client_id, token)
- get_yg_data(stage, vip_id, client_id, token, start, end)
- print(check())
- parse_data()
- def get_channel_info():
- accounts = get_account("阳光")
- client_id = 10008097
- token = '2xa1d55tTPBjeEA8Ho'
- for i in accounts:
- stage = i[0]
- vip_id = i[1]
- print(vip_id)
- get_yg_vip_channel(stage, vip_id, client_id, token)
- def parse_data():
- print(111)
- accounts = get_account("阳光")
- for i in accounts:
- # print(i)
- vip_id = i[1]
- stage = i[0]
- parse_yg_data(vip_id, stage)
- def check():
- x = 1
- while True:
- a = db.quchen_text.getOne("select count(1) from yangguang_path where type ='order' and path is null")
- print(f" 回调接口 待处理数量 {a} ")
- if a == 0:
- info = '回调完成'
- break
- time.sleep(60)
- x += 1
- if x > 10:
- DingTalkUtils.send('阳光订单回调延时10min', '18860455786')
- info = '回调未完成'
- break
- return info
- 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 daily_yg():
- st = du.get_n_days(-10)
- et = du.get_n_days(-1)
- yangguang(st, et)
- if __name__ == '__main__':
- # get_channel_info()
- # exit(0)
- # yangguang('2020-09-20','2020-10-01')
- # exit(0)
- for i in du.split_date2('2020-06-28','2020-11-03',30):
- print(i)
- yangguang(i[0], i[1])
|