Procházet zdrojové kódy

分配库存时用到添加方式的盘点

shish před 3 roky
rodič
revize
07e89ef50c
1 změnil soubory, kde provedl 17 přidání a 10 odebrání
  1. 17 10
      app-ghs/controllers/CheckOrderController.php

+ 17 - 10
app-ghs/controllers/CheckOrderController.php

@@ -125,19 +125,26 @@ class CheckOrderController extends BaseController
             util::fail('花材格式不正确');
         }
 
-//        if ($this->mainId == 2126) {
-//            foreach ($ghsItemInfo as $key => $val) {
-//                $pId = $val['productId'] ?? 0;
-//                $info = ProductClass::getById($pId, true);
-//                if ($info->mainId != 2126) {
-//                    unset($ghsItemInfo[$key]);
-//                }
-//            }
-//        }
-
         //判断花材格式,是否属于当前门店
         ProductClass::valid($ghsItemInfo, $this->mainId);
 
+        $post = Yii::$app->request->post();
+        $changeType = $post['changeType'] ?? 'modify';
+        //分配库存时用到添加方式的盘点
+        if ($changeType == 'add') {
+            $ids = array_column($ghsItemInfo, 'productId');
+            $infoList = ProductClass::getByIds($ids, null, 'id');
+            if (!empty($infoList)) {
+                foreach ($ghsItemInfo as $itemKey => $itemVal) {
+                    $productId = $itemVal['productId'] ?? 0;
+                    $bigNum = $itemVal['bigNum'] ?? 0;
+                    $addBigNum = $infoList[$productId]['stock'] ?? 0;
+                    $newBigNum = bcadd($bigNum, $addBigNum, 2);
+                    $ghsItemInfo[$itemKey]['bigNum'] = $newBigNum;
+                }
+            }
+        }
+
         foreach ($ghsItemInfo as $key => $item) {
             //如果盘点数是99999则转为0
             if (isset($item['bigNum']) && $item['bigNum'] == 99999) {