shish 4 years ago
parent
commit
2b9ae0ffb9
1 changed files with 2 additions and 2 deletions
  1. 2 2
      app-ghs/controllers/StatController.php

+ 2 - 2
app-ghs/controllers/StatController.php

@@ -48,6 +48,7 @@ class StatController extends BaseController
                 $cover = imgUtil::groupImg($shortCover);
                 $num = $waste->itemNum ?? 0;
                 $cost = $waste->itemCost ?? 0;
+                $currentCost = bcmul($cost, $num, 2);
                 $productId = $waste->productId ?? 0;
                 if (isset($stat[$productId]) == false) {
                     $stat[$productId]['name'] = $name;
@@ -56,9 +57,8 @@ class StatController extends BaseController
                     $stat[$productId]['amount'] = 0;
                 }
                 $stat[$productId]['num'] = bcadd($stat[$productId]['num'], $num, 2);
-                $stat[$productId]['amount'] = bcadd($stat[$productId]['amount'], $cost, 2);
+                $stat[$productId]['amount'] = bcadd($stat[$productId]['amount'], $currentCost, 2);
                 $totalNum = bcadd($totalNum, $num, 2);
-                $currentCost = bcmul($cost, $num, 2);
                 $totalCost = bcadd($totalCost, $currentCost, 2);
             }
             $stat = array_values($stat);