Bladeren bron

Merge remote-tracking branch 'origin/master'

liweifan 3 jaren geleden
bovenliggende
commit
c93045163f
20 gewijzigde bestanden met toevoegingen van 330 en 201 verwijderingen
  1. 9 2
      cooleshow-api/src/main/java/com/yonge/cooleshow/api/feign/TeacherFeignService.java
  2. 9 4
      cooleshow-api/src/main/java/com/yonge/cooleshow/api/feign/fallback/TeacherFeignServiceFallback.java
  3. 22 0
      cooleshow-task/src/main/java/com/yonge/cooleshow/task/jobs/DestroyExpiredLiveRoomTask.java
  4. 22 22
      cooleshow-task/src/main/java/com/yonge/cooleshow/task/jobs/TeacherSalaryTask.java
  5. 4 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/CourseScheduleDao.java
  6. 1 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/LiveRoomVideo.java
  7. 1 7
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/enums/CourseScheduleEnum.java
  8. 2 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/enums/TeacherSalaryEnum.java
  9. 2 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/CourseScheduleService.java
  10. 11 11
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/LiveRoomService.java
  11. 9 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/LiveRoomVideoService.java
  12. 23 19
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseScheduleServiceImpl.java
  13. 57 108
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/LiveRoomServiceImpl.java
  14. 14 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/LiveRoomVideoServiceImpl.java
  15. 13 4
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TeacherFreeTimeServiceImpl.java
  16. 33 0
      cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml
  17. 13 13
      cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/TeacherLiveRoomController.java
  18. 56 0
      cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/TeacherLiveRoomVideoController.java
  19. 17 7
      cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/task/TaskController.java
  20. 12 2
      cooleshow-user/user-website/src/main/java/com/yonge/cooleshow/website/controller/LiveRoomVideoController.java

+ 9 - 2
cooleshow-api/src/main/java/com/yonge/cooleshow/api/feign/TeacherFeignService.java

@@ -27,6 +27,13 @@ public interface TeacherFeignService {
     HttpResponseResult<Object> opsCourseGroup();
 
     /**
+     * 定时任务-销毁房间-直播间
+     * 每分钟执行一次
+     */
+    @GetMapping(value = "/task/destroyExpiredLiveRoom")
+    HttpResponseResult<Object> destroyExpiredLiveRoom();
+
+    /**
      * @Description: 课程提醒(每晚9点)
      * @Author: cy
      * @Date: 2022/5/6
@@ -47,6 +54,6 @@ public interface TeacherFeignService {
      * @Author: cy
      * @Date: 2022/5/24
      */
-//    @GetMapping("/task/teacherSalary")
-//    HttpResponseResult<Object> teacherSalary();
+    @GetMapping("/task/teacherSalary")
+    HttpResponseResult<Object> teacherSalary();
 }

+ 9 - 4
cooleshow-api/src/main/java/com/yonge/cooleshow/api/feign/fallback/TeacherFeignServiceFallback.java

@@ -18,6 +18,11 @@ public class TeacherFeignServiceFallback implements TeacherFeignService {
     }
 
     @Override
+    public HttpResponseResult<Object> destroyExpiredLiveRoom() {
+        return null;
+    }
+
+    @Override
     public HttpResponseResult<Object> courseRemind() {
         return null;
     }
@@ -27,8 +32,8 @@ public class TeacherFeignServiceFallback implements TeacherFeignService {
         return null;
     }
 
-//    @Override
-//    public HttpResponseResult<Object> teacherSalary() {
-//        return null;
-//    }
+    @Override
+    public HttpResponseResult<Object> teacherSalary() {
+        return null;
+    }
 }

+ 22 - 0
cooleshow-task/src/main/java/com/yonge/cooleshow/task/jobs/DestroyExpiredLiveRoomTask.java

