浏览代码

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

liujunchi 3 年之前
父节点
当前提交
b58a5591c9

+ 9 - 4
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/LiveRoomServiceImpl.java

@@ -33,6 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.time.LocalDate;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.function.BiFunction;
@@ -156,20 +157,18 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void createCourseLiveRoom() {
-        Date now = new Date();
         //查询房间提前创建的时间
         String preCreateRoomMinute = sysConfigService.findConfigValue(PRE_CREATE_LIVE_ROOM_MINUTE);
         if (StringUtils.isEmpty(preCreateRoomMinute)) {
             log.info("roomDestroy>>>> 未查询到配置:{}", PRE_CREATE_LIVE_ROOM_MINUTE);
             return;
         }
-        Date endTime = DateUtil.addMinutes(now, Integer.parseInt(preCreateRoomMinute));
         //查询课时表生成直播间
         List<CourseSchedule> courseScheduleList = courseScheduleService.list(Wrappers.<CourseSchedule>lambdaQuery()
                 .eq(CourseSchedule::getType, CourseScheduleEnum.LIVE.getCode())
+                .eq(CourseSchedule::getStatus, CourseScheduleEnum.NOT_START.getCode())
                 .eq(CourseSchedule::getLock, 0)
-                .ge(CourseSchedule::getStartTime, now)
-                .le(CourseSchedule::getStartTime, endTime));
+                .eq(CourseSchedule::getClassDate, LocalDate.now().toString()));
         if (CollectionUtils.isEmpty(courseScheduleList)) {
             return;
         }
@@ -188,7 +187,13 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
                 });
         //生成课程对应的房间
         RoomTypeEnum en = RoomTypeEnum.LIVE;
+        Date now = new Date();
         courseScheduleList.forEach(c -> {
+            //课程开始时间-提前创建时间 = 创建房间时间
+            Date createRoomTime = DateUtil.addMinutes(c.getStartTime(), -Integer.parseInt(preCreateRoomMinute));
+            if (now.getTime() < createRoomTime.getTime()) {
+                return;
+            }
             LiveRoom room = new LiveRoom();
             room.setCourseGroupId(c.getCourseGroupId());
             room.setCourseId(c.getId());