diff --git a/luoo_user/src/main/java/com/luoo/user/Scheduler/DrawLotteryScheduler.java b/luoo_user/src/main/java/com/luoo/user/Scheduler/DrawLotteryScheduler.java index 1d73a05..cf489e8 100644 --- a/luoo_user/src/main/java/com/luoo/user/Scheduler/DrawLotteryScheduler.java +++ b/luoo_user/src/main/java/com/luoo/user/Scheduler/DrawLotteryScheduler.java @@ -57,7 +57,9 @@ public class DrawLotteryScheduler { taskScheduler.shutdown(); } - public void scheduleDraw(LocalDateTime drawTime, String id) { + public String scheduleDraw(LocalDateTime drawTime, String id) { + + String result = ""; ScheduledFuture existingFuture = scheduledFutures.get(id); if (existingFuture != null && !existingFuture.isCancelled()) { @@ -90,8 +92,10 @@ public class DrawLotteryScheduler { drawLotteryService.auto(id, null); } catch (Exception e) { e.printStackTrace(); + result = e.getMessage(); } } + return result; } // 取消任务的方法 diff --git a/luoo_user/src/main/java/com/luoo/user/dto/point/LotteryUpdateDto.java b/luoo_user/src/main/java/com/luoo/user/dto/point/LotteryUpdateDto.java index 9432dd8..12948f2 100644 --- a/luoo_user/src/main/java/com/luoo/user/dto/point/LotteryUpdateDto.java +++ b/luoo_user/src/main/java/com/luoo/user/dto/point/LotteryUpdateDto.java @@ -27,18 +27,10 @@ public class LotteryUpdateDto implements Serializable { @NotBlank private String id; - @ApiModelProperty(value = "抽奖编码") - @NotBlank - private String code; - @ApiModelProperty(value = "标题") @NotBlank private String title; - @ApiModelProperty(value = "抽奖类型 1-门票抽奖 2-实物抽奖") - @NotNull - private Integer type; - @ApiModelProperty(value = "奖品总数量") private Integer num; @@ -86,10 +78,6 @@ public class LotteryUpdateDto implements Serializable { @NotBlank private String description; - @ApiModelProperty(value = "抽奖状态 0-编辑中 1-报名中 2-已抽奖 3-已停止") - @NotNull - private Integer status; - @ApiModelProperty(value = "停止原因") private String stopReason; 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 303cce3..cdf9f39 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 @@ -247,7 +247,10 @@ public class LotteryService { lotteryDao.save(lottery); - drawLotteryScheduler.scheduleDraw(lottery.getDrawTime(), id); + String result = drawLotteryScheduler.scheduleDraw(lottery.getDrawTime(), id); + if (StringUtils.isNotBlank(result)) { + throw new BizException(result); + } } @@ -267,7 +270,6 @@ public class LotteryService { lottery.setUpdateUser(userLoginDto.getUserId()); lottery.setUpdateUserName(userLoginDto.getNickName()); lottery.setStopReason(stopReason); - lottery.setStatus(PointEnums.LOTTERY_STATUS_SIGN.getCode()); lotteryDao.save(lottery);