From d9bdc105ab67eb094fe30e227984035d1dddcbee Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Mon, 15 May 2023 14:30:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E6=98=BE=E7=A4=BA=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=9B=B4=E6=96=B0=E6=B7=BB=E5=8A=A0=E4=BA=8B=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repositories/store/product/ProductRepository.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/common/repositories/store/product/ProductRepository.php b/app/common/repositories/store/product/ProductRepository.php index f7e67b4f..0c003b8b 100644 --- a/app/common/repositories/store/product/ProductRepository.php +++ b/app/common/repositories/store/product/ProductRepository.php @@ -1555,8 +1555,16 @@ class ProductRepository extends BaseRepository throw new ValidateException('商品正在参与预售活动'); if ($status == 1 && $product['product_type'] == 3) throw new ValidateException('商品正在参与助力活动'); - $this->dao->update($id,[$field => $status]); - app()->make(SpuRepository::class)->changeStatus($id,$product->product_type); + Db::startTrans(); + if ($this->dao->update($id, [$field => $status]) === false) { + Db::rollback(); + throw new ValidateException('商品更新出错'); + } + if (app()->make(SpuRepository::class)->changeStatus($id, $product->product_type) === false) { + Db::rollback(); + throw new ValidateException('商品spu更新出错'); + } + Db::commit(); } public function batchSwitchShow($id, $status, $field, $merId = 0)