shish 3 жил өмнө
parent
commit
3ffe21541e

+ 6 - 2
app-ghs/controllers/StatItemController.php

@@ -44,6 +44,8 @@ class StatItemController extends BaseController
         }
         $productInfo = ProductClass::getAllByCondition(['mainId' => $this->mainId], null, 'id,name,py', 'id');
         $stat = [];
+        $totalAmount = 0;
+        $totalNum = 0;
         foreach ($list as $order) {
             $orderSn = $order['orderSn'] ?? '';
             $itemList = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
@@ -60,6 +62,9 @@ class StatItemController extends BaseController
                     $currentAmount = bcmul($unitPrice, $num, 2);
                     $currentGross = bcmul($unitGross, $num, 2);
 
+                    $totalNum = bcadd($totalNum, $num, 2);
+                    $totalAmount = bcadd($totalAmount, $currentAmount, 2);
+
                     $stat[$productId]['productId'] = $productId;
                     $stat[$productId]['name'] = $name;
                     $stat[$productId]['py'] = $py;
@@ -105,10 +110,9 @@ class StatItemController extends BaseController
             $rank = 'mll';
         }
         $stat = arrayUtil::arraySort($stat, $rank);
-        util::success(['list' => $stat]);
+        util::success(['list' => $stat, 'totalAmount' => floatval($totalAmount), 'totalNum' => floatval($totalNum),]);
     }
 
-
     //花材销量 ssh 20211021
     public function actionProfile()
     {