Kaynağa Gözat

开单和统计优化

shish 3 yıl önce
ebeveyn
işleme
caff9d5691

+ 16 - 14
app-hd/controllers/StatKindController.php

@@ -30,29 +30,31 @@ class StatKindController extends BaseController
 
         $mainId = $this->mainId;
 
-        $list = KindClass::getAllByCondition(['mainId' => $mainId, 'flower' => 1, 'delStatus' => 0, 'status' => 1], null, '*', 'id');
+        $kindList = KindClass::getAllByCondition(['mainId' => $mainId, 'flower' => 1, 'delStatus' => 0, 'status' => 1], null, '*', 'id');
+
+        $arr = [];
 
         $where = ['mainId' => $mainId, 'status' => 1];
         $where['finishTime'] = ['between', [$currentStartTime, $currentEndTime]];
         $workList = WorkClass::getAllByCondition($where, null, '*', null, true);
         if (!empty($workList)) {
             foreach ($workList as $work) {
-                $workSn = $work->workSn ?? '';
+                $kindId = $work->kindId ?? 0;
+                if (empty($kindId)) {
+                    continue;
+                }
+                $kindName = $kindList[$kindId]['name'] ?? '';
+                $num = $work->num ?? 0;
+                if (isset($arr[$kindId]['makeNum'])) {
+                    $arr[$kindId]['makeNum'] = bcadd($arr[$kindId]['makeNum'], $num);
+                } else {
+                    $arr[$kindId]['makeNum'] = $num;
+                    $arr[$kindId]['name'] = $kindName;
+                }
             }
         }
 
-
-        $contain = $get['contain'] ?? 0;
-        $incomeList = \bizGhs\stat\classes\StatKdClass::eachChannelIncome($this->mainId, $this->shop, $contain);
-        $totalIncome = 0;
-        if (!empty($incomeList)) {
-            foreach ($incomeList as $item) {
-                $amount = $item['amount'] ?? 0;
-                $totalIncome = bcadd($totalIncome, $amount, 2);
-                $totalIncome = floatval($totalIncome);
-            }
-        }
-        util::success(['list' => $incomeList, 'totalIncome' => $totalIncome]);
+        //util::success(['list' => $incomeList, 'totalIncome' => $totalIncome]);
     }
 
 }

+ 4 - 0
biz-hd/order/services/OrderService.php

@@ -133,6 +133,8 @@ class OrderService extends BaseService
                 $name = $goodsInfo[$currentId]['name'] ?? '';
                 $cover = $goodsInfo[$currentId]['cover'] ?? '';
                 $flower = $goodsInfo[$currentId]['flower'] ?? 0;
+                $kindId = $goodsInfo[$currentId]['kindId'] ?? 0;
+                $kindName = $goodsInfo[$currentId]['kindName'] ?? 0;
                 if (!empty($groupCover)) {
                     $groupCover = $cover;
                 }
@@ -154,6 +156,8 @@ class OrderService extends BaseService
                     'num' => $num,
                     'price' => bcmul($unitPrice, $num, 2),
                     'mainId' => $mainId,
+                    'kindId' => $kindId,
+                    'kindName' => $kindName,
                 ];
                 OrderGoodsClass::addData($currentGoodsData);
                 $groupGoodsData[] = ['goodsId' => $currentId, 'num' => $num, 'name' => $name, 'unitPrice' => $unitPrice];