Commit d5c1a2ff9f356dfe7dde4d15af21441dedd83072
1 parent
09aa6b25
【缺陷修复】商城:订单取消收回优惠券失败导致管理员确认退款不成功的问题
Showing
2 changed files
with
4 additions
and
3 deletions
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java
| @@ -22,6 +22,7 @@ import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityType | @@ -22,6 +22,7 @@ import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityType | ||
| 22 | import jakarta.annotation.Resource; | 22 | import jakarta.annotation.Resource; |
| 23 | import lombok.extern.slf4j.Slf4j; | 23 | import lombok.extern.slf4j.Slf4j; |
| 24 | import org.springframework.stereotype.Service; | 24 | import org.springframework.stereotype.Service; |
| 25 | +import org.springframework.transaction.annotation.Propagation; | ||
| 25 | import org.springframework.transaction.annotation.Transactional; | 26 | import org.springframework.transaction.annotation.Transactional; |
| 26 | import org.springframework.validation.annotation.Validated; | 27 | import org.springframework.validation.annotation.Validated; |
| 27 | 28 | ||
| @@ -176,7 +177,7 @@ public class CouponServiceImpl implements CouponService { | @@ -176,7 +177,7 @@ public class CouponServiceImpl implements CouponService { | ||
| 176 | * @param couponId 模版编号 | 177 | * @param couponId 模版编号 |
| 177 | * @param userId 用户编号 | 178 | * @param userId 用户编号 |
| 178 | */ | 179 | */ |
| 179 | - @Transactional(rollbackFor = Exception.class) | 180 | + @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW) // 每次调用开启一个新的事务 |
| 180 | public void invalidateCoupon(Long couponId, Long userId) { | 181 | public void invalidateCoupon(Long couponId, Long userId) { |
| 181 | // 1.1 校验优惠券 | 182 | // 1.1 校验优惠券 |
| 182 | CouponDO coupon = couponMapper.selectByIdAndUserId(couponId, userId); | 183 | CouponDO coupon = couponMapper.selectByIdAndUserId(couponId, userId); |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleServiceImpl.java
| @@ -36,6 +36,7 @@ import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties | @@ -36,6 +36,7 @@ import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties | ||
| 36 | import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; | 36 | import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; |
| 37 | import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; | 37 | import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; |
| 38 | import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; | 38 | import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; |
| 39 | +import jakarta.annotation.Resource; | ||
| 39 | import lombok.extern.slf4j.Slf4j; | 40 | import lombok.extern.slf4j.Slf4j; |
| 40 | import org.springframework.context.annotation.Lazy; | 41 | import org.springframework.context.annotation.Lazy; |
| 41 | import org.springframework.stereotype.Service; | 42 | import org.springframework.stereotype.Service; |
| @@ -44,7 +45,6 @@ import org.springframework.transaction.support.TransactionSynchronization; | @@ -44,7 +45,6 @@ import org.springframework.transaction.support.TransactionSynchronization; | ||
| 44 | import org.springframework.transaction.support.TransactionSynchronizationManager; | 45 | import org.springframework.transaction.support.TransactionSynchronizationManager; |
| 45 | import org.springframework.validation.annotation.Validated; | 46 | import org.springframework.validation.annotation.Validated; |
| 46 | 47 | ||
| 47 | -import jakarta.annotation.Resource; | ||
| 48 | import java.time.LocalDateTime; | 48 | import java.time.LocalDateTime; |
| 49 | 49 | ||
| 50 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 50 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| @@ -386,7 +386,7 @@ public class AfterSaleServiceImpl implements AfterSaleService { | @@ -386,7 +386,7 @@ public class AfterSaleServiceImpl implements AfterSaleService { | ||
| 386 | public void afterCommit() { | 386 | public void afterCommit() { |
| 387 | // 创建退款单 | 387 | // 创建退款单 |
| 388 | PayRefundCreateReqDTO createReqDTO = AfterSaleConvert.INSTANCE.convert(userIp, afterSale, tradeOrderProperties) | 388 | PayRefundCreateReqDTO createReqDTO = AfterSaleConvert.INSTANCE.convert(userIp, afterSale, tradeOrderProperties) |
| 389 | - .setReason(StrUtil.format("退款【{}】", afterSale.getSpuName()));; | 389 | + .setReason(StrUtil.format("退款【{}】", afterSale.getSpuName())); |
| 390 | Long payRefundId = payRefundApi.createRefund(createReqDTO); | 390 | Long payRefundId = payRefundApi.createRefund(createReqDTO); |
| 391 | // 更新售后单的退款单号 | 391 | // 更新售后单的退款单号 |
| 392 | tradeAfterSaleMapper.updateById(new AfterSaleDO().setId(afterSale.getId()).setPayRefundId(payRefundId)); | 392 | tradeAfterSaleMapper.updateById(new AfterSaleDO().setId(afterSale.getId()).setPayRefundId(payRefundId)); |