ck %!s(int64=4) %!d(string=hai) anos
pai
achega
e0c2d9a12f
Modificáronse 1 ficheiros con 18 adicións e 15 borrados
  1. 18 15
      data_manage/pitcher_panel.py

+ 18 - 15
data_manage/pitcher_panel.py

@@ -9,15 +9,18 @@ log = logger()
 
 
 def get_pitcher_panel_channel(pitcher,channel,start,end,page,page_size,order_by,order):
-    sql=f"""select channel,stage,platform,book,formatDateTime(dt,'%Y-%m-%d') as date,cost,first_order_amount,
-           if(cost=0,0,round(first_order_amount/cost,4)) first_roi,
+    sql=f"""select channel,stage,platform,book,
+            formatDateTime(dt,'%Y-%m-%d') as date,
+            cost,
+            first_order_amount,
+           toDecimal32(if(cost=0,0,first_order_amount/cost),4) first_roi,
            first_order_user,first_order_count,
-           if(first_order_user=0,0,round(cost/first_order_user,2)) first_per_cost,
+           toDecimal32(if(first_order_user=0,0,cost/first_order_user),2) first_per_cost,
            view_count,click_count,follow_user,
-           if(click_count=0,0,round(follow_user/click_count,4)) follow_rate,
-           if(follow_user=0,0,round(cost/follow_user,2)) follow_per_cost,
+           toDecimal32(if(click_count=0,0,follow_user/click_count),4) follow_rate,
+           toDecimal32(if(follow_user=0,0,cost/follow_user),2) follow_per_cost,
             total_cost,
-           if(total_cost=0,0,round(total_amount/total_cost,4)) back_rate
+           toDecimal32(if(total_cost=0,0,total_amount/total_cost),2) back_rate
     
            from dw_daily_channel where dt>='{start}' and dt<='{end}'  """
     if pitcher!='all':
@@ -40,15 +43,15 @@ 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,
-               round(sum(cost),2) cost,
-                round(sum(first_order_amount),2) first_order_amount,
-               if(cost=0,0,round(first_order_amount/cost,4)) first_roi ,
-               round(sum(order_amount),2) order_amount,
-               if(cost=0,0,round(sum(reg_order_amount)/cost,4))  today_roi,
-               round(sum(total_cost),2) total_cost,
-               round(sum(total_amount),2) total_amount,
-               total_amount-total_cost total_profit,
-               if(total_cost=0,0,round(total_amount/total_cost,4)) total_roi
+               toDecimal32(sum(cost),2) cost,
+               toDecimal32(sum(first_order_amount),2) first_order_amount,
+               toDecimal32(if(cost=0,0,first_order_amount/cost),4) first_roi ,
+               toDecimal32(sum(order_amount),2) order_amount,
+               toDecimal32(if(cost=0,0,sum(reg_order_amount)/cost),4)  today_roi,
+               toDecimal32(sum(total_cost),2) total_cost,
+               toDecimal32(sum(total_amount),2) total_amount,
+               toDecimal32(total_amount-total_cost,2) total_profit,
+               toDecimal32(if(total_cost=0,0,total_amount/total_cost),4) total_roi
                from dw_daily_channel  where dt>='{start}' and dt<='{end}' """
 
     if pitcher != 'all':