|
@@ -44,7 +44,6 @@ def get_pitcher_panel_channel(pitcher,channel,start,end,page,page_size,order_by,
|
|
|
"""
|
|
|
return getLimitData(db.quchen_text,sql,page,page_size)
|
|
|
|
|
|
-
|
|
|
def get_pitcher_panel_daily(pitcher, start, end, page, page_size, order_by, order):
|
|
|
db=MysqlUtils()
|
|
|
op1= f" and pitcher='{pitcher}'" if pitcher else ''
|
|
@@ -716,63 +715,45 @@ from order where dt>='{start}' {channel_op} group by formatDateTime(reg_time,'
|
|
|
return data,total
|
|
|
|
|
|
def get_channel_summary(channel,pitcher,page,page_size,order_by,order,state,location):
|
|
|
- ck = CkUtils()
|
|
|
- channel_op=f" and channel='{channel}'" if channel!='' else ''
|
|
|
+ db=MysqlUtils()
|
|
|
|
|
|
- if pitcher!='赞象 admin':
|
|
|
- if get_channels_from_user(pitcher).__len__()==0:
|
|
|
- pitcher_op= f" and pitcher='{pitcher}'"
|
|
|
- else:
|
|
|
- pitcher_op=f" and channel in {get_channels_from_user(pitcher)}"
|
|
|
-
|
|
|
- location_op=f" having location='{location}' " if location!='' else ''
|
|
|
-
|
|
|
- sql = f"""select a.channel channel,state,type location,toString(a.start_d) start,toString(a.end_d) end,
|
|
|
- toDecimal32(total_cost,2),toDecimal32(total_amount,2),
|
|
|
- toDecimal32(profit,2),roi,follow_user,toDecimal32(follow_per_cost,2),order_user,
|
|
|
- if(follow_user=0,0,order_user/follow_user) order_tran_rate,toDecimal32(if(order_user=0,0,total_cost/order_user),2) order_tran_cost,
|
|
|
- pitcher
|
|
|
- from
|
|
|
- (
|
|
|
- select channel,
|
|
|
- min(if(cost>0,dt,null)) start_d,max(if(cost>0,dt,null) ) end_d,
|
|
|
- if(end_d>subtractDays(today(),10),'在投','停投') state,case when type ='vx' then 'MP' when type ='qq' then 'GDT' end type
|
|
|
- from dw_daily_channel_cost where 1=1 {pitcher_op} {channel_op} group by channel,type) a
|
|
|
-
|
|
|
- left outer join(
|
|
|
- select channel,sum(follow_user) follow_user,
|
|
|
- if(follow_user=0,0,sum(cost)/follow_user) follow_per_cost
|
|
|
- from dw_daily_channel where 1=1 {pitcher_op} {channel_op} group by channel) b on a.channel=b.channel
|
|
|
-
|
|
|
- left outer join(
|
|
|
- select sum(reg_order_user) order_user,channel
|
|
|
- from dw_daily_channel where 1=1 {pitcher_op} {channel_op} group by channel) c on a.channel=c.channel
|
|
|
-
|
|
|
- left outer join (
|
|
|
- select total_cost,
|
|
|
- total_amount,
|
|
|
- channel,
|
|
|
- total_amount-total_cost profit,
|
|
|
- if(total_cost=0,0,total_amount/total_cost) roi
|
|
|
- from dw_channel_daily_total where dt=today() {channel_op}) d on a.channel=d.channel
|
|
|
- left outer join (
|
|
|
- select pitcher,channel from dw_daily_channel_cost where dt=today() group by pitcher,channel
|
|
|
- ) e on a.channel=e.channel
|
|
|
- {location_op}
|
|
|
- """
|
|
|
- print(sql)
|
|
|
- if channel!='':
|
|
|
- total=1
|
|
|
+ op1=f" and channel='{channel}'" if channel else ''
|
|
|
+
|
|
|
+ if get_channels_from_user(pitcher).__len__()==0:
|
|
|
+ op2= f" and pitcher='{pitcher}'"
|
|
|
else:
|
|
|
- sql+=f" having state='{state}' " if state!='' else ''
|
|
|
- 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} '
|
|
|
+ op2=f" and channel in {get_channels_from_user(pitcher)}"
|
|
|
+
|
|
|
+ op3=f" and channel='{channel}'" if channel else ''
|
|
|
+ op4=f" and location='{location}' " if location else ''
|
|
|
+ op5=f" having state='{state}'" if state else ''
|
|
|
+
|
|
|
+
|
|
|
+ sql = f"""SELECT channel,
|
|
|
+ if(end>date_sub(now(),interval 10 day),'在投','停投') state,
|
|
|
+ location,start,end,total_cost,total_amount,
|
|
|
+ total_amount-total_cost profit,
|
|
|
+ total_amount/total_cost roi,
|
|
|
+ follow_user,
|
|
|
+ total_cost/follow_user follow_per_cost,
|
|
|
+ order_user,
|
|
|
+ order_user/follow_user order_tran_rate,
|
|
|
+ total_cost/order_user order_tran_cost,
|
|
|
+ pitcher,stage
|
|
|
+ FROM
|
|
|
+ (select
|
|
|
+ channel,pitcher,stage,
|
|
|
+ case when type ='vx' then 'MP' when type ='qq' then 'GDT' end location,
|
|
|
+ min(if(cost>0,dt,null)) start,
|
|
|
+ max(if(cost>0,dt,null)) end,
|
|
|
+ sum(cost) total_cost,
|
|
|
+ sum(order_amount) total_amount,
|
|
|
+ sum(follow_user) follow_user,
|
|
|
+ sum(reg_order_user) order_user
|
|
|
+ from dw_channel_daily where 1=1 {op1} {op2} {op3} {op4} GROUP BY channel,type,pitcher,stage) a {op5} ORDER BY {order_by} {order}
|
|
|
+ """
|
|
|
print(sql)
|
|
|
- key=['channel','state','location','start','end','total_cost','total_amount','profit','roi',
|
|
|
- 'follow_user','follow_per_cost','order_user','order_tran_rate','order_tran_cost','pitcher']
|
|
|
- print(ck.execute(sql))
|
|
|
-
|
|
|
- return get_dict_list(key,get_round(ck.execute(sql))),total
|
|
|
+ return getLimitData(db.quchen_text,sql,page,page_size)
|
|
|
|
|
|
|
|
|
|