|
@@ -408,13 +408,13 @@ class OrderH5Info(BaseHandler):
|
|
def get_order_info(self, user_id, start, end):
|
|
def get_order_info(self, user_id, start, end):
|
|
if user_id not in super_auth():
|
|
if user_id not in super_auth():
|
|
return []
|
|
return []
|
|
-
|
|
|
|
|
|
+ # todo: sql中使用min有问题,因为有重复数据
|
|
db = MysqlUtils()
|
|
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 ''
|
|
|
|
|
|
+ op1 = f"and toDate(FROM_UNIXTIME(a.create_time))>='{start}' " if start else ''
|
|
|
|
+ op2 = f"and toDate(FROM_UNIXTIME(a.create_time))<='{end}' " if end else ''
|
|
|
|
|
|
sql = f'''
|
|
sql = f'''
|
|
- select DATE_FORMAT(a.dt,'%Y-%m-%d'),a.h5_game_name,
|
|
|
|
|
|
+ select a.dt,a.h5_game_name,
|
|
b.sum_amount as sum_amount,
|
|
b.sum_amount as sum_amount,
|
|
b.natural_amount as natural_amount,
|
|
b.natural_amount as natural_amount,
|
|
b.amount_rate as amount_rate,
|
|
b.amount_rate as amount_rate,
|
|
@@ -423,47 +423,51 @@ class OrderH5Info(BaseHandler):
|
|
b.human_count_rate as human_count_rate,
|
|
b.human_count_rate as human_count_rate,
|
|
a.channel_game_name as channel_game_name,
|
|
a.channel_game_name as channel_game_name,
|
|
a.is_natural as is_natural,
|
|
a.is_natural as is_natural,
|
|
- a.sum_amount as channel_amount,
|
|
|
|
- a.human_counts as channel_human_count
|
|
|
|
|
|
+ toFloat64(a.sum_amount) as channel_amount,
|
|
|
|
+ toFloat64(a.human_counts) as channel_human_count
|
|
from
|
|
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 ,
|
|
|
|
|
|
+ (select toDate(FROM_UNIXTIME(a.create_time)) dt,a.app_id as app_id ,
|
|
|
|
+ min(b.name) as h5_game_name,
|
|
|
|
+ min(c.app_id) as c_app_id,d.name as channel_game_name,
|
|
|
|
+ if(min(c.agent_id) in ('sdk_one_0','sdk_two_0'),1,0) as is_natural ,
|
|
sum(amount) as sum_amount,count(DISTINCT(a.mem_id)) as human_counts
|
|
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
|
|
|
|
|
|
+ from GameDataSum.h_pay_sum a
|
|
|
|
+ LEFT join GameDataSum.h_game_sum b on a.app_id = b.id
|
|
|
|
+ left join GameDataSum.h_member_sum 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)
|
|
where classify =5)
|
|
and a.app_id != c.app_id
|
|
and a.app_id != c.app_id
|
|
and a.status = 2
|
|
and a.status = 2
|
|
{op1} {op2}
|
|
{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
|
|
|
|
|
|
+ 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
|
|
left join
|
|
left join
|
|
- (select date(FROM_UNIXTIME(a.create_time)) as dt,a.app_id ,
|
|
|
|
|
|
+ (select toDate(FROM_UNIXTIME(a.create_time)) as dt,a.app_id ,
|
|
sum(a.amount) sum_amount,
|
|
sum(a.amount) sum_amount,
|
|
sum(if(a.app_id=c.app_id,a.amount,0)) natural_amount,
|
|
sum(if(a.app_id=c.app_id,a.amount,0)) natural_amount,
|
|
count(DISTINCT(a.mem_id)) as human_count,
|
|
count(DISTINCT(a.mem_id)) as human_count,
|
|
count(DISTINCT(if(a.app_id=c.app_id,a.mem_id,null))) natural_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(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
|
|
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
|
|
|
|
|
|
+ from GameDataSum.h_pay_sum a
|
|
|
|
+ left join GameDataSum.h_member_sum c on a.mem_id = c.id
|
|
|
|
+ where a.app_id in (select id from GameDataSum.h_game_sum
|
|
where classify =5)
|
|
where classify =5)
|
|
{op1} {op2}
|
|
{op1} {op2}
|
|
and a.status=2
|
|
and a.status=2
|
|
- group by date(FROM_UNIXTIME(a.create_time)),a.app_id ) b
|
|
|
|
|
|
+ group by toDate(FROM_UNIXTIME(a.create_time)),a.app_id ) b
|
|
on a.dt=b.dt and a.app_id = b.app_id
|
|
on a.dt=b.dt and a.app_id = b.app_id
|
|
order by a.dt desc,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)
|
|
|
|
|
|
+ print(sql)
|
|
|
|
+ ck = CkUtils()
|
|
|
|
+ df_source = ck.execute(sql)
|
|
game_info = {}
|
|
game_info = {}
|
|
for _ in df_source:
|
|
for _ in df_source:
|
|
- print(_)
|
|
|
|
|
|
+ _ = list(_)
|
|
|
|
+ _[0] = datetime.strftime(_[0], '%Y-%m-%d')
|
|
_[2] = float(_[2])
|
|
_[2] = float(_[2])
|
|
_[3] = float(_[3])
|
|
_[3] = float(_[3])
|
|
_[4] = float(_[4])
|
|
_[4] = float(_[4])
|