| | |
| | | // 秒杀已经开始 |
| | | if (LocalDateTime.now().isAfter(startTime)) { |
| | | handleStartDelayTask(id, DelayTaskEnum.SECKILL_START_TASK, startTime, 3L); |
| | | log.info(">>>>>>>>>>>>>>>>>>>>秒杀商品:{} 开始秒杀<<<<<<<<<<<<<<<<<<<<", id); |
| | | } else { |
| | | Duration duration = Duration.between(LocalDateTime.now(), startTime); |
| | | handleStartDelayTask(id, DelayTaskEnum.SECKILL_START_TASK, startTime, |
| | | duration.getSeconds()); |
| | | } |
| | | log.info(">>>>>>>>>>>>>>>>>>>>秒杀商品:{} 开始秒杀<<<<<<<<<<<<<<<<<<<<", id); |
| | | // 秒杀结束延时任务 |
| | | handleEndDelayTask(id, DelayTaskEnum.SECKILL_END_TASK, endTime); |
| | | } |
| | |
| | | } |
| | | |
| | | private boolean isWithinOneHour(LocalDateTime startTime) { |
| | | LocalDateTime checkTime = LocalDateTime.now().plusHours(1); |
| | | LocalDateTime checkTime = LocalDateTime.now().plusMinutes(61); |
| | | return checkTime.isAfter(startTime); |
| | | } |
| | | |
| | |
| | | startDelayTask.setExecuteTime(LocalDateTime.now().plusSeconds(timeout)); |
| | | startDelayTask.setRedisKey( |
| | | startTaskKey); |
| | | sysUserClient.addDelayTask(startDelayTask, SecurityConstants.INNER); |
| | | |
| | | } |
| | | } |
| | | redisService.setCacheObject(startTaskKey, startTime, timeout, TimeUnit.SECONDS); |