ck %!s(int64=4) %!d(string=hai) anos
pai
achega
7152179925
Modificáronse 1 ficheiros con 7 adicións e 6 borrados
  1. 7 6
      data_manage/pitcher_panel.py

+ 7 - 6
data_manage/pitcher_panel.py

@@ -340,8 +340,9 @@ select
 def get_channel_active(channel,pitcher,start,end,page,page_size,order_by,order):
     # channels=f' and channel in {get_channels_from_user(pitcher)} ' if pitcher !='赞象 admin' else ''
     channels=''
-    channel_op=f" and channel='{channel}' "
-    sql=f"""select formatDateTime(a.dt,'%Y-%m-%d') date, '{channel}' channel,book,toDecimal32(cost,2),toDecimal32(reg_amount,2),roi,new_follow_user,toDecimal32(new_follow_per_cost,2),order_user,order_count,
+    channel_op=f" and channel='{channel}' " if channel!='' else ''
+
+    sql=f"""select pitcher,formatDateTime(a.dt,'%Y-%m-%d') date,channel,book,toDecimal32(cost,2),toDecimal32(reg_amount,2),roi,new_follow_user,toDecimal32(new_follow_per_cost,2),order_user,order_count,
        toDecimal32(order_user_per_cost,2),day7_avg_act_rate,toDecimal32(day7_avg_act_per_cost,2),day30_avg_act_rate,toDecimal32(ay30_avg_act_cost,2),
        toDecimal32(act_per_cost,2),
        concat(toString(reg_order_user1),',',toString(if(reg_order_user1=0,0,cost/reg_order_user1)),',',toString(if(order_user=0,0,reg_order_user1/order_user))),
@@ -377,7 +378,7 @@ def get_channel_active(channel,pitcher,start,end,page,page_size,order_by,order):
 
        from (
 
-select dt,book,cost,
+select dt,book,cost,pitcher,channel
        reg_order_amount reg_amount,
        if(cost=0,0,reg_order_amount/cost) roi,
        follow_user new_follow_user,
@@ -393,7 +394,7 @@ select dt,book,cost,
        from dw_daily_channel where 1=1 {channel_op}  and dt>='{start}' and dt<='{end}') a
 left outer join (
 
-select toDate(formatDateTime(reg_time,'%Y-%m-%d')) dt,
+select toDate(formatDateTime(reg_time,'%Y-%m-%d')) dt,channel,
        count(distinct if(toDate(formatDateTime(reg_time,'%Y-%m-%d'))=date,user_id,NULL)) reg_order_user1,
        count(distinct if(addDays(toDate(formatDateTime(reg_time,'%Y-%m-%d')),1)>=date,user_id,NULL)) reg_order_user2,
        count(distinct if(addDays(toDate(formatDateTime(reg_time,'%Y-%m-%d')),2)>=date,user_id,NULL)) reg_order_user3,
@@ -424,7 +425,7 @@ select toDate(formatDateTime(reg_time,'%Y-%m-%d')) dt,
        count(distinct if(addDays(toDate(formatDateTime(reg_time,'%Y-%m-%d')),27)>=date,user_id,NULL)) reg_order_user28,
        count(distinct if(addDays(toDate(formatDateTime(reg_time,'%Y-%m-%d')),28)>=date,user_id,NULL)) reg_order_user29,
        count(distinct if(addDays(toDate(formatDateTime(reg_time,'%Y-%m-%d')),29)>=date,user_id,NULL)) reg_order_user30
-       from order where  1=1 {channel_op}  and dt>='{start}' group by formatDateTime(reg_time,'%Y-%m-%d')) b on a.dt=b.dt 
+       from order where  1=1 {channel_op}  and dt>='{start}' group by formatDateTime(reg_time,'%Y-%m-%d'),channel ) b on a.dt=b.dt and a.channel=b.channel
 """
     print(sql)
 
@@ -434,7 +435,7 @@ select toDate(formatDateTime(reg_time,'%Y-%m-%d')) dt,
     print(sql)
     print(data)
 
-    key=['date','channel','book','cost','reg_amount','roi','new_follow_user','new_follow_per_cost','order_user','order_count','order_user_per_cost',
+    key=['pitcher','date','channel','book','cost','reg_amount','roi','new_follow_user','new_follow_per_cost','order_user','order_count','order_user_per_cost',
          'day7_avg_act_rate','day7_avg_act_per_cost','day30_avg_act_rate','day30_avg_act_cost','act_per_cost','d1','d2','d3','d4','d5','d6','d7','d8','d9','d10',
          'd11','d12','d13','d14','d15','d16','d17','d18','d19','d20','d21','d22','d23','d24','d25','d26','d27','d28','d29','d30']