mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-10 08:11:52 +08:00
trade: 会员取消订单
This commit is contained in:
@@ -34,4 +34,9 @@ public class CouponApiImpl implements CouponApi {
|
||||
return CouponConvert.INSTANCE.convert(coupon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void returnUsedCoupon(Long id) {
|
||||
couponService.returnUsedCoupon(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -75,4 +75,10 @@ public interface CouponService {
|
||||
*/
|
||||
Long getUnusedCouponCount(Long userId);
|
||||
|
||||
/**
|
||||
* 退还已使用的优惠券
|
||||
*
|
||||
* @param id 优惠券编号
|
||||
*/
|
||||
void returnUsedCoupon(Long id);
|
||||
}
|
||||
|
@@ -125,4 +125,27 @@ public class CouponServiceImpl implements CouponService {
|
||||
return couponMapper.selectCountByUserIdAndStatus(userId, CouponStatusEnum.UNUSED.getStatus());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void returnUsedCoupon(Long id) {
|
||||
// 校验存在
|
||||
CouponDO coupon = couponMapper.selectById(id);
|
||||
if (coupon == null) {
|
||||
throw exception(COUPON_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 校验状态
|
||||
if (!CouponStatusEnum.USED.getStatus().equals(coupon.getStatus())) {
|
||||
throw exception(COUPON_STATUS_NOT_USED);
|
||||
}
|
||||
|
||||
// 退还
|
||||
Integer status = LocalDateTimeUtils.beforeNow(coupon.getValidEndTime())
|
||||
// 退还时可能已经过期了
|
||||
? CouponStatusEnum.EXPIRE.getStatus()
|
||||
: CouponStatusEnum.UNUSED.getStatus();
|
||||
couponMapper.updateById(new CouponDO().setId(id).setStatus(status));
|
||||
|
||||
// TODO 增加优惠券变动记录?
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user