| 
					
				 | 
			
			
				@@ -49,6 +49,7 @@ import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.transaction.annotation.Propagation; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.alibaba.fastjson.JSONObject; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -698,65 +699,30 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CourseSchedule schedule = getCourseScheduleByRoomUid(room.getRoomUid()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //直播课 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (room.getType().equals(RoomTypeEnum.LIVE.getCode())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //查询老师分润表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            List<CourseScheduleTeacherSalary> salaryList = courseScheduleTeacherSalaryService.list(Wrappers.<CourseScheduleTeacherSalary>lambdaQuery() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .eq(CourseScheduleTeacherSalary::getCourseScheduleId,schedule.getId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (!CollectionUtils.isEmpty(salaryList)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                salaryList.forEach(salary -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    //修改教师课酬状态-已结算 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    salary.setStatus(TeacherSalaryEnum.WAIT.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    courseScheduleTeacherSalaryService.updateById(salary); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //修改房间状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        room.setLiveState(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        room.setRoomState(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.updateById(room); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String speakerIdStr = room.getSpeakerId().toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String roomUid = room.getRoomUid(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //关闭直播间发送消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ImRoomMessage message = new ImRoomMessage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        message.setFromUserId(speakerIdStr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        message.setToChatroomId(roomUid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        message.setClientType(ClientEnum.TEACHER.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        message.setObjectName(ImRoomMessage.FORCED_OFFLINE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        message.setContent(speakerIdStr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            this.publishRoomMessage(message); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            log.info("destroyLiveRoom>>>> FORCED_OFFLINE : {}", speakerIdStr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            log.error("destroyLiveRoom>>>>  FORCED_OFFLINE {}", e.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Date now = new Date(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //给老师签退 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        teacherAttendanceService.update(Wrappers.<TeacherAttendance>lambdaUpdate() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                .eq(TeacherAttendance::getTeacherId, room.getSpeakerId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                .eq(TeacherAttendance::getCourseScheduleId, schedule.getId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                .set(TeacherAttendance::getSignOutTime, now)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //获取在线人员信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        RMap<Long, String> onlineUserCache = this.getOnlineUserCache(roomUid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        onlineUserCache.forEach((id, s) -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //观看者签退 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            studentAttendanceService.update(Wrappers.<StudentAttendance>lambdaUpdate() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .eq(StudentAttendance::getStudentId, id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .eq(StudentAttendance::getCourseScheduleId,schedule.getId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .set(StudentAttendance::getSignOutTime, now)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        liveRoomService.closeRoom(room); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //获取所有直播间缓存数据并写入数据库后并清理缓存 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         CompletableFuture.runAsync(() -> insertAndCleanLiveData(room.getRoomUid(), room.getSpeakerId())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         log.info("roomDestroy>>>> insertAndCleanLiveData {}", JSONObject.toJSONString(room)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String speakerIdStr = room.getSpeakerId().toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String roomUid = room.getRoomUid(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //关闭直播间发送消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ImRoomMessage message = new ImRoomMessage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            message.setFromUserId(speakerIdStr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            message.setToChatroomId(roomUid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            message.setClientType(ClientEnum.TEACHER.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            message.setObjectName(ImRoomMessage.FORCED_OFFLINE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            message.setContent(speakerIdStr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                this.publishRoomMessage(message); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.info("destroyLiveRoom>>>> FORCED_OFFLINE : {}", speakerIdStr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.error("destroyLiveRoom>>>>  FORCED_OFFLINE {}", e.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             LivePluginService pluginService = livePluginContext.getPluginService(room.getServiceProvider()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //销毁直播间 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -789,6 +755,46 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void closeRoom(LiveRoom room) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        CourseSchedule schedule = getCourseScheduleByRoomUid(room.getRoomUid()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //直播课 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (room.getType().equals(RoomTypeEnum.LIVE.getCode())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //查询老师分润表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<CourseScheduleTeacherSalary> salaryList = courseScheduleTeacherSalaryService.list(Wrappers.<CourseScheduleTeacherSalary>lambdaQuery() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .eq(CourseScheduleTeacherSalary::getCourseScheduleId,schedule.getId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!CollectionUtils.isEmpty(salaryList)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (CourseScheduleTeacherSalary salary : salaryList) {//修改教师课酬状态-已结算 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    salary.setStatus(TeacherSalaryEnum.WAIT.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    courseScheduleTeacherSalaryService.updateById(salary); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //修改房间状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        room.setLiveState(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        room.setRoomState(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.updateById(room); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Date now = new Date(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //给老师签退 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        teacherAttendanceService.update(Wrappers.<TeacherAttendance>lambdaUpdate() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .eq(TeacherAttendance::getTeacherId, room.getSpeakerId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .eq(TeacherAttendance::getCourseScheduleId, schedule.getId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .set(TeacherAttendance::getSignOutTime, now)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //获取在线人员信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        RMap<Long, String> onlineUserCache = this.getOnlineUserCache(room.getRoomUid()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        onlineUserCache.forEach((id, s) -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //观看者签退 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            studentAttendanceService.update(Wrappers.<StudentAttendance>lambdaUpdate() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .eq(StudentAttendance::getStudentId, id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .eq(StudentAttendance::getCourseScheduleId,schedule.getId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .set(StudentAttendance::getSignOutTime, now)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * <p>主讲人处理进入和退出房间数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * <p>观看者只处理退出房间数据 
			 |