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)