From 3aa91fcf0a1bca866b3acdac567e9186dcf6181e Mon Sep 17 00:00:00 2001 From: devil_gong Date: Fri, 2 Aug 2019 16:37:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E8=A7=84=E6=A0=BC=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/service/GoodsService.php | 38 ++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/application/service/GoodsService.php b/application/service/GoodsService.php index 316066058..e922c2dc6 100755 --- a/application/service/GoodsService.php +++ b/application/service/GoodsService.php @@ -1099,6 +1099,7 @@ class GoodsService 'seo_title' => empty($params['seo_title']) ? '' : $params['seo_title'], 'seo_keywords' => empty($params['seo_keywords']) ? '' : $params['seo_keywords'], 'seo_desc' => empty($params['seo_desc']) ? '' : $params['seo_desc'], + 'is_exist_many_spec' => empty($specifications['data']['title']) ? 0 : 1, ]; // 商品保存处理钩子 @@ -1302,6 +1303,37 @@ class GoodsService return DataReturn('规格值列之间不能重复['.implode(',', array_unique($temp_column)).']', -1); } } + + // 规格值是否重复 + if(!empty($column_value[0])) + { + $temp_row_data = []; + $temp_row_count = count($column_value); + foreach($column_value[0] as $row_key=>$row_value) + { + for($i=0; $i<$temp_row_count; $i++) + { + if(isset($column_value[$i][$row_key])) + { + if(isset($temp_row_data[$row_key])) + { + $temp_row_data[$row_key] .= $column_value[$i][$row_key]; + } else { + $temp_row_data[$row_key] = $column_value[$i][$row_key]; + } + } + } + } + if(!empty($temp_row_data)) + { + $unique_all = array_unique($temp_row_data); + $repeat_rows_all = array_diff_assoc($temp_row_data, $unique_all); + if(!empty($repeat_rows_all)) + { + return DataReturn('规格值不能重复['.implode(',', array_unique($repeat_rows_all)).']', -1); + } + } + } // 规格名称 $names_value = []; @@ -1333,7 +1365,7 @@ class GoodsService $repeat_names_all = array_diff_assoc($names_value, $unique_all); if(!empty($repeat_names_all)) { - return DataReturn('规格名称列之间不能重复['.implode(',', $repeat_names_all).']', -1); + return DataReturn('规格名称列之间不能重复['.implode(',', array_unique($repeat_names_all)).']', -1); } } else { if(empty($data[0][0]) || $data[0][0] <= 0) @@ -1360,7 +1392,9 @@ class GoodsService } } } - +print_r($data); +print_r($title); +die; return DataReturn('success', 0, ['data'=>$data, 'title'=>$title, 'images'=>$images]); }