ck hace 4 años
padre
commit
854a4e68e5
Se han modificado 1 ficheros con 30 adiciones y 22 borrados
  1. 30 22
      app/etl/data_stat_task.py

+ 30 - 22
app/etl/data_stat_task.py

@@ -28,7 +28,7 @@ def dw_daily_channel_cost(ymd):
              from daily_vx where date='{0} 00:00:00'
             union
             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(web_order_count,0) as web_order_count
              from daily_qq where date='{0} 00:00:00') a
@@ -139,26 +139,34 @@ def order_account_text():
 def dw_daily_channel_plus():
     """快照表 每日一更新  t-1"""
     sql="""insert into dw_daily_channel_plus
-            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
-            
-            from
-            (select dt,channel,picher as pitcher,stage,platform,book,cost,view_count,click_count,follow_user,order_count,order_user,order_amount from dw_daily_channel) a
-                left outer join
-                (select toDate(formatDateTime(reg_time,'%Y-%m-%d')) as dt2,channel as channel2,
-                   sum(amount) as reg_order_amount,
-                   count(distinct user_id) as reg_order_user,
-                   count(1) as reg_order_count,
-                   sum(if(subtractDays(date, 30)>reg_time,toDecimal32(0,2),amount)) as reg_order_amount30
-                   from order where reg_time>'2019-03-18 00:00:00' group by toDate(formatDateTime(reg_time,'%Y-%m-%d')),channel) b
-                    on dt=dt2 and channel=channel2 left outer join
-                 (select date as dt3,channel as channel3,
-                 count(1) as first_order_count,
-                    count(distinct user_id) as first_order_user,
-                         sum(amount) as first_order_amount
-                   from order where toDate(reg_time)=date  group by date,channel) c
-                    on dt=dt3 and channel=channel3"""
+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/100,reg_order_count,reg_order_user,reg_order_amount,reg_order_amount30,
+       web_view_count,platform_view_count,web_order_count
+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
+    (select toDate(formatDateTime(reg_time,'%Y-%m-%d')) as dt2,channel as channel2,
+       sum(amount) as reg_order_amount,
+       count(distinct user_id) as reg_order_user,
+       count(1) as reg_order_count,
+       sum(if(subtractDays(date, 30)>reg_time,toDecimal32(0,2),amount)) as reg_order_amount30
+       from order where reg_time>'2019-03-18 00:00:00' group by toDate(formatDateTime(reg_time,'%Y-%m-%d')),channel) b
+        on dt=dt2 and channel=channel2 left outer join
+     (select date as dt3,channel as channel3,
+     count(1) as first_order_count,
+        count(distinct user_id) as first_order_user,
+             sum(amount) as first_order_amount
+       from order where toDate(reg_time)=date  group by date,channel) c
+        on dt=dt3 and channel=channel3
+    left outer join
+    (select date as dt4,channel as channel4,
+     count(1) as order_count,
+        count(distinct user_id) as order_user,
+             sum(amount) as order_amount
+       from order  group by date,channel) d
+        on dt=dt4 and channel=channel4;"""
     ck.execute("truncate table dw_daily_channel_plus")
     ck.execute(sql)
     print("ok")
@@ -178,7 +186,7 @@ if __name__ == '__main__':
         # ods_order(i)
         # channel_by_account_daily(i)
         # channel_info_daily(i)
-        # dw_daily_channel_cost(i)
+        dw_daily_channel_cost(i)
         dw_order_channel_cost_sync_ck(i)