商品规格避免列之间重复造成混乱

feat/task1-c-wallet
gongfuxiang 2019-01-12 01:41:02 +08:00
parent 6b5b4f0d08
commit d3e56c2c82
2 changed files with 39 additions and 6 deletions

View File

@ -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)
{

View File

@ -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');