Explorar el Código

供货商花材优化

林琦海 hace 5 años
padre
commit
9590a0c42a

+ 1 - 1
app/ghs/controllers/ItemClassController.php

@@ -42,7 +42,7 @@ class ItemClassController extends BaseController
     public function actionDelete()
     {
         $id = Yii::$app->request->get('id',0);
-        ItemClassService::deleteGhsItemClass($id);
+        ItemClassService::deleteGhsItemClass($id,$this->sjId);
         util::complete('操作成功');
     }
 

+ 1 - 1
app/ghs/controllers/ItemController.php

@@ -43,7 +43,7 @@ class ItemController extends BaseController
     {
         $get = Yii::$app->request->get();
         $id = isset($get['id']) ? $get['id'] : 0;
-        ItemService::deleteGhsItem($id,$this->shopId,$this->adminId);
+        ItemService::deleteGhsItem($id,$this->shopId,$this->sjId,$this->adminId);
         util::complete('操作成功');
     }
 

+ 1 - 4
biz-ghs/item/classes/ItemClass.php

@@ -47,10 +47,7 @@ class ItemClass extends BaseClass
     //修改花材的信息(库存预警、每扎加价、每扎重量)
     public static function updateGshItem($id,$stockWarning,$unitAddPrice,$unitWeight,$unitCost)
     {
-        $model = self::getById($id);
-        if(!$model){
-            util::fail("该花材不存在");
-        }
+
         $data['stockWarning'] = $stockWarning;
         $data['unitAddPrice'] = $unitAddPrice;
         $data['unitWeight'] = $unitWeight;

+ 3 - 1
biz-ghs/item/classes/ItemClassClass.php

@@ -74,7 +74,9 @@ class ItemClassClass extends BaseClass
         if(!$model){
             util::fail("该花材分类不存在");
         }
-
+        if($model['merchantId'] !== $data['merchantId']){
+            util::fail("参数错误");
+        }
         self::updateById($id,$data);
         return true;
     }

+ 4 - 1
biz-ghs/item/services/ItemClassService.php

@@ -17,13 +17,16 @@ class ItemClassService extends BaseService
 
 
     //删除花材分类. 有花材不让删除
-    public static function deleteGhsItemClass($id)
+    public static function deleteGhsItemClass($id,$sjId)
     {
         //判断是否存在
         $model = ItemClassClass::getById($id);
         if(!$model){
             util::fail("该花材分类不存在");
         }
+        if($model['merchantId'] !== $sjId){
+            util::fail("参数错误");
+        }
         $exist = ItemClass::exists(['classId'=>$id,'merchantId'=>$model['merchantId']]);
         if($exist){
             util::fail("该花材分类还有花材,不能删除");

+ 12 - 2
biz-ghs/item/services/ItemService.php

@@ -95,17 +95,27 @@ class ItemService extends BaseService
             util::fail("成本价不能小于0");
         }
 
+        $model = self::getById($id);
+        if(!$model){
+            util::fail("该花材不存在");
+        }
+        if($model['merchantId'] !== $data['merchantId']){
+            util::fail("参数错误");
+        }
+
         ItemClass::updateGshItem($id,$stockWarning,$unitAddPrice,$unitWeight,$unitCost);
     }
 
     //删除花材,同时修改itemInfo 的状态值 delStatus = 1
-    public static function deleteGhsItem($id,$shopId,$adminId)
+    public static function deleteGhsItem($id,$shopId,$sjId,$adminId)
     {
         $model = ItemClass::getById($id);
         if(!$model){
             util::fail("该花材不存在");
         }
-
+        if($model['merchantId'] !== $sjId){
+            util::fail("参数错误");
+        }
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try{