|
@@ -15,7 +15,6 @@ def get_channel_belong_pitcher(channel):
|
|
|
di={}
|
|
|
for i in data:
|
|
|
di[i[1]]=i[0]
|
|
|
-
|
|
|
return di.get(channel,'')
|
|
|
|
|
|
|
|
@@ -42,7 +41,7 @@ def get_pitcher_panel_channel(pitcher,channel,start,end,page,page_size,order_by,
|
|
|
sql += f" and channel='{channel}' "
|
|
|
|
|
|
total = ck.execute(f"select count(1) from ({sql}) a")[0][0]
|
|
|
- sql += f" order by {order_by} {order} limit {page},{page_size} "
|
|
|
+ sql += f" order by {order_by} {order} limit {(page-1)*page_size},{page_size} "
|
|
|
|
|
|
print(sql)
|
|
|
data=ck.execute(sql)
|
|
@@ -73,7 +72,7 @@ def get_pitcher_panel_daily(pitcher, start, end, page, page_size, order_by, orde
|
|
|
if pitcher != 'all':
|
|
|
sql += f" and pitcher='{pitcher}' "
|
|
|
|
|
|
- sql += f" group by date,pitcher order by {order_by} {order} limit {page},{page_size} "
|
|
|
+ sql += f" group by date,pitcher order by {order_by} {order} limit {(page-1)*page_size},{page_size} "
|
|
|
print(sql)
|
|
|
data = ck.execute(sql)
|
|
|
total=ck.execute(f"select count(1) from ({sql}) a")[0][0]
|
|
@@ -148,7 +147,7 @@ def get_channel_overview(channel,pitcher,start,end,page,page_size,order_by,order
|
|
|
if pitcher!='':
|
|
|
sql+=f" and pitcher='{pitcher}'"
|
|
|
total = ck.execute(f"select count(1) from ({sql}) a")[0][0]
|
|
|
- sql += f" order by {order_by} {order} limit {page},{page_size} "
|
|
|
+ sql += f" order by {order_by} {order} limit {(page-1)*page_size},{page_size} "
|
|
|
print(sql)
|
|
|
|
|
|
key=['channel','date','view_count','click_count','click_rate','follow_user','follow_rate','follow_per_cost','order_rate','order_per_cost','cost',
|
|
@@ -159,8 +158,9 @@ def get_channel_overview(channel,pitcher,start,end,page,page_size,order_by,order
|
|
|
|
|
|
|
|
|
def get_channel_again_order_trend(channel,date,pitcher):
|
|
|
- if get_channel_belong_pitcher(channel)!=pitcher:
|
|
|
- return []
|
|
|
+
|
|
|
+ # if get_channel_belong_pitcher(channel)!=pitcher:
|
|
|
+ # return []
|
|
|
|
|
|
sql=f"""select toString(dt) date,
|
|
|
channel,book,
|
|
@@ -177,9 +177,9 @@ def get_channel_again_order_trend(channel,date,pitcher):
|
|
|
|
|
|
from dw_daily_channel where channel='{channel}' and dt='{date}'
|
|
|
"""
|
|
|
- print(sql)
|
|
|
+ # print(sql)
|
|
|
data=ck.execute(sql)
|
|
|
- print(data)
|
|
|
+ # print(data)
|
|
|
key1=['date','channel','book','cost','reg_amount','roi','new_follow','new_follow_per_cost',
|
|
|
'reg_count','reg_user','cost_per_user','avg_order_amount','avg_again_order_rate','order_count']
|
|
|
json1=get_dict_list(key1,get_round(data))[0]
|
|
@@ -201,7 +201,7 @@ def get_channel_again_order_trend(channel,date,pitcher):
|
|
|
) a group by date"""
|
|
|
|
|
|
df=ck.execute(sql2)
|
|
|
-
|
|
|
+ print(df)
|
|
|
# 补全
|
|
|
xx=[i[0] for i in df]
|
|
|
for i in range(1,8):
|
|
@@ -210,6 +210,7 @@ def get_channel_again_order_trend(channel,date,pitcher):
|
|
|
# 排序
|
|
|
import operator
|
|
|
df.sort(key=operator.itemgetter(0))
|
|
|
+ print(df)
|
|
|
|
|
|
reg_user=json1["reg_user"]
|
|
|
li=[]
|
|
@@ -274,6 +275,7 @@ def get_channel_again_order_trend(channel,date,pitcher):
|
|
|
d['d7'] = d7
|
|
|
|
|
|
li.append(d)
|
|
|
+ print(li)
|
|
|
|
|
|
json1['data']=li
|
|
|
print([json1])
|
|
@@ -369,10 +371,11 @@ select toDate(formatDateTime(reg_time,'%Y-%m-%d')) dt,
|
|
|
count(distinct if(subtractDays(date, 30)>=reg_time,NULL,user_id)) reg_order_user30
|
|
|
from order where channel='{channel}' and dt>='{start}' group by formatDateTime(reg_time,'%Y-%m-%d')) b on a.dt=b.dt
|
|
|
"""
|
|
|
- print(sql)
|
|
|
+
|
|
|
total = ck.execute(f"select count(1) from ({sql}) a")[0][0]
|
|
|
- sql+=f" order by {order_by} {order} limit {page},{page_size} "
|
|
|
+ sql+=f" order by {order_by} {order} limit {(page-1)*page_size},{page_size} "
|
|
|
data = ck.execute(sql)
|
|
|
+ print(sql)
|
|
|
print(data)
|
|
|
|
|
|
key=['date','channel','book','cost','reg_amount','roi','new_follow_user','new_follow_per_cost','order_user','order_count','order_user_per_cost',
|
|
@@ -615,7 +618,7 @@ from order where channel='{channel}' and dt>='{start}' group by formatDateTime(
|
|
|
total=1
|
|
|
else:
|
|
|
total = ck.execute(f"select count(1) from ({sql}) a")[0][0]
|
|
|
- sql += f" order by {order_by} {order} limit {page},{page_size} "
|
|
|
+ sql += f" order by {order_by} {order} limit {(page-1)*page_size},{page_size} "
|
|
|
|
|
|
data=get_round(ck.execute(sql))
|
|
|
# print(data)
|
|
@@ -640,7 +643,7 @@ from order where channel='{channel}' and dt>='{start}' group by formatDateTime(
|
|
|
|
|
|
return get_dict_list(key,data),total
|
|
|
|
|
|
-def get_channel_summary(channel,pitcher,page,page_size,order_by,order):
|
|
|
+def get_channel_summary(channel,pitcher,page,page_size,order_by,order,state):
|
|
|
|
|
|
pitcher_op=f" and pitcher='{pitcher}'" if pitcher!='' else ''
|
|
|
channel_op=f" and channel='{channel}'" if channel!='' else ''
|
|
@@ -676,8 +679,9 @@ def get_channel_summary(channel,pitcher,page,page_size,order_by,order):
|
|
|
if channel!='':
|
|
|
total=1
|
|
|
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},{page_size} '
|
|
|
+ sql += f' order by {order_by} {order} limit {(page-1)*page_size},{page_size} '
|
|
|
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']
|
|
@@ -690,8 +694,8 @@ def get_channel_summary(channel,pitcher,page,page_size,order_by,order):
|
|
|
if __name__ == '__main__':
|
|
|
# a=get_channel_overview('','','',1,10,'date','desc')
|
|
|
# a=get_channel_summary('','')
|
|
|
- # a=get_channel_again_order_trend('龙鳞文学','2021-01-01','宋刚')
|
|
|
+ a=get_channel_again_order_trend('龙鳞文学','2021-01-01','宋刚')
|
|
|
# a=get_channel_active('玉龙书社','2020-09-15','2020-09-20',1,10,'date','desc')
|
|
|
- a,b =get_channel_order_trend("玉龙书社",'王俊杰','2020-12-01','2020-12-12',1,5,'date','desc')
|
|
|
- print(a,b)
|
|
|
+ # a,b =get_channel_order_trend("玉龙书社",'王俊杰','2020-12-01','2020-12-12',1,5,'date','desc')
|
|
|
+ print(a)
|
|
|
pass
|