Răsfoiți Sursa

[智价云] 商品配置校验规则更新

tangyuanwang 5 zile în urmă
părinte
comite
5d1cc2ecd2

+ 21 - 3
app/Http/Controllers/Manager/WashConfig/ControlGoods.php

@@ -109,7 +109,16 @@ class ControlGoods extends Controller
         $store_scope = request('store_scope', '');
         $all_data['store_scope'] = $store_scope;
         //查询是否存在
-        $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'],'platform'=> $all_data['platform']];
+        $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs']];
+        $ControlGoodsModel = $ControlGoodsModel->query();
+        if($all_data['platform'] != ''){
+            $platforms = explode(',', $all_data['platform']);
+            $ControlGoodsModel->where(function ($query) use ($platforms) {
+                foreach ($platforms as $platform) {
+                    $query->orWhere('platform', 'like', "%{$platform}%");
+                }
+            });
+        }
         $data = $ControlGoodsModel->where($map)->first();
         if ($data)     return json_send(['code' => 'error', 'msg' => '记录已存在']);
         // 写入数据表
@@ -136,8 +145,17 @@ class ControlGoods extends Controller
         $all_data = request()->all();
         $store_scope = request('store_scope','');
         $all_data['store_scope'] = $store_scope;
-                //查询是否存在
-        $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'],'platform'=> $all_data['platform']];
+        //查询是否存在
+        $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs']];
+        $ControlGoodsModel = $ControlGoodsModel->query();
+        if($all_data['platform'] != ''){
+            $platforms = explode(',', $all_data['platform']);
+            $ControlGoodsModel->where(function ($query) use ($platforms) {
+                foreach ($platforms as $platform) {
+                    $query->orWhere('platform', 'like', "%{$platform}%");
+                }
+            });
+        }
         $data = $ControlGoodsModel->where($map)->where('id', '!=', $id)->first();
         if ($data)     return json_send(['code' => 'error', 'msg' => '记录已存在']);
         // 更新数据表

+ 20 - 2
app/Http/Controllers/Manager/WashConfig/LowPriceGoods.php

@@ -110,7 +110,16 @@ class LowPriceGoods extends Controller
         $store_scope = request('store_scope', '');
         $all_data['store_scope'] = $store_scope;
         //查询是否存在
-        $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'],'platform'=> $all_data['platform']];
+        $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs']];
+        $LowPriceGoodsModel = $LowPriceGoodsModel->query();
+        if($all_data['platform'] != ''){
+            $platforms = explode(',', $all_data['platform']);
+            $LowPriceGoodsModel->where(function ($query) use ($platforms) {
+                foreach ($platforms as $platform) {
+                    $query->orWhere('platform', 'like', "%{$platform}%");
+                }
+            });
+        }
         $data = $LowPriceGoodsModel->where($map)->first();
         if ($data)     return json_send(['code' => 'error', 'msg' => '记录已存在']);
         // 写入数据表
@@ -138,7 +147,16 @@ class LowPriceGoods extends Controller
         $store_scope = request('store_scope','');
         $all_data['store_scope'] = $store_scope;
                 //查询是否存在
-        $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'],'platform'=> $all_data['platform']];
+        $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs']];
+        $LowPriceGoodsModel = $LowPriceGoodsModel->query();
+        if($all_data['platform'] != ''){
+            $platforms = explode(',', $all_data['platform']);
+            $LowPriceGoodsModel->where(function ($query) use ($platforms) {
+                foreach ($platforms as $platform) {
+                    $query->orWhere('platform', 'like', "%{$platform}%");
+                }
+            });
+        }
         $data = $LowPriceGoodsModel->where($map)->where('id', '!=', $id)->first();
         if ($data)     return json_send(['code' => 'error', 'msg' => '记录已存在']);
         // 更新数据表

+ 20 - 2
app/Http/Controllers/Manager/WashConfig/ViolationProduct.php

@@ -110,7 +110,16 @@ class ViolationProduct extends Controller
         $store_scope = request('store_scope', '');
         $all_data['store_scope'] = $store_scope;
         //查询是否存在
-        $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'],'platform'=> $all_data['platform']];
+        $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs']];
+        $ViolationProductModel = $ViolationProductModel->query();
+        if($all_data['platform'] != ''){
+            $platforms = explode(',', $all_data['platform']);
+            $ViolationProductModel->where(function ($query) use ($platforms) {
+                foreach ($platforms as $platform) {
+                    $query->orWhere('platform', 'like', "%{$platform}%");
+                }
+            });
+        }
         $data = $ViolationProductModel->where($map)->first();
         if ($data)     return json_send(['code' => 'error', 'msg' => '记录已存在']);
         // 写入数据表
@@ -138,7 +147,16 @@ class ViolationProduct extends Controller
         $store_scope = request('store_scope','');
         $all_data['store_scope'] = $store_scope;
                 //查询是否存在
-        $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'],'platform'=> $all_data['platform']];
+        $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs']];
+        $ViolationProductModel = $ViolationProductModel->query();
+        if($all_data['platform'] != ''){
+            $platforms = explode(',', $all_data['platform']);
+            $ViolationProductModel->where(function ($query) use ($platforms) {
+                foreach ($platforms as $platform) {
+                    $query->orWhere('platform', 'like', "%{$platform}%");
+                }
+            });
+        }
         $data = $ViolationProductModel->where($map)->where('id', '!=', $id)->first();
         if ($data)     return json_send(['code' => 'error', 'msg' => '记录已存在']);
         // 更新数据表