Browse Source

1. 排除掉剩余金额为0的订单
2. 最大单件数与最大单金额调整

li.junbo 3 months ago
parent
commit
b4989e6fd6
2 changed files with 13 additions and 4 deletions
  1. 12 3
      data_processor/daily_sales_exporter.py
  2. 1 1
      data_processor/daily_zones_exporter.py

+ 12 - 3
data_processor/daily_sales_exporter.py

@@ -27,6 +27,7 @@ FROM (
         SUM(CASE WHEN t1.remaining_amount_after_return >= 2000 THEN 1 ELSE 0 END) AS `2000+单数`
     FROM sd_sales_order AS t1
     LEFT JOIN sd_big_sales_order AS t2 ON t1.sale_id = t2.sale_id
+    where t1.remaining_amount_after_return > 0
     GROUP BY t1.document_date
 ) AS temp;
 """
@@ -126,14 +127,22 @@ FROM (
         df['单据日期'] = pd.to_datetime(df['单据日期'])
         df = df.sort_values('单据日期').reset_index(drop=True)
 
-        weekly_summary = df.groupby('第几周').agg({
-            col: 'sum' for col in df.columns if col not in ['单据日期', '2000+单数占比', '第几周']
-        }).reset_index()
+        # weekly_summary = df.groupby('第几周').agg({
+        #     col: 'sum' for col in df.columns if col not in ['单据日期', '2000+单数占比', '第几周', '最大单件数', '最大单金额']
+        # }).reset_index()
+
+        # 修改后:
+        agg_dict = {col: 'sum' for col in df.columns if
+                    col not in ['单据日期', '2000+单数占比', '第几周', '最大单件数', '最大单金额']}
+        agg_dict['最大单件数'] = 'max'
+        agg_dict['最大单金额'] = 'max'
+        weekly_summary = df.groupby('第几周').agg(agg_dict).reset_index()
 
         weekly_summary['2000+单数'] = pd.to_numeric(weekly_summary['2000+单数'], errors='coerce')
         weekly_summary['总单数'] = pd.to_numeric(weekly_summary['总单数'], errors='coerce')
         weekly_summary['2000+单数占比'] = (weekly_summary['2000+单数'] / weekly_summary['总单数']).fillna(0).round(4)
 
+
         new_data = []
         current_week = None
 

+ 1 - 1
data_processor/daily_zones_exporter.py

@@ -60,7 +60,7 @@ FROM (
     FROM sd_sales_order AS t1
     LEFT JOIN sd_big_sales_order AS t2 ON t1.sale_id = t2.sale_id
     LEFT JOIN sd_store_info AS t3 ON t3.f360_code = t1.store_code
-    WHERE t3.group_leader IS NOT NULL
+    WHERE t3.group_leader IS NOT NULL and t1.remaining_amount_after_return > 0
     GROUP BY t1.document_date, t1.channel_type, t3.group_leader, t3.division
     ORDER BY `单据日期`, `店铺类型`
 ) AS temp;