|
@@ -169,6 +169,12 @@ class OrderInfo(BaseHandler):
|
|
|
if not start and not user_start:
|
|
|
start = self.thisday
|
|
|
|
|
|
+
|
|
|
+ start = None if not start else int(datetime.strptime(start, '%Y-%m-%d').timestamp())
|
|
|
+ end = None if not end else int(datetime.strptime(end, '%Y-%m-%d').timestamp())
|
|
|
+ user_start = None if not user_start else int(datetime.strptime(user_start, '%Y-%m-%d').timestamp())
|
|
|
+ user_end = None if not user_end else int(datetime.strptime(user_end, '%Y-%m-%d').timestamp())
|
|
|
+
|
|
|
order_id = args.get('order_id')
|
|
|
member_id = args.get('member_id')
|
|
|
status = (args.get('status'))
|
|
@@ -228,27 +234,29 @@ class OrderInfo(BaseHandler):
|
|
|
''' + 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 ''
|
|
|
- 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 ''
|
|
|
- op5 = f" and CONVERT (g.role_name USING utf8)='{role_name}' " if role_name else ''
|
|
|
- op6 = f" and from_unixtime(d.create_time) >'{user_start}' " if user_start else ''
|
|
|
- op7 = f" and from_unixtime(d.create_time) <'{user_end}' " if user_end else ''
|
|
|
- op8 = f" and a.order_id='{order_id}'" if order_id else ''
|
|
|
- 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 in ({"'" + "','".join(game) + "'"}) ''' if game else ''
|
|
|
-
|
|
|
+ op1 = f" where pitcher ='{pitcher}' " if pitcher else ''
|
|
|
+ op2 = f''' where 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 ''
|
|
|
+ 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 ''
|
|
|
+ op9 = f" and mem_id like '_{member_id}'" if member_id else ''
|
|
|
+ op10 = f" and status={status} " if status else ''
|
|
|
+ op11 = f''' where name in ({"'" + "','".join(game) + "'"}) ''' if game else ''
|
|
|
+
|
|
|
+ op12_pay = ''
|
|
|
+ op12_user = ''
|
|
|
|
|
|
if agent_name and '自然流量渠道' in agent_name and '客服渠道' in agent_name:
|
|
|
- op12 = f" and a.agent_id in (12,0) "
|
|
|
+ op12_pay = f" and agent_id in (12,0) "
|
|
|
elif agent_name and '自然流量渠道' in agent_name:
|
|
|
- op12 = f" and a.agent_id=0 "
|
|
|
+ op12_pay = f" and agent_id=0 "
|
|
|
elif agent_name and '客服渠道' in agent_name:
|
|
|
- op12 = f" and a.agent_id=12 "
|
|
|
+ op12_pay = f" and agent_id=12 "
|
|
|
else:
|
|
|
- op12 = f''' and q.user_nicename in ({"'" + "','".join(agent_name) + "'"}) ''' if agent_name else ''
|
|
|
+ op12_user = f''' where user_nicename in ({"'" + "','".join(agent_name) + "'"}) ''' if agent_name else ''
|
|
|
|
|
|
|
|
|
if order_by == 'agent_name':
|
|
@@ -265,61 +273,115 @@ class OrderInfo(BaseHandler):
|
|
|
order_by = 'a.create_time'
|
|
|
|
|
|
op15 = f" order by {order_by} {order_}" if order_by and order_ else ''
|
|
|
- sql = f"""select row_number() over() as id,a.order_id ,h.pitcher,
|
|
|
- if(a.agent_id =21,'客服渠道',if(a.agent_id=0,'自然流量',q.user_nicename)) as agent_name,
|
|
|
- if(a.agent_id =21,'客服渠道',if(a.agent_id=0,'自然流量',c.wx_name)) as channel,
|
|
|
- if(a.create_time is not null ,CONVERT(from_unixtime(a.create_time),char(20)),null) order_time,
|
|
|
- if(d.create_time is not null,CONVERT(from_unixtime(d.create_time),char(20)),null) user_create_time,
|
|
|
- d.id as mem_id,e.name as game ,a.amount ,a.real_amount ,g.server_name ,f.os as system_os,
|
|
|
- CONVERT (g.role_name USING utf8) as role_name,a.payway ,a.status status ,a.mg_mem_id as user_id
|
|
|
- from db_mp.h_pay a
|
|
|
+ sql = f"""select
|
|
|
+ rowNumberInAllBlocks() as id,
|
|
|
+ a.order_id order_id,
|
|
|
+ h.pitcher pitcher,
|
|
|
+ if(a.agent_id like '%_21','客服渠道',if(a.agent_id like '%_0','自然流量',q.user_nicename)) as agent_name,
|
|
|
+ if(a.agent_id like '%_21','客服渠道',if(a.agent_id like '%_0','自然流量',c.wx_name)) as channel,
|
|
|
+ FROM_UNIXTIME(a.create_time) order_time,
|
|
|
+ FROM_UNIXTIME(d.create_time) user_create_time,
|
|
|
+ d.id as mem_id,
|
|
|
+ e.name as game ,
|
|
|
+ a.amount amount,
|
|
|
+ a.real_amount real_amount,
|
|
|
+ g.server_name server_name,
|
|
|
+ f.os as system_os,
|
|
|
+ g.role_name role_name,
|
|
|
+ a.payway payway,a.status status ,a.mg_mem_id as user_id
|
|
|
+ from (
|
|
|
+ select * from GameDataSum.h_pay_sum
|
|
|
+ where 1=1 {op3} {op4} {op8} {op9} {op10} {op12_pay}
|
|
|
+ ) a
|
|
|
left join
|
|
|
(select b.agent_id as agent_id,b.advertiser_conf_id from
|
|
|
(select agent_id,max(update_time) as update_time
|
|
|
- from db_mp.mp_conf_agent mmc
|
|
|
+ from GameDataSum.mp_conf_agent_sum mmc
|
|
|
group by agent_id ) a
|
|
|
- left join db_mp.mp_conf_agent b on a.agent_id=b.agent_id
|
|
|
+ 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 db_mp.mp_mp_conf c on b.advertiser_conf_id = c.id
|
|
|
- left join db_mp.h_member d on a.mem_id = d.id
|
|
|
- left join db_mp.h_game e on a.app_id =e.id
|
|
|
- left join db_mp.h_pay_ext f on a.id = f.pay_id
|
|
|
- left join db_mp.h_mg_role g
|
|
|
+ left join
|
|
|
+ (select id,wx_name from GameDataSum.mp_mp_conf_sum
|
|
|
+ {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
|
|
|
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 db_mp.h_user q on a.agent_id =q.id
|
|
|
-
|
|
|
-
|
|
|
- where 1=1 {op} {op1} {op2} {op3} {op4} {op5}
|
|
|
- {op6} {op7} {op8} {op9} {op10}
|
|
|
- {op11} {op12}
|
|
|
-
|
|
|
- {op15}
|
|
|
+ left join (select name,pitcher
|
|
|
+ from CostSourceData.advertiser_vx {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}
|
|
|
+ {op15}
|
|
|
"""
|
|
|
- print(sql)
|
|
|
+ limit_start = (page - 1) * page_size
|
|
|
+ limit_sql = sql + '\n' + f''' limit {limit_start},{page_size} '''
|
|
|
+ print(limit_sql)
|
|
|
sumsql = f""" select '' as id,'' as order_id ,'' as pitcher,'' as agent_name, '' as channel,
|
|
|
'' as order_time,'' as user_create_time,'' as user_id,
|
|
|
'' as game,sum(amount) as amount ,sum(real_amount) as real_amount ,'' as server_name,
|
|
|
'' as mem_id , '' as role_name,'' as payway ,'' as status ,'' as system_os
|
|
|
from ({sql}) a
|
|
|
"""
|
|
|
-
|
|
|
- data, total, total_data = getLimitSumData(db.dm, sql, sumsql, page, page_size)
|
|
|
+ totalsql = f'''
|
|
|
+ select count(1) from ({sql}) a
|
|
|
+ '''
|
|
|
|
|
|
- print(len(data))
|
|
|
- return data, total, total_data
|
|
|
+ print(sumsql)
|
|
|
+ print(totalsql)
|
|
|
+ ck = CkUtils()
|
|
|
+ data_res = ck.execute(limit_sql)
|
|
|
+ data_res_dict = []
|
|
|
+ data_sum_res = ck.execute(sumsql)
|
|
|
+ data_sum_res_dict = []
|
|
|
+ data_total = ck.execute(totalsql)[0][0]
|
|
|
+ for _ in data_res:
|
|
|
+ tmp_dict = {'id': _[0],
|
|
|
+ 'order_id': _[1],
|
|
|
+ 'pitcher': _[2],
|
|
|
+ 'agent_name': _[3],
|
|
|
+ 'channel': _[4],
|
|
|
+ 'order_time': datetime.strftime(_[5], '%Y-%m-%d %H:%M:%S'),
|
|
|
+ 'user_create_time': datetime.strftime(_[6], '%Y-%m-%d %H:%M:%S'),
|
|
|
+ 'mem_id': _[7],
|
|
|
+ 'game': _[8],
|
|
|
+ 'amount': float(_[9]),
|
|
|
+ 'real_amount': float(_[10]),
|
|
|
+ 'server_name': _[11],
|
|
|
+ 'system_os': _[12],
|
|
|
+ 'role_name': _[13],
|
|
|
+ 'payway': _[14],
|
|
|
+ 'status': _[15],
|
|
|
+ 'user_id': _[16],
|
|
|
+ }
|
|
|
+ data_res_dict.append(tmp_dict)
|
|
|
+ for _ in data_sum_res:
|
|
|
+ tmp_dict = {'id': _[0],
|
|
|
+ 'order_id': _[1],
|
|
|
+ 'pitcher': _[2],
|
|
|
+ 'agent_name': _[3],
|
|
|
+ 'channel': _[4],
|
|
|
+ 'order_time': '',
|
|
|
+ 'user_create_time': '',
|
|
|
+ 'mem_id': _[7],
|
|
|
+ 'game': _[8],
|
|
|
+ 'amount': float(_[9]),
|
|
|
+ 'real_amount': float(_[10]),
|
|
|
+ 'server_name': _[11],
|
|
|
+ 'system_os': _[12],
|
|
|
+ 'role_name': _[13],
|
|
|
+ 'payway': _[14],
|
|
|
+ 'status': _[15],
|
|
|
+ 'user_id': _[16],
|
|
|
+ }
|
|
|
+ data_sum_res_dict.append(tmp_dict)
|
|
|
+
|
|
|
+ data, total, total_data = data_res_dict, data_total, data_sum_res_dict
|
|
|
|
|
|
- def get_game_pitcher(self, user_id):
|
|
|
- sql = '''
|
|
|
- SELECT d.name as game_name,d.id
|
|
|
- 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
|
|
|
- where pitcher ='金康'
|
|
|
- group by id
|
|
|
- '''
|
|
|
+ return data, total, total_data
|
|
|
|
|
|
|
|
|
class OrderH5Info(BaseHandler):
|