From d3e56c2c82ba29d2092886fc876586739186efec Mon Sep 17 00:00:00 2001 From: gongfuxiang <2499232802@qq.com> Date: Sat, 12 Jan 2019 01:41:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E8=A7=84=E6=A0=BC=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E5=88=97=E4=B9=8B=E9=97=B4=E9=87=8D=E5=A4=8D=E9=80=A0?= =?UTF-8?q?=E6=88=90=E6=B7=B7=E4=B9=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/service/GoodsService.php | 40 ++++++++++++++++++++++++++-- public/core.php | 5 +--- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/application/service/GoodsService.php b/application/service/GoodsService.php index 39bc64ba1..aabe20de2 100755 --- a/application/service/GoodsService.php +++ b/application/service/GoodsService.php @@ -1091,6 +1091,9 @@ class GoodsService $title = []; $images = []; + // 基础字段数据字段长度 + $base_count = 6; + // 规格值 foreach($params as $k=>$v) { @@ -1110,12 +1113,45 @@ class GoodsService } } - // 规格名称 + // 规格处理 if(!empty($data[0])) { - $count = count($data[0])-6; + $count = count($data[0])-$base_count; if($count > 0) { + // 列之间是否存在相同的值 + $column_value = []; + foreach($data as $data_value) + { + foreach($data_value as $temp_key=>$temp_value) + { + if($temp_key < $count) + { + $column_value[$temp_key][] = $temp_value; + } + } + } + if(!empty($column_value) && count($column_value) > 1) + { + $temp_column = []; + foreach($column_value as $column_key=>$column_val) + { + foreach($column_value as $column_keys=>$column_vals) + { + if($column_key != $column_keys) + { + $temp = array_intersect($column_val, $column_vals); + $temp_column = array_merge($temp_column, $temp); + } + } + } + if(!empty($temp_column)) + { + return DataReturn('规格值列直接不能重复['.implode(',', array_unique($temp_column)).']', -1); + } + } + + // 规格名称 $names = array_slice($data[0], 0, $count); foreach($names as $v) { diff --git a/public/core.php b/public/core.php index 4442c852c..a6ccb834b 100755 --- a/public/core.php +++ b/public/core.php @@ -10,10 +10,7 @@ // +---------------------------------------------------------------------- // 检测PHP环境 -if(version_compare(PHP_VERSION,'5.6.0','<')) die('PHP版本最低 5.6.0'); - -// 开启缓冲区 -ob_start(); +if(version_compare(PHP_VERSION,'5.5.0','<')) die('PHP版本最低 5.5.0'); // 系统版本 define('APPLICATION_VERSION', 'v1.2.0'); -- GitLab