ck 4 éve
szülő
commit
785e4f555d
2 módosított fájl, 46 hozzáadás és 0 törlés
  1. 3 0
      app/etl/data_stat_hourly.py
  2. 43 0
      app/etl/dm/dm_channel_summary.py

+ 3 - 0
app/etl/data_stat_hourly.py

@@ -4,6 +4,7 @@ from model.DingTalkUtils import DingTalkUtils
 from data_stat_task import *
 from sync_to_ck_task import *
 from app.etl.dm.dm_pitcher_daily_overview import dm_pitcher_daily_overview
+from app.etl.dm.dm_channel_summary import dm_channel_summary
 log=logger()
 du = DateUtils()
 yestoday = du.get_n_days(-1)
@@ -27,6 +28,8 @@ def main():
     do_cost()
     dw_daily_channel()
     dm_pitcher_daily_overview()
+    dm_channel_summary()
+
 
 if __name__ == '__main__':
     main()

+ 43 - 0
app/etl/dm/dm_channel_summary.py

@@ -0,0 +1,43 @@
+
+import time
+from model.DateUtils import DateUtils
+from model.DataBaseUtils import MysqlUtils,CkUtils
+du = DateUtils()
+db= MysqlUtils()
+ck = CkUtils()
+
+
+
+
+def dm_channel_summary():
+    sql="""	 SELECT channel,
+                if(end>date_sub(now(),interval 10 day),'在投','停投') state,
+                location,start,end,total_cost,total_amount,
+                total_amount-total_cost profit,
+                if(total_cost=0,0,total_amount/total_cost) roi,
+                follow_user,
+                if(follow_user=0,0,total_cost/follow_user) follow_per_cost,
+                order_user,
+                if(follow_user=0,0,order_user/follow_user) order_tran_rate,
+                if(order_user=0,0,total_cost/order_user)  order_tran_cost,
+                pitcher,stage
+            FROM
+                (select
+                    channel,pitcher,stage,
+                    case when type ='vx' then 'MP' when type ='qq' then 'GDT' end location,
+                    min(if(cost>0,dt,null)) start,
+                    max(if(cost>0,dt,null)) end,
+                    sum(cost) total_cost,
+                    sum(order_amount) total_amount,
+                    sum(follow_user) follow_user,
+					sum(reg_order_user) order_user
+               from dw_daily_channel   GROUP BY channel,type,pitcher,stage) a"""
+
+    data=ck.execute(sql)
+    db.quchen_text.executeMany("replace into dm_channel_summary values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",data)
+
+
+
+
+if __name__ == '__main__':
+    dm_channel_summary()