Browse Source

添加广告投放,游戏趋势新指标

cola 2 năm trước cách đây
mục cha
commit
095584735d
2 tập tin đã thay đổi với 41 bổ sung13 xóa
  1. 21 13
      data_manage/pitcher_panel.py
  2. 20 0
      data_manage/public_analysis.py

+ 21 - 13
data_manage/pitcher_panel.py

@@ -129,16 +129,19 @@ def get_channel_overview(user_id, channel, pitcher, stage, book,agent_id, start,
             op = f" and channel in {str(UserAuthUtils.get_auth_channel(user_id))}"
     op1 = f" and pitcher ='{pitcher}' " if pitcher else ''
     op2 = f" and channel='{channel}'" if channel else ''
-    op3 = f" and dt>='{start}' " if start else ''
-    op4 = f" and dt<='{end}' " if end else ''
+    op3 = f" and a.dt>='{start}' " if start else ''
+    op4 = f" and a.dt<='{end}' " if end else ''
     op5 = f" order by {order_by} {order}" if order_by and order else ''
     op6 = f" and stage='{stage}'" if stage else ''
     op7 = f" and book='{book}'" if book else ''
     op8 = f" and agent_id = '{agent_id}'" if agent_id else ''
 
-    sql = f"""select channel,dt date,agent_name,reg_num,
+    sql = f"""select a.channel,a.dt date,agent_name,reg_num,
            round(if(reg_num=0,0,cost/reg_num),2) reg_per_cost,
         create_user_num,
+        hundred_user_num, -- 单日付费100+用户数
+		round(cost/hundred_user_num,2) hundred_user_num_cost , --  单日付费100+用户付费成本
+		round(da7/cost,4) roi7, -- 最近7日首日ROI 
        round(if(create_user_num=0,0,cost/create_user_num),2) create_user_per_cost,        
        view_count,click_count,
        round(if(view_count=0,0,click_count/view_count),4) click_rate,
@@ -177,12 +180,17 @@ def get_channel_overview(user_id, channel, pitcher, stage, book,agent_id, start,
         round(reg_order_amount/reg_order_user,2) user_per_amount, 
         round(follow_user/click_count,4) click_follow_rate, 
         round(reg_order_user/follow_user,4) follow_order_rate 
-from dw_channel where 1=1 {op}  {op1} {op2} {op3} {op4} {op6} {op7} {op8} {op5} """
+from dw_channel a
+left join dw_channel_amount_daily b on a.dt=b.dt and a.channel=b.channel
+ where 1=1 {op}  {op1} {op2} {op3} {op4} {op6} {op7} {op8} {op5} """
 
     sumsql = f"""select '总计' date,
     sum(reg_num) reg_num,
     
     max(game_user_sum) game_user_sum,
+    sum(hundred_user_num) hundred_user_num, -- 单日付费100+用户数
+	sum(round(hundred_user_num_cost,2)) hundred_user_num_cost, --  单日付费100+用户付费成本
+	sum(round(roi7,4)) roi7, -- 最近7日首日ROI 
     round(if(sum(reg_num)=0,0,sum(reg_num*sixty_stay_rate)/sum(reg_num)),2) sixty_stay_rate,
     round(if(sum(reg_num)=0,0,sum(reg_num*fortyfive_stay_rate)/sum(reg_num)),2) fortyfive_stay_rate,
     round(if(sum(reg_num)=0,0,sum(reg_num*thirty_stay_rate)/sum(reg_num)),2) thirty_stay_rate,
@@ -1357,7 +1365,7 @@ def get_pitcher_trend(pitcher, start=None, end=None, page=None, page_size=None,
             reg_order_user , -- 至今付费人数
             reg_order_count, -- 至今付费次数
             round(cost/create_user_num,2) create_user_num_cost,  -- 新增创角单价
-            round(cost/reg_order_user) reg_order_user_cost , -- 至今付费单价
+            round(cost/reg_order_user,2) reg_order_user_cost , -- 至今付费单价
             cost,
             reg_amount,
             d1 first_amount,
@@ -1412,18 +1420,18 @@ def get_pitcher_trend(pitcher, start=None, end=None, page=None, page_size=None,
     sum(reg_num) reg_num,
     sum(create_user_num) create_user_num,
     sum(reg_amount) reg_amount,
-    sum(first_order_user) first_order_user, -- 新增付费人数
-    sum(first_order_cost) first_order_cost, -- 新增付费成本
-    sum(create_user_per_cost) create_user_per_cost, -- 新注册用户平均付费
-    sum(ARPU) ARPU, -- 新增付费ARPU
+    sum(round(first_order_user,2)) first_order_user, -- 新增付费人数
+    sum(round(first_order_cost,2)) first_order_cost, -- 新增付费成本
+    sum(round(create_user_per_cost,2)) create_user_per_cost, -- 新注册用户平均付费
+    sum(round(ARPU,2)) ARPU, -- 新增付费ARPU
     sum(round(first_order_rate,4)) first_order_rate, -- 新增付费率
-    sum(order_ARPU) order_ARPU,  -- 付费ARPU
+    sum(round(order_ARPU,2)) order_ARPU,  -- 付费ARPU
     sum(hundred_user_num) hundred_user_num, -- 单日付费100+用户数
-    sum(hundred_user_num_cost) hundred_user_num_cost, --  单日付费100+用户付费成本
+    sum(round(hundred_user_num_cost,2)) hundred_user_num_cost, --  单日付费100+用户付费成本
     sum(reg_order_user) reg_order_user, -- 至今付费人数
     sum(reg_order_count) reg_order_count, -- 至今付费次数
-    sum(create_user_num_cost) create_user_num_cost,  -- 新增创角单价
-    sum(reg_order_user_cost) reg_order_user_cost, -- 至今付费单价
+    sum(round(create_user_num_cost,2)) create_user_num_cost,  -- 新增创角单价
+    sum(round(reg_order_user_cost,2)) reg_order_user_cost, -- 至今付费单价
     round(sum(first_amount)/sum(cost),4) first_roi,
     round(sum(reg_amount)/sum(cost),4) roi,
     sum(profit) profit,

+ 20 - 0
data_manage/public_analysis.py

@@ -51,6 +51,16 @@ def book_trend(start, end, book, book_type, platform, page, page_size, order_by,
 
     sql = f"""
         select dt,book,type,cost,first_order_amount,reg_order_amount,
+            round(cost/reg_num,2) reg_per_cost, -- 新增用户单价
+            round(first_order_amount/first_order_user,2)  ARPU, -- 新增付费ARPU
+            round(first_order_user/reg_num,4) order_rate, -- 新增付费率
+            round(reg_order_amount/reg_order_user,2) order_ARPU,  -- 付费ARPU
+            hundred_user_num, -- 单日付费100+用户数
+            round(cost/hundred_user_num,2) hundred_user_num_cost , --  单日付费100+用户付费成本
+            reg_order_count, -- 至今付费次数
+            round(cost/create_user_num,2) create_user_num_cost,  -- 新增创角单价
+            round(first_order_amount,2) , -- 新增付费金额
+            round(reg_order_amount,2), -- 至今付费金额
             round(first_order_amount/cost,4) first_roi,
             a7,a30,
             round(a7/cost,4) roi7,
@@ -159,6 +169,16 @@ from book_trend where 1=1  {op1} {op2} {op4} {op5}  {op6}
     sum_sql = f"""select concat(date_format(min(dt),'%Y/%m/%d'),'~',date_format(max(dt),'%Y/%m/%d')) dt,
 sum(cost) cost,
 sum(reg_num) reg_num,
+round(sum(reg_per_cost),2) reg_per_cost, -- 新增用户单价
+round(sum(ARPU),2)  ARPU, -- 新增付费ARPU
+round(sum(order_rate),4) order_rate, -- 新增付费率
+round(sum(order_ARPU),2) order_ARPU,  -- 付费ARPU
+sum(hundred_user_num) hundred_user_num, -- 单日付费100+用户数
+round(sum(hundred_user_num_cost),2)  hundred_user_num_cost, --  单日付费100+用户付费成本
+sum(reg_order_count) reg_order_count, -- 至今付费次数
+round(sum(create_user_num_cost),2) create_user_num_cost,  -- 新增创角单价
+round(sum(first_order_amount),2) first_order_amount, -- 新增付费金额
+round(sum(reg_order_amount),2) reg_order_amount, -- 至今付费金额
 sum(create_user_num) create_user_num,
 sum(first_order_amount) first_order_amount,
 sum(reg_order_amount) reg_order_amount,