shish vor 1 Monat
Ursprung
Commit
ee347b4358
1 geänderte Dateien mit 18 neuen und 11 gelöschten Zeilen
  1. 18 11
      app-ghs/controllers/ConsoleController.php

+ 18 - 11
app-ghs/controllers/ConsoleController.php

@@ -125,23 +125,30 @@ class ConsoleController extends BaseController
         ]);
     }
 
-    //获取昨天的收入 ssh 20240830
+    /**
+     * 昨日各渠道收入合计(与 stat-kd/profile、kdIncome 页「合计」口径一致)
+     */
     public function actionGetYesterdayIncome()
     {
-        $mainId = $this->mainId;
-        $respond = StatSaleClass::profile($mainId);
-        $incomeList = $respond['income'] ?? [];
-        $sale = 0;
+        if (empty($this->mainId)) {
+            util::success(['income' => 0]);
+            return;
+        }
+        // 固定查昨日,避免与 kdIncome 选「昨天」日期不一致
+        Yii::$app->request->setQueryParams(array_merge(Yii::$app->request->get(), [
+            'searchTime' => 'yesterday',
+        ]));
+        $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)) {
-            //这里有二个地方同时要修改,请搜索关键词:index_show_income
             foreach ($incomeList as $item) {
-                if (isset($item['id']) && $item['id'] == 'allot') {
-                    continue;
-                }
-                $sale = bcadd($sale, $item['amount'], 2);
+                $amount = $item['amount'] ?? 0;
+                $totalIncome = bcadd($totalIncome, $amount, 2);
             }
         }
-        util::success(['income' => $sale]);
+        util::success(['income' => floatval($totalIncome)]);
     }
 
     //今日概况 ssh 20220723