Преглед изворни кода

Merge branch 'after-sale' into redesign‌-260706

shish пре 1 дан
родитељ
комит
fefe857724
2 измењених фајлова са 27 додато и 22 уклоњено
  1. 24 20
      app-ghs/controllers/ConsoleController.php
  2. 3 2
      app-ghs/controllers/ShopController.php

+ 24 - 20
app-ghs/controllers/ConsoleController.php

@@ -116,6 +116,23 @@ class ConsoleController extends BaseController
         ]);
     }
 
+    /**
+     * 汇总各渠道收入金额(与 kdIncome「合计」一致,不含采购/采购隔天)
+     * @param array $return StatKdClass::eachChannelIncome 返回值
+     * @return float
+     */
+    private static function sumChannelIncomeAmount($return)
+    {
+        $incomeList = $return['incomeList'] ?? [];
+        $totalIncome = '0.00';
+        if (!empty($incomeList)) {
+            foreach ($incomeList as $item) {
+                $totalIncome = bcadd($totalIncome, $item['amount'] ?? 0, 2);
+            }
+        }
+        return floatval($totalIncome);
+    }
+
     /**
      * 昨日各渠道收入合计(与 stat-kd/profile、kdIncome 页「合计」口径一致)
      */
@@ -131,15 +148,7 @@ class ConsoleController extends BaseController
         ]));
         $contain = intval(Yii::$app->request->get('contain', 0));
         $return = StatKdClass::eachChannelIncome($this->mainId, $this->shop, $contain);
-        $incomeList = $return['incomeList'] ?? [];
-        $totalIncome = '0.00';
-        if (!empty($incomeList)) {
-            foreach ($incomeList as $item) {
-                $amount = $item['amount'] ?? 0;
-                $totalIncome = bcadd($totalIncome, $amount, 2);
-            }
-        }
-        util::success(['income' => floatval($totalIncome)]);
+        util::success(['income' => self::sumChannelIncomeAmount($return)]);
     }
 
     //今日概况 ssh 20220723
@@ -176,18 +185,13 @@ class ConsoleController extends BaseController
         //$notice[] = ['title' => '有急事请连续打二次电话 15280215347', 'action' => '', 'page' => ''];
 
         $mainId = $this->mainId;
+        // 概况仍用 profile(订单数/支出等);收入数字与 kdIncome 对齐,见 index_show_income
         $respond = StatSaleClass::profile($mainId);
-        $incomeList = $respond['income'] ?? [];
-        $todaySale = 0;
-        if (!empty($incomeList)) {
-            //这里有二个地方同时要修改,请搜索关键词:index_show_income
-            foreach ($incomeList as $item) {
-                if (isset($item['id']) && $item['id'] == 'allot') {
-                    continue;
-                }
-                $todaySale = bcadd($todaySale, $item['amount'], 2);
-            }
-        }
+        // 工作台「收入」= 各渠道销售收入(含销售隔天扣减),不含采购/采购隔天;与 /stat-kd/profile、昨日收入同口径
+        // 关键词:index_show_income(ShopController 门店列表 todaySale 同步跳过 cgNextDay)
+        $todaySale = self::sumChannelIncomeAmount(
+            StatKdClass::eachChannelIncome($mainId, $this->shop, 0)
+        );
         $expendList = $respond['expend'] ?? [];
         $todayOut = 0;
         if (!empty($expendList)) {

+ 3 - 2
app-ghs/controllers/ShopController.php

@@ -575,9 +575,10 @@ class ShopController extends BaseController
                 }
                 $todaySale = 0;
                 if (!empty($incomeList)) {
+                    // 与工作台收入口径对齐:不算调拨出库、不算采购隔天退款(关键词 index_show_income)
                     foreach ($incomeList as $item) {
-                        //调拨出库暂时不算到收入里去
-                        if (isset($item['id']) && $item['id'] == 'allot') {
+                        $id = $item['id'] ?? '';
+                        if ($id === 'allot' || $id === 'cgNextDay') {
                             continue;
                         }
                         $todaySale = bcadd($todaySale, $item['amount'], 2);