|
@@ -99,55 +99,45 @@ where 1=1 {op1}
|
|
|
|
|
|
|
|
|
def get_channel_overview(channel,pitcher,start,end,page,page_size,order_by,order):
|
|
|
- ck = CkUtils()
|
|
|
- sql="""select channel,toString(dt) date,
|
|
|
+ db=MysqlUtils()
|
|
|
+ if pitcher:
|
|
|
+ op1 = f" and pitcher='{pitcher}'" if get_channels_from_user(
|
|
|
+ pitcher).__len__() == 0 else f" and channel in {get_channels_from_user(pitcher)}"
|
|
|
+ else:
|
|
|
+ op1 = ''
|
|
|
+ op2 = f" and channel='{channel}'" if channel else ''
|
|
|
+ op3 = f" and dt>='{start}' " if start else ''
|
|
|
+ op4 = f" and dt<='{end}' " if end else ''
|
|
|
+ op5 = f" order by {order_by} {order}" if order_by and order else ''
|
|
|
+ sql=f"""select channel,dt date,
|
|
|
view_count,click_count,
|
|
|
- toDecimal32(if(view_count=0,0,click_count/view_count),4) click_rate,
|
|
|
+ round(if(view_count=0,0,click_count/view_count),4) click_rate,
|
|
|
follow_user,
|
|
|
- toDecimal32(if(click_count=0,0,follow_user/click_count),4) follow_rate,
|
|
|
- toDecimal32(if(follow_user=0,0,cost/follow_user),2) follow_per_cost,
|
|
|
- toDecimal32(if(click_count=0,0,first_order_count/click_count),4) order_rate,
|
|
|
- toDecimal32(if(first_order_user=0,0,cost/first_order_user),2) order_per_cost,
|
|
|
- toDecimal32(cost,2),
|
|
|
+ round(if(click_count=0,0,follow_user/click_count),4) follow_rate,
|
|
|
+ round(if(follow_user=0,0,cost/follow_user),2) follow_per_cost,
|
|
|
+ round(if(click_count=0,0,first_order_count/click_count),4) order_rate,
|
|
|
+ round(if(first_order_user=0,0,cost/first_order_user),2) order_per_cost,
|
|
|
+ cost,
|
|
|
first_order_count,first_order_user,
|
|
|
- toDecimal32(first_order_amount,2),
|
|
|
+ first_order_amount,
|
|
|
order_count,order_user,
|
|
|
- toDecimal32(order_amount,2),
|
|
|
- toDecimal32(order_amount-first_order_amount,2),
|
|
|
- toDecimal32(if(first_order_user=0,0,first_order_amount/first_order_user),2) first_amount_per_user,
|
|
|
- toDecimal32(if(follow_user=0,0,first_order_amount/follow_user),2) amount_per_follow,
|
|
|
- toDecimal32(if(first_order_user=0,0,cost/first_order_user),2) first_cost_per_user,
|
|
|
- toDecimal32(if(follow_user=0,0,first_order_user/follow_user),4) new_user_order_rate,
|
|
|
- toDecimal32(reg_order_amount,2),
|
|
|
- toDecimal32(total_cost,2),
|
|
|
- toDecimal32(total_amount,2),
|
|
|
- toDecimal32(if(cost=0,0,first_order_amount/cost),4) day_roi,
|
|
|
- toDecimal32(if(total_cost=0,0,total_amount/total_cost),4) all_roi,
|
|
|
- if(total_cost=0,0,total_first_amount/total_cost) avg_new_order_rate,
|
|
|
- if(reg_order_user=0,0,reg_order_user_again/reg_order_user) old_user_once_order_rate,
|
|
|
- pitcher from dw_daily_channel where 1=1 """
|
|
|
- if channel!='':
|
|
|
- sql+=f" and channel='{channel}'"
|
|
|
- if start!='':
|
|
|
- sql+=f" and dt>='{start}'"
|
|
|
- if end!='':
|
|
|
- sql+=f" and dt<='{end}'"
|
|
|
- if pitcher!='':
|
|
|
- if pitcher!='赞象 admin':
|
|
|
- if get_channels_from_user(pitcher).__len__()==0:
|
|
|
- sql+=f" and pitcher='{pitcher}'"
|
|
|
- else:
|
|
|
- sql+=f" and channel in {get_channels_from_user(pitcher)}"
|
|
|
- print(sql)
|
|
|
- total = ck.execute(f"select count(1) from ({sql}) a")[0][0]
|
|
|
- sql += f" order by {order_by} {order} limit {(page-1)*page_size},{page_size} "
|
|
|
-
|
|
|
+ order_amount,
|
|
|
+ order_amount-first_order_amount,
|
|
|
+ round(if(first_order_user=0,0,first_order_amount/first_order_user),2) first_amount_per_user,
|
|
|
+ round(if(follow_user=0,0,first_order_amount/follow_user),2) amount_per_follow,
|
|
|
+ round(if(first_order_user=0,0,cost/first_order_user),2) first_cost_per_user,
|
|
|
+ round(if(follow_user=0,0,first_order_user/follow_user),4) new_user_order_rate,
|
|
|
+ reg_order_amount,
|
|
|
+ total_cost,
|
|
|
+ total_amount,
|
|
|
+ round(if(cost=0,0,first_order_amount/cost),4) day_roi,
|
|
|
+ round(if(total_cost=0,0,total_amount/total_cost),4) all_roi,
|
|
|
+ round(if(total_cost=0,0,total_first_amount/total_cost),4) avg_new_order_rate,
|
|
|
+ round(if(reg_order_user=0,0,reg_order_user_again/reg_order_user),4) old_user_once_order_rate,
|
|
|
+ pitcher from dw_channel_daily where 1=1 {op1} {op2} {op3} {op4} {op5} """
|
|
|
|
|
|
- key=['channel','date','view_count','click_count','click_rate','follow_user','follow_rate','follow_per_cost','order_rate','order_per_cost','cost',
|
|
|
- 'first_order_count','first_order_user','first_order_amount','order_count','order_user','order_amount','old_order_amount','first_amount_per_user','amount_per_follow','first_cost_per_user',
|
|
|
- 'new_user_order_rate','reg_user_amount','total_cost','total_amount','day_roi','all_roi','avg_new_order_rate','old_user_once_order_rate','pitcher']
|
|
|
-
|
|
|
- return get_dict_list(key,get_round(ck.execute(sql))),total
|
|
|
+ print(sql)
|
|
|
+ return getLimitData(db.quchen_text,sql,page,page_size)
|
|
|
|
|
|
|
|
|
def get_channel_again_order_trend(channel,date,pitcher):
|
|
@@ -719,10 +709,10 @@ def get_channel_summary(channel,pitcher,page,page_size,order_by,order,state,loca
|
|
|
|
|
|
op1=f" and channel='{channel}'" if channel else ''
|
|
|
|
|
|
- if get_channels_from_user(pitcher).__len__()==0:
|
|
|
- op2= f" and pitcher='{pitcher}'"
|
|
|
+ if pitcher:
|
|
|
+ op2=f" and pitcher='{pitcher}'" if get_channels_from_user(pitcher).__len__()==0 else f" and channel in {get_channels_from_user(pitcher)}"
|
|
|
else:
|
|
|
- op2=f" and channel in {get_channels_from_user(pitcher)}"
|
|
|
+ op2=''
|
|
|
|
|
|
op3=f" and channel='{channel}'" if channel else ''
|
|
|
op4=f" and location='{location}' " if location else ''
|