ztt 9 months ago
parent 7507ab918d
commit ed103b2c7d
  1. 8
      app/api/model/Goods.php

@ -658,7 +658,7 @@ class Goods extends GoodsModel
* @throws ModelNotFoundException
*/
public function editGoodsPrice($data) {
if (empty($data['goods_price']) || empty($data['line_price']) || empty($data['id'])) {
if (empty($data['goods_price']) || empty($data['cost_price']) || empty($data['id'])) {
$this->error = "请补全信息";
return false;
}
@ -678,16 +678,16 @@ class Goods extends GoodsModel
foreach ($sku_ids as $sku_id) {
$skuData = GoodsSkuModel::get(['id' => $sku_id,'goods_id' => $data['id']]);
if ($skuData) {
$skuData->save(['goods_price' => $data['goods_price'], 'line_price' => $data['line_price']]);
$skuData->save(['goods_price' => $data['goods_price'], 'cost_price' => $data['cost_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());
// [$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'];
// $data['line_price_min'] = $data['line_price_max'] = $data['line_price'];
}
return $detail->save($data) !== false;
}

Loading…
Cancel
Save