|
@@ -56,22 +56,23 @@ def get_pitcher_panel_channel(pitcher,channel,start,end,page,page_size,order_by,
|
|
|
|
|
|
def get_pitcher_panel_daily(pitcher, start, end, page, page_size, order_by, order):
|
|
|
sql=f"""
|
|
|
- select formatDateTime(dt,'%Y-%m-%d') date ,pitcher,
|
|
|
+ select formatDateTime(dt,'%Y-%m-%d') date,pitcher,cost,first_order_amount,first_roi,
|
|
|
+order_amount,today_roi,total_amount,total_cost,total_amount-total_cost total_profit,
|
|
|
+total_amount/total_cost total_roi from
|
|
|
+ (select dt,pitcher,
|
|
|
round(sum(cost),2) cost,
|
|
|
round(sum(first_order_amount),2) first_order_amount,
|
|
|
round(if(cost=0,0,first_order_amount/cost),4) first_roi ,
|
|
|
round(sum(order_amount),2) order_amount,
|
|
|
round(if(cost=0,0,sum(reg_order_amount)/cost),4) today_roi,
|
|
|
- round(sum(total_cost),2) total_cost,
|
|
|
- round(sum(total_amount),2) total_amount,
|
|
|
- round(total_amount-total_cost,2) total_profit,
|
|
|
- round(if(total_cost=0,0,total_amount/total_cost),4) total_roi
|
|
|
- from dw_daily_channel where dt>='{start}' and dt<='{end}' """
|
|
|
-
|
|
|
- if pitcher != '':
|
|
|
- sql += f" and pitcher='{pitcher}' "
|
|
|
-
|
|
|
- sql+=f" group by date,pitcher"
|
|
|
+ from dw_daily_channel
|
|
|
+ where dt>='{start}' and dt<='{end}' and pitcher='{pitcher}'
|
|
|
+ group by dt) a
|
|
|
+ left outer join (
|
|
|
+ select dt,total_amount,total_cost from dw_daily_pitcher
|
|
|
+) b on a.dt=b.dt
|
|
|
+
|
|
|
+"""
|
|
|
|
|
|
total = ck.execute(f"select count(1) from ({sql}) a")[0][0]
|
|
|
sql += f" order by {order_by} {order} limit {(page-1)*page_size},{page_size} "
|