Browse Source

盘点优化

shish 3 years ago
parent
commit
c8103466fb
1 changed files with 16 additions and 17 deletions
  1. 16 17
      app-ghs/controllers/CheckOrderController.php

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

@@ -32,6 +32,22 @@ class CheckOrderController extends BaseController
         util::success($orderData);
     }
 
+    //分配库存 ssh 20230720
+    public function actionSendStock()
+    {
+        $shopAdmin = $this->shopAdmin;
+        if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
+            util::fail('超管才能盘点');
+        }
+
+        $post = Yii::$app->request->post();
+        $post['sjId'] = $this->sjId;
+        $post['shopId'] = $this->shopId;
+        $post['adminId'] = $this->adminId;
+        $post['mainId'] = $this->mainId;
+        $this->saveOrder($post, false, false);
+    }
+
     //盘点确认 lqh 2021.1.22
     public function actionCreateOrder()
     {
@@ -124,26 +140,9 @@ class CheckOrderController extends BaseController
         if (!is_array($ghsItemInfo)) {
             util::fail('花材格式不正确');
         }
-
         //判断花材格式,是否属于当前门店
         ProductClass::valid($ghsItemInfo, $this->mainId);
 
-        //分配库存时用到添加方式的盘点
-        $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) {