@@ -0,0 +1,22 @@
+package com.yonge.cooleshow.task.jobs;
+
+import com.yonge.cooleshow.api.feign.TeacherFeignService;
+import com.yonge.cooleshow.task.core.BaseTask;
+import com.yonge.cooleshow.task.core.TaskException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Author: liweifan
+ * @Data: 2022/4/25 10:30
+ */
+@Service
+public class DestroyExpiredLiveRoomTask extends BaseTask {
+    @Autowired
+    private TeacherFeignService teacherFeignService;
+
+    @Override
+    public void execute() throws TaskException {
+        teacherFeignService.destroyExpiredLiveRoom();
+    }
+}

+ 22 - 22
cooleshow-task/src/main/java/com/yonge/cooleshow/task/jobs/TeacherSalaryTask.java

@@ -1,22 +1,22 @@
-//package com.yonge.cooleshow.task.jobs;
-//
-//import com.yonge.cooleshow.api.feign.TeacherFeignService;
-//import com.yonge.cooleshow.task.core.BaseTask;
-//import com.yonge.cooleshow.task.core.TaskException;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.stereotype.Service;
-//
-///**
-// * @Author: cy
-// * @Date: 2022/5/24
-// */
-//@Service
-//public class TeacherSalaryTask extends BaseTask {
-//    @Autowired
-//    private TeacherFeignService teacherFeignService;
-//
-//    @Override
-//    public void execute() throws TaskException {
-//        teacherFeignService.teacherSalary();
-//    }
-//}
+package com.yonge.cooleshow.task.jobs;
+
+import com.yonge.cooleshow.api.feign.TeacherFeignService;
+import com.yonge.cooleshow.task.core.BaseTask;
+import com.yonge.cooleshow.task.core.TaskException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Author: cy
+ * @Date: 2022/5/24
+ */
+@Service
+public class TeacherSalaryTask extends BaseTask {
+    @Autowired
+    private TeacherFeignService teacherFeignService;
+
+    @Override
+    public void execute() throws TaskException {
+        teacherFeignService.teacherSalary();
+    }
+}

+ 4 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/CourseScheduleDao.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.dto.PracticeScheduleDto;
+import com.yonge.cooleshow.biz.dal.dto.UserAccountRecordDto;
 import com.yonge.cooleshow.biz.dal.dto.search.HomeworkSearch;
 import com.yonge.cooleshow.biz.dal.dto.search.MyCourseSearch;
 import com.yonge.cooleshow.biz.dal.dto.search.PracticeTeacherSearch;
@@ -231,4 +232,7 @@ public interface CourseScheduleDao extends BaseMapper<CourseSchedule> {
 
     //查琴房课列表
     List<PianoClassVo> queryPianoClass(IPage page,@Param("param") MyCourseSearch search);
+
+    //查询待结算课程
+    List<UserAccountRecordDto> selectWaitCourse(String day);
 }

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/LiveRoomVideo.java

