Эх сурвалжийг харах

[智价云] 采集清洗新增编辑规则更新

tangyuanwang 1 долоо хоног өмнө
parent
commit
c97642b1a6

+ 50 - 56
app/Http/Controllers/Manager/Collect/Product.php

@@ -237,22 +237,11 @@ class Product extends Controller
         $all_data = request()->all();
         $product_brand = request('product_brand', '');
         $product_keyword = request('product_keyword', '');
-        $platform_string = $all_data['platform'];
-        if(empty($platform_string)) return json_send(['code' => 'error', 'msg' => '平台不能为空']);
+        $minimum_order_quantity = request('minimum_order_quantity', 1);
+        $all_data['platform'] =  request('platform', '');
+        $all_data['product_specs'] =  request('product_specs', '');
         $all_data['product_brand'] = $product_brand;
         $all_data['product_keyword'] = $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个']);
-            }
-        }
-        //采集信息配置
-        $enable_full_quantity = request('enable_full_quantity', 1); //全量,0启用,1禁用
-        $all_data['enable_full_quantity'] = $enable_full_quantity;
-        if ($enable_full_quantity == 1 && !isset($all_data['product_specs'])) {
-            return json_send(['code' => 'error', 'msg' => '非全量采集时,商品规格不能为空']);
-        }
         $minimum_order_quantity = request('minimum_order_quantity', 1);
         $sampling_cycle = request('sampling_cycle', '0');
         $sampling_start_time = request('sampling_start_time', '');
@@ -261,10 +250,23 @@ class Product extends Controller
         $all_data['sampling_start_time'] = $sampling_start_time ? strtotime($sampling_start_time . '00:00:00') : '0';
         $all_data['sampling_end_time'] = $sampling_end_time ? strtotime($sampling_end_time . '23:59:59') : '0';
         $all_data['minimum_order_quantity'] = $minimum_order_quantity;
+
         if ($all_data['sampling_start_time']  && strtotime(date('Y-m-d', $all_data['sampling_start_time']) . '23:59:59') < time()) return json_send(['code' => 'error', 'msg' => '采集开始时间必须大于当前时间']);
         if ($all_data['sampling_end_time']  && $all_data['sampling_end_time'] < time()) return json_send(['code' => 'error', 'msg' => '采集结束时间必须大于当前时间']);
+
+        $platform_string = $all_data['platform'];
+        if(empty($platform_string)) return json_send(['code' => 'error', 'msg' => '平台不能为空']);
+        $enable_full_quantity = request('enable_full_quantity', 0); //全量,0启用,1禁用
+        $all_data['enable_full_quantity'] = $enable_full_quantity;
+        if (trim($product_keyword) != '') {
+            $product_keyword_count = count(explode(',', $product_keyword));
+            if ($product_keyword_count > 5) {
+                return json_send(['code' => 'error', 'msg' => '商品关键词不能超过5个']);
+            }
+        }
         //查询是否存在
-        $map = ['product_brand' => $product_brand, 'product_name' => $all_data['product_name']];
+        $map = ['product_name' => $all_data['product_name']];
+        if($product_brand != '') $map['product_brand'] = $product_brand;
         if ($is_admin != 1 && $company_id != 0) {
             $map['company_id'] = $company_id;
             $all_data['company_id'] = $company_id;
@@ -273,7 +275,7 @@ class Product extends Controller
             $all_data['company_id'] = $admin_company_id;
         }
         $data = $ProductModel->where($map)->first();
-        if (!empty($data) && $enable_full_quantity == 1) {
+        if (!empty($data)) {
             //继续校验规格是否存在
             $product_specs_tring = $all_data['product_specs'];
             $product_specs = $product_specs_tring ?  explode(',', $product_specs_tring) : '';
@@ -284,42 +286,29 @@ class Product extends Controller
             $platforms = $platforms ? array_unique($platforms) : '';
 
             $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(['product_brand' => $product_brand, 'product_name' => $all_data['product_name'],'status'=>'0'])
+                    ->where($map_where)
                     ->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]);
+                            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.'存在重复的商品规格记录']);
-                }
-            }
-        }else if (!empty($data) && $enable_full_quantity == 0) {
-            $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_brand, 'product_name' => $all_data['product_name'],'status'=>'0'])
-                    ->first();
-                $platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
-                if (!empty($product_specs_log)) {
-                    return json_send(['code' => 'error', 'msg' => $platform_name.'存在重复的商品记录']);
+                    return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格记录']);
                 }
             }
         }
