|
@@ -600,12 +600,12 @@ def get_channel_summary(user_id,channel,pitcher,page,page_size,order_by,order,st
|
|
|
if user_id in super_auth(): # 超级数据权限
|
|
|
op = ''
|
|
|
else:
|
|
|
- channel_li = UserAuthUtils.get_auth_channel()
|
|
|
+ channel_li = UserAuthUtils.get_auth_channel(user_id)
|
|
|
+ print(channel_li.__len__())
|
|
|
op = f" and a.channel in {tuple(channel_li)}"
|
|
|
|
|
|
op1=f" and a.channel='{channel}'" if channel else ''
|
|
|
op2=f" and pitcher='{pitcher}'" if pitcher else ''
|
|
|
- op4=f" and location='{location}' " if location else ''
|
|
|
op5=f" and state='{state}'" if state else ''
|
|
|
op6=f" and a.dt>='{start}'" if start else ''
|
|
|
op7 =f" and a.dt<='{end}'" if end else ''
|
|
@@ -613,7 +613,8 @@ def get_channel_summary(user_id,channel,pitcher,page,page_size,order_by,order,st
|
|
|
|
|
|
sql = f"""SELECT channel,
|
|
|
if(end>date_sub(now(),interval 10 day),'在投','停投') state,
|
|
|
- location,start,end,total_cost,total_amount,
|
|
|
+ start,end,
|
|
|
+ total_cost,total_amount,
|
|
|
total_amount-total_cost profit,
|
|
|
if(total_cost=0,0,round(total_amount/total_cost,4)) roi,
|
|
|
follow_user,
|
|
@@ -621,11 +622,10 @@ def get_channel_summary(user_id,channel,pitcher,page,page_size,order_by,order,st
|
|
|
order_user,
|
|
|
if(follow_user=0,0,round(order_user/follow_user,4)) order_tran_rate,
|
|
|
if(order_user=0,0,round(total_cost/order_user,2)) order_tran_cost,
|
|
|
- pitcher,stage,td_amount,yd_amount,byd_amount
|
|
|
+ td_amount,yd_amount,byd_amount
|
|
|
FROM
|
|
|
(select
|
|
|
- channel,pitcher,stage,
|
|
|
- type location,
|
|
|
+ channel,
|
|
|
min(if(cost>0,dt,null)) start,
|
|
|
max(if(cost>0,dt,null)) end,
|
|
|
sum(cost) total_cost,
|
|
@@ -637,7 +637,7 @@ def get_channel_summary(user_id,channel,pitcher,page,page_size,order_by,order,st
|
|
|
from dw_channel a
|
|
|
left join dw_channel_amount_daily_reverse b using (dt,channel)
|
|
|
where 1=1 {op} {op1} {op2} {op6} {op7} GROUP BY a.channel) x
|
|
|
- having 1=1 {op4} {op5} ORDER BY {order_by} {order}
|
|
|
+ having 1=1 {op5} ORDER BY {order_by} {order}
|
|
|
|
|
|
"""
|
|
|
print(sql)
|