release: 发布抽奖时允许报错提示 报名未结束,不允许抽奖

release-2024-04-25
huangyw 3 months ago
parent ab22e4f706
commit 09b432d278

@ -57,7 +57,9 @@ public class DrawLotteryScheduler {
taskScheduler.shutdown(); taskScheduler.shutdown();
} }
public void scheduleDraw(LocalDateTime drawTime, String id) { public String scheduleDraw(LocalDateTime drawTime, String id) {
String result = "";
ScheduledFuture<?> existingFuture = scheduledFutures.get(id); ScheduledFuture<?> existingFuture = scheduledFutures.get(id);
if (existingFuture != null && !existingFuture.isCancelled()) { if (existingFuture != null && !existingFuture.isCancelled()) {
@ -90,8 +92,10 @@ public class DrawLotteryScheduler {
drawLotteryService.auto(id, null); drawLotteryService.auto(id, null);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
result = e.getMessage();
} }
} }
return result;
} }
// 取消任务的方法 // 取消任务的方法

@ -27,18 +27,10 @@ public class LotteryUpdateDto implements Serializable {
@NotBlank @NotBlank
private String id; private String id;
@ApiModelProperty(value = "抽奖编码")
@NotBlank
private String code;
@ApiModelProperty(value = "标题") @ApiModelProperty(value = "标题")
@NotBlank @NotBlank
private String title; private String title;
@ApiModelProperty(value = "抽奖类型 1-门票抽奖 2-实物抽奖")
@NotNull
private Integer type;
@ApiModelProperty(value = "奖品总数量") @ApiModelProperty(value = "奖品总数量")
private Integer num; private Integer num;
@ -86,10 +78,6 @@ public class LotteryUpdateDto implements Serializable {
@NotBlank @NotBlank
private String description; private String description;
@ApiModelProperty(value = "抽奖状态 0-编辑中 1-报名中 2-已抽奖 3-已停止")
@NotNull
private Integer status;
@ApiModelProperty(value = "停止原因") @ApiModelProperty(value = "停止原因")
private String stopReason; private String stopReason;

@ -247,7 +247,10 @@ public class LotteryService {
lotteryDao.save(lottery); 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.setUpdateUser(userLoginDto.getUserId());
lottery.setUpdateUserName(userLoginDto.getNickName()); lottery.setUpdateUserName(userLoginDto.getNickName());
lottery.setStopReason(stopReason); lottery.setStopReason(stopReason);
lottery.setStatus(PointEnums.LOTTERY_STATUS_SIGN.getCode());
lotteryDao.save(lottery); lotteryDao.save(lottery);

Loading…
Cancel
Save