603 mall: 优惠券退还优化

This commit is contained in:
YunaiV 2023-09-03 18:06:15 +08:00
parent 670f2ef5da
commit 482a84a6f1
2 changed files with 5 additions and 4 deletions

View File

@ -54,7 +54,7 @@ public class CouponTemplateBaseVO {
@InEnum(PromotionProductScopeEnum.class) @InEnum(PromotionProductScopeEnum.class)
private Integer productScope; private Integer productScope;
@Schema(description = "商品范围编号的数组", example = "1,3") @Schema(description = "商品范围编号的数组", example = "[1, 3]")
private List<Long> productScopeValues; private List<Long> productScopeValues;
@Schema(description = "生效日期类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "生效日期类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")

View File

@ -93,6 +93,7 @@ public class CouponServiceImpl implements CouponService {
public void useCoupon(Long id, Long userId, Long orderId) { public void useCoupon(Long id, Long userId, Long orderId) {
// 校验优惠劵 // 校验优惠劵
validCoupon(id, userId); validCoupon(id, userId);
// 更新状态 // 更新状态
int updateCount = couponMapper.updateByIdAndStatus(id, CouponStatusEnum.UNUSED.getStatus(), int updateCount = couponMapper.updateByIdAndStatus(id, CouponStatusEnum.UNUSED.getStatus(),
new CouponDO().setStatus(CouponStatusEnum.USED.getStatus()) new CouponDO().setStatus(CouponStatusEnum.USED.getStatus())
@ -116,10 +117,10 @@ public class CouponServiceImpl implements CouponService {
// 退还 // 退还
Integer status = LocalDateTimeUtils.beforeNow(coupon.getValidEndTime()) Integer status = LocalDateTimeUtils.beforeNow(coupon.getValidEndTime())
// 退还时可能已经过期了 ? CouponStatusEnum.EXPIRE.getStatus() // 退还时可能已经过期了
? CouponStatusEnum.EXPIRE.getStatus()
: CouponStatusEnum.UNUSED.getStatus(); : CouponStatusEnum.UNUSED.getStatus();
int updateCount = couponMapper.updateByIdAndStatus(id, CouponStatusEnum.UNUSED.getStatus(), new CouponDO().setStatus(status)); int updateCount = couponMapper.updateByIdAndStatus(id, CouponStatusEnum.UNUSED.getStatus(),
new CouponDO().setStatus(status));
if (updateCount == 0) { if (updateCount == 0) {
throw exception(COUPON_STATUS_NOT_USED); throw exception(COUPON_STATUS_NOT_USED);
} }