|
@@ -2,7 +2,10 @@ from model.DateUtils import DateUtils
|
|
|
from model.DataBaseUtils import *
|
|
|
from model.log import logger
|
|
|
from model.CommonUtils import *
|
|
|
+from model import UserAuthUtils
|
|
|
du = DateUtils()
|
|
|
+from config.common_config import *
|
|
|
+from data_manage.operate import get_pitcher
|
|
|
|
|
|
log = logger()
|
|
|
|
|
@@ -108,13 +111,17 @@ where 1=1 {op1}
|
|
|
return db.dm.getData_json(sql)
|
|
|
|
|
|
|
|
|
-def get_channel_overview(channel,pitcher,stage,start,end,page,page_size,order_by,order):
|
|
|
+def get_channel_overview(user_id,channel,pitcher,stage,start,end,page,page_size,order_by,order):
|
|
|
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)}"
|
|
|
+ if user_id in super_auth:
|
|
|
+ op = ''
|
|
|
else:
|
|
|
- op1 = ''
|
|
|
+ if len(UserAuthUtils.get_auth_channel(user_id)) == 0:
|
|
|
+ return None, None, None
|
|
|
+ else:
|
|
|
+ op = f" and channel in {str(UserAuthUtils.get_auth_channel(user_id))}"
|
|
|
+
|
|
|
+ op1 = f" and pitcher ='{pitcher}' " if pitcher else ''
|
|
|
op2 = f" and channel='{channel}'" if channel else ''
|
|
|
op3 = f" and dt>='{start}' " if start else ''
|
|
|
op4 = f" and dt<='{end}' " if end else ''
|
|
@@ -150,7 +157,7 @@ def get_channel_overview(channel,pitcher,stage,start,end,page,page_size,order_by
|
|
|
round(reg_order_amount/reg_order_user,2) user_per_amount,
|
|
|
round(follow_user/click_count,4) click_follow_rate,
|
|
|
round(reg_order_user/follow_user,4) follow_order_rate
|
|
|
-from dw_channel where 1=1 {op1} {op2} {op3} {op4} {op6} {op5} """
|
|
|
+from dw_channel where 1=1 {op} {op1} {op2} {op3} {op4} {op6} {op5} """
|
|
|
|
|
|
print(sql)
|
|
|
sumsql=f"""select '总计' date,
|
|
@@ -192,10 +199,9 @@ from ({sql}) a
|
|
|
return getLimitSumData(db.dm,sql,sumsql,page,page_size)
|
|
|
|
|
|
|
|
|
-def get_channel_again_order_trend(channel,date,pitcher):
|
|
|
+def get_channel_again_order_trend(channel,date):
|
|
|
ck = CkUtils()
|
|
|
- # if get_channel_belong_pitcher(channel)!=pitcher:
|
|
|
- # return []
|
|
|
+
|
|
|
|
|
|
sql=f"""select toString(dt) date,
|
|
|
channel,book,pitcher,stage,
|
|
@@ -357,13 +363,16 @@ select
|
|
|
return [json1]
|
|
|
|
|
|
|
|
|
-def get_channel_active(channel,pitcher,start,end,page,page_size,order_by,order):
|
|
|
+def get_channel_active(user_id,channel,pitcher,start,end,page,page_size,order_by,order):
|
|
|
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)}"
|
|
|
+ if user_id in super_auth:
|
|
|
+ op = ''
|
|
|
else:
|
|
|
- op1 = ''
|
|
|
+ if len(UserAuthUtils.get_auth_channel(user_id)) == 0:
|
|
|
+ return None, None, None
|
|
|
+ else:
|
|
|
+ op = f" and channel in {str(UserAuthUtils.get_auth_channel(user_id))}"
|
|
|
+ op1 = f" and pitcher ='{pitcher}' " if pitcher else ''
|
|
|
op2 = f" and channel='{channel}'" if channel else ''
|
|
|
op3 = f" and dt>='{start}' " if start else ''
|
|
|
op4 = f" and dt<='{end}' " if end else ''
|
|
@@ -415,7 +424,7 @@ concat(dc27-dc26,',',cost/dc27,',',(dc27-dc26)/reg_order_user) d27,
|
|
|
concat(dc28-dc27,',',cost/dc28,',',(dc28-dc27)/reg_order_user) d28,
|
|
|
concat(dc29-dc28,',',cost/dc29,',',(dc29-dc28)/reg_order_user) d29,
|
|
|
concat(dc30-dc29,',',cost/dc30,',',(dc30-dc29)/reg_order_user) d30
|
|
|
-from (select * from dw_channel where cost>0 {op1} {op2} {op3} {op4}) a
|
|
|
+from (select * from dw_channel where cost>0 {op} {op1} {op2} {op3} {op4}) a
|
|
|
left join dw_channel_user_daily b using(dt,channel) {op5}
|
|
|
"""
|
|
|
|
|
@@ -436,13 +445,18 @@ left join dw_channel_user_daily b using(dt,channel) {op5}
|
|
|
|
|
|
return data,total
|
|
|
|
|
|
-def get_channel_order_trend(channel,pitcher,start,end,page,page_size,order_by,order):
|
|
|
- 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)}"
|
|
|
+def get_channel_order_trend(user_id,channel,pitcher,start,end,page,page_size,order_by,order):
|
|
|
+ db = MysqlUtils()
|
|
|
+
|
|
|
+ if user_id in super_auth:
|
|
|
+ op = ''
|
|
|
else:
|
|
|
- op1 = ''
|
|
|
+ if len(UserAuthUtils.get_auth_channel(user_id)) == 0:
|
|
|
+ return None, None, None
|
|
|
+ else:
|
|
|
+ op = f" and channel in {str(UserAuthUtils.get_auth_channel(user_id))}"
|
|
|
+
|
|
|
+ op1 = f" and pitcher ='{pitcher}' " if pitcher else ''
|
|
|
op2 = f" and channel='{channel}'" if channel else ''
|
|
|
op3 = f" and dt>='{start}' " if start else ''
|
|
|
op4 = f" and dt<='{end}' " if end else ''
|
|
@@ -527,7 +541,7 @@ concat(da60-da59 ,',' ,da60/cost ,',', (da60-da59)/cost ,',' ,da60/da1) d60,
|
|
|
concat(dm3-da60 ,',' ,dm3/cost ,',', (dm3-da60)/cost ,',' ,dm3/da1) m3,
|
|
|
concat(dm4-dm3 ,',' ,dm4/cost ,',', (dm4-dm3)/cost ,',' ,dm4/da1) m4,
|
|
|
concat(dm5-dm4 ,',' ,dm5/cost ,',', (dm5-dm4)/cost ,',' ,dm5/da1) m5
|
|
|
-from ( select * from dw_channel where cost+reg_order_amount>0 {op1} {op2} {op3} {op4} ) a
|
|
|
+from ( select * from dw_channel where cost+reg_order_amount>0 {op} {op1} {op2} {op3} {op4} ) a
|
|
|
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
|
|
|
|
|
@@ -572,15 +586,19 @@ left join src_book_info c on a.dt=c.dt and a.book=c.book and a.type=c.type and
|
|
|
print(data)
|
|
|
return data,total,total_data
|
|
|
|
|
|
-def get_channel_summary(channel,pitcher,page,page_size,order_by,order,state,location,start,end):
|
|
|
+def get_channel_summary(user_id,channel,pitcher,page,page_size,order_by,order,state,location,start,end):
|
|
|
db=MysqlUtils()
|
|
|
|
|
|
- op1=f" and a.channel='{channel}'" if channel else ''
|
|
|
-
|
|
|
- if pitcher:
|
|
|
- op2=f" and pitcher='{pitcher}'" if get_channels_from_user(pitcher).__len__()==0 else f" and a.channel in {get_channels_from_user(pitcher)}"
|
|
|
+ if user_id in super_auth:
|
|
|
+ op = ''
|
|
|
else:
|
|
|
- op2=''
|
|
|
+ if len(UserAuthUtils.get_auth_channel(user_id))==0:
|
|
|
+ return None,None,None
|
|
|
+ else:
|
|
|
+ op = f" and a.channel in {str(UserAuthUtils.get_auth_channel(user_id))}"
|
|
|
+
|
|
|
+ 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 ''
|
|
@@ -612,7 +630,7 @@ def get_channel_summary(channel,pitcher,page,page_size,order_by,order,state,loca
|
|
|
|
|
|
from dw_channel a
|
|
|
left join dw_channel_amount_daily_reverse b using (dt,channel)
|
|
|
- where 1=1 {op1} {op2} {op6} {op7} GROUP BY a.channel,type,pitcher,stage) x
|
|
|
+ where 1=1 {op} {op1} {op2} {op6} {op7} GROUP BY a.channel,type,pitcher,stage) x
|
|
|
having 1=1 {op4} {op5} ORDER BY {order_by} {order}
|
|
|
|
|
|
|