Forráskód Böngészése

[智价云] 平台兼容旧数据

tangyuanwang 1 hete
szülő
commit
04dfc7a5e7

+ 51 - 59
app/Http/Controllers/Manager/Collect/Product.php

@@ -288,26 +288,29 @@ class Product extends Controller
             $platform_data = $ProductModel->platform_index_data();
             $map_where = ['product_name' => $all_data['product_name'],'status'=>'0','company_id'=> $all_data['company_id']];
             if ($product_brand != '') $map_where['product_brand'] = $product_brand;
-            foreach ($platforms as $platform) {
-                $product_specs_log = $ProductModel
-                    ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
-                    ->where($map_where)
-                    ->where(function ($query) use ($product_specs) {
-                        // 平台条件(固定)
-                        $query->where(function ($query_li) use ($product_specs) {
-                            if (!empty($product_specs)) {
-                                foreach ($product_specs as $product_spec) {
-                                    if (empty($product_specs)) continue;
-                                    $query_li->orWhereRaw("FIND_IN_SET(?, product_specs)", [$product_spec]);
+            if (!empty($platform_data)) {
+                foreach ($platforms as $platform) {
+                    $product_specs_log = $ProductModel
+                        ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
+                        ->where($map_where)
+                        ->where(function ($query) use ($product_specs) {
+                            // 平台条件(固定)
+                            $query->where(function ($query_li) use ($product_specs) {
+                                if (!empty($product_specs)) {
+                                    foreach ($product_specs as $product_spec) {
+                                        if (empty($product_specs)) continue;
+                                        $query_li->orWhereRaw("FIND_IN_SET(?, product_specs)", [$product_spec]);
+                                    }
                                 }
-                            }
-                        });
-                    })->first();
-                $platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
-                if (!empty($product_specs_log)) {
-                    return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格记录']);
+                            });
+                        })->first();
+                    $platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
+                    if (!empty($product_specs_log)) {
+                        return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格记录']);
+                    }
                 }
             }
+            
         }
         // 写入数据表
         $result     =  $ProductModel->addProduct($all_data);
@@ -416,16 +419,19 @@ class Product extends Controller
             $platform_data = $ProductModel->platform_index_data();
             $map_where = ['product_name' => $all_data['product_name'],'status'=>'0','company_id'=> $all_data['company_id']];
             if($product_brand != '') $map_where['product_brand'] = $product_brand;
-            foreach ($platforms as $platform) {
-                $product_specs_log = $ProductModel
-                    ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
-                    ->where($map_where)
-                    ->first();
-                $platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
-                if (!empty($product_specs_log)) {
-                    return json_send(['code' => 'error', 'msg' => $platform_name.'存在重复的商品记录']);
+            if (!empty($platform_data)) {
+                foreach ($platforms as $platform) {
+                    $product_specs_log = $ProductModel
+                        ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
+                        ->where($map_where)
+                        ->first();
+                    $platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
+                    if (!empty($product_specs_log)) {
+                        return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品记录']);
+                    }
                 }
             }
+            
         }
         // 更新数据表
         $where = ['id' => $id];
@@ -484,7 +490,7 @@ class Product extends Controller
         }
         $Product = $ProductModel->where($where)->first();
         if (!$Product) return json_send(['code' => 'error', 'msg' => '记录不存在']);
-        if (!empty($Product) && $Product->enable_full_quantity == 1) {
+        if (!empty($Product)) {
             //继续校验规格是否存在
             $product_specs_tring = $Product->product_specs;
             $product_specs = $product_specs_tring ?  explode(',', $product_specs_tring) : '';
@@ -496,40 +502,26 @@ class Product extends Controller
             $platforms = $platforms ? array_unique($platforms) : '';
 
             $platform_data = $ProductModel->platform_data();
-            foreach ($platforms as $platform) {
-                $product_specs_log = $ProductModel
-                    ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
-                    ->where(['product_brand' => $Product->product_brand, 'product_name' => $Product->product_name,'status'=>'0','company_id'=> $Product->company_id])
-                    ->where('id', '!=', $id)
-                    ->where(function ($query) use ($product_specs) {
-                        // 平台条件(固定)
-                        $query->where(function ($query_li) use ($product_specs) {
+            if (!empty($platform_data)) {
+                foreach ($platforms as $platform) {
+                    $product_specs_log = $ProductModel
+                        ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
+                        ->where(['product_brand' => $Product->product_brand, 'product_name' => $Product->product_name, 'status' => '0', 'company_id' => $Product->company_id])
+                        ->where('id', '!=', $id)
+                        ->where(function ($query) use ($product_specs) {
+                            // 平台条件(固定)
+                            $query->where(function ($query_li) use ($product_specs) {
 
-                            foreach ($product_specs as $product_spec) {
-                                if (empty($product_specs)) continue;
-                                $query_li->orWhereRaw("FIND_IN_SET(?, product_specs)", [$product_spec]);
-                            }
-                        });
-                    })->first();
-                $platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
-                if (!empty($product_specs_log)) {
-                    return json_send(['code' => 'error', 'msg' => $platform_name.'存在重复的商品规格启用记录']);
-                }
-            }
-        }else if (!empty($data) && $Product->enable_full_quantity == 0) {
-            $platform_string = $Product->platform;
-            $platforms = $platform_string ?  explode(',', $platform_string) : '';
-            $platforms = $platforms ? array_unique($platforms) : '';
-
-            $platform_data = $ProductModel->platform_index_data();
-            foreach ($platforms as $platform) {
-                $product_specs_log = $ProductModel
-                    ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
-                    ->where(['product_brand' => $Product->product_brand, 'product_name' => $Product->product_name,'status'=>'0','company_id'=> $Product->company_id])
-                    ->where('id', '!=', $id)->first();
-                $platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
-                if (!empty($product_specs_log)) {
-                    return json_send(['code' => 'error', 'msg' => $platform_name.'存在重复的商品启用记录']);
+                                foreach ($product_specs as $product_spec) {
+                                    if (empty($product_specs)) continue;
+                                    $query_li->orWhereRaw("FIND_IN_SET(?, product_specs)", [$product_spec]);
+                                }
+                            });
+                        })->first();
+                    $platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
+                    if (!empty($product_specs_log)) {
+                        return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格启用记录']);
+                    }
                 }
             }
         }

+ 65 - 58
app/Http/Controllers/Manager/WashConfig/LowPriceGoods.php

@@ -208,8 +208,8 @@ class LowPriceGoods extends Controller
         $specify_responsible_person = request('specify_responsible_person', '0');
         $all_data['specify_responsible_person'] = $specify_responsible_person;
         //查询是否存在
-        $map = ['product_name' => $all_data['product_name'],'suggested_price'=> $all_data['suggested_price']];
-        if ($all_data['product_brand'] !='') $map['product_brand'] = $all_data['product_brand'];
+        $map = ['product_name' => $all_data['product_name'], 'suggested_price' => $all_data['suggested_price']];
+        if ($all_data['product_brand'] != '') $map['product_brand'] = $all_data['product_brand'];
         if ($is_admin != 1 && $company_id != 0) {
             $map['company_id'] = $company_id;
             $all_data['company_id'] = $company_id;
@@ -231,26 +231,29 @@ class LowPriceGoods extends Controller
             $platform_data = $LowPriceGoodsModel->platform_index_data();
             $map_where = ['product_name' => $all_data['product_name'], 'suggested_price' => $all_data['suggested_price'], 'status' => '0', 'company_id' => $all_data['company_id']];
             if ($product_brand != '') $map_where['product_brand'] = $product_brand;
-            foreach ($platforms as $platform) {
-                $product_specs_log = $LowPriceGoodsModel
-                    ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
-                    ->where($map_where)
-                    ->where(function ($query) use ($product_specs) {
-                        // 平台条件(固定)
-                        $query->where(function ($query_li) use ($product_specs) {
-                            if (!empty($product_specs)) {
-                                foreach ($product_specs as $product_spec) {
-                                    if (empty($product_specs)) continue;
-                                    $query_li->orWhereRaw("FIND_IN_SET(?, product_specs)", [$product_spec]);
+            if (!empty($platform_data)) {
+                foreach ($platforms as $platform) {
+                    $product_specs_log = $LowPriceGoodsModel
+                        ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
+                        ->where($map_where)
+                        ->where(function ($query) use ($product_specs) {
+                            // 平台条件(固定)
+                            $query->where(function ($query_li) use ($product_specs) {
+                                if (!empty($product_specs)) {
+                                    foreach ($product_specs as $product_spec) {
+                                        if (empty($product_specs)) continue;
+                                        $query_li->orWhereRaw("FIND_IN_SET(?, product_specs)", [$product_spec]);
+                                    }
                                 }
-                            }
-                        });
-                    })->first();
-                $platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
-                if (!empty($product_specs_log)) {
-                    return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格记录']);
+                            });
+                        })->first();
+                    $platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
+                    if (!empty($product_specs_log)) {
+                        return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格记录']);
+                    }
                 }
             }
+            
         }
         // 写入数据表
         $result     =  $LowPriceGoodsModel->addLowProduct($all_data);
@@ -308,8 +311,8 @@ class LowPriceGoods extends Controller
         $specify_responsible_person = request('specify_responsible_person', '0');
         $all_data['specify_responsible_person'] = $specify_responsible_person;
         //查询是否存在
-        $map = ['product_name' => $all_data['product_name'],'suggested_price'=> $all_data['suggested_price']];
-        if ($all_data['product_brand'] !='') $map['product_brand'] = $all_data['product_brand'];
+        $map = ['product_name' => $all_data['product_name'], 'suggested_price' => $all_data['suggested_price']];
+        if ($all_data['product_brand'] != '') $map['product_brand'] = $all_data['product_brand'];
         if ($is_admin != 1 && $company_id != 0) {
             $map['company_id'] = $company_id;
             $all_data['company_id'] = $company_id;
@@ -329,27 +332,29 @@ class LowPriceGoods extends Controller
             $platforms = $platforms ? array_unique($platforms) : '';
 
             $platform_data = $LowPriceGoodsModel->platform_index_data();
-            $map_where = ['product_brand' => $product_brand, 'product_name' => $all_data['product_name'],'suggested_price'=> $all_data['suggested_price'], 'status' => '0','company_id' => $all_data['company_id']];
+            $map_where = ['product_brand' => $product_brand, 'product_name' => $all_data['product_name'], 'suggested_price' => $all_data['suggested_price'], 'status' => '0', 'company_id' => $all_data['company_id']];
             if ($product_brand != '') $map_where['product_brand'] = $product_brand;
-            foreach ($platforms as $platform) {
-                $product_specs_log = $LowPriceGoodsModel
-                    ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
-                    ->where($map_where)
-                    ->where('id', '!=', $id)
-                    ->where(function ($query) use ($product_specs) {
-                        // 平台条件(固定)
-                        $query->where(function ($query_li) use ($product_specs) {
-                            if (!empty($product_specs)) {
-                                foreach ($product_specs as $product_spec) {
-                                    if (empty($product_specs)) continue;
-                                    $query_li->orWhereRaw("FIND_IN_SET(?, product_specs)", [$product_spec]);
+            if (!empty($platform_data)) {
+                foreach ($platforms as $platform) {
+                    $product_specs_log = $LowPriceGoodsModel
+                        ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
+                        ->where($map_where)
+                        ->where('id', '!=', $id)
+                        ->where(function ($query) use ($product_specs) {
+                            // 平台条件(固定)
+                            $query->where(function ($query_li) use ($product_specs) {
+                                if (!empty($product_specs)) {
+                                    foreach ($product_specs as $product_spec) {
+                                        if (empty($product_specs)) continue;
+                                        $query_li->orWhereRaw("FIND_IN_SET(?, product_specs)", [$product_spec]);
+                                    }
                                 }
-                            }
-                        });
-                    })->first();
-                $platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
-                if (!empty($product_specs_log)) {
-                    return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格记录']);
+                            });
+                        })->first();
+                    $platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
+                    if (!empty($product_specs_log)) {
+                        return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格记录']);
+                    }
                 }
             }
         }
@@ -430,25 +435,27 @@ class LowPriceGoods extends Controller
             $platforms = $platforms ? array_unique($platforms) : '';
 
             $platform_data = $LowPriceGoodsModel->platform_index_data();
-            foreach ($platforms as $platform) {
-                $product_specs_log = $LowPriceGoodsModel
-                    ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
-                    ->where(['product_brand' => $LowProduct->product_brand, 'product_name' => $LowProduct->product_name, 'suggested_price' => $LowProduct->suggested_price, 'status' => '0', 'company_id' => $LowProduct->company_id])
-                    ->where('id', '!=', $id)
-                    ->where(function ($query) use ($product_specs) {
-                        // 平台条件(固定)
-                        $query->where(function ($query_li) use ($product_specs) {
-                            if (!empty($product_specs)) {
-                                foreach ($product_specs as $product_spec) {
-                                    if (empty($product_specs)) continue;
-                                    $query_li->orWhereRaw("FIND_IN_SET(?, product_specs)", [$product_spec]);
+            if (!empty($platform_data)) {
+                foreach ($platforms as $platform) {
+                    $product_specs_log = $LowPriceGoodsModel
+                        ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
+                        ->where(['product_brand' => $LowProduct->product_brand, 'product_name' => $LowProduct->product_name, 'suggested_price' => $LowProduct->suggested_price, 'status' => '0', 'company_id' => $LowProduct->company_id])
+                        ->where('id', '!=', $id)
+                        ->where(function ($query) use ($product_specs) {
+                            // 平台条件(固定)
+                            $query->where(function ($query_li) use ($product_specs) {
+                                if (!empty($product_specs)) {
+                                    foreach ($product_specs as $product_spec) {
+                                        if (empty($product_specs)) continue;
+                                        $query_li->orWhereRaw("FIND_IN_SET(?, product_specs)", [$product_spec]);
+                                    }
                                 }
-                            }
-                        });
-                    })->first();
-                $platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
-                if (!empty($product_specs_log)) {
-                    return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格启用记录']);
+                            });
+                        })->first();
+                    $platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
+                    if (!empty($product_specs_log)) {
+                        return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格启用记录']);
+                    }
                 }
             }
         }

+ 70 - 63
app/Http/Controllers/Manager/WashConfig/ViolationProduct.php

@@ -169,7 +169,7 @@ class ViolationProduct extends Controller
      * @date      2025-12-03
      * 
      */
-    public function add(Request $request, ViolationProductModel $ViolationProductModel )
+    public function add(Request $request, ViolationProductModel $ViolationProductModel)
     {
         $request->scene('add')->validate();
         $admin_company_id = request('admin_company_id', '0');
@@ -198,7 +198,7 @@ class ViolationProduct extends Controller
         $all_data['product_keyword'] = $product_keyword;
         $enable_full_quantity = request('enable_full_quantity', 0); //全量,0启用,1禁用
         $all_data['enable_full_quantity'] = $enable_full_quantity;
-        if(trim($product_keyword) !=''){
+        if (trim($product_keyword) != '') {
             $product_keyword_count = count(explode(',', $product_keyword));
             if ($product_keyword_count > 5) {
                 return json_send(['code' => 'error', 'msg' => '商品关键词不能超过5个']);
@@ -215,7 +215,7 @@ class ViolationProduct extends Controller
         $all_data['specify_responsible_person'] = $specify_responsible_person;
         //查询是否存在
         $map = ['product_name' => $all_data['product_name']];
-        if ($all_data['product_brand'] !='') $map['product_brand'] = $all_data['product_brand'];
+        if ($all_data['product_brand'] != '') $map['product_brand'] = $all_data['product_brand'];
         if ($is_admin != 1 && $company_id != 0) {
             $map['company_id'] = $company_id;
             $all_data['company_id'] = $company_id;
@@ -235,31 +235,33 @@ class ViolationProduct extends Controller
             $platforms = $platforms ? array_unique($platforms) : '';
 
             $platform_data = $ViolationProductModel->platform_index_data();
-            $map_where = ['product_name' => $all_data['product_name'], 'status' => '0','company_id' => $all_data['company_id']];
+            $map_where = ['product_name' => $all_data['product_name'], 'status' => '0', 'company_id' => $all_data['company_id']];
             if ($product_brand != '') $map_where['product_brand'] = $product_brand;
-            foreach ($platforms as $platform) {
-                $product_specs_log = $ViolationProductModel
-                    ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
-                    ->where($map_where)
-                    ->where(function ($query) use ($product_specs) {
-                        // 平台条件(固定)
-                        $query->where(function ($query_li) use ($product_specs) {
-                            if (!empty($product_specs)) {
-                                foreach ($product_specs as $product_spec) {
-                                    if (empty($product_specs)) continue;
-                                    $query_li->orWhereRaw("FIND_IN_SET(?, product_specs)", [$product_spec]);
+            if (!empty($platform_data)) {
+                foreach ($platforms as $platform) {
+                    $product_specs_log = $ViolationProductModel
+                        ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
+                        ->where($map_where)
+                        ->where(function ($query) use ($product_specs) {
+                            // 平台条件(固定)
+                            $query->where(function ($query_li) use ($product_specs) {
+                                if (!empty($product_specs)) {
+                                    foreach ($product_specs as $product_spec) {
+                                        if (empty($product_specs)) continue;
+                                        $query_li->orWhereRaw("FIND_IN_SET(?, product_specs)", [$product_spec]);
+                                    }
                                 }
-                            }
-                        });
-                    })->first();
-                $platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
-                if (!empty($product_specs_log)) {
-                    return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格记录']);
+                            });
+                        })->first();
+                    $platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
+                    if (!empty($product_specs_log)) {
+                        return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格记录']);
+                    }
                 }
             }
         }
         // 写入数据表
-       
+
         $result     =  $ViolationProductModel->addViolationProduct($all_data);
         // 如果操作失败
         if (!$result)     return json_send(['code' => 'error', 'msg' => '新增失败']);
@@ -298,7 +300,7 @@ class ViolationProduct extends Controller
         $all_data['product_keyword'] = $product_keyword;
         $enable_full_quantity = request('enable_full_quantity', 0); //全量,0启用,1禁用
         $all_data['enable_full_quantity'] = $enable_full_quantity;
-        if(trim($product_keyword) !=''){
+        if (trim($product_keyword) != '') {
             $product_keyword_count = count(explode(',', $product_keyword));
             if ($product_keyword_count > 5) {
                 return json_send(['code' => 'error', 'msg' => '商品关键词不能超过5个']);
@@ -315,7 +317,7 @@ class ViolationProduct extends Controller
         $all_data['specify_responsible_person'] = $specify_responsible_person;
         //查询是否存在
         $map = ['product_name' => $all_data['product_name']];
-        if ($all_data['product_brand'] !='') $map['product_brand'] = $all_data['product_brand'];
+        if ($all_data['product_brand'] != '') $map['product_brand'] = $all_data['product_brand'];
         if ($is_admin != 1 && $company_id != 0) {
             $map['company_id'] = $company_id;
             $all_data['company_id'] = $company_id;
@@ -335,27 +337,29 @@ class ViolationProduct extends Controller
             $platforms = $platforms ? array_unique($platforms) : '';
 
             $platform_data = $ViolationProductModel->platform_index_data();
-            $map_where = ['product_name' => $all_data['product_name'], 'status' => '0','company_id' => $all_data['company_id']];
+            $map_where = ['product_name' => $all_data['product_name'], 'status' => '0', 'company_id' => $all_data['company_id']];
             if ($product_brand != '') $map_where['product_brand'] = $product_brand;
-            foreach ($platforms as $platform) {
-                $product_specs_log = $ViolationProductModel
-                    ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
-                    ->where($map_where)
-                    ->where('id', '!=', $id)
-                    ->where(function ($query) use ($product_specs) {
-                        // 平台条件(固定)
-                        $query->where(function ($query_li) use ($product_specs) {
-                            if (!empty($product_specs)) {
-                                foreach ($product_specs as $product_spec) {
-                                    if (empty($product_specs)) continue;
-                                    $query_li->orWhereRaw("FIND_IN_SET(?, product_specs)", [$product_spec]);
+            if (!empty($platform_data)) {
+                foreach ($platforms as $platform) {
+                    $product_specs_log = $ViolationProductModel
+                        ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
+                        ->where($map_where)
+                        ->where('id', '!=', $id)
+                        ->where(function ($query) use ($product_specs) {
+                            // 平台条件(固定)
+                            $query->where(function ($query_li) use ($product_specs) {
+                                if (!empty($product_specs)) {
+                                    foreach ($product_specs as $product_spec) {
+                                        if (empty($product_specs)) continue;
+                                        $query_li->orWhereRaw("FIND_IN_SET(?, product_specs)", [$product_spec]);
+                                    }
                                 }
-                            }
-                        });
-                    })->first();
-                $platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
-                if (!empty($product_specs_log)) {
-                    return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格记录']);
+                            });
+                        })->first();
+                    $platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
+                    if (!empty($product_specs_log)) {
+                        return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格记录']);
+                    }
                 }
             }
         }
@@ -427,27 +431,30 @@ class ViolationProduct extends Controller
             $platforms = $platforms ? array_unique($platforms) : '';
 
             $platform_data = $ViolationProductModel->platform_index_data();
-            foreach ($platforms as $platform) {
-                $product_specs_log = $ViolationProductModel
-                    ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
-                    ->where(['product_brand' => $ViolationProduct->product_brand, 'product_name' => $ViolationProduct->product_name, 'status' => '0', 'company_id' => $ViolationProduct->company_id])
-                    ->where('id', '!=', $id)
-                    ->where(function ($query) use ($product_specs) {
-                        // 平台条件(固定)
-                        $query->where(function ($query_li) use ($product_specs) {
-                            if (!empty($product_specs)) {
-                                foreach ($product_specs as $product_spec) {
-                                    if (empty($product_specs)) continue;
-                                    $query_li->orWhereRaw("FIND_IN_SET(?, product_specs)", [$product_spec]);
+            if (!empty($platform_data)) {
+                foreach ($platforms as $platform) {
+                    $product_specs_log = $ViolationProductModel
+                        ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
+                        ->where(['product_brand' => $ViolationProduct->product_brand, 'product_name' => $ViolationProduct->product_name, 'status' => '0', 'company_id' => $ViolationProduct->company_id])
+                        ->where('id', '!=', $id)
+                        ->where(function ($query) use ($product_specs) {
+                            // 平台条件(固定)
+                            $query->where(function ($query_li) use ($product_specs) {
+                                if (!empty($product_specs)) {
+                                    foreach ($product_specs as $product_spec) {
+                                        if (empty($product_specs)) continue;
+                                        $query_li->orWhereRaw("FIND_IN_SET(?, product_specs)", [$product_spec]);
+                                    }
                                 }
-                            }
-                        });
-                    })->first();
-                $platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
-                if (!empty($product_specs_log)) {
-                    return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格启用记录']);
+                            });
+                        })->first();
+                    $platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
+                    if (!empty($product_specs_log)) {
+                        return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格启用记录']);
+                    }
                 }
             }
+            
         }
         // 执行修改
         $result            =  $ViolationProductModel->changeStatus($ViolationProduct, $status);
@@ -557,7 +564,7 @@ class ViolationProduct extends Controller
         exit;
     }
 
-        /**
+    /**
      * 导入Excel数据
      * @author    唐远望
      * @version   1.0
@@ -613,7 +620,7 @@ class ViolationProduct extends Controller
                     $insert_product_data['company_id']  = $admin_company_id;
                 }
                 $insert_product_data['product_name'] = $item[0]; // 商品名称
-                $insert_product_data['category_id'] =$category_id; // 商品分类
+                $insert_product_data['category_id'] = $category_id; // 商品分类
                 $insert_product_data['product_specs'] = $item[2]; // 商品规格
                 $insert_product_data['platform'] = $platform_id_text != '' ? substr($platform_id_text, 0, -1) : '0'; // 平台:0=全部,1=淘宝,2=京东,3=拼多多,4=美团,5=药师帮,6=1药城,7=药久久
                 $insert_product_data['store_scope'] = ''; // 店铺范围(为空时全部,指定时为店铺ID多个逗号隔开)