|  | @@ -1,21 +1,26 @@
 | 
											
												
													
														|  |  package com.yonge.cooleshow.biz.dal.service.impl;
 |  |  package com.yonge.cooleshow.biz.dal.service.impl;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  import com.alibaba.fastjson.JSONObject;
 |  |  import com.alibaba.fastjson.JSONObject;
 | 
											
												
													
														|  | 
 |  | +import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
											
												
													
														|  |  import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 |  |  import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 | 
											
												
													
														|  | 
 |  | +import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
											
												
													
														|  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 |  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
											
												
													
														|  |  import com.beust.jcommander.internal.Lists;
 |  |  import com.beust.jcommander.internal.Lists;
 | 
											
												
													
														|  |  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.UserAccountRecordDto;
 |  | 
 | 
											
												
													
														|  |  import com.yonge.cooleshow.biz.dal.entity.*;
 |  |  import com.yonge.cooleshow.biz.dal.entity.*;
 | 
											
												
													
														|  | -import com.yonge.cooleshow.biz.dal.enums.*;
 |  | 
 | 
											
												
													
														|  | 
 |  | +import com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum;
 | 
											
												
													
														|  | 
 |  | +import com.yonge.cooleshow.biz.dal.enums.OrderStatusEnum;
 | 
											
												
													
														|  | 
 |  | +import com.yonge.cooleshow.biz.dal.enums.RoomTypeEnum;
 | 
											
												
													
														|  | 
 |  | +import com.yonge.cooleshow.biz.dal.enums.TeacherSalaryEnum;
 | 
											
												
													
														|  |  import com.yonge.cooleshow.biz.dal.service.*;
 |  |  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.UserOrderVo;
 |  |  import com.yonge.cooleshow.biz.dal.vo.UserOrderVo;
 | 
											
												
													
														|  |  import com.yonge.toolset.base.exception.BizException;
 |  |  import com.yonge.toolset.base.exception.BizException;
 | 
											
												
													
														|  | 
 |  | +import com.yonge.toolset.base.page.PageInfo;
 | 
											
												
													
														|  | 
 |  | +import com.yonge.toolset.mybatis.support.PageUtil;
 | 
											
												
													
														|  |  import com.yonge.toolset.utils.date.DateUtil;
 |  |  import com.yonge.toolset.utils.date.DateUtil;
 | 
											
												
													
														|  |  import org.apache.commons.collections.CollectionUtils;
 |  |  import org.apache.commons.collections.CollectionUtils;
 | 
											
												
													
														|  |  import org.apache.commons.lang3.StringUtils;
 |  |  import org.apache.commons.lang3.StringUtils;
 | 
											
										
											
												
													
														|  | @@ -24,7 +29,6 @@ import org.redisson.api.RMap;
 | 
											
												
													
														|  |  import org.redisson.api.RedissonClient;
 |  |  import org.redisson.api.RedissonClient;
 | 
											
												
													
														|  |  import org.slf4j.Logger;
 |  |  import org.slf4j.Logger;
 | 
											
												
													
														|  |  import org.slf4j.LoggerFactory;
 |  |  import org.slf4j.LoggerFactory;
 | 
											
												
													
														|  | -import org.springframework.beans.BeanUtils;
 |  | 
 | 
											
												
													
														|  |  import org.springframework.beans.factory.annotation.Autowired;
 |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
											
												
													
														|  |  import org.springframework.stereotype.Service;
 |  |  import org.springframework.stereotype.Service;
 | 
											
												
													
														|  |  import org.springframework.transaction.annotation.Transactional;
 |  |  import org.springframework.transaction.annotation.Transactional;
 | 
											
										
											
												
													
														|  | @@ -36,7 +40,8 @@ import java.util.function.Function;
 | 
											
												
													
														|  |  import java.util.stream.Collectors;
 |  |  import java.util.stream.Collectors;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  import static com.yonge.cooleshow.biz.dal.constant.LiveRoomConstant.*;
 |  |  import static com.yonge.cooleshow.biz.dal.constant.LiveRoomConstant.*;
 | 
											
												
													
														|  | -import static com.yonge.cooleshow.common.constant.SysConfigConstant.*;
 |  | 
 | 
											
												
													
														|  | 
 |  | +import static com.yonge.cooleshow.common.constant.SysConfigConstant.DESTROY_EXPIRED_LIVE_ROOM_MINUTE;
 | 
											
												
													
														|  | 
 |  | +import static com.yonge.cooleshow.common.constant.SysConfigConstant.PRE_CREATE_LIVE_ROOM_MINUTE;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
												
													
														|  |   * 直播房间与课程的关系表表(LiveRoom)表服务实现类
 |  |   * 直播房间与课程的关系表表(LiveRoom)表服务实现类
 | 
											
										
											
												
													
														|  | @@ -61,8 +66,6 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
												
													
														|  |      private SysConfigService sysConfigService;
 |  |      private SysConfigService sysConfigService;
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
												
													
														|  | -    private UserAccountService userAccountService;
 |  | 
 | 
											
												
													
														|  | -    @Autowired
 |  | 
 | 
											
												
													
														|  |      private UserOrderService userOrderService;
 |  |      private UserOrderService userOrderService;
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
												
													
														|  |      private CourseScheduleTeacherSalaryService courseScheduleTeacherSalaryService;
 |  |      private CourseScheduleTeacherSalaryService courseScheduleTeacherSalaryService;
 | 
											
										
											
												
													
														|  | @@ -88,23 +91,23 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      /**
 |  |      /**
 | 
											
												
													
														|  | -     * 根据房间uid查询房间信息
 |  | 
 | 
											
												
													
														|  | 
 |  | +     * 分页查询当前用户关联的房间信息
 | 
											
												
													
														|  |       *
 |  |       *
 | 
											
												
													
														|  | -     * @param roomUid 房间uid
 |  | 
 | 
											
												
													
														|  | 
 |  | +     * @param param 参数
 | 
											
												
													
														|  | 
 |  | +     *              <p>roomType 房间类型  LIVE-直播课  TEMP-临时直播间
 | 
											
												
													
														|  | 
 |  | +     *              <p>page 页数
 | 
											
												
													
														|  | 
 |  | +     *              <p>rows 每页数量
 | 
											
												
													
														|  |       */
 |  |       */
 | 
											
												
													
														|  |      @Override
 |  |      @Override
 | 
											
												
													
														|  | -    public RoomVo queryRoomInfo(String roomUid) {
 |  | 
 | 
											
												
													
														|  | -        LiveRoom liveRoom = this.getOne(Wrappers.<LiveRoom>lambdaQuery()
 |  | 
 | 
											
												
													
														|  | -                .eq(LiveRoom::getRoomUid, roomUid));
 |  | 
 | 
											
												
													
														|  | -        if (liveRoom == null) {
 |  | 
 | 
											
												
													
														|  | -            throw new BizException("房间不存在");
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -        RoomVo roomVo = new RoomVo();
 |  | 
 | 
											
												
													
														|  | -        BeanUtils.copyProperties(liveRoom, roomVo);
 |  | 
 | 
											
												
													
														|  | -        roomVo.setSpeakerName(getSysUser(liveRoom.getSpeakerId()).getRealName());
 |  | 
 | 
											
												
													
														|  | -        roomVo.setLikeNum(getLike(roomUid));
 |  | 
 | 
											
												
													
														|  | -        roomVo.setLookNum(getNum.apply(this::getOnlineUserCache, roomUid));
 |  | 
 | 
											
												
													
														|  | -        return roomVo;
 |  | 
 | 
											
												
													
														|  | 
 |  | +    public PageInfo<LiveRoom> queryPageRoom(Map<String, Object> param) {
 | 
											
												
													
														|  | 
 |  | +        String roomType = WrapperUtil.toStr(param, "roomType");
 | 
											
												
													
														|  | 
 |  | +        Long userId = getSysUser().getId();
 | 
											
												
													
														|  | 
 |  | +        Page<LiveRoom> pageInfo = PageUtil.getPageInfo(param);
 | 
											
												
													
														|  | 
 |  | +        IPage<LiveRoom> page = this.page(pageInfo, Wrappers.<LiveRoom>lambdaQuery()
 | 
											
												
													
														|  | 
 |  | +                .eq(WrapperUtil.StrPredicate.test(roomType), LiveRoom::getType, roomType)
 | 
											
												
													
														|  | 
 |  | +                .eq(LiveRoom::getSpeakerId, userId)
 | 
											
												
													
														|  | 
 |  | +        );
 | 
											
												
													
														|  | 
 |  | +        return PageUtil.pageInfo(page);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      /**
 |  |      /**
 | 
											
										
											
												
													
														|  | @@ -210,12 +213,21 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
 | 
											
												
													
														|  |      public String createTempLiveRoom(Map<String, Object> param) {
 |  |      public String createTempLiveRoom(Map<String, Object> param) {
 | 
											
												
													
														|  |          //查询主讲人信息
 |  |          //查询主讲人信息
 | 
											
												
													
														|  |          SysUser sysUser = getSysUser();
 |  |          SysUser sysUser = getSysUser();
 | 
											
												
													
														|  | 
 |  | +        Long teacherId = sysUser.getId();
 | 
											
												
													
														|  | 
 |  | +        List<LiveRoom> liveRoomList = this.list(Wrappers.<LiveRoom>lambdaQuery()
 | 
											
												
													
														|  | 
 |  | +                .eq(LiveRoom::getSpeakerId, teacherId)
 | 
											
												
													
														|  | 
 |  | +                .eq(LiveRoom::getType, RoomTypeEnum.TEMP.getCode())
 | 
											
												
													
														|  | 
 |  | +                .eq(LiveRoom::getLiveState, 1)
 | 
											
												
													
														|  | 
 |  | +                .eq(LiveRoom::getRoomState, 0)
 | 
											
												
													
														|  | 
 |  | +        );
 | 
											
												
													
														|  | 
 |  | +        if (CollectionUtils.isNotEmpty(liveRoomList)) {
 | 
											
												
													
														|  | 
 |  | +            throw new BizException("当前有直播间未结束,无需创建直播!");
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  |          String roomTitle = WrapperUtil.toStr(param, "roomTitle", "房间标题不能为空!");
 |  |          String roomTitle = WrapperUtil.toStr(param, "roomTitle", "房间标题不能为空!");
 | 
											
												
													
														|  |          String liveRemark = WrapperUtil.toStr(param, "liveRemark", "直播间描述不能为空!");
 |  |          String liveRemark = WrapperUtil.toStr(param, "liveRemark", "直播间描述不能为空!");
 | 
											
												
													
														|  |          Integer liveTime = WrapperUtil.toInt(param, "liveTime", "请选择直播时长!");
 |  |          Integer liveTime = WrapperUtil.toInt(param, "liveTime", "请选择直播时长!");
 | 
											
												
													
														|  |          Date liveStartTime = new Date();
 |  |          Date liveStartTime = new Date();
 | 
											
												
													
														|  |          Date liveEndTime = DateUtil.addMinutes(liveStartTime, liveTime);
 |  |          Date liveEndTime = DateUtil.addMinutes(liveStartTime, liveTime);
 | 
											
												
													
														|  | -        Long teacherId = sysUser.getId();
 |  | 
 | 
											
												
													
														|  |          //当前时间有课程则不能开启直播
 |  |          //当前时间有课程则不能开启直播
 | 
											
												
													
														|  |          boolean check = courseScheduleService.checkTeacherCourseTime(teacherId, liveStartTime, liveEndTime);
 |  |          boolean check = courseScheduleService.checkTeacherCourseTime(teacherId, liveStartTime, liveEndTime);
 | 
											
												
													
														|  |          if (check) {
 |  |          if (check) {
 | 
											
										
											
												
													
														|  | @@ -233,7 +245,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
 | 
											
												
													
														|  |          room.setSpeakerId(teacherId);
 |  |          room.setSpeakerId(teacherId);
 | 
											
												
													
														|  |          room.setLiveStartTime(liveStartTime);
 |  |          room.setLiveStartTime(liveStartTime);
 | 
											
												
													
														|  |          room.setLiveEndTime(liveEndTime);
 |  |          room.setLiveEndTime(liveEndTime);
 | 
											
												
													
														|  | -        room.setLiveState(0);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        room.setLiveState(1);
 | 
											
												
													
														|  |          room.setRoomState(0);
 |  |          room.setRoomState(0);
 | 
											
												
													
														|  |          room.setCreatedBy(teacherId);
 |  |          room.setCreatedBy(teacherId);
 | 
											
												
													
														|  |          room.setCreatedTime(liveStartTime);
 |  |          room.setCreatedTime(liveStartTime);
 | 
											
										
											
												
													
														|  | @@ -327,14 +339,18 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
 | 
											
												
													
														|  |          List<LiveRoom> list = this.list(Wrappers.<LiveRoom>lambdaQuery()
 |  |          List<LiveRoom> list = this.list(Wrappers.<LiveRoom>lambdaQuery()
 | 
											
												
													
														|  |                  .eq(LiveRoom::getRoomState, 0)
 |  |                  .eq(LiveRoom::getRoomState, 0)
 | 
											
												
													
														|  |                  .eq(LiveRoom::getLiveState, 1)
 |  |                  .eq(LiveRoom::getLiveState, 1)
 | 
											
												
													
														|  | -                .eq(LiveRoom::getType, RoomTypeEnum.LIVE.getCode())
 |  | 
 | 
											
												
													
														|  |                  .le(LiveRoom::getLiveEndTime, now));
 |  |                  .le(LiveRoom::getLiveEndTime, now));
 | 
											
												
													
														|  |          if (CollectionUtils.isEmpty(list)) {
 |  |          if (CollectionUtils.isEmpty(list)) {
 | 
											
												
													
														|  |              return;
 |  |              return;
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          list.forEach(room -> {
 |  |          list.forEach(room -> {
 | 
											
												
													
														|  | -            Date expiredDate = DateUtil.addMinutes(room.getLiveEndTime(), Integer.parseInt(expiredMinuteStr));
 |  | 
 | 
											
												
													
														|  | -            //当前时间 大于(结束播时间 + 设置的过期分钟数)
 |  | 
 | 
											
												
													
														|  | 
 |  | +            //直播间过期时间
 | 
											
												
													
														|  | 
 |  | +            Date expiredDate = room.getLiveEndTime();
 | 
											
												
													
														|  | 
 |  | +            if (room.getType().equals(RoomTypeEnum.LIVE.getCode())) {
 | 
											
												
													
														|  | 
 |  | +                //如果是直播课,那么结束时间 = 直播间结束时间 + 设置的过期分钟数
 | 
											
												
													
														|  | 
 |  | +                expiredDate = DateUtil.addMinutes(room.getLiveEndTime(), Integer.parseInt(expiredMinuteStr));
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +            //当前时间 大于 直播间过期时间
 | 
											
												
													
														|  |              if (now.getTime() >= expiredDate.getTime()) {
 |  |              if (now.getTime() >= expiredDate.getTime()) {
 | 
											
												
													
														|  |                  destroyLiveRoom(room);
 |  |                  destroyLiveRoom(room);
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
										
											
												
													
														|  | @@ -362,93 +378,26 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
 | 
											
												
													
														|  |          if (Objects.isNull(room)) {
 |  |          if (Objects.isNull(room)) {
 | 
											
												
													
														|  |              return;
 |  |              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 (room.getType().equals(RoomTypeEnum.LIVE.getCode())) {
 | 
											
												
													
														|  | 
 |  | +            //查询老师分润表
 | 
											
												
													
														|  | 
 |  | +            List<CourseScheduleTeacherSalary> salaryList = courseScheduleTeacherSalaryService.list(Wrappers.<CourseScheduleTeacherSalary>lambdaQuery()
 | 
											
												
													
														|  | 
 |  | +                    .eq(CourseScheduleTeacherSalary::getCourseScheduleId, room.getCourseId())
 | 
											
												
													
														|  |              );
 |  |              );
 | 
											
												
													
														|  | -            if (Objects.isNull(payment)) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +            if (CollectionUtils.isEmpty(salaryList)) {
 | 
											
												
													
														|  |                  return;
 |  |                  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);
 |  | 
 | 
											
												
													
														|  | -        });
 |  | 
 | 
											
												
													
														|  | 
 |  | +            salaryList.forEach(salary -> {
 | 
											
												
													
														|  | 
 |  | +                //修改教师课酬状态-已结算
 | 
											
												
													
														|  | 
 |  | +                salary.setStatus(TeacherSalaryEnum.WAIT.getCode());
 | 
											
												
													
														|  | 
 |  | +                courseScheduleTeacherSalaryService.updateById(salary);
 | 
											
												
													
														|  | 
 |  | +            });
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  |          //删除房间
 |  |          //删除房间
 | 
											
												
													
														|  |          ImDestroyLiveRoom(room.getRoomUid());
 |  |          ImDestroyLiveRoom(room.getRoomUid());
 | 
											
												
													
														|  | -    }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -    /**
 |  | 
 | 
											
												
													
														|  | -     * 定时任务-清理过期的房间-陪练课
 |  | 
 | 
											
												
													
														|  | -     */
 |  | 
 | 
											
												
													
														|  | -    public void destroyExpiredPracticeRoom() {
 |  | 
 | 
											
												
													
														|  | -        //查询房间过期时间
 |  | 
 | 
											
												
													
														|  | -        String expiredMinuteStr = sysConfigService.findConfigValue(PRE_CREATE_PRACTICE_ROOM_MINUTE);
 |  | 
 | 
											
												
													
														|  | -        if (StringUtils.isEmpty(expiredMinuteStr)) {
 |  | 
 | 
											
												
													
														|  | -            log.info("roomDestroy>>>> 未查询到配置:{}", PRE_CREATE_PRACTICE_ROOM_MINUTE);
 |  | 
 | 
											
												
													
														|  | -            return;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -        Date now = new Date();
 |  | 
 | 
											
												
													
														|  | -        //查询已经开始并且没有删除及销毁的直播间
 |  | 
 | 
											
												
													
														|  | -        List<LiveRoom> list = this.list(Wrappers.<LiveRoom>lambdaQuery()
 |  | 
 | 
											
												
													
														|  | -                .eq(LiveRoom::getRoomState, 0)
 |  | 
 | 
											
												
													
														|  | -                .eq(LiveRoom::getLiveState, 1)
 |  | 
 | 
											
												
													
														|  | -                .eq(LiveRoom::getType, RoomTypeEnum.PRACTICE.getCode())
 |  | 
 | 
											
												
													
														|  | -                .le(LiveRoom::getLiveEndTime, now));
 |  | 
 | 
											
												
													
														|  | -        if (CollectionUtils.isEmpty(list)) {
 |  | 
 | 
											
												
													
														|  | -            return;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -        list.forEach(room -> {
 |  | 
 | 
											
												
													
														|  | -            Date expiredDate = DateUtil.addMinutes(room.getLiveEndTime(), Integer.parseInt(expiredMinuteStr));
 |  | 
 | 
											
												
													
														|  | -            //当前时间 大于(结束播时间 + 设置的过期分钟数)
 |  | 
 | 
											
												
													
														|  | -            if (now.getTime() >= expiredDate.getTime()) {
 |  | 
 | 
											
												
													
														|  | -                //删除房间
 |  | 
 | 
											
												
													
														|  | -                ImDestroyLiveRoom(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.PRACTICE);
 |  | 
 | 
											
												
													
														|  | -                userAccountRecord.setBizId(room.getCourseId());
 |  | 
 | 
											
												
													
														|  | -                userAccountRecord.setBizName(room.getRoomTitle());
 |  | 
 | 
											
												
													
														|  | -                userAccountRecord.setTransAmount(salary.getActualSalary());//扣除手续费后所得金额
 |  | 
 | 
											
												
													
														|  | -                userAccountRecord.setOrderNo(payment.getOrderNo());
 |  | 
 | 
											
												
													
														|  | -                userAccountService.accountChange(userAccountRecord);
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | -        });
 |  | 
 | 
											
												
													
														|  | 
 |  | +        //修改房间状态
 | 
											
												
													
														|  | 
 |  | +        room.setLiveState(2);
 | 
											
												
													
														|  | 
 |  | +        this.updateById(room);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      /**
 |  |      /**
 |