|
@@ -402,11 +402,64 @@ def image_rank(start, end, type,book, page, page_size, order_by, order):
|
|
|
|
|
|
db = MysqlUtils().quchen_text
|
|
db = MysqlUtils().quchen_text
|
|
|
|
|
|
- sql =f"""select image_id,preview_url,
|
|
|
|
|
|
+ sql =f"""select preview_url,
|
|
sum(cost),
|
|
sum(cost),
|
|
round(sum(click_count)/sum(view_count),4) ctr,
|
|
round(sum(click_count)/sum(view_count),4) ctr,
|
|
round(sum(cost)/sum(click_count),2) cpc
|
|
round(sum(cost)/sum(click_count),2) cpc
|
|
- from dm_image_cost_day where 1=1 {op1} {op2} {op3} {op4} GROUP BY image_id,preview_url
|
|
|
|
|
|
+ from dm_image_cost_day where preview_url!='' {op1} {op2} {op3} {op4} GROUP BY signature,preview_url
|
|
{op5} """
|
|
{op5} """
|
|
|
|
|
|
- return getLimitData(db, sql, page, page_size)
|
|
|
|
|
|
+ return getLimitData(db, sql, page, page_size)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+"""广告排行榜"""
|
|
|
|
+def advertisement_rank(start,end,ad_id,channel,pitcher,stage,site,type,page,page_size,order,order_by):
|
|
|
|
+ op1=f" and ad_id='{ad_id}' " if ad_id else ''
|
|
|
|
+ op2=f" and dt>='{start}' " if start else ''
|
|
|
|
+ op3=f" and dt<='{end}' " if end else ''
|
|
|
|
+ op4=f" and channel='{channel}' " if channel else ''
|
|
|
|
+ op5=f" and pitcher='{pitcher}' " if pitcher else ''
|
|
|
|
+ op6=f" and stage='{stage}'" if stage else ''
|
|
|
|
+ op7=f" and site='{site}'" if site else ''
|
|
|
|
+ op8=f" and type='{type}'" if type else ''
|
|
|
|
+ op9=f" order by {order_by} {order}" if order_by and order else ''
|
|
|
|
+ db =MysqlUtils().dm
|
|
|
|
+
|
|
|
|
+ sql=f"""select
|
|
|
|
+ dt,channel,pitcher,stage,platform,book,ad_name,ad_id,`type`,site, cost,
|
|
|
|
+ view_count,
|
|
|
|
+ click_count,
|
|
|
|
+ follow_count,
|
|
|
|
+ round((cost/view_count)*1000,4) cpm,
|
|
|
|
+ round(click_count/view_count,4) ctr,
|
|
|
|
+ round(cost/click_count,2) cpc,
|
|
|
|
+ order_count,
|
|
|
|
+ order_amount,
|
|
|
|
+ round(order_count/click_count,4) order_rate,
|
|
|
|
+ round(order_amount/order_count,2) unit_price,
|
|
|
|
+ round(cost/order_count,2) order_cost,
|
|
|
|
+ round(order_amount/cost,4) roi,
|
|
|
|
+ title,
|
|
|
|
+ description,
|
|
|
|
+ image_id,
|
|
|
|
+ preview_url
|
|
|
|
+ from dw_ad_day
|
|
|
|
+ where 1=1 {op1} {op2} {op3} {op4} {op5} {op6} {op7} {op8} {op9}
|
|
|
|
+ """
|
|
|
|
+ sum_sql = f"""select '总计' as pitcher,
|
|
|
|
+ sum(cost) cost,
|
|
|
|
+ sum(view_count) view_count,
|
|
|
|
+ sum(click_count) click_count,
|
|
|
|
+ sum(follow_count) follow_count,
|
|
|
|
+ round((sum(cost)/sum(view_count))*1000,4) cpm,
|
|
|
|
+ round(sum(click_count)/sum(view_count),4) ctr,
|
|
|
|
+ round(sum(cost)/sum(click_count),2) cpc,
|
|
|
|
+ sum(order_count),
|
|
|
|
+ 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(order_count),2) order_cost,
|
|
|
|
+ round(sum(order_amount)/sum(cost),4) ROI
|
|
|
|
+ from ({sql}) a
|
|
|
|
+ """
|
|
|
|
+ return getLimitSumData(db,sql,sum_sql, page, page_size)
|