-
         // 写入数据表
         $result     =  $ProductModel->addProduct($all_data);
         // 如果操作失败
@@ -352,22 +341,11 @@ class Product extends Controller
         $all_data = request()->all();
         $product_brand = request('product_brand', '');
         $product_keyword = request('product_keyword', '');
-        $platform_string = $all_data['platform'];
-        if(empty($platform_string)) return json_send(['code' => 'error', 'msg' => '平台不能为空']);
+        $minimum_order_quantity = request('minimum_order_quantity', 1);
+        $all_data['platform'] =  request('platform', '');
+        $all_data['product_specs'] =  request('product_specs', '');
         $all_data['product_brand'] = $product_brand;
         $all_data['product_keyword'] = $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个']);
-            }
-        }
-        //采集信息配置
-        $enable_full_quantity = request('enable_full_quantity', 1); //全量,0启用,1禁用
-        $all_data['enable_full_quantity'] = $enable_full_quantity;
-        if ($enable_full_quantity == 1 && !isset($all_data['product_specs'])) {
-            return json_send(['code' => 'error', 'msg' => '非全量采集时,商品规格不能为空']);
-        }
         $minimum_order_quantity = request('minimum_order_quantity', 1);
         $sampling_cycle = request('sampling_cycle', '0');
         $sampling_start_time = request('sampling_start_time', '');
@@ -376,8 +354,20 @@ class Product extends Controller
         $all_data['sampling_start_time'] = $sampling_start_time ? strtotime($sampling_start_time . '00:00:00') : '0';
         $all_data['sampling_end_time'] = $sampling_end_time ? strtotime($sampling_end_time . '23:59:59') : '0';
         $all_data['minimum_order_quantity'] = $minimum_order_quantity;
+
         if ($all_data['sampling_start_time']  && strtotime(date('Y-m-d', $all_data['sampling_start_time']) . '23:59:59') < time()) return json_send(['code' => 'error', 'msg' => '采集开始时间必须大于当前时间']);
         if ($all_data['sampling_end_time']  && $all_data['sampling_end_time'] < time()) return json_send(['code' => 'error', 'msg' => '采集结束时间必须大于当前时间']);
