|
@@ -6,14 +6,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
import com.yonge.cooleshow.biz.dal.dao.LiveRoomDao;
|
|
import com.yonge.cooleshow.biz.dal.dao.LiveRoomDao;
|
|
-import com.yonge.cooleshow.biz.dal.dto.CheckCourseTimeDto;
|
|
|
|
|
|
+import com.yonge.cooleshow.biz.dal.dto.UserAccountRecordDto;
|
|
import com.yonge.cooleshow.biz.dal.entity.*;
|
|
import com.yonge.cooleshow.biz.dal.entity.*;
|
|
-import com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum;
|
|
|
|
-import com.yonge.cooleshow.biz.dal.enums.RoomTypeEnum;
|
|
|
|
-import com.yonge.cooleshow.biz.dal.service.CourseGroupService;
|
|
|
|
-import com.yonge.cooleshow.biz.dal.service.CourseScheduleService;
|
|
|
|
-import com.yonge.cooleshow.biz.dal.service.LiveRoomService;
|
|
|
|
-import com.yonge.cooleshow.biz.dal.service.SysConfigService;
|
|
|
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.*;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.service.*;
|
|
import com.yonge.cooleshow.biz.dal.support.IMHelper;
|
|
import com.yonge.cooleshow.biz.dal.support.IMHelper;
|
|
import com.yonge.cooleshow.biz.dal.support.WrapperUtil;
|
|
import com.yonge.cooleshow.biz.dal.support.WrapperUtil;
|
|
import com.yonge.cooleshow.biz.dal.vo.RoomVo;
|
|
import com.yonge.cooleshow.biz.dal.vo.RoomVo;
|
|
@@ -62,6 +58,16 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
private CourseScheduleService courseScheduleService;
|
|
private CourseScheduleService courseScheduleService;
|
|
@Autowired
|
|
@Autowired
|
|
private SysConfigService sysConfigService;
|
|
private SysConfigService sysConfigService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private UserAccountService userAccountService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private CourseScheduleTeacherSalaryService courseScheduleTeacherSalaryService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private CourseScheduleStudentPaymentService courseScheduleStudentPaymentService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private StudentAttendanceService studentAttendanceService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private TeacherAttendanceService teacherAttendanceService;
|
|
|
|
|
|
//生成房间UID
|
|
//生成房间UID
|
|
public static BiFunction<Long, RoomTypeEnum, String> GenRoomUid = (userId, en) -> String.join("-", COOLESHOW, en.getCode(), userId.toString(), new Date().getTime() + "");
|
|
public static BiFunction<Long, RoomTypeEnum, String> GenRoomUid = (userId, en) -> String.join("-", COOLESHOW, en.getCode(), userId.toString(), new Date().getTime() + "");
|
|
@@ -204,7 +210,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
Boolean check = WrapperUtil.inInterSection(now, now, course.getStartTime(), course.getEndTime(), false);
|
|
Boolean check = WrapperUtil.inInterSection(now, now, course.getStartTime(), course.getEndTime(), false);
|
|
if (check) {
|
|
if (check) {
|
|
//如果当前时间和课程时间有交集则不能开启临时直播
|
|
//如果当前时间和课程时间有交集则不能开启临时直播
|
|
- throw new BizException("当前有陪练课无法开启直播");
|
|
|
|
|
|
+ throw new BizException("当前有课无法开启直播");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -242,6 +248,8 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
String configValue = sysConfigService.findConfigValue(PRE_CREATE_LIVE_ROOM_MINUTE);
|
|
String configValue = sysConfigService.findConfigValue(PRE_CREATE_LIVE_ROOM_MINUTE);
|
|
roomCache.setExpiredMinute(Integer.parseInt(configValue));
|
|
roomCache.setExpiredMinute(Integer.parseInt(configValue));
|
|
roomCache.setRoomType(room.getType());
|
|
roomCache.setRoomType(room.getType());
|
|
|
|
+ roomCache.setCourseId(room.getCourseId());
|
|
|
|
+ roomCache.setCourseGroupId(room.getCourseGroupId());
|
|
|
|
|
|
//写入房间信息
|
|
//写入房间信息
|
|
redissonClient.getBucket(LIVE_ROOM_INFO.replace(ROOM_UID, room.getRoomUid()))
|
|
redissonClient.getBucket(LIVE_ROOM_INFO.replace(ROOM_UID, room.getRoomUid()))
|
|
@@ -299,6 +307,34 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
if (now.getTime() >= expiredDate.getTime()) {
|
|
if (now.getTime() >= expiredDate.getTime()) {
|
|
//删除房间
|
|
//删除房间
|
|
destroyLiveRoom(room.getRoomUid());
|
|
destroyLiveRoom(room.getRoomUid());
|
|
|
|
+ //查询老师分润表
|
|
|
|
+ CourseScheduleTeacherSalary salary = courseScheduleTeacherSalaryService.getOne(Wrappers.<CourseScheduleTeacherSalary>lambdaQuery()
|
|
|
|
+ .eq(CourseScheduleTeacherSalary::getCourseScheduleId, room.getCourseId())
|
|
|
|
+ );
|
|
|
|
+ if (Objects.isNull(salary)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ //查询该学生及课程id 对应的支付订单号
|
|
|
|
+ CourseScheduleStudentPayment payment = courseScheduleStudentPaymentService.getOne(Wrappers.<CourseScheduleStudentPayment>lambdaQuery()
|
|
|
|
+ .eq(CourseScheduleStudentPayment::getCourseId, room.getCourseId())
|
|
|
|
+ .eq(CourseScheduleStudentPayment::getUserId, salary.getStudentId())
|
|
|
|
+ );
|
|
|
|
+ if (Objects.isNull(payment)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ //获取教师课酬写入到金额变更表
|
|
|
|
+ UserAccountRecordDto userAccountRecord = new UserAccountRecordDto();
|
|
|
|
+ userAccountRecord.setUserId(room.getSpeakerId());
|
|
|
|
+ userAccountRecord.setInOrOut(InOrOutEnum.IN);
|
|
|
|
+ userAccountRecord.setBizType(AccountBizTypeEnum.LIVE);
|
|
|
|
+ userAccountRecord.setBizId(room.getCourseId());
|
|
|
|
+ userAccountRecord.setBizName(room.getRoomTitle());
|
|
|
|
+ userAccountRecord.setTransAmount(salary.getExpectSalary());//扣除手续费后所得金额
|
|
|
|
+ userAccountRecord.setOrderNo(payment.getOrderNo());
|
|
|
|
+ userAccountService.accountChange(userAccountRecord);
|
|
|
|
+ //修改老师课酬表
|
|
|
|
+ salary.setStatus(TeacherSalaryEnum.COMPLETE.getCode());
|
|
|
|
+ courseScheduleTeacherSalaryService.updateById(salary);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -325,7 +361,6 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
log.info("destroyLiveRoom success: {}", roomId);
|
|
log.info("destroyLiveRoom success: {}", roomId);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* <p>主讲人处理进入和退出房间数据
|
|
* <p>主讲人处理进入和退出房间数据
|
|
* <p>观看者只处理退出房间数据
|
|
* <p>观看者只处理退出房间数据
|
|
@@ -369,28 +404,52 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
RoomInfoCache roomInfo = roomInfoCache.get();
|
|
RoomInfoCache roomInfo = roomInfoCache.get();
|
|
|
|
+ //用户id
|
|
|
|
+ Long userId = Long.valueOf(userIdStr);
|
|
//主讲人
|
|
//主讲人
|
|
if (roomInfo.getSpeakerId().toString().equals(userIdStr)) {
|
|
if (roomInfo.getSpeakerId().toString().equals(userIdStr)) {
|
|
|
|
+ //进退房间写老师考勤表
|
|
|
|
+ TeacherAttendance teacherAttendance = teacherAttendanceService.getOne(Wrappers.<TeacherAttendance>lambdaQuery()
|
|
|
|
+ .eq(TeacherAttendance::getTeacherId, userId)
|
|
|
|
+ .eq(TeacherAttendance::getCourseScheduleId, roomInfo.getCourseId()));
|
|
//主讲人进入房间
|
|
//主讲人进入房间
|
|
if (user.getStatus().equals("0")) {
|
|
if (user.getStatus().equals("0")) {
|
|
roomInfo.setSpeakerState(0);
|
|
roomInfo.setSpeakerState(0);
|
|
roomInfo.setJoinRoomTime(now);
|
|
roomInfo.setJoinRoomTime(now);
|
|
log.info("opsRoom>>>> join roomInfo {}", JSONObject.toJSONString(roomInfo));
|
|
log.info("opsRoom>>>> join roomInfo {}", JSONObject.toJSONString(roomInfo));
|
|
roomInfoCache.set(roomInfo);
|
|
roomInfoCache.set(roomInfo);
|
|
|
|
+ //查询老师是否有进入过,没有则写老师考勤表的进入时间
|
|
|
|
+ if (Objects.isNull(teacherAttendance)) {
|
|
|
|
+ setTeacherAttendance(userId, roomInfo.getCourseGroupId(), roomInfo.getCourseId());
|
|
|
|
+ }
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
roomInfo.setSpeakerState(1);
|
|
roomInfo.setSpeakerState(1);
|
|
roomInfo.setExitRoomTime(now);
|
|
roomInfo.setExitRoomTime(now);
|
|
log.info("opsRoom>>>> exit roomInfo {}", JSONObject.toJSONString(roomInfo));
|
|
log.info("opsRoom>>>> exit roomInfo {}", JSONObject.toJSONString(roomInfo));
|
|
roomInfoCache.set(roomInfo);
|
|
roomInfoCache.set(roomInfo);
|
|
|
|
+ if (Objects.isNull(teacherAttendance)) {
|
|
|
|
+ teacherAttendance = new TeacherAttendance();
|
|
|
|
+ teacherAttendance.setTeacherId(userId);
|
|
|
|
+ teacherAttendance.setCourseGroupType(CourseScheduleEnum.LIVE.getCode());
|
|
|
|
+ teacherAttendance.setCourseGroupId(roomInfo.getCourseGroupId());
|
|
|
|
+ teacherAttendance.setCourseScheduleId(roomInfo.getCourseId());
|
|
|
|
+ teacherAttendance.setSignInTime(now);
|
|
|
|
+ teacherAttendance.setSignOutTime(now);
|
|
|
|
+ teacherAttendance.setCreateTime(now);
|
|
|
|
+ teacherAttendanceService.save(teacherAttendance);
|
|
|
|
+ } else {
|
|
|
|
+ //修改老师考勤表
|
|
|
|
+ teacherAttendance.setSignOutTime(now);
|
|
|
|
+ teacherAttendance.setUpdateTime(now);
|
|
|
|
+ teacherAttendanceService.updateById(teacherAttendance);
|
|
|
|
+ }
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- //观看者只接受退出消息 status=0 是进入房间
|
|
|
|
|
|
+ //观看者只需要接收退出房间的消息 status=0进入房间
|
|
if (user.getStatus().equals("0")) {
|
|
if (user.getStatus().equals("0")) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- //观看者
|
|
|
|
- Long userId = Long.valueOf(userIdStr);
|
|
|
|
//从房间累计用户信息中查询该用户的信息
|
|
//从房间累计用户信息中查询该用户的信息
|
|
RMap<Long, RoomUserInfoCache> roomTotalUser = redissonClient.getMap(LIVE_ROOM_TOTAL_USER_LIST.replace(ROOM_UID, roomUid));
|
|
RMap<Long, RoomUserInfoCache> roomTotalUser = redissonClient.getMap(LIVE_ROOM_TOTAL_USER_LIST.replace(ROOM_UID, roomUid));
|
|
//该房间未查询到用户数据则不处理
|
|
//该房间未查询到用户数据则不处理
|
|
@@ -418,6 +477,8 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
userInfo.setLastOutTime(now);
|
|
userInfo.setLastOutTime(now);
|
|
userInfo.setState(1);
|
|
userInfo.setState(1);
|
|
roomTotalUser.fastPut(userId, userInfo);
|
|
roomTotalUser.fastPut(userId, userInfo);
|
|
|
|
+ //todo 写学生考勤表
|
|
|
|
+
|
|
log.info("opsRoom>>>> looker userInfo: {}", JSONObject.toJSONString(userInfo));
|
|
log.info("opsRoom>>>> looker userInfo: {}", JSONObject.toJSONString(userInfo));
|
|
});
|
|
});
|
|
|
|
|
|
@@ -459,8 +520,13 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
roomInfo.setSpeakerState(0);
|
|
roomInfo.setSpeakerState(0);
|
|
roomInfo.setJoinRoomTime(now);
|
|
roomInfo.setJoinRoomTime(now);
|
|
roomInfoCache.set(roomInfo);
|
|
roomInfoCache.set(roomInfo);
|
|
|
|
+ //查询老师是否有进入过,没有则写老师考勤表的进入时间
|
|
|
|
+ setTeacherAttendance(userId, roomInfo.getCourseGroupId(), roomInfo.getCourseId());
|
|
return roomInfo;
|
|
return roomInfo;
|
|
}
|
|
}
|
|
|
|
+ //todo 查询是否是临时直播间,临时直播间可以直接进入教师
|
|
|
|
+ //todo 校验观看者是否可以进入该房间,查询该学员购买成功则有权限进入该房间
|
|
|
|
+
|
|
|
|
|
|
//房间累计用户信息-指只要进入到该房间的用户都要记录
|
|
//房间累计用户信息-指只要进入到该房间的用户都要记录
|
|
RMap<Long, RoomUserInfoCache> roomTotalUser = redissonClient.getMap(LIVE_ROOM_TOTAL_USER_LIST.replace(ROOM_UID, roomUid));
|
|
RMap<Long, RoomUserInfoCache> roomTotalUser = redissonClient.getMap(LIVE_ROOM_TOTAL_USER_LIST.replace(ROOM_UID, roomUid));
|
|
@@ -476,6 +542,8 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
userInfo.setUserId(sysUser.getId());
|
|
userInfo.setUserId(sysUser.getId());
|
|
userInfo.setUserName(sysUser.getRealName());
|
|
userInfo.setUserName(sysUser.getRealName());
|
|
userInfo.setFirstJoinTime(now);
|
|
userInfo.setFirstJoinTime(now);
|
|
|
|
+ //查询学生是否有进入过,没有则写学生考勤表的进入时间
|
|
|
|
+ setStudentAttendance(userId, roomInfo.getCourseGroupId(), roomInfo.getCourseId());
|
|
}
|
|
}
|
|
userInfo.setState(0);//0:在房间 1:不在房间
|
|
userInfo.setState(0);//0:在房间 1:不在房间
|
|
userInfo.setDynamicJoinTime(now);
|
|
userInfo.setDynamicJoinTime(now);
|
|
@@ -485,6 +553,55 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 查询学生是否有进入过,没有则写学生考勤表的进入时间
|
|
|
|
+ *
|
|
|
|
+ * @param studentId 学生id
|
|
|
|
+ * @param courseGroupId 课程组id
|
|
|
|
+ * @param courseId 课程id
|
|
|
|
+ */
|
|
|
|
+ private void setStudentAttendance(Long studentId, Long courseGroupId, Long courseId) {
|
|
|
|
+ Date now = new Date();
|
|
|
|
+ //写学生第一次进入时间
|
|
|
|
+ StudentAttendance studentAttendance = studentAttendanceService.getOne(Wrappers.<StudentAttendance>lambdaQuery()
|
|
|
|
+ .eq(StudentAttendance::getStudentId, studentId)
|
|
|
|
+ .eq(StudentAttendance::getCourseScheduleId, courseId));
|
|
|
|
+ if (Objects.isNull(studentAttendance)) {
|
|
|
|
+ studentAttendance = new StudentAttendance();
|
|
|
|
+ studentAttendance.setCourseGroupType(CourseScheduleEnum.LIVE.getCode());
|
|
|
|
+ studentAttendance.setCourseGroupId(courseGroupId);
|
|
|
|
+ studentAttendance.setCourseScheduleId(courseId);
|
|
|
|
+ studentAttendance.setStudentId(studentId);
|
|
|
|
+ studentAttendance.setSignInTime(now);
|
|
|
|
+ studentAttendance.setCreateTime(now);
|
|
|
|
+ studentAttendanceService.save(studentAttendance);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询老师是否有进入过,没有则写老师考勤表的进入时间
|
|
|
|
+ *
|
|
|
|
+ * @param teacherId 老师id
|
|
|
|
+ * @param courseGroupId 课程组id
|
|
|
|
+ * @param courseId 课程id
|
|
|
|
+ */
|
|
|
|
+ private void setTeacherAttendance(Long teacherId, Long courseGroupId, Long courseId) {
|
|
|
|
+ TeacherAttendance teacherAttendance = teacherAttendanceService.getOne(Wrappers.<TeacherAttendance>lambdaQuery()
|
|
|
|
+ .eq(TeacherAttendance::getTeacherId, teacherId)
|
|
|
|
+ .eq(TeacherAttendance::getCourseScheduleId, courseId));
|
|
|
|
+ if (Objects.isNull(teacherAttendance)) {
|
|
|
|
+ Date now = new Date();
|
|
|
|
+ teacherAttendance = new TeacherAttendance();
|
|
|
|
+ teacherAttendance.setTeacherId(teacherId);
|
|
|
|
+ teacherAttendance.setCourseGroupType(CourseScheduleEnum.LIVE.getCode());
|
|
|
|
+ teacherAttendance.setCourseGroupId(courseGroupId);
|
|
|
|
+ teacherAttendance.setCourseScheduleId(courseId);
|
|
|
|
+ teacherAttendance.setSignInTime(now);
|
|
|
|
+ teacherAttendance.setCreateTime(now);
|
|
|
|
+ teacherAttendanceService.save(teacherAttendance);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 发送消息
|
|
* 发送消息
|
|
*
|
|
*
|
|
* @param message
|
|
* @param message
|
|
@@ -575,16 +692,15 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
public Map<String, Object> test(String roomUid) {
|
|
public Map<String, Object> test(String roomUid) {
|
|
//result
|
|
//result
|
|
Map<String, Object> result = new HashMap<>();
|
|
Map<String, Object> result = new HashMap<>();
|
|
- //{"day":"01","month":"05","year":"2022","singleCourseMinutes":60,"teacherId":4}
|
|
|
|
- Map<String, Object> param = new HashMap<>();
|
|
|
|
- param.put("day", "05");
|
|
|
|
- param.put("month", "06");
|
|
|
|
- param.put("year", "2022");
|
|
|
|
- param.put("teacherId", "174");
|
|
|
|
- param.put("studentId", 164);
|
|
|
|
- List<CourseCalendarEntity> courseTimeEntities = courseScheduleService.createPracticeCourseCalender(param);
|
|
|
|
|
|
+// Map<String, Object> param = new HashMap<>();
|
|
|
|
+// param.put("day", "05");
|
|
|
|
+// param.put("month", "06");
|
|
|
|
+// param.put("year", "2022");
|
|
|
|
+// param.put("teacherId", "174");
|
|
|
|
+// param.put("studentId", 164);
|
|
|
|
+// List<CourseCalendarEntity> courseTimeEntities = courseScheduleService.createPracticeCourseCalender(param);
|
|
// List<CourseCalendarEntity> courseTimeEntities = courseScheduleService.createLiveCourseCalendar(param);
|
|
// List<CourseCalendarEntity> courseTimeEntities = courseScheduleService.createLiveCourseCalendar(param);
|
|
- result.put("自动生成课时", courseTimeEntities);
|
|
|
|
|
|
+// result.put("自动生成课时", courseTimeEntities);
|
|
|
|
|
|
//获取房间信息
|
|
//获取房间信息
|
|
RBucket<RoomInfoCache> speakerCache = redissonClient.getBucket(LIVE_ROOM_INFO.replace(ROOM_UID, roomUid));
|
|
RBucket<RoomInfoCache> speakerCache = redissonClient.getBucket(LIVE_ROOM_INFO.replace(ROOM_UID, roomUid));
|