|
@@ -131,6 +131,8 @@ def get_tt_data(account_info, li, st, et):
|
|
|
order_roi,order_count,order_rate,order_unit_price,
|
|
|
web_order_cost,first_day_order_amount,first_day_order_count,account_id
|
|
|
'''
|
|
|
+ # print(account_info)
|
|
|
+ # print(rsp.text)
|
|
|
result = rsp.json()
|
|
|
for _ in result['data']['list']:
|
|
|
campaign_info = (_['stat_datetime'][:10], _['cost'] * 100, _['show'], _['click'],
|
|
@@ -212,7 +214,7 @@ def get_daily_qq(st, et):
|
|
|
|
|
|
|
|
|
def get_daily_tt(st, et):
|
|
|
- def refresh_access_token(appid, secret, refresh_token):
|
|
|
+ def refresh_access_token(appid, account_id, secret, refresh_token):
|
|
|
open_api_url_prefix = "https://ad.oceanengine.com/open_api/"
|
|
|
uri = "oauth2/refresh_token/"
|
|
|
refresh_token_url = open_api_url_prefix + uri
|
|
@@ -230,26 +232,25 @@ def get_daily_tt(st, et):
|
|
|
sql = f'''
|
|
|
update bytedance_login_info
|
|
|
set refresh_token='{new_refresh_token}' ,access_token='{new_access_token}'
|
|
|
- where appid='{appid}'
|
|
|
+ where appid='{appid}' and account_id='{account_id}'
|
|
|
'''
|
|
|
db.quchen_text.execute(sql)
|
|
|
return rsp_data['data']['access_token']
|
|
|
|
|
|
# 1.获取refresh_token
|
|
|
sql = '''
|
|
|
- select appid,secret,refresh_token from bytedance_login_info
|
|
|
+ select appid,account_id,secret,refresh_token from bytedance_login_info
|
|
|
'''
|
|
|
accounts_info = db.quchen_text.getData(sql)
|
|
|
|
|
|
# 2.刷新refresh_token,并获取最新的access_token
|
|
|
for account_info in accounts_info:
|
|
|
-
|
|
|
- appid, secret, refresh_token = account_info
|
|
|
- access_token = refresh_access_token(appid, secret, refresh_token)
|
|
|
+ appid, account_id, secret, refresh_token = account_info
|
|
|
+ access_token = refresh_access_token(appid, account_id, secret, refresh_token)
|
|
|
# 3.获取agent_id
|
|
|
sql = f'''
|
|
|
select distinct(advertiser_id) from bytedance_pitcher_change
|
|
|
- where appid='{appid}'
|
|
|
+ where appid='{appid}' and account_id='{account_id}'
|
|
|
'''
|
|
|
advertiser_ids = db.quchen_text.getData(sql)
|
|
|
logging.info("获取头条账号:" + str(advertiser_ids.__len__()))
|
|
@@ -274,6 +275,7 @@ def run(st, et):
|
|
|
get_daily_tt(st, et)
|
|
|
logging.info('头条消耗数据拉取,结束')
|
|
|
|
|
|
+
|
|
|
def old_cost_hourly():
|
|
|
st = et = du.getNow()
|
|
|
logging.info('消耗数据拉取,开始')
|