|
@@ -5,7 +5,7 @@ from model.CommonUtils import *
|
|
from model import UserAuthUtils
|
|
from model import UserAuthUtils
|
|
from model.UserAuthUtils import super_auth
|
|
from model.UserAuthUtils import super_auth
|
|
from model.DateUtils import DateUtils
|
|
from model.DateUtils import DateUtils
|
|
-from datetime import datetime,timedelta
|
|
|
|
|
|
+from datetime import datetime, timedelta
|
|
|
|
|
|
|
|
|
|
class OrderInfoGame(BaseHandler):
|
|
class OrderInfoGame(BaseHandler):
|
|
@@ -38,10 +38,10 @@ class OrderInfoAgent(BaseHandler):
|
|
if len(UserAuthUtils.get_auth_channel(user_id)) == 0:
|
|
if len(UserAuthUtils.get_auth_channel(user_id)) == 0:
|
|
return None, None, None
|
|
return None, None, None
|
|
elif len(UserAuthUtils.get_auth_channel(user_id)) == 1:
|
|
elif len(UserAuthUtils.get_auth_channel(user_id)) == 1:
|
|
- op = f" and c.wx_name = '{UserAuthUtils.get_auth_channel(user_id)[0]}'"
|
|
|
|
|
|
+ op = f" and b.wx_name = '{UserAuthUtils.get_auth_channel(user_id)[0]}'"
|
|
|
|
|
|
else:
|
|
else:
|
|
- op = f" and c.wx_name in {str(UserAuthUtils.get_auth_channel(user_id))}"
|
|
|
|
|
|
+ op = f" and b.wx_name in {str(UserAuthUtils.get_auth_channel(user_id))}"
|
|
|
|
|
|
sql = f'''
|
|
sql = f'''
|
|
select row_number() over() as id,
|
|
select row_number() over() as id,
|
|
@@ -78,21 +78,21 @@ class OrderInfo(BaseHandler):
|
|
start = args.get("start", self.thisday)
|
|
start = args.get("start", self.thisday)
|
|
|
|
|
|
if args.get("end"):
|
|
if args.get("end"):
|
|
- tmp_end =args.get("end")
|
|
|
|
- tmp_end = datetime.strptime(tmp_end,'%Y-%m-%d')
|
|
|
|
|
|
+ tmp_end = args.get("end")
|
|
|
|
+ tmp_end = datetime.strptime(tmp_end, '%Y-%m-%d')
|
|
tmp_end = tmp_end + timedelta(days=1)
|
|
tmp_end = tmp_end + timedelta(days=1)
|
|
end = tmp_end.strftime('%Y-%m-%d')
|
|
end = tmp_end.strftime('%Y-%m-%d')
|
|
else:
|
|
else:
|
|
- end=None
|
|
|
|
|
|
+ end = None
|
|
|
|
|
|
user_start = args.get("user_start")
|
|
user_start = args.get("user_start")
|
|
if args.get("user_end"):
|
|
if args.get("user_end"):
|
|
- tmp_end =args.get("user_end")
|
|
|
|
- tmp_end = datetime.strptime(tmp_end,'%Y-%m-%d')
|
|
|
|
|
|
+ tmp_end = args.get("user_end")
|
|
|
|
+ tmp_end = datetime.strptime(tmp_end, '%Y-%m-%d')
|
|
tmp_end = tmp_end + timedelta(days=1)
|
|
tmp_end = tmp_end + timedelta(days=1)
|
|
user_end = tmp_end.strftime('%Y-%m-%d')
|
|
user_end = tmp_end.strftime('%Y-%m-%d')
|
|
else:
|
|
else:
|
|
- user_end=None
|
|
|
|
|
|
+ user_end = None
|
|
|
|
|
|
order_id = args.get('order_id')
|
|
order_id = args.get('order_id')
|
|
member_id = args.get('member_id')
|
|
member_id = args.get('member_id')
|
|
@@ -128,19 +128,29 @@ class OrderInfo(BaseHandler):
|
|
if user_id in super_auth():
|
|
if user_id in super_auth():
|
|
op = ''
|
|
op = ''
|
|
op_sup1 = ''
|
|
op_sup1 = ''
|
|
|
|
+ op_sup2 = ''
|
|
|
|
+ op_sup3 = ''
|
|
else:
|
|
else:
|
|
- op_sup1 = f' and i.start_date is not null and d.create_time >= unix_timestamp(i.start_date) '
|
|
|
|
|
|
+ # 限制为自己游戏的1.自然流量,2.客服流量
|
|
|
|
+ # op_sup1 = f' or a.agent_id=0 or a.agent_id=21 '
|
|
|
|
+ op_sup1 = ''
|
|
|
|
+ # 限制为自己公众号开始时候的数据
|
|
|
|
+ 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:
|
|
if len(UserAuthUtils.get_auth_channel(user_id)) == 0:
|
|
return None, None, None
|
|
return None, None, None
|
|
elif len(UserAuthUtils.get_auth_channel(user_id)) == 1:
|
|
elif len(UserAuthUtils.get_auth_channel(user_id)) == 1:
|
|
- op = f" and c.wx_name = '{UserAuthUtils.get_auth_channel(user_id)[0]}'"
|
|
|
|
|
|
+ op = f''' and c.wx_name = '{UserAuthUtils.get_auth_channel(user_id)[0]}'
|
|
|
|
+ '''
|
|
else:
|
|
else:
|
|
op = f" and c.wx_name in {str(UserAuthUtils.get_auth_channel(user_id))}"
|
|
op = f" and c.wx_name in {str(UserAuthUtils.get_auth_channel(user_id))}"
|
|
|
|
|
|
op1 = f" and h.pitcher ='{pitcher}' " if pitcher else ''
|
|
op1 = f" and h.pitcher ='{pitcher}' " if pitcher else ''
|
|
- op2 = f" and c.wx_name='{channel}'" if channel 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 ''
|
|
op3 = f" and from_unixtime(a.create_time) >'{start}' " if start else ''
|
|
op4 = f" and from_unixtime(a.create_time) <'{end}' " if end 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 ''
|
|
op5 = f" and CONVERT (g.role_name USING utf8)='{role_name}' " if role_name else ''
|
|
@@ -151,12 +161,12 @@ class OrderInfo(BaseHandler):
|
|
op10 = f" and a.status={status} " if status else ''
|
|
op10 = f" and a.status={status} " if status else ''
|
|
op11 = f" and e.name='{game}'" if game else ''
|
|
op11 = f" and e.name='{game}'" if game else ''
|
|
print(agent_name)
|
|
print(agent_name)
|
|
- if agent_name == '自然流量渠道':
|
|
|
|
|
|
+ if agent_name and agent_name == '自然流量渠道':
|
|
op12 = f" and a.agent_id=0 "
|
|
op12 = f" and a.agent_id=0 "
|
|
- elif agent_name == '客服渠道':
|
|
|
|
|
|
+ elif agent_name and agent_name == '客服渠道':
|
|
op12 = f" and a.agent_id=12 "
|
|
op12 = f" and a.agent_id=12 "
|
|
else:
|
|
else:
|
|
- op12 = f" and q.user_nicename='{agent_name}'" if agent_name else ''
|
|
|
|
|
|
+ op12 = f''' and q.user_nicename in ({"'" + "','".join(agent_name) + "'"}) ''' if agent_name else ''
|
|
|
|
|
|
# 选项:order_date:订单时间,user_date:用户时间,amount:金额,game:游戏名字,payway:支付方式,agent_name:渠道
|
|
# 选项:order_date:订单时间,user_date:用户时间,amount:金额,game:游戏名字,payway:支付方式,agent_name:渠道
|
|
if order_by == 'agent_name':
|
|
if order_by == 'agent_name':
|
|
@@ -200,12 +210,13 @@ class OrderInfo(BaseHandler):
|
|
left join quchen_text.advertiser_vx i on c.wx_name =i.name
|
|
left join quchen_text.advertiser_vx i on c.wx_name =i.name
|
|
|
|
|
|
|
|
|
|
- where 1=1 {op} {op_sup1} {op1} {op2} {op3} {op4} {op5}
|
|
|
|
|
|
+ where 1=1 {op} {op_sup1} {op_sup2} {op_sup3} {op1} {op2} {op3} {op4} {op5}
|
|
{op6} {op7} {op8} {op9} {op10}
|
|
{op6} {op7} {op8} {op9} {op10}
|
|
{op11} {op12}
|
|
{op11} {op12}
|
|
|
|
|
|
{op15}
|
|
{op15}
|
|
"""
|
|
"""
|
|
|
|
+ print(sql)
|
|
sumsql = f""" select '' as id,'' as order_id ,'' as pitcher,'' as agent_name, '' as channel,
|
|
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 order_time,'' as user_create_time,'' as user_id,
|
|
'' as game,sum(amount) as amount ,'' as real_amount ,'' as server_name,
|
|
'' as game,sum(amount) as amount ,'' as real_amount ,'' as server_name,
|