|
@@ -433,7 +433,7 @@ def image_rank(start, end, type,book, page, page_size, order_by, order):
|
|
|
|
|
|
|
|
|
"""广告排行榜"""
|
|
|
-def advertisement_rank(user_id,start,end,type,page,page_size,order,order_by,book,channel,pitcher):
|
|
|
+def advertisement_rank(user_id,start,end,type,page,page_size,order,order_by,book,channel,pitcher,has_order):
|
|
|
if user_id in super_auth():
|
|
|
op1 = ''
|
|
|
else:
|
|
@@ -450,6 +450,7 @@ def advertisement_rank(user_id,start,end,type,page,page_size,order,order_by,book
|
|
|
op8=f" and type='{type}'" if type else ''
|
|
|
op9=f" order by {order_by} {order}" if order_by and order else ''
|
|
|
op10=f" and book='{book}'" if book else ''
|
|
|
+ op11 =f" and order_count>0" if has_order else ''
|
|
|
db =MysqlUtils().dm
|
|
|
|
|
|
sql=f"""select
|
|
@@ -464,6 +465,7 @@ def advertisement_rank(user_id,start,end,type,page,page_size,order,order_by,book
|
|
|
order_amount,
|
|
|
round(order_count/click_count,4) order_rate,
|
|
|
round(order_amount/order_count,2) unit_price,
|
|
|
+ round(cost/follow_count) follow_cost,
|
|
|
round(cost/order_count,2) order_cost,
|
|
|
round(order_amount/cost,4) roi,
|
|
|
title,
|
|
@@ -471,7 +473,7 @@ def advertisement_rank(user_id,start,end,type,page,page_size,order,order_by,book
|
|
|
image_id,
|
|
|
preview_url
|
|
|
from dw_image_cost_day
|
|
|
- where preview_url!='' {op1} {op2} {op3} {op4} {op5} {op8} {op10} {op9}
|
|
|
+ where preview_url!='' {op1} {op2} {op3} {op4} {op5} {op8} {op10} {op11} {op9}
|
|
|
"""
|
|
|
|
|
|
print(sql)
|
|
@@ -487,6 +489,7 @@ def advertisement_rank(user_id,start,end,type,page,page_size,order,order_by,book
|
|
|
sum(order_amount),
|
|
|
round(sum(order_count)/sum(click_count),4) order_rate,
|
|
|
round(sum(order_amount)/sum(order_count),2) unit_price,
|
|
|
+ round(sum(cost)/sum(follow_count),2) follow_cost,
|
|
|
round(sum(cost)/sum(order_count),2) order_cost,
|
|
|
round(sum(order_amount)/sum(cost),4) ROI
|
|
|
from ({sql}) a
|