Commit f6acc9dea5b2197c8095b61fde579a3b01d4257e

Authored by 芋道源码
Committed by Gitee
2 parents abfbe1ea d5c1a2ff

!1315 修复了一些问题

Merge pull request !1315 from puhui999/develop-tmp
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 22 import jakarta.annotation.Resource;
23 23 import lombok.extern.slf4j.Slf4j;
24 24 import org.springframework.stereotype.Service;
  25 +import org.springframework.transaction.annotation.Propagation;
25 26 import org.springframework.transaction.annotation.Transactional;
26 27 import org.springframework.validation.annotation.Validated;
27 28  
... ... @@ -180,7 +181,7 @@ public class CouponServiceImpl implements CouponService {
180 181 * @param couponId 模版编号
181 182 * @param userId 用户编号
182 183 */
183   - @Transactional(rollbackFor = Exception.class)
  184 + @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW) // 每次调用开启一个新的事务
184 185 public void invalidateCoupon(Long couponId, Long userId) {
185 186 if (couponId == null || couponId <= 0) {
186 187 return;
... ... @@ -270,13 +271,17 @@ public class CouponServiceImpl implements CouponService {
270 271 if (CollUtil.isEmpty(userIds)) {
271 272 throw exception(COUPON_TEMPLATE_USER_ALREADY_TAKE);
272 273 }
273   -
274 274 // 校验模板
275 275 if (couponTemplate == null) {
276 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 285 && couponTemplate.getTakeCount() + userIds.size() > couponTemplate.getTotalCount()) {
281 286 throw exception(COUPON_TEMPLATE_NOT_ENOUGH);
282 287 }
... ... @@ -286,10 +291,7 @@ public class CouponServiceImpl implements CouponService {
286 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 36 import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService;
37 37 import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService;
38 38 import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService;
  39 +import jakarta.annotation.Resource;
39 40 import lombok.extern.slf4j.Slf4j;
40 41 import org.springframework.context.annotation.Lazy;
41 42 import org.springframework.stereotype.Service;
... ... @@ -44,7 +45,6 @@ import org.springframework.transaction.support.TransactionSynchronization;
44 45 import org.springframework.transaction.support.TransactionSynchronizationManager;
45 46 import org.springframework.validation.annotation.Validated;
46 47  
47   -import jakarta.annotation.Resource;
48 48 import java.time.LocalDateTime;
49 49  
50 50 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
... ... @@ -386,7 +386,7 @@ public class AfterSaleServiceImpl implements AfterSaleService {
386 386 public void afterCommit() {
387 387 // 创建退款单
388 388 PayRefundCreateReqDTO createReqDTO = AfterSaleConvert.INSTANCE.convert(userIp, afterSale, tradeOrderProperties)
389   - .setReason(StrUtil.format("退款【{}】", afterSale.getSpuName()));;
  389 + .setReason(StrUtil.format("退款【{}】", afterSale.getSpuName()));
390 390 Long payRefundId = payRefundApi.createRefund(createReqDTO);
391 391 // 更新售后单的退款单号
392 392 tradeAfterSaleMapper.updateById(new AfterSaleDO().setId(afterSale.getId()).setPayRefundId(payRefundId));
... ...