diff --git a/luoo_common/src/main/java/constants/ErrorConstants.java b/luoo_common/src/main/java/constants/ErrorConstants.java index 77ac9f1..2dd893a 100644 --- a/luoo_common/src/main/java/constants/ErrorConstants.java +++ b/luoo_common/src/main/java/constants/ErrorConstants.java @@ -47,6 +47,7 @@ public class ErrorConstants { // 抽奖部分 public static final String CAN_NOT_EDIT = "不允许修改"; public static final String NOT_IN_THE_SIGN_UP_PERIOD = "不是报名中,不允许参与"; + public static final String NOT_IN_THE_SIGN_UP_TIME = "不在报名时间之内"; public static final String NOT_MEMBER = "非会员不能参与"; public static final String NOT_PERMANENT_MEMBER = "非永久会员不能参与"; public static final String NOT_CONTRIBUTOR = "非贡献者不能参与"; diff --git a/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java b/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java index c52318b..51f76d3 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java @@ -351,7 +351,11 @@ public class LotteryService { // 不是报名中,不允许参与 throw new BizException(ErrorConstants.NOT_IN_THE_SIGN_UP_PERIOD); } - + // 判断当前是否在报名时间范围之内 + if (lottery.getApplyStartTime().isAfter(LocalDateTime.now()) || + lottery.getApplyEndTime().isBefore(LocalDateTime.now())) { + throw new BizException(ErrorConstants.NOT_IN_THE_SIGN_UP_TIME); + } // 校验用户是否可参与 UserInfo userInfo = userInfoDao.findById(userLoginDto.getUserId()).get();