Forráskód Böngészése

FIX:自然流量筛选

cxyu 3 éve
szülő
commit
541d0b2476
1 módosított fájl, 29 hozzáadás és 20 törlés
  1. 29 20
      handlers/OrderHandler.py

+ 29 - 20
handlers/OrderHandler.py

@@ -126,30 +126,29 @@ class OrderInfo(BaseHandler):
         db = MysqlUtils()
 
         if user_id in super_auth():
-            op = ''
-            op_sup1 = ''
-            op_sup2 = ''
-            op_sup3 = ''
+            op_channel = ''
+            op_game = ''
         else:
+            op_game = ''
+            op_base = f' and j.game_name is not null and d.create_time >= j.create_time '
+
             # 限制为自己游戏的1.自然流量,2.客服流量
-            # op_sup1 = f' or a.agent_id=0 or a.agent_id=21 '
-            op_sup1 = ''
+            if agent_name and ('自然流量渠道' in agent_name or '客服渠道' in agent_name):
+                op_game = '' + op_base
             # 限制为自己公众号开始时候的数据
-            op_sup2 = f' and i.start_date is not null and d.create_time >= unix_timestamp(i.start_date) '
-
-            # 限制为自己的游戏
-            op_sup3 = f''
 
             if len(UserAuthUtils.get_auth_channel(user_id)) == 0:
                 return None, None, None
             elif len(UserAuthUtils.get_auth_channel(user_id)) == 1:
-                op = f''' and c.wx_name = '{UserAuthUtils.get_auth_channel(user_id)[0]}'
-                        '''
+                op_channel = f''' and c.wx_name = '{UserAuthUtils.get_auth_channel(user_id)[0]}'
+                        ''' + op_base
             else:
-                op = f" and c.wx_name in {str(UserAuthUtils.get_auth_channel(user_id))}"
+                op_channel = f'''                        
+                        and c.wx_name in {str(UserAuthUtils.get_auth_channel(user_id))}
+                        ''' + op_base
+        op = op_game if agent_name and ('自然流量渠道' in agent_name or '客服渠道' in agent_name) else op_channel
 
         op1 = f" and h.pitcher ='{pitcher}' " if pitcher else ''
-        print(type(channel))
         op2 = f''' and c.wx_name in ({"'" + "','".join(channel) + "'"})''' if channel else ''
         op3 = f" and from_unixtime(a.create_time) >'{start}' " if start else ''
         op4 = f" and from_unixtime(a.create_time) <'{end}' " if end else ''
@@ -160,10 +159,13 @@ class OrderInfo(BaseHandler):
         op9 = f" and a.mem_id='{member_id}'" if member_id else ''
         op10 = f" and a.status={status} " if status else ''
         op11 = f" and e.name='{game}'" if game else ''
-        print(agent_name)
-        if agent_name and agent_name == '自然流量渠道':
+
+        #有自然流量和客服渠道时,其他渠道进行规避
+        if agent_name and '自然流量渠道' in agent_name and '客服渠道' in agent_name:
+            op12 = f" and a.agent_id in (12,0) "
+        elif agent_name and '自然流量渠道' in agent_name:
             op12 = f" and a.agent_id=0 "
-        elif agent_name and agent_name == '客服渠道':
+        elif agent_name and '客服渠道' in agent_name:
             op12 = f" and a.agent_id=12 "
         else:
             op12 = f''' and q.user_nicename in ({"'" + "','".join(agent_name) + "'"}) ''' if agent_name else ''
@@ -205,12 +207,19 @@ class OrderInfo(BaseHandler):
                         left join db_mp.h_mg_role 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 quchen_text.advertiser_vx h on c.wx_name =h.name 
+                        left join quchen_text.advertiser_vx h on c.wx_name = h.name 
                         left join db_mp.h_user q on a.agent_id =q.id 
-                        left join quchen_text.advertiser_vx i on c.wx_name =i.name
+                        left join (
+                                SELECT a.pitcher as pitcher ,a.name as channel ,
+                                d.name as game_name, UNIX_TIMESTAMP(a.start_date) as create_time 
+                                FROM quchen_text.advertiser_vx a
+                                left join db_mp.mp_mp_conf b on  a.name =b.wx_name 
+                                left join db_mp.mp_conf_agent c on c.advertiser_conf_id = b.id
+                                left join db_mp.h_game d on c.app_id = d.id
+                                ) j on e.name = j.game_name
 
                         
-                        where 1=1  {op} {op_sup1} {op_sup2} {op_sup3} {op1} {op2} {op3} {op4} {op5}  
+                        where 1=1  {op} {op1} {op2} {op3} {op4} {op5}  
                                 {op6} {op7} {op8} {op9} {op10} 
                                 {op11} {op12}