shish 1 год назад
Родитель
Сommit
2891c9db71

+ 4 - 2
app-ghs/controllers/ItemController.php

@@ -20,12 +20,13 @@ use Yii;
 class ItemController extends BaseController
 {
 
-    //增加和减少半扎
+    //增加和减少半扎 ssh 20250417
     public function actionChangeHalf()
     {
         $post = Yii::$app->request->post();
         $productId = $post['productId'] ?? '';
         $add = $post['add'] ?? 0;
+        $remark = $post['remark'] ?? '';
         $product = ProductClass::getLockById($productId);
         if (empty($product)) {
             util::fail('没有找到花材');
@@ -38,7 +39,7 @@ class ItemController extends BaseController
         }
 
         //避免重复提交
-        util::checkRepeatCommit($this->adminId, 6);
+        util::checkRepeatCommit($this->adminId, 5);
 
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
@@ -52,6 +53,7 @@ class ItemController extends BaseController
                 'staffId' => $staffId,
                 'staffName' => $staffName,
                 'adminId' => $adminId,
+                'remark' => $remark,
             ];
             ItemClass::modifyHalf($shop, $product, $params, $add);
             $product = ProductClass::getLockById($productId);

+ 49 - 0
app-hd/controllers/ItemController.php

@@ -7,6 +7,7 @@ use biz\item\classes\PtItemClass;
 
 use bizGhs\item\classes\ItemClass;
 use bizGhs\item\services\ItemService;
+use bizHd\product\classes\ProductClass;
 use common\components\dict;
 use common\components\util;
 use Yii;
@@ -14,6 +15,54 @@ use Yii;
 class ItemController extends BaseController
 {
 
+    //增加和减少半扎 ssh 20250417
+    public function actionChangeHalf()
+    {
+        $post = Yii::$app->request->post();
+        $productId = $post['productId'] ?? '';
+        $add = $post['add'] ?? 0;
+        $remark = $post['remark'] ?? '';
+        $product = ProductClass::getLockById($productId);
+        if (empty($product)) {
+            util::fail('没有找到花材');
+        }
+        if ($product->mainId != $this->mainId) {
+            util::fail('不是你的花材');
+        }
+        if ($product->ratioType == 1) {
+            util::fail('若干扎的花材不能减半份');
+        }
+
+        //避免重复提交
+        util::checkRepeatCommit($this->adminId, 5);
+
+        $connection = Yii::$app->db;
+        $transaction = $connection->beginTransaction();
+        try {
+            $shop = $this->shop;
+            $staff = $this->shopAdmin;
+            $staffName = $staff->name ?? '';
+            $staffId = $staff->id;
+            $adminId = $this->adminId;
+            $params = [
+                'staffId' => $staffId,
+                'staffName' => $staffName,
+                'adminId' => $adminId,
+                'remark' => $remark,
+            ];
+            ItemClass::modifyHalf($shop, $product, $params, $add);
+            $product = ProductClass::getLockById($productId);
+            $stock = $product->stock;
+            $stock = floatval($stock);
+            $transaction->commit();
+            util::success(['stock' => $stock]);
+        } catch (\Exception $e) {
+            $transaction->rollBack();
+            Yii::info("加减半份失败原因:" . $e->getMessage());
+            util::fail('加减半份失败');
+        }
+    }
+
     //检测是否要刷新
     public function actionCheckRefresh()
     {

+ 2 - 0
biz-ghs/item/classes/ItemClass.php

@@ -35,6 +35,7 @@ class ItemClass extends BaseClass
         $sjId = $shop->sjId;
         $adminId = $params['adminId'] ?? 0;
         $staffName = $params['staffName'] ?? '';
+        $remark = $params['remark'] ?? '';
         $ratio = $product->ratio ?? 0;
         $formNum = ProductClass::formatStock($newStock, $ratio);
         $ghsItemInfo = [['productId' => $product->id, 'bigNum' => $formNum['bigNum'], 'smallNum' => $formNum['smallNum']]];
@@ -45,6 +46,7 @@ class ItemClass extends BaseClass
         $pdData['adminId'] = $adminId;
         $pdData['mainId'] = $mainId;
         $pdData['staffName'] = $staffName;
+        $pdData['remark'] = $remark;
         CheckOrderClass::opOrder($pdData, false, false);
     }