+
+        $platform_string = $all_data['platform'];
+        if(empty($platform_string)) return json_send(['code' => 'error', 'msg' => '平台不能为空']);
+        $enable_full_quantity = request('enable_full_quantity', 0); //全量,0启用,1禁用
+        $all_data['enable_full_quantity'] = $enable_full_quantity;
+        if (trim($product_keyword) != '') {
+            $product_keyword_count = count(explode(',', $product_keyword));
+            if ($product_keyword_count > 5) {
+                return json_send(['code' => 'error', 'msg' => '商品关键词不能超过5个']);
+            }
+        }
         //查询是否存在
         $map = ['product_brand' => $product_brand, 'product_name' => $all_data['product_name']];
         if ($is_admin != 1 && $company_id != 0) {
@@ -397,10 +387,12 @@ class Product extends Controller
             $platforms = $platforms ? array_unique($platforms) : '';
 
             $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(['product_brand' => $product_brand, 'product_name' => $all_data['product_name'],'status'=>'0'])
+                    ->where($map_where)
                     ->where('id', '!=', $id)
                     ->where(function ($query) use ($product_specs) {
                         // 平台条件(固定)
@@ -422,10 +414,12 @@ class Product extends Controller
             $platforms = $platforms ? array_unique($platforms) : '';
 
             $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(['product_brand' => $product_brand, 'product_name' => $all_data['product_name'],'status'=>'0'])
+                    ->where($map_where)
                     ->first();
                 $platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
                 if (!empty($product_specs_log)) {
@@ -505,7 +499,7 @@ class Product extends Controller
             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'])
+                    ->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) {
                         // 平台条件(固定)
@@ -531,7 +525,7 @@ class Product extends Controller
             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'])
+                    ->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)) {

+ 35 - 74
app/Http/Controllers/Manager/WashConfig/LowPriceGoods.php

@@ -186,14 +186,12 @@ class LowPriceGoods extends Controller
         $product_brand = request('product_brand', '');
         $product_keyword = request('product_keyword', '');
         $product_specs = request('product_specs', '');
+        $all_data['platform'] = request('platform', '');
         $all_data['product_specs'] = $product_specs;
         $all_data['product_brand'] = $product_brand;
         $all_data['product_keyword'] = $product_keyword;
-        $enable_full_quantity = request('enable_full_quantity', 1); //全量,0启用,1禁用
+        $enable_full_quantity = request('enable_full_quantity', 0); //全量,0启用,1禁用
         $all_data['enable_full_quantity'] = $enable_full_quantity;
-        if ($enable_full_quantity == 1 && !isset($all_data['product_specs'])) {
-            return json_send(['code' => 'error', 'msg' => '非全量清洗时,商品规格不能为空']);
-        }
         if (trim($product_keyword) != '') {
             $product_keyword_count = count(explode(',', $product_keyword));
             if ($product_keyword_count > 5) {
@@ -210,7 +208,8 @@ class LowPriceGoods extends Controller
         $specify_responsible_person = request('specify_responsible_person', '0');
         $all_data['specify_responsible_person'] = $specify_responsible_person;
         //查询是否存在
-        $map = ['product_brand' => $all_data['product_brand'], 'product_name' => $all_data['product_name'],'suggested_price'=> $all_data['suggested_price']];
+        $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 (isset($all_data['product_specs']) && $all_data['product_specs'] != '') {
             $map['product_specs'] = $all_data['product_specs'];
         }
@@ -222,7 +221,7 @@ class LowPriceGoods extends Controller
             $all_data['company_id'] = $admin_company_id;
         }
         $data = $LowPriceGoodsModel->where($map)->first();
-        if (!empty($data) && $enable_full_quantity == 1) {
+        if (!empty($data)) {
             //继续校验规格是否存在
             $product_specs_tring = $all_data['product_specs'];
             $product_specs = $product_specs_tring ?  explode(',', $product_specs_tring) : '';
@@ -233,17 +232,20 @@ class LowPriceGoods extends Controller
             $platforms = $platforms ? array_unique($platforms) : '';
 
             $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(['product_brand' => $product_brand, 'product_name' => $all_data['product_name'],'suggested_price'=> $all_data['suggested_price'], 'status' => '0'])
+                    ->where($map_where)
                     ->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]);
+                            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();
@@ -252,21 +254,6 @@ class LowPriceGoods extends Controller
                     return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格记录']);
                 }
             }
-        } else if (!empty($data) && $enable_full_quantity == 0) {
-            $platforms = $platform_string ?  explode(',', $platform_string) : '';
-            $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' => $product_brand, 'product_name' => $all_data['product_name'],'suggested_price'=> $all_data['suggested_price'], 'status' => '0'])
-                    ->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);
@@ -302,14 +289,12 @@ class LowPriceGoods extends Controller
         $product_brand = request('product_brand', '');
         $product_keyword = request('product_keyword', '');
         $product_specs = request('product_specs', '');
+        $all_data['platform'] = request('platform', '');
         $all_data['product_specs'] = $product_specs;
         $all_data['product_brand'] = $product_brand;
         $all_data['product_keyword'] = $product_keyword;
-        $enable_full_quantity = request('enable_full_quantity', 1); //全量,0启用,1禁用
+        $enable_full_quantity = request('enable_full_quantity', 0); //全量,0启用,1禁用
         $all_data['enable_full_quantity'] = $enable_full_quantity;
-        if ($enable_full_quantity == 1 && !isset($all_data['product_specs'])) {
-            return json_send(['code' => 'error', 'msg' => '非全量清洗时,商品规格不能为空']);
-        }
         if (trim($product_keyword) != '') {
             $product_keyword_count = count(explode(',', $product_keyword));
             if ($product_keyword_count > 5) {
@@ -326,17 +311,20 @@ class LowPriceGoods extends Controller
         $specify_responsible_person = request('specify_responsible_person', '0');
         $all_data['specify_responsible_person'] = $specify_responsible_person;
         //查询是否存在
-        $map = ['product_brand' => $all_data['product_brand'], 'product_name' => $all_data['product_name'],'suggested_price'=> $all_data['suggested_price']];
+        $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 (isset($all_data['product_specs']) && $all_data['product_specs'] != '') {
             $map['product_specs'] = $all_data['product_specs'];
         }
         if ($is_admin != 1 && $company_id != 0) {
             $map['company_id'] = $company_id;
+            $all_data['company_id'] = $company_id;
         } else {
             $map['company_id'] = $admin_company_id;
+            $all_data['company_id'] = $admin_company_id;
         }
         $data = $LowPriceGoodsModel->where($map)->first();
-        if (!empty($data) && $enable_full_quantity == 1) {
+        if (!empty($data)) {
             //继续校验规格是否存在
             $product_specs_tring = $all_data['product_specs'];
             $product_specs = $product_specs_tring ?  explode(',', $product_specs_tring) : '';
@@ -347,18 +335,21 @@ 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']];
+            if ($product_brand != '') $map_where['product_brand'] = $product_brand;
             foreach ($platforms as $platform) {
                 $product_specs_log = $LowPriceGoodsModel
                     ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
-                    ->where(['product_brand' => $product_brand, 'product_name' => $all_data['product_name'],'suggested_price'=> $all_data['suggested_price'], 'status' => '0'])
+                    ->where($map_where)
                     ->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]);
+                            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();
@@ -367,21 +358,6 @@ class LowPriceGoods extends Controller
                     return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格记录']);
                 }
             }
-        } else if (!empty($data) && $enable_full_quantity == 0) {
-            $platforms = $platform_string ?  explode(',', $platform_string) : '';
-            $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' => $product_brand, 'product_name' => $all_data['product_name'],'suggested_price'=> $all_data['suggested_price'], 'status' => '0'])
-                    ->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];
@@ -448,7 +424,7 @@ class LowPriceGoods extends Controller
         }
         $LowProduct = $LowPriceGoodsModel->where($where)->first();
         if (!$LowProduct) return json_send(['code' => 'error', 'msg' => '记录不存在']);
