|
@@ -19,7 +19,7 @@ log = logger()
|
|
# di={}
|
|
# di={}
|
|
# for i in data:
|
|
# for i in data:
|
|
# di[i[1]]=i[0]
|
|
# di[i[1]]=i[0]
|
|
-# return di.get(channel,'')
|
|
|
|
|
|
+# return di.get(channel,'')
|
|
|
|
|
|
"""根据名字获取其归属的公众号"""
|
|
"""根据名字获取其归属的公众号"""
|
|
|
|
|
|
@@ -483,7 +483,7 @@ left join dw_channel_user_daily b using(dt,channel) {op5}
|
|
return data, total
|
|
return data, total
|
|
|
|
|
|
|
|
|
|
-def get_channel_order_trend(user_id, channel, pitcher, start, end, page, page_size, order_by, order):
|
|
|
|
|
|
+def get_channel_order_trend(user_id, channel, pitcher,agent_id, start, end, page, page_size, order_by, order):
|
|
db = MysqlUtils()
|
|
db = MysqlUtils()
|
|
if user_id in super_auth():
|
|
if user_id in super_auth():
|
|
op = ''
|
|
op = ''
|
|
@@ -508,23 +508,23 @@ def get_channel_order_trend(user_id, channel, pitcher, start, end, page, page_si
|
|
op3 = f" and dt>='{start}' " if start else ''
|
|
op3 = f" and dt>='{start}' " if start else ''
|
|
op4 = f" and dt<='{end}' " if end else ''
|
|
op4 = f" and dt<='{end}' " if end else ''
|
|
op5 = f" order by {order_by} {order}" if order_by and order else ''
|
|
op5 = f" order by {order_by} {order}" if order_by and order else ''
|
|
|
|
+ op6 = f" and agent_id = '{agent_id}' " if agent_id else ""
|
|
|
|
|
|
base_sql_multi_channel = f'''
|
|
base_sql_multi_channel = f'''
|
|
- ( select a.dt,a.create_user_num,a.reg_num,group_concat(a.channel) channel ,group_concat(a.pitcher ) pitcher ,
|
|
|
|
|
|
+ select a.dt,a.create_user_num,sum(a.reg_num) reg_num ,group_concat(a.channel) channel ,group_concat(a.pitcher ) pitcher ,
|
|
group_concat(a.stage ) stage ,group_concat(a.platform) platform ,
|
|
group_concat(a.stage ) stage ,group_concat(a.platform) platform ,
|
|
group_concat(a.book) book, group_concat(a.type) type,sum(a.order_count ) order_count ,
|
|
group_concat(a.book) book, group_concat(a.type) type,sum(a.order_count ) order_count ,
|
|
sum(a.order_user ) order_user ,sum(a.order_amount ) order_amount ,
|
|
sum(a.order_user ) order_user ,sum(a.order_amount ) order_amount ,
|
|
sum(a.reg_order_amount) reg_order_amount,
|
|
sum(a.reg_order_amount) reg_order_amount,
|
|
|
|
+ SUM(first_order_user) first_order_user,SUM(hundred_user_num) hundred_user_num,
|
|
sum(a.first_order_amount ) first_order_amount ,sum(a.view_count) view_count,
|
|
sum(a.first_order_amount ) first_order_amount ,sum(a.view_count) view_count,
|
|
sum(a.click_count) click_count ,sum(a.follow_user) follow_user ,
|
|
sum(a.click_count) click_count ,sum(a.follow_user) follow_user ,
|
|
max(game_user_sum) game_user_sum,
|
|
max(game_user_sum) game_user_sum,
|
|
-
|
|
|
|
round(if(sum(reg_num)=0,0,sum(reg_num*sixty_stay_rate)/sum(reg_num)),2) sixty_stay_rate,
|
|
round(if(sum(reg_num)=0,0,sum(reg_num*sixty_stay_rate)/sum(reg_num)),2) sixty_stay_rate,
|
|
round(if(sum(reg_num)=0,0,sum(reg_num*fortyfive_stay_rate)/sum(reg_num)),2) fortyfive_stay_rate,
|
|
round(if(sum(reg_num)=0,0,sum(reg_num*fortyfive_stay_rate)/sum(reg_num)),2) fortyfive_stay_rate,
|
|
round(if(sum(reg_num)=0,0,sum(reg_num*thirty_stay_rate)/sum(reg_num)),2) thirty_stay_rate,
|
|
round(if(sum(reg_num)=0,0,sum(reg_num*thirty_stay_rate)/sum(reg_num)),2) thirty_stay_rate,
|
|
round(if(sum(reg_num)=0,0,sum(reg_num*fifteen_stay_rate)/sum(reg_num)),2) fifteen_stay_rate,
|
|
round(if(sum(reg_num)=0,0,sum(reg_num*fifteen_stay_rate)/sum(reg_num)),2) fifteen_stay_rate,
|
|
round(if(sum(reg_num)=0,0,sum(reg_num*seven_stay_rate)/sum(reg_num)),2) seven_stay_rate,
|
|
round(if(sum(reg_num)=0,0,sum(reg_num*seven_stay_rate)/sum(reg_num)),2) seven_stay_rate,
|
|
-
|
|
|
|
round(if(sum(reg_num)=0,0,sum(reg_num*third_stay_rate)/sum(reg_num)),2) third_stay_rate,
|
|
round(if(sum(reg_num)=0,0,sum(reg_num*third_stay_rate)/sum(reg_num)),2) third_stay_rate,
|
|
round(if(sum(reg_num)=0,0,sum(reg_num*second_stay_rate)/sum(reg_num)),2) second_stay_rate,
|
|
round(if(sum(reg_num)=0,0,sum(reg_num*second_stay_rate)/sum(reg_num)),2) second_stay_rate,
|
|
round(if(max(game_user_sum)=0,0,sum(game_user_sum*today_active_user_rate)/max(game_user_sum)),2) today_active_user_rate,
|
|
round(if(max(game_user_sum)=0,0,sum(game_user_sum*today_active_user_rate)/max(game_user_sum)),2) today_active_user_rate,
|
|
@@ -600,7 +600,7 @@ def get_channel_order_trend(user_id, channel, pitcher, start, end, page, page_si
|
|
group_concat(annual_mult) as annual_mult
|
|
group_concat(annual_mult) as annual_mult
|
|
from
|
|
from
|
|
( select * from dw_channel where cost+reg_order_amount>0
|
|
( select * from dw_channel where cost+reg_order_amount>0
|
|
- {op} {op1} {op2} {op3} {op4} ) a
|
|
|
|
|
|
+ {op} {op1} {op2} {op3} {op4} {op6} ) a
|
|
left join dw_channel_amount_daily b on a.channel=b.channel
|
|
left join dw_channel_amount_daily b on a.channel=b.channel
|
|
and a.dt=b.dt
|
|
and a.dt=b.dt
|
|
left join src_book_info c on a.dt=c.dt and a.book=c.book
|
|
left join src_book_info c on a.dt=c.dt and a.book=c.book
|
|
@@ -609,7 +609,7 @@ def get_channel_order_trend(user_id, channel, pitcher, start, end, page, page_si
|
|
'''
|
|
'''
|
|
|
|
|
|
base_sql_singel_channel = f'''
|
|
base_sql_singel_channel = f'''
|
|
- ( select * from dw_channel where cost+reg_order_amount>0 {op} {op1} {op2} {op3} {op4} ) a
|
|
|
|
|
|
+ ( select * from dw_channel where cost+reg_order_amount>0 {op} {op1} {op2} {op3} {op4} {op6} ) a
|
|
left join dw_channel_amount_daily b on a.channel=b.channel and a.dt=b.dt
|
|
left join dw_channel_amount_daily b on a.channel=b.channel and a.dt=b.dt
|
|
left join src_book_info c on a.dt=c.dt and a.book=c.book and a.type=c.type and a.platform=c.platform
|
|
left join src_book_info c on a.dt=c.dt and a.book=c.book and a.type=c.type and a.platform=c.platform
|
|
'''
|
|
'''
|
|
@@ -619,6 +619,13 @@ def get_channel_order_trend(user_id, channel, pitcher, start, end, page, page_si
|
|
stage,pitcher,a.channel,a.dt date,a.book,cost,
|
|
stage,pitcher,a.channel,a.dt date,a.book,cost,
|
|
a.type,
|
|
a.type,
|
|
a.reg_num,
|
|
a.reg_num,
|
|
|
|
+ first_order_user, --新增付费人数
|
|
|
|
+ round(cost/first_order_user,2) first_order_cost, -- as '新增付费成本',
|
|
|
|
+ round(first_order_amount/first_order_user,2) ARPU, -- 新增付费ARPU
|
|
|
|
+ hundred_user_num, -- 单日付费100+用户数
|
|
|
|
+ round(cost/hundred_user_num,2) hundred_user_num_cost , -- 单日付费100+用户付费成本
|
|
|
|
+ round(first_order_user/a.reg_num,4) first_order_rate, -- 新增付费率
|
|
|
|
+ round(reg_order_amount /reg_order_user,2) order_ARPU, -- 付费ARPU
|
|
round(if(a.reg_num=0,0,cost/a.reg_num),2) reg_per_cost,
|
|
round(if(a.reg_num=0,0,cost/a.reg_num),2) reg_per_cost,
|
|
a.create_user_num,
|
|
a.create_user_num,
|
|
round(if( a.create_user_num=0,0,cost/ a.create_user_num),2) create_user_per_cost,
|
|
round(if( a.create_user_num=0,0,cost/ a.create_user_num),2) create_user_per_cost,
|
|
@@ -720,6 +727,13 @@ def get_channel_order_trend(user_id, channel, pitcher, start, end, page, page_si
|
|
|
|
|
|
sumsql = f"""select concat(date_format(min(date),'%Y/%m/%d'),'~',date_format(max(date),'%Y/%m/%d')) date,
|
|
sumsql = f"""select concat(date_format(min(date),'%Y/%m/%d'),'~',date_format(max(date),'%Y/%m/%d')) date,
|
|
sum(create_user_num) create_user_num,
|
|
sum(create_user_num) create_user_num,
|
|
|
|
+ sum(first_order_user) first_order_user,
|
|
|
|
+ round(sum(first_order_cost),2) , -- as '新增付费成本',
|
|
|
|
+ round(sum(ARPU),2) , -- 新增付费ARPU
|
|
|
|
+ sum(hundred_user_num), -- 单日付费100+用户数
|
|
|
|
+ round(sum(hundred_user_num_cost),2) , -- 单日付费100+用户付费成本
|
|
|
|
+ round(sum(first_order_rate),4) , -- 新增付费率
|
|
|
|
+ round(sum(order_ARPU),2) , -- 付费ARPU
|
|
round(if( sum(create_user_num)=0,0,sum(cost)/ sum(create_user_num)),2) create_user_per_cost,
|
|
round(if( sum(create_user_num)=0,0,sum(cost)/ sum(create_user_num)),2) create_user_per_cost,
|
|
sum(reg_num) reg_num,
|
|
sum(reg_num) reg_num,
|
|
round(if(sum(reg_num)=0,0,sum(cost)/sum(reg_num)),2) reg_per_cost,
|
|
round(if(sum(reg_num)=0,0,sum(cost)/sum(reg_num)),2) reg_per_cost,
|