|
@@ -143,7 +143,7 @@ def get_channel_overview(channel,pitcher,start,end,page,page_size,order_by,order
|
|
|
reg_order_user_again,
|
|
|
reg_order_user,
|
|
|
round(if(reg_order_user=0,0,reg_order_user_again/reg_order_user),4) old_user_once_order_rate,
|
|
|
- pitcher,stage,
|
|
|
+ pitcher,stage,book,
|
|
|
round(cost/first_order_user,2) first_order_user_per_cost,
|
|
|
round(reg_order_amount/reg_order_user,2) user_per_amount,
|
|
|
round(follow_user/click_count,4) click_follow_rate,
|
|
@@ -496,6 +496,9 @@ def get_channel_order_trend(channel,pitcher,start,end,page,page_size,order_by,or
|
|
|
else:
|
|
|
pitcher_op = f" and channel in {get_channels_from_user(pitcher)}"
|
|
|
|
|
|
+ op1 =f" and dt>='{start}' " if start else ''
|
|
|
+ op2=f" and dt<='{end}' " if end else ''
|
|
|
+
|
|
|
sql=f"""select stage,pitcher,channel,toString(dt) date,book,
|
|
|
require_roi,require_mult,
|
|
|
toDecimal32(r1*require_mult-cost,2),
|
|
@@ -577,7 +580,7 @@ select pitcher,channel,dt,book,cost,reg_order_amount,stage,
|
|
|
if(follow_user=0,0,cost/follow_user) new_follow_per_cost,
|
|
|
reg_order_user order_user, reg_order_count order_count,
|
|
|
if(reg_order_user=0,0,cost/reg_order_user) order_user_per_cost
|
|
|
- from dw_daily_channel where dt>='{start}' and dt<='{end}' {channel_op} {pitcher_op} and cost>0) a
|
|
|
+ from dw_daily_channel where 1=1 {op1} {op2} {channel_op} {pitcher_op} and cost>0) a
|
|
|
|
|
|
left outer join (
|
|
|
select toDate(formatDateTime(reg_time,'%Y-%m-%d')) dt,channel,
|
|
@@ -707,7 +710,7 @@ r60-r59 a60,if(r1=0,0,r60/r1) b60,
|
|
|
r90-r60 a90,if(r1=0,0,r90/r1) b90,
|
|
|
r120-r90 a120,if(r1=0,0,r120/r1) b120,
|
|
|
r150-r120 a150,if(r1=0,0,r150/r1) b150
|
|
|
-from order where dt>='{start}' {channel_op} group by formatDateTime(reg_time,'%Y-%m-%d'),channel
|
|
|
+from order where 1=1 {op1} {channel_op} group by formatDateTime(reg_time,'%Y-%m-%d'),channel
|
|
|
) b on a.dt=b.dt and a.channel=b.channel
|
|
|
"""
|
|
|
print(sql)
|
|
@@ -753,7 +756,7 @@ from order where dt>='{start}' {channel_op} group by formatDateTime(reg_time,'
|
|
|
expect_profit+=i['expect_profit']
|
|
|
count= len(data)
|
|
|
if count==0:
|
|
|
- return [],0
|
|
|
+ return [],0,{}
|
|
|
total_data={'cost':round(cost,2),'reg_amount':round(reg_amount,2),'profit':round(profit,2),'expect_profit':round(expect_profit,2),'roi':round(reg_amount/cost,4), 'new_follow_user':new_follow_user,
|
|
|
'new_follow_per_cost':round(new_follow_per_cost/count,2),'order_user':order_user,'order_count':order_count,
|
|
|
'order_user_per_cost':round(order_user_per_cost/count,2),'channel':'-','date':'总计','book':'-'
|
|
@@ -902,6 +905,8 @@ def get_pitcher_trend(pitcher,start=None,end=None,page=None,page_size=None,order
|
|
|
return data,total,total_data
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
if __name__ == '__main__':
|
|
|
get_pitcher_trend(pitcher="陈凯")
|
|
|
|