|
|
|
@ -645,16 +645,24 @@ class Goods extends GoodsModel |
|
|
|
|
$this->error = "请补全信息"; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
$detail = $this->with(['skuList']) |
|
|
|
|
->where('goods_id', '=', $data['id'])->find(); |
|
|
|
|
$detail = $this->where('goods_id', '=', $data['id'])->find(); |
|
|
|
|
if ($detail->isEmpty()) { |
|
|
|
|
$this->error = "异常数据"; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
// 整理商品的价格 |
|
|
|
|
if ($detail['spec_type'] == GoodsSpecTypeEnum::MULTI) { |
|
|
|
|
[$data['goods_price_min'], $data['goods_price_max']] = GoodsSkuModel::getGoodsPrices($detail['skuList']->toArray()); |
|
|
|
|
[$data['line_price_min'], $data['line_price_max']] = GoodsSkuModel::getLinePrices($detail['skuList']->toArray()); |
|
|
|
|
if(empty($data['sku_id'])) { |
|
|
|
|
$this->error = "请输入sku_id"; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
$skuData = GoodsSkuModel::get(['id' => $data['sku_id'],'goods_id' => $data['id']]); |
|
|
|
|
if ($skuData) { |
|
|
|
|
$skuData->save(['goods_price' => $data['goods_price'], 'line_price' => $data['line_price']]); |
|
|
|
|
} |
|
|
|
|
$skuList = GoodsSkuModel::getSkuList((int)$data['id']); |
|
|
|
|
[$data['goods_price_min'], $data['goods_price_max']] = GoodsSkuModel::getGoodsPrices($skuList->toArray()); |
|
|
|
|
[$data['line_price_min'], $data['line_price_max']] = GoodsSkuModel::getLinePrices($skuList->toArray()); |
|
|
|
|
} elseif ($detail['spec_type'] == GoodsSpecTypeEnum::SINGLE) { |
|
|
|
|
$data['goods_price_min'] = $data['goods_price_max'] = $data['goods_price']; |
|
|
|
|
$data['line_price_min'] = $data['line_price_max'] = $data['line_price']; |
|
|
|
|