Răsfoiți Sursa

改价和入库

shish 2 ani în urmă
părinte
comite
cb6d84655d
1 a modificat fișierele cu 13 adăugiri și 2 ștergeri
  1. 13 2
      app-hd/controllers/ProductController.php

+ 13 - 2
app-hd/controllers/ProductController.php

@@ -214,6 +214,7 @@ class ProductController extends BaseController
         }
         //normal常规改价,cg采购改价
         $changeType = Yii::$app->request->post('changeType', 'normal');
+        $doType = Yii::$app->request->post('doType', 0);
         $targetId = Yii::$app->request->post('targetId', 0);
         $changeParams = ['staffId' => $shopAdmin->id, 'staffName' => $shopAdmin->name, 'changeType' => $changeType, 'targetId' => $targetId];
         $post = Yii::$app->request->post();
@@ -229,7 +230,7 @@ class ProductController extends BaseController
         $transaction = $connection->beginTransaction();
         try {
 
-            if (!empty($targetId)) {
+            if ($doType == 0 || $doType == 1) {
                 $cg = PurchaseClass::getLockById($targetId);
                 if (!empty($cg)) {
                     if (isset($cg->mainId) == false || $cg->mainId != $this->mainId) {
@@ -242,6 +243,16 @@ class ProductController extends BaseController
                     //确认收货并入库
                     if ($cg->status == PurchaseClass::STATUS_SENDING) {
                         PurchaseClass::takeToPutIn($cg);
+                        if ($doType == 1) {
+                            $transaction->commit();
+                            util::complete('入库成功');
+                        }
+                    } else {
+                        util::fail('订单不是待入库状态');
+                    }
+                } else {
+                    if ($doType == 1) {
+                        util::fail('入库失败,没有找到采购单');
                     }
                 }
             }
@@ -321,7 +332,7 @@ class ProductController extends BaseController
             }
 
             $transaction->commit();
-            util::complete('修改成功');
+            util::complete('入库改价成功');
         } catch (\Exception $e) {
             $transaction->rollBack();
             Yii::info("失败原因:" . $e->getMessage());