|
@@ -51,6 +51,7 @@ import java.math.RoundingMode;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.time.Instant;
|
|
import java.time.Instant;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
|
+import java.time.LocalDateTime;
|
|
import java.time.temporal.ChronoUnit;
|
|
import java.time.temporal.ChronoUnit;
|
|
import java.time.temporal.TemporalAdjusters;
|
|
import java.time.temporal.TemporalAdjusters;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -59,6 +60,7 @@ import java.util.function.BiConsumer;
|
|
import java.util.function.BiFunction;
|
|
import java.util.function.BiFunction;
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
import static com.yonge.cooleshow.biz.dal.support.WrapperUtil.inInterSection;
|
|
import static com.yonge.cooleshow.biz.dal.support.WrapperUtil.inInterSection;
|
|
|
|
|
|
@@ -1610,12 +1612,40 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
*/
|
|
*/
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public void scheduleTask() {
|
|
public void scheduleTask() {
|
|
- //课程开始(开课时间 ≤ NOW ≤ 结束时间)
|
|
|
|
- List<CourseSchedule> courseStart = baseMapper.selectList(Wrappers.<CourseSchedule>lambdaQuery()
|
|
|
|
|
|
+ //查询房间配置时间
|
|
|
|
+ LocalDateTime liveMinute = LocalDateTime.now().plusMinutes(Long.parseLong(sysConfigService.findConfigValue(SysConfigConstant.PRE_CREATE_LIVE_ROOM_MINUTE)));
|
|
|
|
+ LocalDateTime practiceMinute = LocalDateTime.now().plusMinutes(Long.parseLong(sysConfigService.findConfigValue(SysConfigConstant.PRE_CREATE_PRACTICE_ROOM_MINUTE)));
|
|
|
|
+ LocalDateTime pianoMinute = LocalDateTime.now().plusMinutes(Long.parseLong(sysConfigService.findConfigValue(SysConfigConstant.PRE_CREATE_PIANO_ROOM_MINUTE)));
|
|
|
|
+
|
|
|
|
+ //课程开始(开课时间 ≤ (NOW + 提前进入房间时间(分)) && NOW ≤ 结束时间)
|
|
|
|
+ List<CourseSchedule> liveStart = baseMapper.selectList(Wrappers.<CourseSchedule>lambdaQuery()
|
|
|
|
+ .eq(CourseSchedule::getLock, 0)
|
|
|
|
+ .eq(CourseSchedule::getStatus, CourseScheduleEnum.NOT_START)
|
|
|
|
+ .eq(CourseSchedule::getType, CourseScheduleEnum.LIVE)
|
|
|
|
+ .le(CourseSchedule::getStartTime, liveMinute)
|
|
|
|
+ .ge(CourseSchedule::getEndTime, LocalDateTime.now()));
|
|
|
|
+ List<CourseSchedule> practiceStart = baseMapper.selectList(Wrappers.<CourseSchedule>lambdaQuery()
|
|
|
|
+ .eq(CourseSchedule::getLock, 0)
|
|
|
|
+ .eq(CourseSchedule::getStatus, CourseScheduleEnum.NOT_START)
|
|
|
|
+ .eq(CourseSchedule::getType, CourseScheduleEnum.PRACTICE)
|
|
|
|
+ .le(CourseSchedule::getStartTime, practiceMinute)
|
|
|
|
+ .ge(CourseSchedule::getEndTime, LocalDateTime.now()));
|
|
|
|
+ List<CourseSchedule> pianoStart = baseMapper.selectList(Wrappers.<CourseSchedule>lambdaQuery()
|
|
.eq(CourseSchedule::getLock, 0)
|
|
.eq(CourseSchedule::getLock, 0)
|
|
.eq(CourseSchedule::getStatus, CourseScheduleEnum.NOT_START)
|
|
.eq(CourseSchedule::getStatus, CourseScheduleEnum.NOT_START)
|
|
- .le(CourseSchedule::getStartTime, new Date())
|
|
|
|
- .ge(CourseSchedule::getEndTime, new Date()));
|
|
|
|
|
|
+ .eq(CourseSchedule::getType, CourseScheduleEnum.PIANO_ROOM_CLASS)
|
|
|
|
+ .le(CourseSchedule::getStartTime, pianoMinute)
|
|
|
|
+ .ge(CourseSchedule::getEndTime, LocalDateTime.now()));
|
|
|
|
+ if (CollectionUtils.isEmpty(liveStart)) {
|
|
|
|
+ liveStart = new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+ if (CollectionUtils.isEmpty(practiceStart)) {
|
|
|
|
+ practiceStart = new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+ if (CollectionUtils.isEmpty(pianoStart)) {
|
|
|
|
+ pianoStart = new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+ List<CourseSchedule> courseStart = Stream.of(liveStart, practiceStart, pianoStart).flatMap(Collection::stream).collect(Collectors.toList());
|
|
if (CollectionUtils.isNotEmpty(courseStart)) {
|
|
if (CollectionUtils.isNotEmpty(courseStart)) {
|
|
//课程状态更新为ING
|
|
//课程状态更新为ING
|
|
baseMapper.updateStartTime(courseStart);
|
|
baseMapper.updateStartTime(courseStart);
|
|
@@ -1634,19 +1664,21 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
practiceList = practiceList.stream().filter(s -> !courseIds.contains(s.getCourseId())).collect(Collectors.toList());
|
|
practiceList = practiceList.stream().filter(s -> !courseIds.contains(s.getCourseId())).collect(Collectors.toList());
|
|
}
|
|
}
|
|
//创建课程评论
|
|
//创建课程评论
|
|
- repliedDao.insertBatch(practiceList);
|
|
|
|
-
|
|
|
|
- //老师课酬状态改为已完成
|
|
|
|
- courseScheduleTeacherSalaryService.update(null, Wrappers.<CourseScheduleTeacherSalary>lambdaUpdate()
|
|
|
|
- .set(CourseScheduleTeacherSalary::getStatus, TeacherSalaryEnum.WAIT.getCode())
|
|
|
|
- .in(CourseScheduleTeacherSalary::getCourseScheduleId, practiceList.stream().map(CourseScheduleStudentVo::getCourseId).collect(Collectors.toList())));
|
|
|
|
-
|
|
|
|
- //清除缓存
|
|
|
|
- for (CourseScheduleStudentVo practice : practiceList) {
|
|
|
|
- //清除学生统计缓存
|
|
|
|
- redissonClient.getBucket(CacheNameEnum.STUDENT_TOTAL.getRedisKey(practice.getStudentId())).delete();
|
|
|
|
- //清除老师统计缓存
|
|
|
|
- redissonClient.getBucket(CacheNameEnum.TEACHER_TOTAL.getRedisKey(practice.getTeacherId())).delete();
|
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(practiceList)) {
|
|
|
|
+ repliedDao.insertBatch(practiceList);
|
|
|
|
+
|
|
|
|
+ //老师课酬状态改为已完成
|
|
|
|
+ courseScheduleTeacherSalaryService.update(null, Wrappers.<CourseScheduleTeacherSalary>lambdaUpdate()
|
|
|
|
+ .set(CourseScheduleTeacherSalary::getStatus, TeacherSalaryEnum.WAIT.getCode())
|
|
|
|
+ .in(CourseScheduleTeacherSalary::getCourseScheduleId, practiceList.stream().map(CourseScheduleStudentVo::getCourseId).collect(Collectors.toList())));
|
|
|
|
+
|
|
|
|
+ //清除缓存
|
|
|
|
+ for (CourseScheduleStudentVo practice : practiceList) {
|
|
|
|
+ //清除学生统计缓存
|
|
|
|
+ redissonClient.getBucket(CacheNameEnum.STUDENT_TOTAL.getRedisKey(practice.getStudentId())).delete();
|
|
|
|
+ //清除老师统计缓存
|
|
|
|
+ redissonClient.getBucket(CacheNameEnum.TEACHER_TOTAL.getRedisKey(practice.getTeacherId())).delete();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1716,7 +1748,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public void teacherSalaryTask() {
|
|
public void teacherSalaryTask() {
|
|
//课程结算日期(天)
|
|
//课程结算日期(天)
|
|
- Integer settlementDay = Integer.valueOf(sysConfigService.findConfigValue(SysConfigConstant.COURSE_SALARY_SETTLEMENT_DAY));
|
|
|
|
|
|
+ Integer settlementDay = Integer.valueOf(sysConfigService.findConfigValue(SysConfigConstant.COURSE_SETTLEMENT_TIME_DAY));
|
|
//获取n天前日期
|
|
//获取n天前日期
|
|
String day = DateUtil.getDayAgoOrAftString(-settlementDay);
|
|
String day = DateUtil.getDayAgoOrAftString(-settlementDay);
|
|
|
|
|