|
|
@ -77,8 +77,13 @@ class GoodsPrice extends GoodsPriceModel |
|
|
|
//校验是否有冲突的区间 |
|
|
|
//校验是否有冲突的区间 |
|
|
|
$catList = $this->where(['cat_id' => $data['cat_id'], 'type' => $data['type']])->select(); |
|
|
|
$catList = $this->where(['cat_id' => $data['cat_id'], 'type' => $data['type']])->select(); |
|
|
|
if (!empty($catList)) { |
|
|
|
if (!empty($catList)) { |
|
|
|
|
|
|
|
|
|
|
|
foreach ($catList as $k => $v) { |
|
|
|
foreach ($catList as $k => $v) { |
|
|
|
if ($v->max_price <= $data['min_price'] || $v->min_price >= $data['max_price']) { |
|
|
|
if ($data['min_price'] >= $v->min_price && $data['min_price'] <= $v->max_price ) { |
|
|
|
|
|
|
|
$this->error = "该分类价格区间冲突,请重新设置价格"; |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if ( $data['max_price'] <= $v->max_price && $data['max_price'] >= $v->min_price ) { |
|
|
|
$this->error = "该分类价格区间冲突,请重新设置价格"; |
|
|
|
$this->error = "该分类价格区间冲突,请重新设置价格"; |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
@ -95,6 +100,24 @@ class GoodsPrice extends GoodsPriceModel |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function edit(array $data): bool |
|
|
|
public function edit(array $data): bool |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (empty($data['type']) || empty($data['max_price']) || empty($data['cat_id']) || empty($data['markup_rate']) || empty($data['id'])) { |
|
|
|
|
|
|
|
$this->error = "请补全信息"; |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//校验是否有冲突的区间 |
|
|
|
|
|
|
|
$catList = $this->where(['cat_id' => $data['cat_id'], 'type' => $data['type']])->where('id','<>',$data['id'])->select(); |
|
|
|
|
|
|
|
if (!empty($catList)) { |
|
|
|
|
|
|
|
foreach ($catList as $k => $v) { |
|
|
|
|
|
|
|
if ($data['min_price'] >= $v->min_price && $data['min_price'] <= $v->max_price ) { |
|
|
|
|
|
|
|
$this->error = "该分类价格区间冲突,请重新设置价格"; |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if ( $data['max_price'] <= $v->max_price && $data['max_price'] >= $v->min_price ) { |
|
|
|
|
|
|
|
$this->error = "该分类价格区间冲突,请重新设置价格"; |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return $this->save($data) !== false; |
|
|
|
return $this->save($data) !== false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|