Explorar el Código

MOD:添加创角人数平均付费,注册人数平均付费

cxyu hace 3 años
padre
commit
0cc2180a5b
Se han modificado 1 ficheros con 20 adiciones y 3 borrados
  1. 20 3
      app/etl/data_stat_task.py

+ 20 - 3
app/etl/data_stat_task.py

@@ -94,7 +94,7 @@ def dw_daily_channel_cost(ymd):
                ifnull(platform_view_count,0) platform_view_count,
                ifnull(web_order_count,0) web_order_count,
                if(stage ='趣程15期' or stage ='趣程26期' or stage ='趣程30期','GDT','MP') type
-                ,0 require_roi,0 require_mult,ifnull(y.create_user_num,0)
+                ,0 require_roi,0 require_mult,ifnull(y.reg_num,0),ifnull(w.create_user_num,0)
                  from
         ( select dt, channel,stage,pitcher,platform,book  from channel_info_daily cid 
             where dt='{ymd}' and channel !=''
@@ -131,7 +131,7 @@ def dw_daily_channel_cost(ymd):
        left join     
         (
         select c.name as channel ,DATE(FROM_UNIXTIME(origin.create_time)) as wx_date,
-        count(*) as create_user_num
+        count(*) as reg_num
         from 
         db_mp.h_member origin left join
         db_mp.mp_conf_agent a  on origin.app_id =a.app_id and origin.agent_id = a.agent_id 
@@ -144,10 +144,27 @@ def dw_daily_channel_cost(ymd):
         group by name,wx_date
         ) y on x.channel= y.channel
         
+        left join     
+        (
+        select f.name as channel,DATE(FROM_UNIXTIME(a.create_time)) as wx_date,
+        count(*) as create_user_num
+        from db_mp.h_mg_role a
+        left join db_mp.h_mem_game b on a.mg_mem_id = b.id
+        left join db_mp.h_member c on b.mem_id = c.id
+        left join db_mp.mp_conf_agent d on c.app_id = d.app_id  and c.agent_id = d.agent_id 
+        left join db_mp.mp_mp_conf e on d.advertiser_conf_id =e.id
+        left join quchen_text.advertiser_vx f on e.mp_id = f.wechat_account_id 
+        where f.name is not null 
+        and a.create_time > {timestamp_ymd} and a.create_time < {timestamp_tom}
+        group by f.name,wx_date
+        order by wx_date desc
+        ) w on x.channel= w.channel
+
+        
         """
     data = db.quchen_text.get_data_list(sql)
     data1 = []
-    col = "dt,channel,pitcher,stage,platform,book,view_count,click_count,follow_user,cost,web_view_count,platform_view_count,web_order_count,type,require_roi,require_mult,create_user_num"
+    col = "dt,channel,pitcher,stage,platform,book,view_count,click_count,follow_user,cost,web_view_count,platform_view_count,web_order_count,type,require_roi,require_mult,reg_num,create_user_num"
     for i in data:
         i[0] = str(i[0])
         i[9] = str(i[9])