|
@@ -147,7 +147,7 @@ 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
|
|
|
+ web_view_count,platform_view_count,web_order_count,total_cost,total_amount,reg_order_user2
|
|
|
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
|
|
|
left outer join
|
|
@@ -173,7 +173,14 @@ from
|
|
|
on dt=dt4 and channel=channel4
|
|
|
left outer join
|
|
|
(select dt dt5,channel channel5,total_cost,total_amount from dw_channel_daily_total ) e
|
|
|
- on dt=dt5 and channel=channel5
|
|
|
+ on dt=dt5 and channel=channel5
|
|
|
+
|
|
|
+left outer join (
|
|
|
+select sum(if(user_order_count>1,1,0)) reg_order_user2,channel channel6,toDate(reg_date) dt6 from (
|
|
|
+select formatDateTime(reg_time,'%Y-%m-%d') reg_date,channel,count(1) user_order_count
|
|
|
+ from order group by formatDateTime(reg_time,'%Y-%m-%d') ,user_id,channel
|
|
|
+ ) x group by reg_date,channel
|
|
|
+ ) f on dt=dt6 and channel=channel6
|
|
|
"""
|
|
|
ck.execute("truncate table dw_daily_channel")
|
|
|
ck.execute(sql)
|
|
@@ -251,14 +258,13 @@ having pitcher != ''"""
|
|
|
|
|
|
|
|
|
def dw_channel_daily_total(ymd):
|
|
|
- """每天的公众号数据 (不包含向后数据)"""
|
|
|
sql=f"""insert into dw_channel_daily_total
|
|
|
select '{ymd}' dt,channel,total_cost,total_amount from
|
|
|
(select channel,sum(cost) total_cost from dw_daily_channel_cost where dt<='{ymd}' group by channel)a
|
|
|
left outer join
|
|
|
(select channel,sum(amount) total_amount from order where date<='{ymd}' group by channel) b
|
|
|
on a.channel=b.channel"""
|
|
|
- ck.execute(f"alter table dm_pitcher_daily_page_total drop partition '{ymd}'")
|
|
|
+ ck.execute(f"alter table dw_channel_daily_total drop partition '{ymd}'")
|
|
|
ck.execute(sql)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
@@ -274,11 +280,12 @@ if __name__ == '__main__':
|
|
|
# dm_pitcher_daily_page_total()
|
|
|
# dw_channel_daily_total('2020-12-28')
|
|
|
# exit(0)
|
|
|
-
|
|
|
- for i in dt.getDateLists('2019-03-18','2021-01-04'):
|
|
|
+ dw_daily_channel()
|
|
|
+ exit(0)
|
|
|
+ for i in dt.getDateLists('2019-03-18','2021-01-05'):
|
|
|
print(i)
|
|
|
# ods_order(i)
|
|
|
# channel_info_daily(i)
|
|
|
- dw_daily_channel_cost(i)
|
|
|
- dw_order_channel_cost_sync_ck(i)
|
|
|
-
|
|
|
+ # dw_daily_channel_cost(i)
|
|
|
+ # dw_order_channel_cost_sync_ck(i)
|
|
|
+ dw_channel_daily_total(i)
|