ck 4 лет назад
Родитель
Сommit
4980f0bfe8
1 измененных файлов с 9 добавлено и 5 удалено
  1. 9 5
      data_manage/pitcher_panel.py

+ 9 - 5
data_manage/pitcher_panel.py

@@ -497,6 +497,7 @@ def get_channel_order_trend(channel,pitcher,start,end,page,page_size,order_by,or
             pitcher_op = f" and channel in {get_channels_from_user(pitcher)}"
 
     sql=f"""select stage,pitcher,channel,toString(dt) date,book,
+        require_roi,require_mult,r1*require_mult-cost,
         toDecimal32(cost,2),
         toDecimal32(reg_order_amount,2),
         toDecimal32(reg_order_amount-cost,2),
@@ -569,6 +570,7 @@ concat(toString(a150),',',toString(r150/cost),',', toString(a150/cost),',',toStr
 from
               (
 select pitcher,channel,dt,book,cost,reg_order_amount,stage,
+       ifnull(require_roi,0) require_roi,ifnull(require_mult,0) require_mult,
        if(cost=0,0,reg_order_amount/cost) roi,
        follow_user new_follow_user,
        if(follow_user=0,0,cost/follow_user) new_follow_per_cost,
@@ -726,17 +728,17 @@ from order where  dt>='{start}' {channel_op}  group by formatDateTime(reg_time,'
 
     for i in data:
         for x,y in enumerate(i):
-            if x>=14:
+            if x>=17:
                 i[x]=parse(y)
     print(data)
-    key=['stage','pitcher','channel','date','book','cost','reg_amount','profit','roi','new_follow_user','new_follow_per_cost','order_user','order_count',
+    key=['stage','pitcher','channel','date','book','require_roi','require_mult','expect_profit','cost','reg_amount','profit','roi','new_follow_user','new_follow_per_cost','order_user','order_count',
          'order_user_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','d31','d32','d33','d34','d35','d36','d37','d38',
          'd39','d40','d41','d42','d43','d44','d45','d46','d47','d48','d49','d50','d51','d52','d53','d54','d55','d56','d57','d58','d59',
          'd60','m3','m4','m5']
     data=get_dict_list(key,data)
 
-    cost=reg_amount=roi=new_follow_user=new_follow_per_cost=order_user=order_count=order_user_per_cost=profit=0
+    cost=reg_amount=roi=new_follow_user=new_follow_per_cost=order_user=order_count=order_user_per_cost=profit=expect_profit=0
     for i in data:
         cost+= i['cost']
         reg_amount+=i['reg_amount']
@@ -747,10 +749,11 @@ from order where  dt>='{start}' {channel_op}  group by formatDateTime(reg_time,'
         order_user+=i['order_user']
         order_count+=i['order_count']
         order_user_per_cost+=i['order_user_per_cost']
+        expect_profit+=i['expect_profit']
     count= len(data)
     if count==0:
         return [],0
-    total_data={'cost':round(cost,2),'reg_amount':round(reg_amount,2),'profit':round(profit,2),'roi':round(reg_amount/cost,4), 'new_follow_user':new_follow_user,
+    total_data={'cost':round(cost,2),'reg_amount':round(reg_amount,2),'profit':round(profit,2),'expect_profit':round(expect_profit,2),'roi':round(reg_amount/cost,4), 'new_follow_user':new_follow_user,
         'new_follow_per_cost':round(new_follow_per_cost/count,2),'order_user':order_user,'order_count':order_count,
         'order_user_per_cost':round(order_user_per_cost/count,2),'channel':'-','date':'总计','book':'-'
         }
@@ -832,7 +835,8 @@ def get_pitcher_trend(pitcher,start=None,end=None,page=None,page_size=None,order
             round(d7/cost,4) roi7,
             d30 reg_amount30,
             round(d30/cost,4) roi30,
-            reg_amount-cost profit,   
+            reg_amount-cost profit,
+            inva_cost,
             CONCAT(d1,",",0,',',round(d1/cost,4)) d1,
             CONCAT(d2-d1,",",round((d2-d1)/cost,4),',',round(d2/cost,4)) d2,
             CONCAT(d3-d2,",",round((d3-d2)/cost,4),',',round(d3/cost,4)) d3,