-        if (!empty($LowProduct) && $LowProduct->enable_full_quantity == 1) {
+        if (!empty($LowProduct)) {
             //继续校验规格是否存在
             $product_specs_tring = $LowProduct->product_specs;
             $product_specs = $product_specs_tring ?  explode(',', $product_specs_tring) : '';
@@ -463,15 +439,16 @@ class LowPriceGoods extends Controller
             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'])
+                    ->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) {
-
-                            foreach ($product_specs as $product_spec) {
-                                if (empty($product_specs)) continue;
-                                $query_li->orWhereRaw("FIND_IN_SET(?, product_specs)", [$product_spec]);
+                            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();
@@ -480,22 +457,6 @@ class LowPriceGoods extends Controller
                     return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格启用记录']);
                 }
             }
-        } else if (!empty($LowProduct) && $LowProduct->enable_full_quantity == 0) {
-            $platform_string = $LowProduct->platform;
-            $platforms = $platform_string ?  explode(',', $platform_string) : '';
-            $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'])
-                    ->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 . '存在重复的商品启用记录']);
-                }
-            }
         }
         // 执行修改
         $result            =  $LowPriceGoodsModel->changeStatus($LowProduct, $status);

+ 29 - 72
app/Http/Controllers/Manager/WashConfig/ViolationProduct.php

@@ -192,14 +192,12 @@ class ViolationProduct extends Controller
         $product_brand = request('product_brand', '');
         $product_keyword = request('product_keyword', '');
         $product_specs = request('product_specs', '');
+        $all_data['platform'] = request('platform', '');
         $all_data['product_specs'] = $product_specs;
         $all_data['product_brand'] = $product_brand;
         $all_data['product_keyword'] = $product_keyword;
-        $enable_full_quantity = request('enable_full_quantity', 1); //全量,0启用,1禁用
+        $enable_full_quantity = request('enable_full_quantity', 0); //全量,0启用,1禁用
         $all_data['enable_full_quantity'] = $enable_full_quantity;
