|
|
|
@ -40,8 +40,6 @@ class GoodsPrice extends GoodsPriceModel |
|
|
|
|
$temp = []; |
|
|
|
|
if (!empty($v['price'])) { |
|
|
|
|
foreach ($v['price'] as $pk => $pv) { |
|
|
|
|
$pv['profit_min'] = round($pv['min_price'] * $pv['markup_rate'] / 100, 2); |
|
|
|
|
$pv['profit_max'] = round($pv['max_price'] * $pv['markup_rate'] / 100, 2); |
|
|
|
|
if (!empty($params['type'])) { |
|
|
|
|
if ($pv['type'] == $params['type']) { |
|
|
|
|
$temp[] = $pv; |
|
|
|
@ -79,16 +77,18 @@ class GoodsPrice extends GoodsPriceModel |
|
|
|
|
if (!empty($catList)) { |
|
|
|
|
|
|
|
|
|
foreach ($catList as $k => $v) { |
|
|
|
|
if ($data['min_price'] >= $v->min_price && $data['min_price'] <= $v->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 ) { |
|
|
|
|
if ($data['max_price'] <= $v->max_price && $data['max_price'] >= $v->min_price) { |
|
|
|
|
$this->error = "该分类价格区间冲突,请重新设置价格"; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$data['profit_min'] = round($data['min_price'] * $data['markup_rate'] / 100, 2); |
|
|
|
|
$data['profit_max'] = round($data['max_price'] * $data['markup_rate'] / 100, 2); |
|
|
|
|
$data['store_id'] = self::$storeId; |
|
|
|
|
return $this->save($data); |
|
|
|
|
} |
|
|
|
@ -104,21 +104,28 @@ class GoodsPrice extends GoodsPriceModel |
|
|
|
|
$this->error = "请补全信息"; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
$detail = $this->where('id', '=', $data['id'])->find(); |
|
|
|
|
if ($detail->isEmpty()) { |
|
|
|
|
$this->error = "异常数据"; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
//校验是否有冲突的区间 |
|
|
|
|
$catList = $this->where(['cat_id' => $data['cat_id'], 'type' => $data['type']])->where('id','<>',$data['id'])->select(); |
|
|
|
|
$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 ) { |
|
|
|
|
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 ) { |
|
|
|
|
if ($data['max_price'] <= $v->max_price && $data['max_price'] >= $v->min_price) { |
|
|
|
|
$this->error = "该分类价格区间冲突,请重新设置价格"; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return $this->save($data) !== false; |
|
|
|
|
$data['profit_min'] = round($data['min_price'] * $data['markup_rate'] / 100, 2); |
|
|
|
|
$data['profit_max'] = round($data['max_price'] * $data['markup_rate'] / 100, 2); |
|
|
|
|
return $detail->save($data) !== false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -126,14 +133,14 @@ class GoodsPrice extends GoodsPriceModel |
|
|
|
|
* @return bool |
|
|
|
|
* @throws \Exception |
|
|
|
|
*/ |
|
|
|
|
public function remove(): bool |
|
|
|
|
public function del($data): bool |
|
|
|
|
{ |
|
|
|
|
// 判断该服务是否被商品引用 |
|
|
|
|
$goodsCount = ServiceRelModel::getCountByServiceId($this['service_id']); |
|
|
|
|
if ($goodsCount > 0) { |
|
|
|
|
$this->error = "该记录被{$goodsCount}个商品引用,不允许删除"; |
|
|
|
|
$detail = $this->where('id', '=', $data['id'])->find(); |
|
|
|
|
if ($detail->isEmpty()) { |
|
|
|
|
$this->error = "异常数据"; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return $this->save(['is_delete' => 1]) !== false; |
|
|
|
|
return $detail->delete() !== false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|