|
@@ -19,28 +19,27 @@ def dw_daily_channel_cost(ymd):
|
|
ifnull(web_order_count,0) web_order_count,
|
|
ifnull(web_order_count,0) web_order_count,
|
|
ifnull(type,''),0 require_roi,0 require_mult
|
|
ifnull(type,''),0 require_roi,0 require_mult
|
|
from
|
|
from
|
|
- (select dt,channel,stage,pitcher,platform,book from channel_info_daily where dt='{0}' and channel!='') x
|
|
|
|
|
|
+ (select dt,channel,stage,pitcher,platform,book from channel_info_daily where dt='{0}' and channel!='' ) x
|
|
left join
|
|
left join
|
|
(select channel,sum(cost) as cost,sum(view_count) as view_count,sum(valid_click_count) as click_count,sum(from_follow_uv) as follow_user,
|
|
(select channel,sum(cost) as cost,sum(view_count) as view_count,sum(valid_click_count) as click_count,sum(from_follow_uv) as follow_user,
|
|
- sum(web_view_count) as web_view_count,sum(platform_view_count) as platform_view_count,sum(web_order_count) as web_order_count
|
|
|
|
|
|
+ sum(web_view_count) as web_view_count,sum(platform_view_count) as platform_view_count,sum(web_order_count) as web_order_count,type
|
|
from
|
|
from
|
|
(select account_id,cost,view_count,valid_click_count,round(valid_click_count*official_account_follow_rate,0) as from_follow_uv,
|
|
(select account_id,cost,view_count,valid_click_count,round(valid_click_count*official_account_follow_rate,0) as from_follow_uv,
|
|
0 as web_view_count,
|
|
0 as web_view_count,
|
|
0 as platform_view_count,
|
|
0 as platform_view_count,
|
|
- 0 as web_order_count
|
|
|
|
|
|
+ 0 as web_order_count,'vx' type
|
|
from daily_vx where date='{0} 00:00:00'
|
|
from daily_vx where date='{0} 00:00:00'
|
|
union
|
|
union
|
|
select account_id,cost,view_count,valid_click_count,from_follow_uv,
|
|
select account_id,cost,view_count,valid_click_count,from_follow_uv,
|
|
ifnull(web_commodity_page_view_count,0) as web_view_count,
|
|
ifnull(web_commodity_page_view_count,0) as web_view_count,
|
|
ifnull(platform_page_view_count,0) as platform_view_count,
|
|
ifnull(platform_page_view_count,0) as platform_view_count,
|
|
- ifnull(web_order_count,0) as web_order_count
|
|
|
|
- from daily_qq where date='{0} 00:00:00') a
|
|
|
|
|
|
+ ifnull(web_order_count,0) as web_order_count,'qq' type
|
|
|
|
+ from daily_qq where date='{0} 00:00:00' ) a
|
|
left join
|
|
left join
|
|
- (select account_id,channel from channel_by_account_daily where dt='{0}') b on a.account_id=b.account_id group by channel)
|
|
|
|
- z on x.channel=z.channel
|
|
|
|
- left join (SELECT channel,type from channel_by_account_daily GROUP By channel,type) k on x.channel=k.channel
|
|
|
|
|
|
+ (select account_id,channel from channel_by_account_daily where dt='{0}') b
|
|
|
|
+ on a.account_id=b.account_id group by channel)
|
|
|
|
+ z on x.channel=z.channel
|
|
|
|
|
|
-
|
|
|
|
""".format(ymd)
|
|
""".format(ymd)
|
|
data=db.quchen_text.get_data_list(sql)
|
|
data=db.quchen_text.get_data_list(sql)
|
|
data1 = []
|
|
data1 = []
|
|
@@ -64,10 +63,10 @@ def channel_by_account_daily(ymd):
|
|
"""返回当天消耗账户对应的公众号表"""
|
|
"""返回当天消耗账户对应的公众号表"""
|
|
print("run> channel_by_account_daily")
|
|
print("run> channel_by_account_daily")
|
|
sql="""replace into channel_by_account_daily
|
|
sql="""replace into channel_by_account_daily
|
|
- select '{0}' as dt,a.account_id as account_id, ifnull(ifnull(b.name,a.name),'') as channel,type from
|
|
|
|
- (select account_id,name,'qq' as type from advertiser_qq
|
|
|
|
|
|
+ select '{0}' as dt,a.account_id as account_id, ifnull(ifnull(b.name,a.name),'') as channel,'' type from
|
|
|
|
+ (select account_id,name from advertiser_qq
|
|
union
|
|
union
|
|
- select account_id,name,'vx' as type from advertiser_vx
|
|
|
|
|
|
+ select account_id,name as type from advertiser_vx
|
|
) a
|
|
) a
|
|
left join
|
|
left join
|
|
(select b.account_id,b.name from
|
|
(select b.account_id,b.name from
|
|
@@ -159,5 +158,8 @@ def order_account_text():
|
|
db.quchen_text.execute("insert into order_account_text(platform,text) values ('文鼎','{}')".format(i))
|
|
db.quchen_text.execute("insert into order_account_text(platform,text) values ('文鼎','{}')".format(i))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
- dw_daily_channel_cost('2019-10-23')
|
|
|
|
|
|
+
|
|
|
|
+ for i in dt.getDateLists('2020-04-23','2021-02-05'):
|
|
|
|
+ print(i)
|
|
|
|
+ dw_daily_channel_cost(i)
|
|
|
|
|