From fa33583b3c39fb9a72eeb2d3a0006ab3b726b7b0 Mon Sep 17 00:00:00 2001 From: ztt <835303992@qq.com> Date: Wed, 28 Feb 2024 11:42:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E8=A7=84=E6=A0=BC=E5=95=86=E5=93=81?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/model/Goods.php | 11 +++++-- app/common/model/store/shop/Comment.php | 43 +++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 app/common/model/store/shop/Comment.php diff --git a/app/api/model/Goods.php b/app/api/model/Goods.php index 2d568cf6..e5065b68 100644 --- a/app/api/model/Goods.php +++ b/app/api/model/Goods.php @@ -656,10 +656,15 @@ class Goods extends GoodsModel $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']]); + //批量修改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'], '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()); diff --git a/app/common/model/store/shop/Comment.php b/app/common/model/store/shop/Comment.php new file mode 100644 index 00000000..a54d3981 --- /dev/null +++ b/app/common/model/store/shop/Comment.php @@ -0,0 +1,43 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\common\model\store\shop; + +use cores\BaseModel; +use think\model\relation\BelongsTo; + +/** + * 商家门店评论模型 + * Class Clerk + * @package app\common\model\store + */ +class Comment extends BaseModel +{ + // 定义表名 + protected $name = 'store_shop_comment'; + + // 定义主键 + protected $pk = 'id'; + + protected $updateTime = false; + + /** + * 关联门店记录 + * @return BelongsTo + */ + public function shop(): BelongsTo + { + $module = static::getCalledModule(); + return $this->BelongsTo("app\\{$module}\\model\\store\\Shop", 'shop_id'); + } + +}