Parcourir la source

记录订单成本

shish il y a 9 mois
Parent
commit
268f6a5b6c

+ 8 - 0
biz-ghs/order/classes/OrderClass.php

@@ -848,6 +848,14 @@ class OrderClass extends BaseClass
         $data['itemNum'] = $respond['totalItemNum'] ?? 0;
         $data['reachDiscountPrice'] = $respond['totalReachDiscount'] ?? 0;
 
+        //记录订单的总成本
+        $totalCost = $respond['totalCost'] ?? 0;
+        $packCost = $data['packCost'] ?? 0;
+        $totalCost = bcadd($totalCost, $packCost,2);
+        $totalCost = bcadd($totalCost, $sendCost,2);
+        $data['totalCost'] = $totalCost;
+        $data['remainCost'] = $totalCost;
+
         //默认订单要打单
         $data['needPrint'] = $data['needPrint'] ?? dict::getDict('needPrint', 'need');
 

+ 6 - 1
biz-ghs/product/classes/ProductClass.php

@@ -1370,6 +1370,7 @@ class ProductClass extends BaseClass
         //满减累计
         $totalReachDiscount = 0;
 
+        $totalCost = 0;
         foreach ($itemInfo as $v) {
             $ghsProductId = $v['productId'];
 
@@ -1472,6 +1473,9 @@ class ProductClass extends BaseClass
 
             $xhPrice = bcmul($xhNum, $itemPrice, 2);
 
+            $currentCost = bcmul($xhNum, $cost, 2);
+            $totalCost = bcadd($totalCost, $currentCost, 2);
+
             $tmp['xhNum'] = $xhNum;
             $tmp['xhUnitName'] = $xhUnitName;
             $tmp['xhUnitType'] = $xhUnitType;
@@ -1486,7 +1490,8 @@ class ProductClass extends BaseClass
             $data[] = $tmp;
         }
 
-        return ['product' => $data, 'totalReachDiscount' => $totalReachDiscount, 'smallNum' => $totalSmallNum, 'bigNum' => $totalBigNum, 'price' => $totalPrice, 'totalItemNum' => $totalItemNum];
+        return ['product' => $data, 'totalReachDiscount' => $totalReachDiscount, 'smallNum' => $totalSmallNum,
+            'bigNum' => $totalBigNum, 'price' => $totalPrice, 'totalItemNum' => $totalItemNum, 'totalCost' => $totalCost];
     }
 
     //  //修改某个花材的成本价(采购之后要用到) lqh 2021.04.06