ck 4 years ago
parent
commit
c3c7f05e8b
1 changed files with 16 additions and 10 deletions
  1. 16 10
      data_manage/pitcher_panel.py

+ 16 - 10
data_manage/pitcher_panel.py

@@ -572,18 +572,16 @@ left join src_book_info c on a.dt=c.dt and a.book=c.book  and a.type=c.type
 def get_channel_summary(channel,pitcher,page,page_size,order_by,order,state,location,start,end):
     db=MysqlUtils()
 
-    op1=f" and channel='{channel}'" if channel else ''
+    op1=f" and a.channel='{channel}'" if channel else ''
 
     if pitcher:
-        op2=f" and pitcher='{pitcher}'" if get_channels_from_user(pitcher).__len__()==0 else f" and channel in {get_channels_from_user(pitcher)}"
+        op2=f" and pitcher='{pitcher}'" if get_channels_from_user(pitcher).__len__()==0 else f" and a.channel in {get_channels_from_user(pitcher)}"
     else:
         op2=''
-
-    op3=f" and channel='{channel}'" if channel else ''
     op4=f" and location='{location}' " if location else ''
     op5=f" and state='{state}'" if state else ''
-    op6=f" and dt>='{start}'" if start else ''
-    op7=f" and dt<='{end}'" if end else ''
+    op6=f" and a.dt>='{start}'" if start else ''
+    op7=f" and a.dt<='{end}'" if end else ''
 
 
     sql = f"""SELECT channel,
@@ -596,7 +594,7 @@ def get_channel_summary(channel,pitcher,page,page_size,order_by,order,state,loca
                 order_user,
                 if(follow_user=0,0,round(order_user/follow_user,4)) order_tran_rate,
                 if(order_user=0,0,round(total_cost/order_user,2))  order_tran_cost,
-                pitcher,stage
+                pitcher,stage,td_amount,yd_amount,byd_amount
             FROM
                 (select
                     channel,pitcher,stage,
@@ -606,8 +604,15 @@ def get_channel_summary(channel,pitcher,page,page_size,order_by,order,state,loca
                     sum(cost) total_cost,
                     sum(reg_order_amount) total_amount,
                     sum(follow_user) follow_user,
-					sum(reg_order_user) order_user
-               from dw_channel   where 1=1 {op1} {op2} {op3} {op6} {op7} GROUP BY channel,type,pitcher,stage) a having 1=1  {op4} {op5}  ORDER BY {order_by} {order}
+					sum(reg_order_user) order_user,
+                    sum(ba1) td_amount,sum(ba2) yd_amount,sum(ba3) byd_amount
+            
+               from  dw_channel  a 
+                left join dw_channel_amount_daily_reverse b using (dt,channel)
+                where 1=1 {op1} {op2}  {op6} {op7} GROUP BY a.channel,type,pitcher,stage) x
+                having 1=1  {op4} {op5}  ORDER BY {order_by} {order}
+                
+                
                 """
     print(sql)
     sumsql=f"""select '总计' channel,
@@ -618,7 +623,8 @@ def get_channel_summary(channel,pitcher,page,page_size,order_by,order,state,loca
             sum(order_user) order_user,
             round(sum(total_cost)/sum(follow_user),2) follow_per_cost,
             round(sum(order_user)/sum(follow_user),4) order_tran_rate,
-            round(sum(total_cost)/sum(order_user),2)  order_tran_cost 
+            round(sum(total_cost)/sum(order_user),2)  order_tran_cost ,
+            sum(td_amount) td_amount,sum(yd_amount) yd_amount,sum(byd_amount) byd_amount
             from ({sql}) a
             
     """