cxyu 3 rokov pred
rodič
commit
08b8ef53a4
1 zmenil súbory, kde vykonal 21 pridanie a 14 odobranie
  1. 21 14
      handlers/OrderHandler.py

+ 21 - 14
handlers/OrderHandler.py

@@ -247,11 +247,11 @@ class OrderInfo(BaseHandler):
                         ''' + op_base
         op = op_game if agent_name and ('自然流量渠道' in agent_name or '客服渠道' in agent_name) else op_channel
 
-        op1 = f" where pitcher ='{pitcher}' " if pitcher else ''
-        op2 = f''' where wx_name in ({"'" + "','".join(channel) + "'"})''' if channel else ''
+        op1 = f" and pitcher ='{pitcher}' " if pitcher else ''
+        op2 = f''' and wx_name in ({"'" + "','".join(channel) + "'"})''' if channel else ''
         op3 = f" and create_time >{start} " if start else ''
         op4 = f" and create_time <{end} " if end else ''
-        op5 = f" where role_name ='{role_name}' " if role_name else ''
+        op5 = f" and role_name ='{role_name}' " if role_name else ''
         op6 = f" and create_time >{user_start} " if user_start else ''
         op7 = f" and create_time <{user_end} " if user_end else ''
         op8 = f" and order_id like '%_{order_id}'" if order_id else ''
@@ -315,19 +315,21 @@ class OrderInfo(BaseHandler):
                                 and a.update_time = b.update_time) b on  a.agent_id =b.agent_id 
                         left join
                           (select id,wx_name from GameDataSum.mp_mp_conf_sum
-                        	{op2} )  c on b.advertiser_conf_id = c.id 
+                        	where 1=1  {op2} )  c on b.advertiser_conf_id = c.id 
                         left join (select id,create_time from GameDataSum.h_member_sum 
                                 where 1=1  {op6} {op7} ) d on a.mem_id = d.id
                         left join ( select * from GameDataSum.h_game_sum {op11} ) e on a.app_id =e.id 
                         left join GameDataSum.h_pay_ext_sum f on a.id = f.pay_id  
-                        left join ( select * from GameDataSum.h_mg_role_sum {op5} ) g 
+                        left join ( select * from GameDataSum.h_mg_role_sum where 1=1 {op5} ) g 
                         	on g.role_id = f.role_id and g.server_id = f.server_id 
                         	and g.app_id = a.app_id and g.mg_mem_id =a.mg_mem_id 
                         left join (select name,pitcher ,start_date
-                        from CostSourceData.advertiser_vx {op1}
+                        from CostSourceData.advertiser_vx where 1=1 {op1}
                                 ) h on c.wx_name = h.name
                         left join (select * from GameDataSum.h_user_sum {op12_user} ) q on a.agent_id =q.id       
-              where 1=1 {op}
+              where 1=1 
+              and mem_id is not null and game is not null
+                {op} {op1} {op5}
               {op15}
             """
         limit_start = (page - 1) * page_size
@@ -455,11 +457,12 @@ class OrderH5Info(BaseHandler):
                 sum(amount) as sum_amount,count(DISTINCT(a.mem_id)) as human_counts
                 from (select * from GameDataSum.h_pay_sum where 1=1  {op1} {op2} ) a
                 LEFT  join GameDataSum.h_game_sum b on a.app_id = b.id
-                left join (select * from GameDataSum.h_member_sum where 1=1  {op1} {op2} ) c on a.mem_id = c.id 
+                left join (select * from GameDataSum.h_member_sum where 1=1   {op2} ) c on a.mem_id = c.id 
                 LEFT  join GameDataSum.h_game_sum d on c.app_id = d.id
                 where a.app_id in (select id from GameDataSum.h_game_sum 
                         where classify =5)
                 and a.app_id != c.app_id 
+                and c.id is not null
                 and a.status = 2
                 group by toDate(FROM_UNIXTIME(a.create_time)),a.app_id ,
                 c.app_id ,d.name,if(c.agent_id in ('sdk_one_0','sdk_two_0'),1,0) ) as a
@@ -472,10 +475,11 @@ class OrderH5Info(BaseHandler):
                 ROUND(if(sum(a.amount)>0,sum(if(a.app_id=c.app_id,a.amount,0)) /sum(a.amount),0) ,2) amount_rate,
                 ROUND( if(count(DISTINCT(a.mem_id))>0,count(DISTINCT(if(a.app_id=c.app_id,a.mem_id,null)))/count(DISTINCT(a.mem_id)),0),2) human_count_rate
                 from (select * from GameDataSum.h_pay_sum where 1=1 {op1} {op2} ) a
-                left join (select * from GameDataSum.h_member_sum where 1=1  {op1} {op2}  ) c on a.mem_id = c.id 
+                left join (select * from GameDataSum.h_member_sum where 1=1   {op2}  ) c on a.mem_id = c.id 
                 where a.app_id in (select id from GameDataSum.h_game_sum 
                         where classify =5) 
                   and a.status=2
+                  and c.id is not null
                 group by  toDate(FROM_UNIXTIME(a.create_time)),a.app_id ) b
             on a.dt=b.dt and a.app_id = b.app_id
             order by a.dt desc,a.app_id,c_app_id
@@ -573,10 +577,11 @@ class OrderH5Info(BaseHandler):
                 sum(amount) as sum_amount,count(DISTINCT(a.mem_id)) as human_counts
                 from (select * from GameDataSum.h_pay_sum where 1=1  {op1} {op2} ) a
                 LEFT  join GameDataSum.h_game_sum b on a.app_id = b.id
-                left join (select * from GameDataSum.h_member_sum where 1=1  {op1} {op2} ) c on a.mem_id = c.id 
+                left join (select * from GameDataSum.h_member_sum where 1=1  {op2} ) c on a.mem_id = c.id 
                 LEFT  join GameDataSum.h_game_sum d on c.app_id = d.id
                 where a.app_id in (select id from GameDataSum.h_game_sum 
                         where classify =5)
+                and c.id is not null
                 and a.app_id != c.app_id 
                 and a.status = 2
                 group by toDate(FROM_UNIXTIME(a.create_time)),a.app_id ,
@@ -590,10 +595,11 @@ class OrderH5Info(BaseHandler):
                 ROUND(if(sum(a.amount)>0,sum(if(a.app_id=c.app_id,a.amount,0)) /sum(a.amount),0) ,2) amount_rate,
                 ROUND( if(count(DISTINCT(a.mem_id))>0,count(DISTINCT(if(a.app_id=c.app_id,a.mem_id,null)))/count(DISTINCT(a.mem_id)),0),2) human_count_rate
                 from (select * from GameDataSum.h_pay_sum where 1=1 {op1} {op2} ) a
-                left join (select * from GameDataSum.h_member_sum where 1=1  {op1} {op2}  ) c on a.mem_id = c.id 
+                left join (select * from GameDataSum.h_member_sum where 1=1  {op2}  ) c on a.mem_id = c.id 
                 where a.app_id in (select id from GameDataSum.h_game_sum 
                         where classify =5) 
-                  and a.status=2
+                and c.id is not null
+                and a.status=2
                 group by  toDate(FROM_UNIXTIME(a.create_time)),a.app_id ) b
             on a.dt=b.dt and a.app_id = b.app_id
         order by a.dt desc,a.app_id,c_app_id
@@ -676,12 +682,12 @@ class OrderH5InfoSpecial(BaseHandler):
                     left join GameDataSum.mp_conf_agent_sum b on  a.agent_id=b.agent_id 
                     and a.update_time = b.update_time) b on  a.agent_id =b.agent_id 
             left join GameDataSum.mp_mp_conf_sum c on b.advertiser_conf_id = c.id
-            left join (select * from GameDataSum.h_member_sum where 1=1 {op1} {op2} ) d
+            left join (select * from GameDataSum.h_member_sum where 1=1 {op2} ) d
                         on a.mem_id = d.id
             left join GameDataSum.h_game_sum e on a.app_id =e.id 
             left join GameDataSum.h_game_sum e2 on d.app_id =e2.id 
             left join GameDataSum.h_pay_ext_sum f on a.id = f.pay_id 
-            left join  (select * from GameDataSum.h_mg_role_sum where 1=1 {op1} {op2} ) g 
+            left join  (select * from GameDataSum.h_mg_role_sum where 1=1  {op2} ) g 
               on g.role_id = f.role_id and g.server_id = f.server_id 
               and g.app_id = a.app_id and g.mg_mem_id =a.mg_mem_id 
             left join CostSourceData.advertiser_vx h on c.wx_name = h.name
@@ -693,6 +699,7 @@ class OrderH5InfoSpecial(BaseHandler):
             and d.app_id in('sdk_one_6','sdk_one_13','sdk_one_23',
             				'sdk_two_6','sdk_two_13','sdk_two_23')
             and a.status =2
+            and d.id is not null and g.role_name is not null 
             '''
         print(sql)
         data = ck.execute(sql)