cqp 1 nedēļu atpakaļ
vecāks
revīzija
8d7e185bec
2 mainītis faili ar 15 papildinājumiem un 4 dzēšanām
  1. 4 0
      app/Model/FreightFee.php
  2. 11 4
      app/Service/StatisticsService.php

+ 4 - 0
app/Model/FreightFee.php

@@ -17,6 +17,10 @@ class FreightFee extends UseScopeBaseModel
         self::deliveryModeNormal => '纯自提',
         self::deliveryModeRightNow => '当日达',
     ];
+    public static $business = [
+        self::businessTypeNormal => '普通销售',
+        self::businessTypeReturn => '销售退货',
+    ];
 
     const employee_column = 'employee_id_1';
 

+ 11 - 4
app/Service/StatisticsService.php

@@ -643,7 +643,7 @@ class StatisticsService extends Service
         $return = [];
         foreach ($fee as $value) {
             $value = $this->calculateFreightFeeRow($value, $time_amount);
-            $key = $value['order_time'] . $value['area_hs'];
+            $key = $value['order_time'] . '|' . $value['area_hs'];
             $return[$value['business_type_id']][$key][] = $value;
         }
 
@@ -652,8 +652,11 @@ class StatisticsService extends Service
         $sumFields = ['xs', 'weight', 'freight_amount', 'js_amount', 'customer_store_zx_fee', 'jj_fee', 'dh_fee', 'total_amount'];
 
         // 业务类型 日期 地区 算一张表算运费
-        foreach ($return as $group) {
-            foreach ($group as $val) {
+        foreach ($return as $g => $group) {
+            $g_title = FreightFee::$business[$g] ?? "";
+            foreach ($group as $key => $val) {
+                $tmp_key = explode('|', $key);
+                $title = $tmp_key[1] . "(" . $g_title . ")";
                 // 计算合计
                 $sumRow = [];
                 foreach ($val as $key => $row) {
@@ -677,7 +680,11 @@ class StatisticsService extends Service
                 }
 
                 $val[] = $footer;
-                $result[] = $val;
+
+                $result[] = [
+                    'key' => $title,
+                    'list' => $val
+                ];
             }
         }