shish пре 1 дан
родитељ
комит
19f1891ecf
2 измењених фајлова са 11 додато и 2 уклоњено
  1. 1 1
      app-ghs/controllers/StatKhCgController.php
  2. 10 1
      biz-ghs/stat/classes/StatSaleClass.php

+ 1 - 1
app-ghs/controllers/StatKhCgController.php

@@ -28,7 +28,7 @@ class StatKhCgController extends BaseController
         util::success($respond);
         util::success($respond);
     }
     }
 
 
-    //客户按片区划分业绩 ssh 20251117
+    // 客户按片区划分业绩 ssh 20251117;返回 list + totalNum/totalCount/totalAmount/totalCost/totalProfit
     public function actionDist()
     public function actionDist()
     {
     {
         ini_set('memory_limit', '2045M');
         ini_set('memory_limit', '2045M');

+ 10 - 1
biz-ghs/stat/classes/StatSaleClass.php

@@ -1688,6 +1688,10 @@ class StatSaleClass extends BaseClass
         return $arr;
         return $arr;
     }
     }
 
 
+    /**
+     * 片区业绩:按片区汇总笔数/扎数/金额/成本/利润,供 ghsApp distSale、/stat-kh-cg/dist 使用。
+     * totalCount 为总扎数(含隔天售后扣减),与各行 count 口径一致。
+     */
     public static function customDistStat($mainId)
     public static function customDistStat($mainId)
     {
     {
         $get = Yii::$app->request->get();
         $get = Yii::$app->request->get();
@@ -1718,6 +1722,7 @@ class StatSaleClass extends BaseClass
         $ghsOrderList = OrderClass::getAllByCondition($where, null, '*');
         $ghsOrderList = OrderClass::getAllByCondition($where, null, '*');
         $totalAmount = 0;
         $totalAmount = 0;
         $totalNum = 0;
         $totalNum = 0;
+        $totalCount = 0;
         $totalProfit = 0;
         $totalProfit = 0;
         $totalCost = 0;
         $totalCost = 0;
         if (!empty($ghsOrderList)) {
         if (!empty($ghsOrderList)) {
@@ -1746,6 +1751,7 @@ class StatSaleClass extends BaseClass
                 $distName = isset($distMap[$distId]) ? $distMap[$distId]['name'] : '未划片区';
                 $distName = isset($distMap[$distId]) ? $distMap[$distId]['name'] : '未划片区';
 
 
                 $totalNum++;
                 $totalNum++;
+                $totalCount = bcadd($totalCount, $count, 2);
                 $totalAmount = bcadd($totalAmount, $actPrice, 2);
                 $totalAmount = bcadd($totalAmount, $actPrice, 2);
                 $totalProfit = bcadd($totalProfit, $profit, 2);
                 $totalProfit = bcadd($totalProfit, $profit, 2);
                 $totalCost = bcadd($totalCost, $cost, 2);
                 $totalCost = bcadd($totalCost, $cost, 2);
@@ -1822,6 +1828,7 @@ class StatSaleClass extends BaseClass
                 }
                 }
                 $profit = bcsub($actPrice, $cost, 2);
                 $profit = bcsub($actPrice, $cost, 2);
                 $totalNum++;
                 $totalNum++;
+                $totalCount = bcadd($totalCount, $count, 2);
                 $totalAmount = bcadd($totalAmount, $actPrice, 2);
                 $totalAmount = bcadd($totalAmount, $actPrice, 2);
                 $totalProfit = bcadd($totalProfit, $profit, 2);
                 $totalProfit = bcadd($totalProfit, $profit, 2);
                 $totalCost = bcadd($totalCost, $cost, 2);
                 $totalCost = bcadd($totalCost, $cost, 2);
@@ -1879,6 +1886,7 @@ class StatSaleClass extends BaseClass
             $arr[$distId]['count'] = bcsub((string)($arr[$distId]['count'] ?? 0), (string)$qty, 2);
             $arr[$distId]['count'] = bcsub((string)($arr[$distId]['count'] ?? 0), (string)$qty, 2);
             $totalAmount = bcsub((string)$totalAmount, (string)$amt, 2);
             $totalAmount = bcsub((string)$totalAmount, (string)$amt, 2);
             $totalProfit = bcsub((string)$totalProfit, (string)$amt, 2);
             $totalProfit = bcsub((string)$totalProfit, (string)$amt, 2);
+            $totalCount = bcsub((string)$totalCount, (string)$qty, 2);
         }
         }
 
 
         $hdAmtMap = HdNextDayRefundClass::sumAmountGroupByCustom($mainId, $currentStartTime, $currentEndTime);
         $hdAmtMap = HdNextDayRefundClass::sumAmountGroupByCustom($mainId, $currentStartTime, $currentEndTime);
@@ -1911,12 +1919,13 @@ class StatSaleClass extends BaseClass
             $arr[$hdDistKey]['count'] = bcsub((string)($arr[$hdDistKey]['count'] ?? 0), $hdQtyTotal, 2);
             $arr[$hdDistKey]['count'] = bcsub((string)($arr[$hdDistKey]['count'] ?? 0), $hdQtyTotal, 2);
             $totalAmount = bcsub((string)$totalAmount, $hdAmtTotal, 2);
             $totalAmount = bcsub((string)$totalAmount, $hdAmtTotal, 2);
             $totalProfit = bcsub((string)$totalProfit, $hdAmtTotal, 2);
             $totalProfit = bcsub((string)$totalProfit, $hdAmtTotal, 2);
+            $totalCount = bcsub((string)$totalCount, $hdQtyTotal, 2);
         }
         }
         if (!empty($arr)) {
         if (!empty($arr)) {
             $arr = arrayUtil::arraySort($arr, 'profit');
             $arr = arrayUtil::arraySort($arr, 'profit');
         }
         }
         $totalAmount = floatval($totalAmount);
         $totalAmount = floatval($totalAmount);
-        return ['list' => $arr, 'totalAmount' => $totalAmount, 'totalNum' => $totalNum, 'totalCost' => $totalCost, 'totalProfit' => $totalProfit];
+        return ['list' => $arr, 'totalAmount' => $totalAmount, 'totalNum' => $totalNum, 'totalCount' => floatval($totalCount), 'totalCost' => $totalCost, 'totalProfit' => $totalProfit];
     }
     }
 
 
     /**
     /**