فهرست منبع

Merge branch 'master' of http://git.dayaedu.com/yonge/cooleshow

liujunchi 3 سال پیش
والد
کامیت
3b68413504

+ 0 - 6
cooleshow-common/src/main/java/com/yonge/cooleshow/common/constant/SysConfigConstant.java

@@ -140,12 +140,6 @@ public interface SysConfigConstant {
      * @updateTime 2022/4/20 11:43
      */
     String GOOD_LOGO_PIANO_ROOM = "good_logo_piano_room";
-    /***
-     * 陪练课&直播课老师课程结算日期(天)
-     * @author cy
-     * @updateTime 2022/5/24 10:03
-     */
-    String COURSE_SALARY_SETTLEMENT_DAY = "course_salary_settlement_day";
 
     /**
      * 琴房学员解绑未上课天数

+ 38 - 6
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseScheduleServiceImpl.java

@@ -51,6 +51,7 @@ import java.math.RoundingMode;
 import java.text.SimpleDateFormat;
 import java.time.Instant;
 import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.time.temporal.ChronoUnit;
 import java.time.temporal.TemporalAdjusters;
 import java.util.*;
@@ -59,6 +60,7 @@ import java.util.function.BiConsumer;
 import java.util.function.BiFunction;
 import java.util.function.Function;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 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)
     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::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)) {
             //课程状态更新为ING
             baseMapper.updateStartTime(courseStart);
@@ -1634,7 +1664,9 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
                     practiceList = practiceList.stream().filter(s -> !courseIds.contains(s.getCourseId())).collect(Collectors.toList());
                 }
                 //创建课程评论
-                repliedDao.insertBatch(practiceList);
+                if (CollectionUtils.isNotEmpty(practiceList)) {
+                    repliedDao.insertBatch(practiceList);
+                }
 
                 //老师课酬状态改为已完成
                 courseScheduleTeacherSalaryService.update(null, Wrappers.<CourseScheduleTeacherSalary>lambdaUpdate()
@@ -1716,7 +1748,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
     @Transactional(rollbackFor = Exception.class)
     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天前日期
         String day = DateUtil.getDayAgoOrAftString(-settlementDay);