-        if ($enable_full_quantity == 1 && !isset($all_data['product_specs'])) {
-            return json_send(['code' => 'error', 'msg' => '非全量清洗时,商品规格不能为空']);
-        }
         if(trim($product_keyword) !=''){
             $product_keyword_count = count(explode(',', $product_keyword));
             if ($product_keyword_count > 5) {
@@ -228,7 +226,7 @@ class ViolationProduct extends Controller
             $all_data['company_id'] = $admin_company_id;
         }
         $data = $ViolationProductModel->where($map)->first();
-        if (!empty($data) && $enable_full_quantity == 1) {
+        if (!empty($data)) {
             //继续校验规格是否存在
             $product_specs_tring = $all_data['product_specs'];
             $product_specs = $product_specs_tring ?  explode(',', $product_specs_tring) : '';
@@ -239,17 +237,20 @@ 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']];
+            if ($product_brand != '') $map_where['product_brand'] = $product_brand;
             foreach ($platforms as $platform) {
                 $product_specs_log = $ViolationProductModel
                     ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
-                    ->where(['product_brand' => $product_brand, 'product_name' => $all_data['product_name'], 'status' => '0'])
+                    ->where($map_where)
                     ->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]);
+                            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();
@@ -258,21 +259,6 @@ class ViolationProduct extends Controller
                     return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格记录']);
                 }
             }
-        } else if (!empty($data) && $enable_full_quantity == 0) {
-            $platforms = $platform_string ?  explode(',', $platform_string) : '';
-            $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' => $product_brand, 'product_name' => $all_data['product_name'], 'status' => '0'])
-                    ->first();
-                $platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
-                if (!empty($product_specs_log)) {
-                    return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品记录']);
-                }
-            }
         }
         // 写入数据表
        
@@ -308,14 +294,12 @@ class ViolationProduct extends Controller
         $product_brand = request('product_brand', '');
         $product_keyword = request('product_keyword', '');
         $product_specs = request('product_specs', '');
+        $all_data['platform'] = request('platform', '');
         $all_data['product_specs'] = $product_specs;
         $all_data['product_brand'] = $product_brand;
         $all_data['product_keyword'] = $product_keyword;
-        $enable_full_quantity = request('enable_full_quantity', 1); //全量,0启用,1禁用
+        $enable_full_quantity = request('enable_full_quantity', 0); //全量,0启用,1禁用
         $all_data['enable_full_quantity'] = $enable_full_quantity;
-        if ($enable_full_quantity == 1 && !isset($all_data['product_specs'])) {
-            return json_send(['code' => 'error', 'msg' => '非全量清洗时,商品规格不能为空']);
-        }
         if(trim($product_keyword) !=''){
             $product_keyword_count = count(explode(',', $product_keyword));
             if ($product_keyword_count > 5) {
@@ -344,7 +328,7 @@ class ViolationProduct extends Controller
             $all_data['company_id'] = $admin_company_id;
         }
         $data = $ViolationProductModel->where($map)->where('id', '!=', $id)->first();
-        if (!empty($data) && $enable_full_quantity == 1) {
+        if (!empty($data)) {
             //继续校验规格是否存在
             $product_specs_tring = $all_data['product_specs'];
             $product_specs = $product_specs_tring ?  explode(',', $product_specs_tring) : '';
@@ -355,18 +339,21 @@ 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']];
+            if ($product_brand != '') $map_where['product_brand'] = $product_brand;
             foreach ($platforms as $platform) {
                 $product_specs_log = $ViolationProductModel
                     ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
-                    ->where(['product_brand' => $product_brand, 'product_name' => $all_data['product_name'], 'status' => '0'])
+                    ->where($map_where)
                     ->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]);
+                            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();
@@ -375,21 +362,6 @@ class ViolationProduct extends Controller
                     return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格记录']);
                 }
             }
-        } else if (!empty($data) && $enable_full_quantity == 0) {
-            $platforms = $platform_string ?  explode(',', $platform_string) : '';
-            $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' => $product_brand, 'product_name' => $all_data['product_name'], 'status' => '0'])
-                    ->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];
@@ -447,7 +419,7 @@ class ViolationProduct extends Controller
         }
         $ViolationProduct = $ViolationProductModel->where($where)->first();
         if (!$ViolationProduct) return json_send(['code' => 'error', 'msg' => '记录不存在']);
