!603 mall: 优惠券退还优化

Merge pull request !603 from 疯狂的世界/mall_order_cancel
This commit is contained in:
芋道源码 2023-09-03 10:04:41 +00:00 committed by Gitee
commit 670f2ef5da
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 4 additions and 2 deletions

View File

@ -115,12 +115,14 @@ public class CouponServiceImpl implements CouponService {
}
// 退还
// TODO @疯狂最好 where status避免可能存在的并发问题
Integer status = LocalDateTimeUtils.beforeNow(coupon.getValidEndTime())
// 退还时可能已经过期了
? CouponStatusEnum.EXPIRE.getStatus()
: CouponStatusEnum.UNUSED.getStatus();
couponMapper.updateById(new CouponDO().setId(id).setStatus(status));
int updateCount = couponMapper.updateByIdAndStatus(id, CouponStatusEnum.UNUSED.getStatus(), new CouponDO().setStatus(status));
if (updateCount == 0) {
throw exception(COUPON_STATUS_NOT_USED);
}
// TODO 增加优惠券变动记录
}