Commit f6acc9dea5b2197c8095b61fde579a3b01d4257e
Committed by
Gitee
!1315 修复了一些问题
Merge pull request !1315 from puhui999/develop-tmp
Showing
2 changed files
with
11 additions
and
9 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 | ||
| @@ -180,7 +181,7 @@ public class CouponServiceImpl implements CouponService { | @@ -180,7 +181,7 @@ public class CouponServiceImpl implements CouponService { | ||
| 180 | * @param couponId 模版编号 | 181 | * @param couponId 模版编号 |
| 181 | * @param userId 用户编号 | 182 | * @param userId 用户编号 |
| 182 | */ | 183 | */ |
| 183 | - @Transactional(rollbackFor = Exception.class) | 184 | + @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW) // 每次调用开启一个新的事务 |
| 184 | public void invalidateCoupon(Long couponId, Long userId) { | 185 | public void invalidateCoupon(Long couponId, Long userId) { |
| 185 | if (couponId == null || couponId <= 0) { | 186 | if (couponId == null || couponId <= 0) { |
| 186 | return; | 187 | return; |
| @@ -270,13 +271,17 @@ public class CouponServiceImpl implements CouponService { | @@ -270,13 +271,17 @@ public class CouponServiceImpl implements CouponService { | ||
| 270 | if (CollUtil.isEmpty(userIds)) { | 271 | if (CollUtil.isEmpty(userIds)) { |
| 271 | throw exception(COUPON_TEMPLATE_USER_ALREADY_TAKE); | 272 | throw exception(COUPON_TEMPLATE_USER_ALREADY_TAKE); |
| 272 | } | 273 | } |
| 273 | - | ||
| 274 | // 校验模板 | 274 | // 校验模板 |
| 275 | if (couponTemplate == null) { | 275 | if (couponTemplate == null) { |
| 276 | throw exception(COUPON_TEMPLATE_NOT_EXISTS); | 276 | throw exception(COUPON_TEMPLATE_NOT_EXISTS); |
| 277 | } | 277 | } |
| 278 | + // 校验领取方式 | ||
| 279 | + if (ObjUtil.notEqual(couponTemplate.getTakeType(), takeType.getType())) { | ||
| 280 | + throw exception(COUPON_TEMPLATE_CANNOT_TAKE); | ||
| 281 | + } | ||
| 278 | // 校验剩余数量 | 282 | // 校验剩余数量 |
| 279 | - if (ObjUtil.notEqual(couponTemplate.getTakeLimitCount(), CouponTemplateDO.TIME_LIMIT_COUNT_MAX) // 非不限制 | 283 | + if (ObjUtil.equal(CouponTakeTypeEnum.USER.getType(), couponTemplate.getTakeType()) // 直接领取 |
| 284 | + && ObjUtil.notEqual(couponTemplate.getTakeLimitCount(), CouponTemplateDO.TIME_LIMIT_COUNT_MAX) // 非不限制 | ||
| 280 | && couponTemplate.getTakeCount() + userIds.size() > couponTemplate.getTotalCount()) { | 285 | && couponTemplate.getTakeCount() + userIds.size() > couponTemplate.getTotalCount()) { |
| 281 | throw exception(COUPON_TEMPLATE_NOT_ENOUGH); | 286 | throw exception(COUPON_TEMPLATE_NOT_ENOUGH); |
| 282 | } | 287 | } |
| @@ -286,10 +291,7 @@ public class CouponServiceImpl implements CouponService { | @@ -286,10 +291,7 @@ public class CouponServiceImpl implements CouponService { | ||
| 286 | throw exception(COUPON_TEMPLATE_EXPIRED); | 291 | throw exception(COUPON_TEMPLATE_EXPIRED); |
| 287 | } | 292 | } |
| 288 | } | 293 | } |
| 289 | - // 校验领取方式 | ||
| 290 | - if (ObjectUtil.notEqual(couponTemplate.getTakeType(), takeType.getType())) { | ||
| 291 | - throw exception(COUPON_TEMPLATE_CANNOT_TAKE); | ||
| 292 | - } | 294 | + |
| 293 | } | 295 | } |
| 294 | 296 | ||
| 295 | /** | 297 | /** |
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)); |