-        if (!empty($ViolationProduct) && $ViolationProduct->enable_full_quantity == 1) {
+        if (!empty($ViolationProduct)) {
             //继续校验规格是否存在
             $product_specs_tring = $ViolationProduct->product_specs;
             $product_specs = $product_specs_tring ?  explode(',', $product_specs_tring) : '';
@@ -462,15 +434,16 @@ class ViolationProduct extends Controller
             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'])
+                    ->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) {
-
-                            foreach ($product_specs as $product_spec) {
-                                if (empty($product_specs)) continue;
-                                $query_li->orWhereRaw("FIND_IN_SET(?, product_specs)", [$product_spec]);
+                            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();
@@ -479,22 +452,6 @@ class ViolationProduct extends Controller
                     return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格启用记录']);
                 }
             }
-        } else if (!empty($ViolationProduct) && $ViolationProduct->enable_full_quantity == 0) {
-            $platform_string = $ViolationProduct->platform;
-            $platforms = $platform_string ?  explode(',', $platform_string) : '';
-            $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'])
-                    ->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 . '存在重复的商品启用记录']);
-                }
-            }
         }
         // 执行修改
         $result            =  $ViolationProductModel->changeStatus($ViolationProduct, $status);

+ 2 - 2
app/Http/Requests/Manager/Collect/Product.php

@@ -44,8 +44,8 @@ class Product extends BaseRequest
     protected   $scenes         = [
         'detail'             => ['id'],
         'list'               => ['page', 'limit'],
-        'add'                      => ['platform','product_brand','product_name'],
-        'edit'                  => ['id','platform','product_brand','product_name'],
+        'add'                      => ['platform','product_name'],
+        'edit'                  => ['id','platform','product_name'],
         'set_status'              => ['id', 'status'],
         'delete'                  => ['id'],
         'product_name_specs_list' => [],

+ 2 - 2
app/Http/Requests/Manager/WashConfig/LowPriceGoods.php

@@ -45,8 +45,8 @@ class LowPriceGoods extends BaseRequest
     protected   $scenes         = [
         'detail'             => ['id'],
         'list'               => ['page', 'limit'],
-        'add'                      => ['platform','product_brand','product_name', 'suggested_price','enable_full_quantity'],
-        'edit'                  => ['id','product_brand','platform', 'product_name','suggested_price','enable_full_quantity'],
+        'add'                      => ['platform','product_name', 'suggested_price'],
+        'edit'                  => ['id','platform', 'product_name','suggested_price'],
         'set_status'              => ['id', 'status'],
         'delete'                  => ['id'],
         'spec_list'             => ['page', 'limit'],

+ 2 - 2
app/Http/Requests/Manager/WashConfig/ViolationProduct.php

@@ -44,8 +44,8 @@ class ViolationProduct extends BaseRequest
     protected   $scenes         = [
         'detail'             => ['id'],
         'list'               => ['page', 'limit'],
-        'add'                      => ['platform', 'product_name', 'enable_full_quantity'],
-        'edit'                  => ['id', 'platform', 'product_name', 'enable_full_quantity'],
+        'add'                      => ['platform','product_name'],
+        'edit'                  => ['id', 'platform','product_name'],
         'set_status'              => ['id', 'status'],
         'delete'                  => ['id'],
         'import_data'            => ['file'],

+ 3 - 3
app/Models/Manager/Collect/Product.php

@@ -60,7 +60,7 @@ class Product extends Model
     public function addProduct_content($data)
     {
         $insert_data = [
-            'enable_full_quantity' => $data['enable_full_quantity'],
+            'enable_full_quantity' => isset($data['enable_full_quantity']) ? $data['enable_full_quantity'] : 0,
             'platform' => $data['platform'],
             'product_name' => $data['product_name'],
             'product_specs' => $data['product_specs'],
@@ -103,7 +103,7 @@ class Product extends Model
             //移除数组内空值
             $product_specs_data = !empty($product_specs_data) ? array_filter($product_specs_data) : '';
             $insert_data = [
-                'enable_full_quantity' => $data['enable_full_quantity'],
+                'enable_full_quantity' => isset($data['enable_full_quantity']) ? $data['enable_full_quantity'] : 0,
                 'platform' => $data['platform'],
                 'product_brand' => $data['product_brand'],
                 'product_name' => $data['product_name'],
@@ -160,7 +160,7 @@ class Product extends Model
             //移除数组内空值
             $product_specs_data = !empty($product_specs_data) ? array_filter($product_specs_data) : '';
 
-            $Product->enable_full_quantity = $data['enable_full_quantity'];
+            $Product->enable_full_quantity = isset($data['enable_full_quantity']) ? $data['enable_full_quantity'] : 0;
             $Product->platform = $data['platform'];
             $Product->product_brand = $data['product_brand'];
             $Product->product_name = $data['product_name'];