Browse Source

MOD:自然量用户充值表修改

cxyu 3 years ago
parent
commit
e1740f60b8
1 changed files with 60 additions and 2 deletions
  1. 60 2
      handlers/OrderHandler.py

+ 60 - 2
handlers/OrderHandler.py

@@ -394,7 +394,7 @@ class OrderH5Info(BaseHandler):
               and a.status=2
             group by  date(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,a.app_id,c_app_id
+    order by a.dt desc,a.app_id,c_app_id
     
             '''
         df_source = db.dm.get_data_list(sql)
@@ -444,7 +444,6 @@ class OrderH5Info(BaseHandler):
             channel_game_list_unnatural.sort(key=lambda x: str(x['channel_game_name']))
             channel_game_list_natural.sort(key=lambda x: str(x['channel_game_name']))
 
-
             tmp = {'dt': k[0], 'game_name': k[1], 'sum_amount': k[2], 'natural_amount': k[3],
                    'natural_amount_rate': k[4], 'human_count': k[5], 'natural_human_count': k[6],
                    'natural_human_count_rate': k[7], 'channel_game_natural_list': channel_game_list_natural,
@@ -452,3 +451,62 @@ class OrderH5Info(BaseHandler):
                    }
             res_game_info.append(tmp)
         return res_game_info
+
+    def get_order_info_download(self, user_id, start, end):
+        if user_id not in super_auth():
+            return []
+
+        db = MysqlUtils()
+        op1 = f"and date(FROM_UNIXTIME(a.create_time))>='{start}' " if start else ''
+        op2 = f"and date(FROM_UNIXTIME(a.create_time))<='{end}' " if end else ''
+
+        sql = f'''
+      select DATE_FORMAT(a.dt,'%Y-%m-%d') 日期,
+      a.h5_game_name 游戏名称H5,
+    b.sum_amount as 今日总充值,
+    b.natural_amount as H5自然量充值,
+    b.amount_rate as 充值额比例,
+    b.human_count as 今日总充值人数,
+    b.natural_human_count H5自然量人数,
+    b.human_count_rate as 用户比例,
+    a.channel_game_name as 游戏名称小程序,
+    a.is_natural as 小程序的量是否为自然量,
+    a.sum_amount as 小程序导入用户充值, 
+    a.human_counts as 小程序导入人数
+    from 
+        (select date(FROM_UNIXTIME(a.create_time)) dt,a.app_id as app_id ,
+            b.name as h5_game_name,
+            c.app_id as c_app_id,d.name as channel_game_name,if(c.agent_id=0,1,0) as is_natural ,
+            sum(amount) as sum_amount,count(DISTINCT(a.mem_id)) as human_counts
+            from db_mp.h_pay a
+            LEFT  join db_mp.h_game b on a.app_id = b.id
+            left join db_mp.h_member c on a.mem_id = c.id 
+            LEFT  join db_mp.h_game d on c.app_id = d.id
+            where a.app_id in (select id from db_mp.h_game 
+                    where classify =5)
+            and a.app_id != c.app_id 
+            and a.status = 2
+            {op1} {op2}
+            group by date(FROM_UNIXTIME(a.create_time)),a.app_id ,
+            c.app_id ,d.name,if(c.agent_id=0,1,0) ) as a
+    left join
+        (select date(FROM_UNIXTIME(a.create_time)) as dt,a.app_id ,
+            sum(a.amount) sum_amount, 
+            sum(if(a.app_id=c.app_id,a.amount,0)) natural_amount,
+            count(DISTINCT(a.mem_id)) as human_count,
+            count(DISTINCT(if(a.app_id=c.app_id,a.mem_id,null))) natural_human_count,
+            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 db_mp.h_pay a
+            left join db_mp.h_member c on a.mem_id = c.id 
+            where a.app_id in (select id from db_mp.h_game 
+                    where classify =5) 
+             {op1} {op2}
+              and a.status=2
+            group by  date(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
+    
+            '''
+        data = db.dm.getData_json(sql)
+        return data