|
@@ -305,5 +305,42 @@ concat(sum(m5-m4),',',sum(m5-m4)/sum(if(dt>=SUBDATE(CURRENT_DATE,INTERVAL 148 da
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-def pitcher_overview(start, end, page, page_size, order_by, order):
|
|
|
|
- pass
|
|
|
|
|
|
+def pitcher_overview(start, end, pitcher, page, page_size, order_by, order):
|
|
|
|
+ op1 = f" and pitcher='{pitcher}' " if pitcher else ''
|
|
|
|
+ op2 = f" and dt>='{start}' " if start else ''
|
|
|
|
+ op3 = f" and dt<='{end}' " if end else ''
|
|
|
|
+ op4 = f" order by {order_by} {order}" if order_by and order else ''
|
|
|
|
+
|
|
|
|
+ db = MysqlUtils()
|
|
|
|
+
|
|
|
|
+ sql=f""" select pitcher,
|
|
|
|
+ DATE_FORMAT(min(dt),'%Y%m%d') start_date,
|
|
|
|
+ DATE_FORMAT(max(dt),'%Y%m%d') end_date,
|
|
|
|
+ sum(cost) cost,
|
|
|
|
+ sum(reg_amount) amount,
|
|
|
|
+ sum(first_order_amount) first_amount,
|
|
|
|
+ round(sum(reg_amount)/sum(cost),4) roi,
|
|
|
|
+ round(sum(first_order_amount)/sum(cost),4) first_roi,
|
|
|
|
+ round(sum(d7)/sum(cost),4) roi7,
|
|
|
|
+ round(sum(d30)/sum(cost),4) roi30,
|
|
|
|
+ sum(reg_amount-cost) profit,
|
|
|
|
+ round(sum(click_count)/sum(view_count),4) click_rate,
|
|
|
|
+ round(sum(follow_user)/sum(click_count),4) follow_rate,
|
|
|
|
+ round(sum(reg_order_user)/sum(click_count),4) order_rate,
|
|
|
|
+ round(sum(first_order_user)/sum(click_count),4) first_order_rate,
|
|
|
|
+ sum(view_count) view_count,
|
|
|
|
+ sum(click_count) click_count,
|
|
|
|
+ sum(follow_user) follow_user,
|
|
|
|
+ sum(reg_order_user) order_user,
|
|
|
|
+ sum(first_order_user) first_order_user,
|
|
|
|
+ round(sum(cost)/sum(follow_user),2) follow_cost,
|
|
|
|
+ round(sum(cost)/sum(reg_order_user),2) order_cost,
|
|
|
|
+ round(sum(cost)/sum(first_order_user),2) first_order_cost,
|
|
|
|
+ round(sum(reg_amount)/sum(reg_order_user),2) avg_amount,
|
|
|
|
+ sum(ba1) td_amount,
|
|
|
|
+ sum(ba2) yd_amount,
|
|
|
|
+ sum(ba3) byd_amount
|
|
|
|
+ from dw_pitcher_trend where cost>0 {op1} {op2} {op3} group by pitcher {op4}
|
|
|
|
+ """
|
|
|
|
+
|
|
|
|
+ return getLimitData(db.dm, sql, page, page_size)
|