ck vor 4 Jahren
Ursprung
Commit
1693c6a988
1 geänderte Dateien mit 14 neuen und 5 gelöschten Zeilen
  1. 14 5
      data_manage/pitcher_panel.py

+ 14 - 5
data_manage/pitcher_panel.py

@@ -338,9 +338,13 @@ 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}' " if channel!='' else ''
+    if pitcher != '赞象 admin':
+        if get_channels_from_user(pitcher).__len__() == 0:
+            pitcher_op = f"  and pitcher='{pitcher}'"
+        else:
+            pitcher_op = f" and channel in {get_channels_from_user(pitcher)}"
 
     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),
@@ -391,7 +395,7 @@ select dt,book,cost,pitcher,channel,
        if(follow_user=0,0,reg_order_user30/follow_user) day30_avg_act_rate,
        if(reg_order_user30=0,0,cost/reg_order_user30) ay30_avg_act_cost,
        if(reg_order_user=0,0,cost/reg_order_user) act_per_cost
-       from dw_daily_channel where 1=1 {channel_op}  and dt>='{start}' and dt<='{end}') a
+       from dw_daily_channel where 1=1 {channel_op}  and dt>='{start}' and dt<='{end}' {pitcher_op}) a
 left outer join (
 
 select toDate(formatDateTime(reg_time,'%Y-%m-%d')) dt,channel,
@@ -465,9 +469,14 @@ select toDate(formatDateTime(reg_time,'%Y-%m-%d')) dt,channel,
     return li,total
 
 def get_channel_order_trend(channel,pitcher,start,end,page,page_size,order_by,order):
-    # channels = f' and channel in {get_channels_from_user(pitcher)} ' if pitcher != '赞象 admin' else ''
+
 
     channel_op =f" and channel='{channel}' " if channel!='' else ''
+    if pitcher != '赞象 admin':
+        if get_channels_from_user(pitcher).__len__() == 0:
+            pitcher_op = f"  and pitcher='{pitcher}'"
+        else:
+            pitcher_op = f" and channel in {get_channels_from_user(pitcher)}"
 
     sql=f"""select pitcher,channel,toString(dt) date,book,toDecimal32(cost,2),toDecimal32(reg_order_amount,2),roi,new_follow_user,new_follow_per_cost,order_user,order_count,
        toDecimal32(order_user_per_cost,2),
@@ -542,7 +551,7 @@ select pitcher,channel,dt,book,cost,reg_order_amount,
        if(follow_user=0,0,cost/follow_user) new_follow_per_cost,
        reg_order_user order_user, reg_order_count order_count,
        if(reg_order_user=0,0,cost/reg_order_user) order_user_per_cost
-       from dw_daily_channel where dt>='{start}' and dt<='{end}' {channel_op} and pitcher='{pitcher}'  and cost>0) a
+       from dw_daily_channel where dt>='{start}' and dt<='{end}' {channel_op} {pitcher_op}  and cost>0) a
 
 left outer join (
 select toDate(formatDateTime(reg_time,'%Y-%m-%d')) dt,channel,