|
@@ -337,40 +337,64 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
Date expiredDate = DateUtil.addMinutes(room.getLiveEndTime(), Integer.parseInt(expiredMinuteStr));
|
|
|
//当前时间 大于(结束播时间 + 设置的过期分钟数)
|
|
|
if (now.getTime() >= expiredDate.getTime()) {
|
|
|
- //删除房间
|
|
|
- destroyLiveRoom(room.getRoomUid());
|
|
|
- //查询老师分润表
|
|
|
- List<CourseScheduleTeacherSalary> salaryList = courseScheduleTeacherSalaryService.list(Wrappers.<CourseScheduleTeacherSalary>lambdaQuery()
|
|
|
- .eq(CourseScheduleTeacherSalary::getCourseScheduleId, room.getCourseId())
|
|
|
- );
|
|
|
- if (CollectionUtils.isEmpty(salaryList)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- salaryList.forEach(salary -> {
|
|
|
- //查询该学生及课程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.getActualSalary());//扣除手续费后所得金额
|
|
|
- userAccountRecord.setOrderNo(payment.getOrderNo());
|
|
|
- userAccountService.accountChange(userAccountRecord);
|
|
|
- //修改教师课酬状态-已结算
|
|
|
- salary.setStatus(TeacherSalaryEnum.COMPLETE.getCode());
|
|
|
- courseScheduleTeacherSalaryService.updateById(salary);
|
|
|
- });
|
|
|
+ destroyLiveRoom(room);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 关闭直播间
|
|
|
+ *
|
|
|
+ * @param roomUId 房间uid
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void destroyLiveRoom(String roomUId) {
|
|
|
+ LiveRoom liveRoom = this.getOne(Wrappers.<LiveRoom>lambdaQuery().eq(LiveRoom::getRoomUid, roomUId));
|
|
|
+ destroyLiveRoom(liveRoom);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 关闭直播间
|
|
|
+ *
|
|
|
+ * @param room 房间信息
|
|
|
+ */
|
|
|
+ private void destroyLiveRoom(LiveRoom room) {
|
|
|
+ if (Objects.isNull(room)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //查询老师分润表
|
|
|
+ List<CourseScheduleTeacherSalary> salaryList = courseScheduleTeacherSalaryService.list(Wrappers.<CourseScheduleTeacherSalary>lambdaQuery()
|
|
|
+ .eq(CourseScheduleTeacherSalary::getCourseScheduleId, room.getCourseId())
|
|
|
+ );
|
|
|
+ if (CollectionUtils.isEmpty(salaryList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ salaryList.forEach(salary -> {
|
|
|
+ //查询该学生及课程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.getActualSalary());//扣除手续费后所得金额
|
|
|
+ userAccountRecord.setOrderNo(payment.getOrderNo());
|
|
|
+ userAccountService.accountChange(userAccountRecord);
|
|
|
+ //修改教师课酬状态-已结算
|
|
|
+ salary.setStatus(TeacherSalaryEnum.COMPLETE.getCode());
|
|
|
+ courseScheduleTeacherSalaryService.updateById(salary);
|
|
|
});
|
|
|
+ //删除房间
|
|
|
+ ImDestroyLiveRoom(room.getRoomUid());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -398,7 +422,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
//当前时间 大于(结束播时间 + 设置的过期分钟数)
|
|
|
if (now.getTime() >= expiredDate.getTime()) {
|
|
|
//删除房间
|
|
|
- destroyLiveRoom(room.getRoomUid());
|
|
|
+ ImDestroyLiveRoom(room.getRoomUid());
|
|
|
//查询老师分润表
|
|
|
CourseScheduleTeacherSalary salary = courseScheduleTeacherSalaryService.getOne(Wrappers.<CourseScheduleTeacherSalary>lambdaQuery()
|
|
|
.eq(CourseScheduleTeacherSalary::getCourseScheduleId, room.getCourseId())
|
|
@@ -433,7 +457,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
*
|
|
|
* @param roomId 房间Uid
|
|
|
*/
|
|
|
- private void destroyLiveRoom(String roomId) {
|
|
|
+ private void ImDestroyLiveRoom(String roomId) {
|
|
|
try {
|
|
|
//删除服务器房间
|
|
|
List<String> deleteRoomIds = Lists.newArrayList(roomId);
|