新增后台管理系统(答辩用
This commit is contained in:
+67
@@ -0,0 +1,67 @@
|
||||
package cn.novalon.gym.manage.groupcourse.scheduler;
|
||||
|
||||
import cn.novalon.gym.manage.groupcourse.service.IGroupCourseService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 团课超时与自动结课定时任务
|
||||
*
|
||||
* 功能:
|
||||
* 1. 检查已超时未开课的课程,标记为超时并返还用户权益
|
||||
* 2. 检查已超时未结课的课程,自动结课并发送教练警告
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-06-23
|
||||
*/
|
||||
@Component
|
||||
public class GroupCourseTimeoutScheduler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GroupCourseTimeoutScheduler.class);
|
||||
|
||||
private final IGroupCourseService groupCourseService;
|
||||
|
||||
public GroupCourseTimeoutScheduler(IGroupCourseService groupCourseService) {
|
||||
this.groupCourseService = groupCourseService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 每分钟检查一次超时未开课的课程
|
||||
* 超时条件:status='0' 且 actual_start_time IS NULL 且 start_time + 10分钟 < 当前时间
|
||||
*/
|
||||
@Scheduled(fixedRate = 60000)
|
||||
public void checkAndHandleTimeoutCourses() {
|
||||
logger.debug("定时任务开始检查超时未开课的团课");
|
||||
|
||||
groupCourseService.processTimeoutCourses()
|
||||
.subscribe(
|
||||
count -> {
|
||||
if (count > 0) {
|
||||
logger.warn("定时任务完成,处理了 {} 个超时团课,已返还用户权益", count);
|
||||
}
|
||||
},
|
||||
error -> logger.error("超时团课处理定时任务执行失败:{}", error.getMessage(), error)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 每分钟检查一次需要自动结课的课程
|
||||
* 自动结课条件:status='3'(进行中) 且 actual_end_time IS NULL 且 end_time + 10分钟 < 当前时间
|
||||
*/
|
||||
@Scheduled(fixedRate = 60000)
|
||||
public void checkAndHandleAutoEndCourses() {
|
||||
logger.debug("定时任务开始检查需要自动结课的团课");
|
||||
|
||||
groupCourseService.processAutoEndCourses()
|
||||
.subscribe(
|
||||
count -> {
|
||||
if (count > 0) {
|
||||
logger.warn("定时任务完成,自动结课 {} 个团课,请通知相关教练", count);
|
||||
}
|
||||
},
|
||||
error -> logger.error("自动结课定时任务执行失败:{}", error.getMessage(), error)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user