From 272ee7850a04e783b724ab4de1fce2c7797c4ca1 Mon Sep 17 00:00:00 2001 From: lqmac Date: Tue, 16 Apr 2024 16:42:18 +0800 Subject: [PATCH] 1 --- app/api/model/Goods.php | 48 ++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/app/api/model/Goods.php b/app/api/model/Goods.php index f38d445c..1554e55d 100644 --- a/app/api/model/Goods.php +++ b/app/api/model/Goods.php @@ -669,28 +669,31 @@ class Goods extends GoodsModel return false; } // 整理商品的价格 - if ($detail['spec_type'] == GoodsSpecTypeEnum::MULTI) { - if(empty($data['sku_id'])) { - $this->error = "请输入sku_id"; - return false; - } - //批量修改sku价格 - $sku_ids = explode(',', $data['sku_id']); - 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'], '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()); - } 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']; - } - return $detail->save($data) !== false; + // if ($detail['spec_type'] == GoodsSpecTypeEnum::MULTI) { + // if(empty($data['sku_id'])) { + // $this->error = "请输入sku_id"; + // return false; + // } + // //批量修改sku价格 + // $sku_ids = explode(',', $data['sku_id']); + // 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'], 'cost_price' => $data['cost_price']]); + // } + // } + + // $skuList = GoodsSkuModel::getSkuList((int)$data['id']); + // [$data['goods_price_min'], $data['goods_price_max']] = GoodsSkuModel::getGoodsPrices($skuList->toArray()); + // } elseif ($detail['spec_type'] == GoodsSpecTypeEnum::SINGLE) { + + //} + $data['goods_price_min'] = $data['goods_price_max'] = $data['line_price_min'] = $data['line_price_max'] = $data['goods_price']; + $data['cost_price_min'] = $data['cost_price']; + $detail->save($data); + //更新sku的价格 + GoodsSkuModel::where('goods_id', $data['id'])->update(['cost_price'=>$data['cost_price'], 'goods_price' => $data['goods_price']]); + return true; } public function editGoodsSeckillPrice($data) { @@ -720,6 +723,7 @@ class Goods extends GoodsModel 'limit_times' => $data['limit_times'], 'sec_start_time' => $data['sec_start_time'], 'sec_end_time' => $data['sec_end_time'], + 'sec_hour' => $data['sec_hour'], ]; $skuData->save($up_data); }