@@ -51,7 +51,7 @@ public class LiveRoomVideo implements Serializable {
     private Date endTime;
 
     @TableField("type")
-    @ApiModelProperty(value = "1: 录制开始;2: 录制切片;3: 录制结束;4: 文件上传-融云回调完成;0开始录制  1录制结束 2融云回调完成")
+    @ApiModelProperty(value = "1: 录制开始;2: 录制切片;3: 录制结束;4: 文件上传-融云回调完成")
     private Integer type;
 
     @TableField("created_time_")

+ 1 - 7
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/enums/CourseScheduleEnum.java

@@ -42,13 +42,7 @@ public enum CourseScheduleEnum implements BaseEnum<String, CourseScheduleEnum> {
         CourseScheduleEnum[] values = {PRACTICE, LIVE, PIANO_ROOM_CLASS};
         existCourse(values, code, errMsg);
         //返回枚举对象
-        if (code.equals(CourseScheduleEnum.PRACTICE.getCode())) {
-            return CourseScheduleEnum.PRACTICE;
-        } else if (code.equals(CourseScheduleEnum.LIVE.getCode())) {
-            return CourseScheduleEnum.LIVE;
-        } else {
-            return CourseScheduleEnum.PIANO_ROOM_CLASS;
-        }
+        return CourseScheduleEnum.valueOf(code);
     }
 
     /**

+ 2 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/enums/TeacherSalaryEnum.java

@@ -8,9 +8,10 @@ import com.yonge.toolset.base.enums.BaseEnum;
  */
 public enum TeacherSalaryEnum implements BaseEnum<String, TeacherSalaryEnum> {
     //未上课-还未开始上课等待上课结束后结算
-    NOT_START("未结算"),
+    NOT_START("未开始"),
     //已结算-已经结算完成
     COMPLETE("已结算"),
+    WAIT("未结算"),
     //已取消-学生发起退款等等其他操作
     CANCEL("已取消");
 

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/CourseScheduleService.java

@@ -236,6 +236,8 @@ public interface CourseScheduleService extends IService<CourseSchedule> {
 
     void scheduleTask();
 
+    void teacherSalaryTask();
+
     PianoRoomTimeVo selectRemainTime(Long teacherId);
 
     PageInfo<CourseStudentVo> selectStudent(Map<String, Object> param);

+ 11 - 11
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/LiveRoomService.java

@@ -2,9 +2,11 @@ package com.yonge.cooleshow.biz.dal.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.yonge.cooleshow.biz.dal.dao.LiveRoomDao;
-import com.yonge.cooleshow.biz.dal.entity.*;
-import com.yonge.cooleshow.biz.dal.vo.RoomVo;
-import org.springframework.transaction.annotation.Transactional;
+import com.yonge.cooleshow.biz.dal.entity.ImRoomMessage;
+import com.yonge.cooleshow.biz.dal.entity.ImUserStateSync;
+import com.yonge.cooleshow.biz.dal.entity.LiveRoom;
+import com.yonge.cooleshow.biz.dal.entity.RoomInfoCache;
+import com.yonge.toolset.base.page.PageInfo;
 
 import java.util.List;
 import java.util.Map;
@@ -20,11 +22,14 @@ public interface LiveRoomService extends IService<LiveRoom> {
     LiveRoomDao getDao();
 
     /**
-     * 根据房间uid查询房间信息
+     * 分页查询当前用户关联的房间信息
      *
-     * @param roomUid 房间uid
+     * @param param 参数
+     *              <p>roomType 房间类型  LIVE-直播课  TEMP-临时直播间
+     *              <p>page 页数
+     *              <p>rows 每页数量
      */
-    RoomVo queryRoomInfo(String roomUid);
+    PageInfo<LiveRoom> queryPageRoom(Map<String, Object> param);
 
     /**
      * 校验房间信息,及个人信息
@@ -60,11 +65,6 @@ public interface LiveRoomService extends IService<LiveRoom> {
     void destroyLiveRoom(String roomUId);
 
     /**
-     * 定时任务-清理过期的房间-陪练课
-     */
-    void destroyExpiredPracticeRoom();
-
-    /**
      * 创建临时房间-直播间
      */
     String createTempLiveRoom(Map<String, Object> param);

+ 9 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/LiveRoomVideoService.java

@@ -5,6 +5,8 @@ import com.yonge.cooleshow.biz.dal.dao.LiveRoomVideoDao;
 import com.yonge.cooleshow.biz.dal.entity.LiveRoomVideo;
 import com.yonge.cooleshow.biz.dal.entity.RecordNotify;
 
+import java.util.List;
+
 /**
  * 直播视频记录(LiveRoomVideo)表服务接口
  *
@@ -15,6 +17,13 @@ public interface LiveRoomVideoService extends IService<LiveRoomVideo> {
 
     LiveRoomVideoDao getDao();
 
+    /**
+     * 查询对应房间的录像
+     *
+     * @param roomUid 房间uid
+     */
+    List<LiveRoomVideo> queryVideo(String roomUid);
+
     void recordSync(RecordNotify recordNotify);
 }
 

+ 23 - 19
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseScheduleServiceImpl.java

@@ -1619,18 +1619,12 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 
                 //老师课酬状态改为已完成
                 courseScheduleTeacherSalaryService.update(null, Wrappers.<CourseScheduleTeacherSalary>lambdaUpdate()
-                        .set(CourseScheduleTeacherSalary::getStatus, CourseScheduleEnum.COMPLETE.getCode())
+                        .set(CourseScheduleTeacherSalary::getStatus, TeacherSalaryEnum.WAIT.getCode())
                         .set(CourseScheduleTeacherSalary::getSettlementTime, new Date())
                         .in(CourseScheduleTeacherSalary::getCourseScheduleId, practiceList.stream().map(CourseScheduleStudentVo::getCourseId).collect(Collectors.toList())));
 
-                //获取教师课酬写入到金额变更表
+                //清除缓存
                 for (CourseScheduleStudentVo practice : practiceList) {
-                    userAccountService.accountChange(
-                            new UserAccountRecordDto(practice.getTeacherId(), practice.getActualSalary()
-                                    , InOrOutEnum.IN, AccountBizTypeEnum.PRACTICE, practice.getCourseId(),
-                                    practice.getGroupName(), practice.getOrderNo())
-                    );
-
                     //清除学生统计缓存
                     redissonClient.getBucket(CacheNameEnum.STUDENT_TOTAL.getRedisKey(practice.getStudentId())).delete();
                     //清除老师统计缓存
@@ -1698,17 +1692,27 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
      * @Author: cy
      * @Date: 2022/5/24
      */
-//    @Transactional(rollbackFor = Exception.class)
-//    public void teacherSalaryTask() {
-//        //课程结算日期(天)
-//        Integer settlementDay = Integer.valueOf(sysConfigService.findConfigValue(SysConfigConstant.COURSE_SALARY_SETTLEMENT_DAY));
-//        //获取n天前日期
-//        String day = DateUtil.getDayAgoOrAftString(-settlementDay);
-//        //获取小于n天前所有课程id
-//        List<Long> idList = baseMapper.selectIdList(day);
-//        //更新老师课酬表
-//        baseMapper.updateTeacherSalary(idList);
-//    }
+    @Transactional(rollbackFor = Exception.class)
+    public void teacherSalaryTask() {
+        //课程结算日期(天)
+        Integer settlementDay = Integer.valueOf(sysConfigService.findConfigValue(SysConfigConstant.COURSE_SALARY_SETTLEMENT_DAY));
+        //获取n天前日期
+        String day = DateUtil.getDayAgoOrAftString(-settlementDay);
+
+        List<UserAccountRecordDto> list = baseMapper.selectWaitCourse(day);
+        if (CollectionUtils.isNotEmpty(list)){
+            for (UserAccountRecordDto dto : list) {
+                userAccountService.accountChange(dto);
+            }
+
+            Set<Long> bizIds = list.stream().map(UserAccountRecordDto::getBizId).collect(Collectors.toSet());
+            courseScheduleTeacherSalaryService.update(null, Wrappers.<CourseScheduleTeacherSalary>lambdaUpdate()
+                    .set(CourseScheduleTeacherSalary::getStatus, TeacherSalaryEnum.COMPLETE.getCode())
+                    .set(CourseScheduleTeacherSalary::getSettlementTime, new Date())
+                    .in(CourseScheduleTeacherSalary::getCourseScheduleId,bizIds));
+        }
+
+    }
 
     /**
      * @Description: 查询琴房剩余时长、冻结时长、统计学员人数

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

@@ -1,21 +1,26 @@
 package com.yonge.cooleshow.biz.dal.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 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.beust.jcommander.internal.Lists;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 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.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.support.IMHelper;
 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.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 org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -24,7 +29,6 @@ import org.redisson.api.RMap;
 import org.redisson.api.RedissonClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -36,7 +40,8 @@ import java.util.function.Function;
 import java.util.stream.Collectors;
 
 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)表服务实现类
@@ -61,8 +66,6 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
     @Autowired
     private SysConfigService sysConfigService;
     @Autowired
-    private UserAccountService userAccountService;
-    @Autowired
     private UserOrderService userOrderService;
     @Autowired
     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
-    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) {
         //查询主讲人信息
         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 liveRemark = WrapperUtil.toStr(param, "liveRemark", "直播间描述不能为空!");
         Integer liveTime = WrapperUtil.toInt(param, "liveTime", "请选择直播时长!");
         Date liveStartTime = new Date();
         Date liveEndTime = DateUtil.addMinutes(liveStartTime, liveTime);
-        Long teacherId = sysUser.getId();
         //当前时间有课程则不能开启直播
         boolean check = courseScheduleService.checkTeacherCourseTime(teacherId, liveStartTime, liveEndTime);
         if (check) {
@@ -233,7 +245,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
         room.setSpeakerId(teacherId);
         room.setLiveStartTime(liveStartTime);
         room.setLiveEndTime(liveEndTime);
-        room.setLiveState(0);
+        room.setLiveState(1);
         room.setRoomState(0);
         room.setCreatedBy(teacherId);
         room.setCreatedTime(liveStartTime);
@@ -327,14 +339,18 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
         List<LiveRoom> list = this.list(Wrappers.<LiveRoom>lambdaQuery()
                 .eq(LiveRoom::getRoomState, 0)
                 .eq(LiveRoom::getLiveState, 1)
-                .eq(LiveRoom::getType, RoomTypeEnum.LIVE.getCode())
                 .le(LiveRoom::getLiveEndTime, now));
         if (CollectionUtils.isEmpty(list)) {
             return;
         }
         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()) {
                 destroyLiveRoom(room);
             }
@@ -362,93 +378,26 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
         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 (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;
             }
-            //获取教师课酬写入到金额变更表
-            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());
-    }
-
-    /**
-     * 定时任务-清理过期的房间-陪练课
-     */
-    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);
     }
 
     /**

+ 14 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/LiveRoomVideoServiceImpl.java

@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.Date;
+import java.util.List;
 import java.util.Objects;
 
 /**
@@ -36,6 +37,19 @@ public class LiveRoomVideoServiceImpl extends ServiceImpl<LiveRoomVideoDao, Live
         return this.baseMapper;
     }
 
+    /**
+     * 查询对应房间的录像
+     *
+     * @param roomUid 房间uid
+     */
+    @Override
+    public List<LiveRoomVideo> queryVideo(String roomUid) {
+        return this.list(Wrappers.<LiveRoomVideo>lambdaQuery()
+                .eq(LiveRoomVideo::getRoomUid, roomUid)
+                .eq(LiveRoomVideo::getType, 4)
+        );
+    }
+
     @Override
     public void recordSync(RecordNotify recordNotify) {
         if (recordNotify.getCode().equals(200)) {

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

@@ -1,8 +1,10 @@
 package com.yonge.cooleshow.biz.dal.service.impl;
 
+import com.alibaba.excel.util.CollectionUtils;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.yonge.cooleshow.biz.dal.dao.TeacherFreeTimeDao;
 import com.yonge.cooleshow.biz.dal.dto.PracticeTimesSetting;
@@ -12,6 +14,7 @@ import com.yonge.cooleshow.biz.dal.service.TeacherFreeTimeService;
 import com.yonge.cooleshow.biz.dal.vo.TeacherFreeTimeVo;
 import com.yonge.cooleshow.biz.dal.vo.WeekVo;
 import com.yonge.toolset.base.exception.BizException;
+import com.yonge.toolset.payment.core.entity.SysConfigPayment;
 import com.yonge.toolset.utils.date.DateUtil;
 import jodd.util.StringUtil;
 import org.slf4j.Logger;
@@ -41,9 +44,12 @@ public class TeacherFreeTimeServiceImpl extends ServiceImpl<TeacherFreeTimeDao,
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void upSet(TeacherFreeTime teacherFreeTime) {
-        TeacherFreeTime oldTeacherFreeTime = baseMapper.findOne(teacherFreeTime.getTeacherId(),
-                teacherFreeTime.getCourseMinutes(),
-                teacherFreeTime.getFreeMinutes());
+        Long teacherId = teacherFreeTime.getTeacherId();
+        TeacherFreeTime oldTeacherFreeTime = baseMapper.selectOne(Wrappers.<TeacherFreeTime>lambdaQuery().eq(TeacherFreeTime::getTeacherId, teacherId));
+
+//        TeacherFreeTime oldTeacherFreeTime = baseMapper.findOne(teacherFreeTime.getTeacherId(),
+//                teacherFreeTime.getCourseMinutes(),
+//                teacherFreeTime.getFreeMinutes());
 
         //删除原有设置
         if(Objects.nonNull(oldTeacherFreeTime)){
@@ -51,7 +57,10 @@ public class TeacherFreeTimeServiceImpl extends ServiceImpl<TeacherFreeTimeDao,
             baseMapper.deleteSubjectPrice(oldTeacherFreeTime.getId());
         }
         //将其他配置改为非默认
-        baseMapper.updateDefaultFlag(false,teacherFreeTime.getTeacherId());
+//        List<TeacherFreeTime> checkGapLock = baseMapper.selectList(Wrappers.<TeacherFreeTime>lambdaQuery().eq(TeacherFreeTime::getTeacherId, teacherFreeTime.getTeacherId()));
+//        if (!CollectionUtils.isEmpty(checkGapLock)){
+//            baseMapper.updateDefaultFlag(false,teacherFreeTime.getTeacherId());
+//        }
         baseMapper.insert(teacherFreeTime);
 
         List<TeacherSubjectPrice> priceList= JSONArray.parseArray(teacherFreeTime.getSubjectPrice(), TeacherSubjectPrice.class);

+ 33 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -877,4 +877,37 @@
             <![CDATA[ AND s.class_date_ <= #{param.endDate} ]]>
         </if>
     </select>
+    <select id="selectWaitCourse" resultType="com.yonge.cooleshow.biz.dal.dto.UserAccountRecordDto">
+        SELECT DISTINCT
+            ts.teacher_id_ AS userId,
+            ts.actual_salary_ AS transAmount,
+            ts.course_group_type_ AS bizType,
+            ts.course_schedule_id_ AS bizId,
+            lr.room_title_ AS bizName,
+            'IN' AS inOrOut,
+            sp.order_no_ AS orderNo,
+            ts.update_time_ AS updateTime
+        FROM course_schedule_teacher_salary ts
+        LEFT JOIN live_room lr ON ts.course_schedule_id_ = lr.course_id_
+        LEFT JOIN course_schedule_student_payment sp ON ts.course_schedule_id_ = sp.course_id_
+        WHERE ts.course_group_type_ = 'LIVE'
+        AND ts.status_ = 'WAIT'
+        <![CDATA[ AND ts.update_time_ <= #{day}]]>
+        UNION
+        SELECT DISTINCT
+            ts.teacher_id_ AS userId,
+            ts.actual_salary_ AS transAmount,
+            ts.course_group_type_ AS bizType,
+            ts.course_schedule_id_ AS bizId,
+            g.name_ AS bizName,
+            'IN' AS inOrOut,
+            sp.order_no_ AS orderNo,
+            ts.update_time_ AS updateTime
+        FROM course_schedule_teacher_salary ts
+        LEFT JOIN course_group g ON ts.course_group_id_ = g.id_
+        LEFT JOIN course_schedule_student_payment sp ON ts.course_schedule_id_ = sp.course_id_
+        WHERE ts.course_group_type_ = 'PRACTICE'
+        AND ts.status_ = 'WAIT'
+        <![CDATA[ AND ts.update_time_ <= #{day}]]>
+    </select>
 </mapper>

+ 13 - 13
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/TeacherLiveRoomController.java

@@ -1,12 +1,13 @@
 package com.yonge.cooleshow.teacher.controller;
 
-
 import com.alibaba.fastjson.JSONObject;
 import com.yonge.cooleshow.biz.dal.entity.ImUserStateSync;
+import com.yonge.cooleshow.biz.dal.entity.LiveRoom;
 import com.yonge.cooleshow.biz.dal.entity.RoomInfoCache;
 import com.yonge.cooleshow.biz.dal.service.LiveRoomService;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import com.yonge.toolset.base.page.PageInfo;
 import io.swagger.annotations.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -33,6 +34,17 @@ public class TeacherLiveRoomController extends BaseController {
     @Resource
     private LiveRoomService liveRoomService;
 
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "roomType", dataType = "String", value = "房间类型  LIVE-直播课  TEMP-临时直播间"),
+            @ApiImplicitParam(name = "page", dataType = "Integer", value = "页数"),
+            @ApiImplicitParam(name = "rows", dataType = "Integer", value = "每页数量"),
+    })
+    @ApiOperation("分页查询当前用户关联的房间信息")
+    @PostMapping("/queryPageRoom")
+    public HttpResponseResult<PageInfo<LiveRoom>> queryPageRoom(@RequestBody Map<String, Object> param) {
+        return succeed(liveRoomService.queryPageRoom(param));
+    }
+
     /**
      * 根据房间uid查询房间信息
      *
@@ -74,18 +86,6 @@ public class TeacherLiveRoomController extends BaseController {
         liveRoomService.createCourseLiveRoom();
     }
 
-    @ApiOperation("定时任务-销毁房间-直播间")
-    @GetMapping("/destroyExpiredLiveRoom")
-    public void destroyExpiredLiveRoom() {
-        liveRoomService.destroyExpiredLiveRoom();
-    }
-
-    @ApiOperation("定时任务-销毁房间-直播间-陪练课")
-    @GetMapping("/destroyExpiredPracticeRoom")
-    public void destroyExpiredPracticeRoom() {
-        liveRoomService.destroyExpiredPracticeRoom();
-    }
-
     @ApiOperation("手动关闭直播间")
     @GetMapping("/destroyLiveRoom")
     public HttpResponseResult<Object> destroyLiveRoom(@ApiParam(value = "房间uid", required = true) String roomUid) {

+ 56 - 0
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/TeacherLiveRoomVideoController.java

@@ -0,0 +1,56 @@
+package com.yonge.cooleshow.teacher.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.yonge.cooleshow.biz.dal.entity.LiveRoomVideo;
+import com.yonge.cooleshow.biz.dal.entity.RecordNotify;
+import com.yonge.cooleshow.biz.dal.service.LiveRoomVideoService;
+import com.yonge.cooleshow.common.controller.BaseController;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * 直播视频记录(LiveRoomVideo)表控制层
+ *
+ * @author hgw
+ * @since 2022-03-18 15:41:17
+ */
+@Api(tags = "直播视频记录")
+@RestController
+@RequestMapping("/liveRoomVideo")
+public class TeacherLiveRoomVideoController extends BaseController {
+
+    private final static Logger log = LoggerFactory.getLogger(TeacherLiveRoomVideoController.class);
+
+    /**
+     * 服务对象
+     */
+    @Resource
+    private LiveRoomVideoService liveRoomVideoService;
+
+    @ApiOperation("查询直播回放")
+    @GetMapping("/queryVideo")
+    public HttpResponseResult<List<LiveRoomVideo>> queryVideo(@ApiParam(value = "房间uid", required = true) String roomUid) {
+        return succeed(liveRoomVideoService.queryVideo(roomUid));
+    }
+
+    @ApiOperation("录制结果回调")
+    @RequestMapping(value = "/recordSync")
+    public void recordSync(@RequestBody String body) {
+        log.info("recordSync body:{}", body);
+        RecordNotify recordNotify = JSONObject.parseObject(body, RecordNotify.class);
+        liveRoomVideoService.recordSync(recordNotify);
+    }
+
+}
+

+ 17 - 7
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/task/TaskController.java

@@ -3,10 +3,11 @@ package com.yonge.cooleshow.teacher.task;
 import com.yonge.cooleshow.biz.dal.entity.TeacherTotal;
 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.TeacherTotalService;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
-import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -29,6 +30,9 @@ public class TaskController extends BaseController {
     private CourseGroupService courseGroupService;
     @Autowired
     private CourseScheduleService scheduleService;
+    @Autowired
+    private LiveRoomService liveRoomService;
+
 
     /***
      * 查询所有老师统计数据
@@ -46,11 +50,17 @@ public class TaskController extends BaseController {
      * <p>定时将符合结束售卖日期的在售卖中的直播课课程组修改为取消或者成课状态状态-每隔10分钟执行一次
      */
     @GetMapping("/opsCourseGroup")
-    public HttpResponseResult<Object> opsCourseGroup(){
+    public HttpResponseResult<Object> opsCourseGroup() {
         courseGroupService.opsCourseGroup();
         return HttpResponseResult.succeed();
     }
 
+    @ApiOperation("定时任务-销毁房间-直播间")
+    @GetMapping("/destroyExpiredLiveRoom")
+    public void destroyExpiredLiveRoom() {
+        liveRoomService.destroyExpiredLiveRoom();
+    }
+
     @GetMapping("/getRedisValueByKey")
     public HttpResponseResult<Object> getRedisValueByKey(String key) {
         return succeed(teacherTotalService.getRedisValueByKey(key));
@@ -68,9 +78,9 @@ public class TaskController extends BaseController {
         return HttpResponseResult.succeed();
     }
 
-//    @GetMapping("/teacherSalary")
-//    public HttpResponseResult<Object> teacherSalary() {
-//        scheduleService.teacherSalaryTask();
-//        return HttpResponseResult.succeed();
-//    }
+    @GetMapping("/teacherSalary")
+    public HttpResponseResult<Object> teacherSalary() {
+        scheduleService.teacherSalaryTask();
+        return HttpResponseResult.succeed();
+    }
 }

+ 12 - 2
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/LiveRoomVideoController.java → cooleshow-user/user-website/src/main/java/com/yonge/cooleshow/website/controller/LiveRoomVideoController.java

@@ -1,19 +1,23 @@
-package com.yonge.cooleshow.teacher.controller;
-
+package com.yonge.cooleshow.website.controller;
 
 import com.alibaba.fastjson.JSONObject;
+import com.yonge.cooleshow.biz.dal.entity.LiveRoomVideo;
 import com.yonge.cooleshow.biz.dal.entity.RecordNotify;
 import com.yonge.cooleshow.biz.dal.service.LiveRoomVideoService;
 import com.yonge.cooleshow.common.controller.BaseController;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import java.util.List;
 
 /**
  * 直播视频记录(LiveRoomVideo)表控制层
@@ -34,6 +38,12 @@ public class LiveRoomVideoController extends BaseController {
     @Resource
     private LiveRoomVideoService liveRoomVideoService;
 
+    @ApiOperation("查询直播回放")
+    @GetMapping("/queryVideo")
+    public HttpResponseResult<List<LiveRoomVideo>> queryVideo(@ApiParam(value = "房间uid", required = true) String roomUid) {
+        return succeed(liveRoomVideoService.queryVideo(roomUid));
+    }
+
     @ApiOperation("录制结果回调")
     @RequestMapping(value = "/recordSync")
     public void recordSync(@RequestBody String body) {