feat:本年可以领取,本月使用
This commit is contained in:
1 parent
10a114cf95
commit
2d39bbe3c2
1 file changed
+38
-13
+38
-13
@@ -140,17 +140,24 @@ public class ActCouponRecordServiceImpl extends ServiceImpl<ActCouponRecordMappe
|
||||
if (ObjectUtil.isEmpty(record)) {
|
||||
throw new ServiceException("优惠券不存在");
|
||||
}
|
||||
// 2. 预处理
|
||||
ActCouponRecordEntity actCouponEntity = actCouponComUtilService.preCancel(record);
|
||||
// 2. 查询活动
|
||||
ActCouponEntity actCouponEntity = actCouponService.getById(record.getCouponId());
|
||||
if (ObjectUtil.isEmpty(actCouponEntity)) {
|
||||
throw new ServiceException("活动不存在");
|
||||
}
|
||||
// 3. 预处理
|
||||
ActCouponRecordEntity actCouponRecordEntity = actCouponComUtilService.preCancel(record);
|
||||
if (ObjectUtil.isEmpty(actCouponRecordEntity)) {
|
||||
throw new ServiceException("优惠券不存在");
|
||||
}
|
||||
// 3. 执行核销逻辑
|
||||
actCouponComUtilService.doCancel(actCouponEntity.getId(), orderId, useAmountPrice);
|
||||
// 4. 优惠券核销成功后,执行生命周期方法
|
||||
actCouponComUtilService.afterCancel(actCouponEntity);
|
||||
// 5. 核销短码
|
||||
walletCodeUseService.cancelCode(actCouponEntity.getId());
|
||||
// 4. 特殊核销
|
||||
specialCancelCoupon(actCouponEntity, actCouponRecordEntity, sysUser);
|
||||
// 5. 执行核销逻辑
|
||||
actCouponComUtilService.doCancel(actCouponRecordEntity.getId(), orderId, useAmountPrice);
|
||||
// 6. 优惠券核销成功后,执行生命周期方法
|
||||
actCouponComUtilService.afterCancel(actCouponRecordEntity);
|
||||
// 7. 核销短码
|
||||
walletCodeUseService.cancelCode(actCouponRecordEntity.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,6 +168,28 @@ public class ActCouponRecordServiceImpl extends ServiceImpl<ActCouponRecordMappe
|
||||
return actCouponComUtilService.actIsCanCancel(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 特殊核销规则
|
||||
*/
|
||||
public void specialCancelCoupon(ActCouponEntity actCouponEntity, ActCouponRecordEntity actCouponRecordEntity, SysUser sysUser) {
|
||||
String uniqueCode = actCouponEntity.getUniqueCode();
|
||||
if (ObjectUtil.equals(uniqueCode, "1qRgFo")) {
|
||||
// 只能本月核销
|
||||
LocalDate birthday = sysUser.getBirthday();
|
||||
if (ObjectUtil.isEmpty(birthday)) {
|
||||
log.info("|{}|{}用户核销{}活动失败:请填写生日", TAG, sysUser.getName(), uniqueCode);
|
||||
throw new ServiceException("请填写生日");
|
||||
}
|
||||
if (ObjectUtil.notEqual(LocalDate.now().getMonth().getValue(), birthday.getMonth().getValue())) {
|
||||
log.info("|{}|{}用户核销{}活动成功:在生日当月核销", TAG, sysUser.getName(), uniqueCode);
|
||||
throw new ServiceException("只能在生日当月核销");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 特殊领取规则
|
||||
*/
|
||||
public ActUserReceiveEnum specialCoupon(ActCouponEntity actCouponEntity, SysUser sysUser) {
|
||||
String uniqueCode = actCouponEntity.getUniqueCode();
|
||||
// 食堂生日券
|
||||
@@ -193,16 +222,12 @@ public class ActCouponRecordServiceImpl extends ServiceImpl<ActCouponRecordMappe
|
||||
log.info("|{}|{}用户参加{}活动失败:用户最近3个月没有充值{}分", TAG, sysUser.getName(), uniqueCode, walletTotalPrice);
|
||||
return ActUserReceiveEnum.USER_CANNOT_PARTICIPATE;
|
||||
}
|
||||
// 要在生日当月领取
|
||||
// 要在本年领取
|
||||
LocalDate birthday = sysUser.getBirthday();
|
||||
if (ObjectUtil.isEmpty(birthday)) {
|
||||
log.info("|{}|{}用户参加{}活动失败:请填写生日", TAG, sysUser.getName(), uniqueCode);
|
||||
return ActUserReceiveEnum.PLEASE_FILL_BIRTH_DATE;
|
||||
}
|
||||
if (ObjectUtil.notEqual(LocalDate.now().getMonth().getValue(), birthday.getMonth().getValue())) {
|
||||
log.info("|{}|{}用户参加{}活动成功:在生日当月领取", TAG, sysUser.getName(), uniqueCode);
|
||||
return ActUserReceiveEnum.PLEASE_RECEIVE_IN_BIRTH_MONTH;
|
||||
}
|
||||
return ActUserReceiveEnum.USER_CAN_JOIN_ACT;
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in new issue
Block a user