|
@@ -16,11 +16,12 @@ def dw_daily_channel_cost(ymd):
|
|
|
ifnull(view_count,0),ifnull(click_count,0),ifnull(follow_user,0),ifnull(cost,0)/100 as cost,
|
|
|
ifnull(web_view_count,0) web_view_count,
|
|
|
ifnull(platform_view_count,0) platform_view_count,
|
|
|
- ifnull(web_order_count,0) web_order_count
|
|
|
+ ifnull(web_order_count,0) web_order_count,
|
|
|
+ ifnull(type,'')
|
|
|
from
|
|
|
(select dt,channel,stage,pitcher,platform,book from channel_info_daily where dt='{0}' and channel!='') x
|
|
|
left join
|
|
|
- (select channel,type,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
|
|
|
from
|
|
|
(select account_id,cost,view_count,valid_click_count,round(valid_click_count*official_account_follow_rate,0) as from_follow_uv,
|
|
@@ -35,8 +36,12 @@ def dw_daily_channel_cost(ymd):
|
|
|
ifnull(web_order_count,0) as web_order_count
|
|
|
from daily_qq where date='{0} 00:00:00') a
|
|
|
left join
|
|
|
- (select account_id,channel,type from channel_by_account_daily where dt='{0}') b on a.account_id=b.account_id group by channel,type) z on x.channel=z.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
|
|
|
+ left join (SELECT channel,type from channel_by_account_daily GROUP By channel,type) k on x.channel=k.channel
|
|
|
+
|
|
|
""".format(ymd)
|
|
|
+ print(sql)
|
|
|
|
|
|
db.quchen_text.execute(sql)
|
|
|
|
|
@@ -53,6 +58,7 @@ def channel_by_account_daily(ymd):
|
|
|
(select b.account_id,b.name from
|
|
|
(select min(end_time) as end_time,account_id from account_change where end_time>'{0}' GROUP BY account_id) a
|
|
|
left join account_change b on a.end_time=b.end_time and a.account_id=b.account_id) b on a.account_id=b.account_id""".format(ymd)
|
|
|
+ print(sql)
|
|
|
db.quchen_text.execute(sql)
|
|
|
|
|
|
def channel_info_daily(ymd):
|
|
@@ -75,7 +81,8 @@ def channel_info_daily(ymd):
|
|
|
select name,ifnull(stage,'') stage,ifnull(pitcher,'') pitcher,ifnull(platform,'') platform,ifnull(book,'') book from advertiser_qq where name is not null group by name,stage,pitcher,platform,book
|
|
|
union
|
|
|
select name,ifnull(stage,'') stage,ifnull(pitcher,'') pitcher,ifnull(platform,'') platform,ifnull(book,'') book from advertiser_vx where name is not null and name !=''
|
|
|
- ) b on a.name=b.name""".format(ymd)
|
|
|
+ ) b on a.name=b.name
|
|
|
+ """.format(ymd)
|
|
|
data=db.quchen_text.get_data_list(sql)
|
|
|
|
|
|
|
|
@@ -147,9 +154,9 @@ select
|
|
|
dt,channel,pitcher,stage,platform,book,
|
|
|
order_count,order_user,order_amount,first_order_count,first_order_user,first_order_amount,
|
|
|
view_count,click_count,follow_user,cost,reg_order_count,reg_order_user,reg_order_amount,reg_order_amount30,
|
|
|
- web_view_count,platform_view_count,web_order_count,total_cost,total_amount,reg_order_user_again,reg_order_user7,reg_order_user30,reg_order_amount7
|
|
|
+ web_view_count,platform_view_count,web_order_count,total_cost,total_amount,reg_order_user_again,reg_order_user7,reg_order_user30,reg_order_amount7,type
|
|
|
from
|
|
|
-(select dt,channel, pitcher,stage,platform,book,cost,view_count,click_count,follow_user,web_view_count,platform_view_count,web_order_count from dw_daily_channel_cost) a
|
|
|
+(select dt,channel, pitcher,stage,platform,book,cost,view_count,click_count,follow_user,web_view_count,platform_view_count,web_order_count,type from dw_daily_channel_cost) a
|
|
|
left outer join
|
|
|
(select toDate(formatDateTime(reg_time,'%Y-%m-%d')) as dt2,channel as channel2,
|
|
|
sum(amount) as reg_order_amount,
|
|
@@ -299,12 +306,15 @@ if __name__ == '__main__':
|
|
|
# exit(0)
|
|
|
# dm_pitcher_daily_page_total()
|
|
|
# dm_pitcher_daily_page_total()
|
|
|
- dw_channel_daily_total('2021-01-11')
|
|
|
+ # dw_channel_daily_total('2021-01-11')
|
|
|
+ dw_daily_channel_cost('2021-01-12')
|
|
|
exit(0)
|
|
|
+
|
|
|
# dw_daily_channel()
|
|
|
# # exit(0)
|
|
|
- # for i in dt.getDateLists('2019-03-18','2021-01-05'):
|
|
|
- # print(i)
|
|
|
+ for i in dt.getDateLists('2019-03-18','2020-12-18'):
|
|
|
+ print(i)
|
|
|
+ channel_by_account_daily(i)
|
|
|
# order_sync_ck(today)
|
|
|
# # ods_order(i)
|
|
|
# channel_info_daily(i)
|