|  | @@ -96,6 +96,10 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 | 
	
		
			
				|  |  |      private HolidaysFestivalsDao holidaysFestivalsDao;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private PinaoRoomTimeDao pinaoRoomTimeDao;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private UserBindingTeacherDao userBindingTeacherDao;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private CourseScheduleStudentDao courseScheduleStudentDao;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public CourseScheduleDao getDao() {
 | 
	
	
		
			
				|  | @@ -1485,12 +1489,26 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |      public void scheduleTask() {
 | 
	
		
			
				|  |  | -        //查询课程id(开课时间 ≤ NOW ≤ 结束时间)
 | 
	
		
			
				|  |  | -        List<Long> startIds=baseMapper.selectUpStartIds();
 | 
	
		
			
				|  |  | -        if (CollectionUtils.isNotEmpty(startIds)){
 | 
	
		
			
				|  |  | -            baseMapper.updateStartTime(startIds);
 | 
	
		
			
				|  |  | +        //更新课程开始状态(开课时间 ≤ NOW ≤ 结束时间)
 | 
	
		
			
				|  |  | +        List<CourseSchedule> courseStart = baseMapper.selectList(Wrappers.<CourseSchedule>lambdaQuery()
 | 
	
		
			
				|  |  | +                .eq(CourseSchedule::getLock, 0)
 | 
	
		
			
				|  |  | +                .eq(CourseSchedule::getType, CourseScheduleEnum.NOT_START)
 | 
	
		
			
				|  |  | +                .le(CourseSchedule::getStartTime, new Date())
 | 
	
		
			
				|  |  | +                .ge(CourseSchedule::getEndTime, new Date()));
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isNotEmpty(courseStart)) {
 | 
	
		
			
				|  |  | +            baseMapper.updateStartTime(courseStart);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //更新课程结束状态(NOW ≥ 结束时间)
 | 
	
		
			
				|  |  | +        List<String> typeList = Arrays.asList(CourseScheduleEnum.ING.getCode(), CourseScheduleEnum.NOT_START.getCode());
 | 
	
		
			
				|  |  | +        List<CourseSchedule> courseEnd = baseMapper.selectList(Wrappers.<CourseSchedule>lambdaQuery()
 | 
	
		
			
				|  |  | +                .in(CourseSchedule::getType, typeList)
 | 
	
		
			
				|  |  | +                .eq(CourseSchedule::getLock, 0)
 | 
	
		
			
				|  |  | +                .le(CourseSchedule::getEndTime, new Date()));
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isNotEmpty(courseEnd)) {
 | 
	
		
			
				|  |  | +            baseMapper.updateEndTime(courseEnd);
 | 
	
		
			
				|  |  | +            //TODO 根据老师&学生id 更新绑定学员结课时间
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        baseMapper.updateEndTime();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
	
		
			
				|  | @@ -1510,145 +1528,156 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 | 
	
		
			
				|  |  |          baseMapper.updateTeacherSalary(idList);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * @Description: 查询琴房剩余时长、冻结时长、统计学员人数
 | 
	
		
			
				|  |  | +     * @Author: cy
 | 
	
		
			
				|  |  | +     * @Date: 2022/5/27
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  |      public PinaoRoomTimeVo selectRemainTime(Long teacherId) {
 | 
	
		
			
				|  |  |          return pinaoRoomTimeDao.selectRemainTime(teacherId);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -//    public PageInfo<CourseStudentVo> selectStudent(Map<String, Object> param) {
 | 
	
		
			
				|  |  | -//        Integer courseId = (Integer) param.get("courseId");
 | 
	
		
			
				|  |  | -//        if (courseId != null) {
 | 
	
		
			
				|  |  | -//            CourseScheduleStudent teacherTime = baseMapper.selectOne(Wrappers.<CourseScheduleStudent>lambdaQuery().eq(CourseScheduleStudent::getCourseScheduleId, courseId));
 | 
	
		
			
				|  |  | -//            if (teacherTime == null) {
 | 
	
		
			
				|  |  | -//                throw new BizException("未查到课程");
 | 
	
		
			
				|  |  | -//            }
 | 
	
		
			
				|  |  | -//            String studentIdList = teacherTime.getStudentIdList();
 | 
	
		
			
				|  |  | -//            List<String> idList = Arrays.asList(studentIdList.split(","));
 | 
	
		
			
				|  |  | -//            param.put("idList", idList);//根据课程id查询报课学员
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  | -//        return PageUtil.pageInfo(userBindingTeacherDao.selectStudent(PageUtil.getPageInfo(param), param));
 | 
	
		
			
				|  |  | -//    }
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//    public void arrangeCourse(ArrangeCourseVo arrangeCourseVo, Long teacherId) {
 | 
	
		
			
				|  |  | -//        DistributedLock.of(redissonClient)
 | 
	
		
			
				|  |  | -//                .runIfLockCanGet(CacheNameEnum.LOCK_EXECUTE_ORDER.getRedisKey("teacherId:" + teacherId)
 | 
	
		
			
				|  |  | -//                        , () -> this.checkArrangeCourse(arrangeCourseVo, teacherId), 60L, TimeUnit.SECONDS);
 | 
	
		
			
				|  |  | -//    }
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//    @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | -//    public void checkArrangeCourse(ArrangeCourseVo arrangeCourseVo, Long teacherId) {
 | 
	
		
			
				|  |  | -//        Integer classNum = arrangeCourseVo.getClassNum();//课时数
 | 
	
		
			
				|  |  | -//        Integer singleClssTime = arrangeCourseVo.getSingleClssTime();//单课时长
 | 
	
		
			
				|  |  | -//        List<Long> studentIds = arrangeCourseVo.getStudentIds();//学员id集合
 | 
	
		
			
				|  |  | -//        Integer consumTime = classNum * singleClssTime * studentIds.size();//消耗时长
 | 
	
		
			
				|  |  | -//        List<CourseTimeEntity> timeList = arrangeCourseVo.getTimeList();//选课时间
 | 
	
		
			
				|  |  | -//        Integer consumeTime = arrangeCourseVo.getConsumeTime();
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//        //校验课时
 | 
	
		
			
				|  |  | -//        if (timeList.size() != classNum) {
 | 
	
		
			
				|  |  | -//            throw new BizException("课时数与排课数不符");
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//        //校验消耗时长
 | 
	
		
			
				|  |  | -//        if (!consumTime.equals(consumeTime)) {
 | 
	
		
			
				|  |  | -//            throw new BizException("时长计算错误");
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//        //校验上下课时间
 | 
	
		
			
				|  |  | -//        for (int i = 1; i <= timeList.size(); i++) {
 | 
	
		
			
				|  |  | -//            if (!DateUtil.offsetMinute(timeList.get(i).getStartTime(), singleClssTime).equals(timeList.get(i).getEndTime())) {
 | 
	
		
			
				|  |  | -//                throw new BizException("第{}节课结束时间计算错误", i);
 | 
	
		
			
				|  |  | -//            }
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//        //校验时长
 | 
	
		
			
				|  |  | -//        PinaoRoomTime pinaoRoomTime = pinaoRoomTimeDao.selectOne(Wrappers.<PinaoRoomTime>lambdaQuery().eq(PinaoRoomTime::getTeacherId, teacherId));
 | 
	
		
			
				|  |  | -//        if (pinaoRoomTime == null) {
 | 
	
		
			
				|  |  | -//            throw new BizException("未查询到老师剩余时长");
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  | -//        Long remainTime = pinaoRoomTime.getRemainTime();
 | 
	
		
			
				|  |  | -//        Long frozenTime = pinaoRoomTime.getFrozenTime();
 | 
	
		
			
				|  |  | -//        if (consumTime > remainTime) {
 | 
	
		
			
				|  |  | -//            throw new BizException("剩余时长不足");
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//        //校验学员是否绑定
 | 
	
		
			
				|  |  | -//        List<UserBindingTeacher> bindingTeachers = userBindingTeacherDao.selectList(Wrappers.<UserBindingTeacher>lambdaQuery().eq(UserBindingTeacher::getTeacherId, teacherId));
 | 
	
		
			
				|  |  | -//        if (com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isEmpty(bindingTeachers)) {
 | 
	
		
			
				|  |  | -//            throw new BizException("无绑定学员");
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  | -//        List<Long> studentList = bindingTeachers.stream().map(UserBindingTeacher::getStudentId).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -//        for (Long studentId : studentIds) {
 | 
	
		
			
				|  |  | -//            if (!studentList.contains(studentId)) {
 | 
	
		
			
				|  |  | -//                throw new BizException("学员id:{},未绑定", studentId);
 | 
	
		
			
				|  |  | -//            }
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//        //校验传入时间是否交集
 | 
	
		
			
				|  |  | -//        if (timeList.size() > 1) {
 | 
	
		
			
				|  |  | -//            for (int i = 0; i < timeList.size(); i++) {
 | 
	
		
			
				|  |  | -//                if (i == timeList.size() - 1) {
 | 
	
		
			
				|  |  | -//                    break;
 | 
	
		
			
				|  |  | -//                }
 | 
	
		
			
				|  |  | -//                CourseTimeEntity o = timeList.get(i);
 | 
	
		
			
				|  |  | -//                List<CourseTimeEntity> newList = timeList.subList(i + 1, timeList.size());
 | 
	
		
			
				|  |  | -//                boolean checkParamTime = courseScheduleService.checkCourseTime(newList, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime, o.getStartTime(), o.getEndTime());
 | 
	
		
			
				|  |  | -//                if (checkParamTime) {
 | 
	
		
			
				|  |  | -//                    throw new BizException(DateUtil.dateToString(o.getStartTime(), "yyyy年MM月dd号 HH点mm分") + "的课程时间重复!");
 | 
	
		
			
				|  |  | -//                }
 | 
	
		
			
				|  |  | -//            }
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//        //批量检查老师课时在数据库是否重复
 | 
	
		
			
				|  |  | -//        groupService.batchCheckTeacherCourseTime(teacherId, timeList, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime);
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//        //校验购买的课程组每节课时间是否和自己的课时冲突
 | 
	
		
			
				|  |  | -//        for (Long studentId : studentIds) {
 | 
	
		
			
				|  |  | -//            groupService.batchCheckStudentCourseTime(studentId, timeList, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime);
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//        //添加课程组
 | 
	
		
			
				|  |  | -//        CourseGroup courseGroup = new CourseGroup();
 | 
	
		
			
				|  |  | -//        courseGroup.setType(CourseScheduleEnum.PIANO_ROOM_CLASS.getCode());
 | 
	
		
			
				|  |  | -//        courseGroup.setTeacherId(teacherId);
 | 
	
		
			
				|  |  | -//        courseGroup.setName(arrangeCourseVo.getCourseName());
 | 
	
		
			
				|  |  | -//        courseGroup.setSubjectId(arrangeCourseVo.getSubjectId());
 | 
	
		
			
				|  |  | -//        courseGroup.setSingleCourseMinutes(singleClssTime);
 | 
	
		
			
				|  |  | -//        courseGroup.setCourseNum(classNum);
 | 
	
		
			
				|  |  | -//        courseGroup.setStatus(CourseGroupEnum.NOT_SALE.getCode());
 | 
	
		
			
				|  |  | -//        courseGroup.setCreatedBy(teacherId);
 | 
	
		
			
				|  |  | -//        courseGroupDao.insert(courseGroup);
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//        for (int i = 0; i < timeList.size(); i++) {
 | 
	
		
			
				|  |  | -//            //添加课程
 | 
	
		
			
				|  |  | -//            CourseTimeEntity courseTimeEntity = timeList.get(i);
 | 
	
		
			
				|  |  | -//            CourseSchedule schedule = new CourseSchedule();
 | 
	
		
			
				|  |  | -//            schedule.setCourseGroupId(courseGroup.getId());
 | 
	
		
			
				|  |  | -//            schedule.setType(CourseScheduleEnum.PIANO_ROOM_CLASS.getCode());
 | 
	
		
			
				|  |  | -//            schedule.classNum(i + 1);
 | 
	
		
			
				|  |  | -//            schedule.setTeacherId(teacherId);
 | 
	
		
			
				|  |  | -//            schedule.setClassDate(DateUtil.trunc(courseTimeEntity.getStartTime()));
 | 
	
		
			
				|  |  | -//            schedule.setStartTime(courseTimeEntity.getStartTime());
 | 
	
		
			
				|  |  | -//            schedule.setEndTime(courseTimeEntity.getEndTime());
 | 
	
		
			
				|  |  | -//            schedule.setLock(0);
 | 
	
		
			
				|  |  | -//            schedule.setStatus(CourseScheduleEnum.NOT_START.getCode());
 | 
	
		
			
				|  |  | -//            schedule.setCreatedBy(teacherId);
 | 
	
		
			
				|  |  | -//            courseScheduleDao.insert(schedule);
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//            //添加course_schedule_teacher_time
 | 
	
		
			
				|  |  | -//            CourseScheduleStudent teacherTime = new CourseScheduleStudent();
 | 
	
		
			
				|  |  | -//            teacherTime.setCourseGroupId(courseGroup.getId());
 | 
	
		
			
				|  |  | -//            teacherTime.setCourseScheduleId(schedule.getId());
 | 
	
		
			
				|  |  | -//            teacherTime.setTeacherId(teacherId);
 | 
	
		
			
				|  |  | -//            teacherTime.setStudentIdList(org.apache.commons.lang.StringUtils.join(studentIds, ","));
 | 
	
		
			
				|  |  | -//            teacherTime.setClassNum(i + 1);
 | 
	
		
			
				|  |  | -//            teacherTime.setConsumeTime(Long.valueOf(singleClssTime));
 | 
	
		
			
				|  |  | -//            baseMapper.insert(teacherTime);
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//        //扣减pinao_room_time
 | 
	
		
			
				|  |  | -//        PinaoRoomTime roomTime = new PinaoRoomTime();
 | 
	
		
			
				|  |  | -//        roomTime.setRemainTime(remainTime - consumTime);
 | 
	
		
			
				|  |  | -//        roomTime.setFrozenTime(frozenTime + consumTime);
 | 
	
		
			
				|  |  | -//        pinaoRoomTimeDao.update(roomTime, Wrappers.<PinaoRoomTime>lambdaQuery().eq(PinaoRoomTime::getTeacherId, teacherId));
 | 
	
		
			
				|  |  | -//    }
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * @Description: 我的学员&课内学员
 | 
	
		
			
				|  |  | +     * @Author: cy
 | 
	
		
			
				|  |  | +     * @Date: 2022/5/27
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public PageInfo<CourseStudentVo> selectStudent(Map<String, Object> param) {
 | 
	
		
			
				|  |  | +        Integer courseId = (Integer) param.get("courseId");
 | 
	
		
			
				|  |  | +        if (courseId != null) {
 | 
	
		
			
				|  |  | +            List<CourseScheduleStudent> studentList = courseScheduleStudentDao.selectList(Wrappers.<CourseScheduleStudent>lambdaQuery().eq(CourseScheduleStudent::getCourseId, courseId));
 | 
	
		
			
				|  |  | +            param.put("studentList", studentList);//根据课程id查询报课学员
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return PageUtil.pageInfo(userBindingTeacherDao.selectStudent(PageUtil.getPageInfo(param), param));
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * @Description: 排课
 | 
	
		
			
				|  |  | +     * @Author: cy
 | 
	
		
			
				|  |  | +     * @Date: 2022/5/27
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public void arrangeCourse(ArrangeCourseVo arrangeCourseVo, Long teacherId) {
 | 
	
		
			
				|  |  | +        DistributedLock.of(redissonClient)
 | 
	
		
			
				|  |  | +                .runIfLockCanGet(CacheNameEnum.LOCK_EXECUTE_ORDER.getRedisKey("teacherId:" + teacherId)
 | 
	
		
			
				|  |  | +                        , () -> this.checkArrangeCourse(arrangeCourseVo, teacherId), 60L, TimeUnit.SECONDS);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | +    public void checkArrangeCourse(ArrangeCourseVo arrangeCourseVo, Long teacherId) {
 | 
	
		
			
				|  |  | +        Integer classNum = arrangeCourseVo.getClassNum();//课时数
 | 
	
		
			
				|  |  | +        Integer singleClssTime = arrangeCourseVo.getSingleClssTime();//单课时长
 | 
	
		
			
				|  |  | +        List<Long> studentIds = arrangeCourseVo.getStudentIds();//学员id集合
 | 
	
		
			
				|  |  | +        Integer consumTime = classNum * singleClssTime * studentIds.size();//消耗时长
 | 
	
		
			
				|  |  | +        List<CourseTimeEntity> timeList = arrangeCourseVo.getTimeList();//选课时间
 | 
	
		
			
				|  |  | +        Integer consumeTime = arrangeCourseVo.getConsumeTime();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //校验课时
 | 
	
		
			
				|  |  | +        if (timeList.size() != classNum) {
 | 
	
		
			
				|  |  | +            throw new BizException("课时数与排课数不符");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //校验消耗时长
 | 
	
		
			
				|  |  | +        if (!consumTime.equals(consumeTime)) {
 | 
	
		
			
				|  |  | +            throw new BizException("时长计算错误");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //校验上下课时间
 | 
	
		
			
				|  |  | +        for (int i = 0; i < timeList.size(); i++) {
 | 
	
		
			
				|  |  | +            if (!DateUtil.offsetMinute(timeList.get(i).getStartTime(), singleClssTime).equals(timeList.get(i).getEndTime())) {
 | 
	
		
			
				|  |  | +                throw new BizException("第{}节课结束时间计算错误", i + 1);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //校验时长
 | 
	
		
			
				|  |  | +        PinaoRoomTime pinaoRoomTime = pinaoRoomTimeDao.selectOne(Wrappers.<PinaoRoomTime>lambdaQuery().eq(PinaoRoomTime::getTeacherId, teacherId));
 | 
	
		
			
				|  |  | +        if (pinaoRoomTime == null) {
 | 
	
		
			
				|  |  | +            throw new BizException("未查询到老师剩余时长");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        Long remainTime = pinaoRoomTime.getRemainTime();
 | 
	
		
			
				|  |  | +        Long frozenTime = pinaoRoomTime.getFrozenTime();
 | 
	
		
			
				|  |  | +        if (consumTime > remainTime) {
 | 
	
		
			
				|  |  | +            throw new BizException("剩余时长不足");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //校验学员是否绑定
 | 
	
		
			
				|  |  | +        List<UserBindingTeacher> bindingTeachers = userBindingTeacherDao.selectList(Wrappers.<UserBindingTeacher>lambdaQuery().eq(UserBindingTeacher::getTeacherId, teacherId));
 | 
	
		
			
				|  |  | +        if (com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isEmpty(bindingTeachers)) {
 | 
	
		
			
				|  |  | +            throw new BizException("无绑定学员");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        List<Long> studentList = bindingTeachers.stream().map(UserBindingTeacher::getStudentId).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        for (Long studentId : studentIds) {
 | 
	
		
			
				|  |  | +            if (!studentList.contains(studentId)) {
 | 
	
		
			
				|  |  | +                throw new BizException("学员id:{},未绑定", studentId);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //校验传入时间是否交集
 | 
	
		
			
				|  |  | +        if (timeList.size() > 1) {
 | 
	
		
			
				|  |  | +            for (int i = 0; i < timeList.size(); i++) {
 | 
	
		
			
				|  |  | +                if (i == timeList.size() - 1) {
 | 
	
		
			
				|  |  | +                    break;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                CourseTimeEntity o = timeList.get(i);
 | 
	
		
			
				|  |  | +                List<CourseTimeEntity> newList = timeList.subList(i + 1, timeList.size());
 | 
	
		
			
				|  |  | +                boolean checkParamTime = this.checkCourseTime(newList, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime, o.getStartTime(), o.getEndTime());
 | 
	
		
			
				|  |  | +                if (checkParamTime) {
 | 
	
		
			
				|  |  | +                    throw new BizException(DateUtil.dateToString(o.getStartTime(), "yyyy年MM月dd号 HH点mm分") + "的课程时间重复!");
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //批量检查老师课时在数据库是否重复
 | 
	
		
			
				|  |  | +        this.batchCheckTeacherCourseTime(teacherId, timeList, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //校验购买的课程组每节课时间是否和自己的课时冲突
 | 
	
		
			
				|  |  | +        for (Long studentId : studentIds) {
 | 
	
		
			
				|  |  | +            this.batchCheckStudentCourseTime(studentId, timeList, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //添加课程组
 | 
	
		
			
				|  |  | +        CourseGroup courseGroup = new CourseGroup();
 | 
	
		
			
				|  |  | +        courseGroup.setType(CourseScheduleEnum.PIANO_ROOM_CLASS.getCode());
 | 
	
		
			
				|  |  | +        courseGroup.setTeacherId(teacherId);
 | 
	
		
			
				|  |  | +        courseGroup.setName(arrangeCourseVo.getCourseName());
 | 
	
		
			
				|  |  | +        courseGroup.setSubjectId(arrangeCourseVo.getSubjectId());
 | 
	
		
			
				|  |  | +        courseGroup.setSingleCourseMinutes(singleClssTime);
 | 
	
		
			
				|  |  | +        courseGroup.setCourseNum(classNum);
 | 
	
		
			
				|  |  | +        courseGroup.setStatus(CourseGroupEnum.NOT_SALE.getCode());
 | 
	
		
			
				|  |  | +        courseGroup.setCreatedBy(teacherId);
 | 
	
		
			
				|  |  | +        courseGroupService.getDao().insert(courseGroup);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        for (int i = 0; i < timeList.size(); i++) {
 | 
	
		
			
				|  |  | +            //添加课程
 | 
	
		
			
				|  |  | +            CourseTimeEntity courseTimeEntity = timeList.get(i);
 | 
	
		
			
				|  |  | +            CourseSchedule schedule = new CourseSchedule();
 | 
	
		
			
				|  |  | +            schedule.setCourseGroupId(courseGroup.getId());
 | 
	
		
			
				|  |  | +            schedule.setType(CourseScheduleEnum.PIANO_ROOM_CLASS.getCode());
 | 
	
		
			
				|  |  | +            schedule.classNum(i + 1);
 | 
	
		
			
				|  |  | +            schedule.setTeacherId(teacherId);
 | 
	
		
			
				|  |  | +            schedule.setClassDate(DateUtil.trunc(courseTimeEntity.getStartTime()));
 | 
	
		
			
				|  |  | +            schedule.setStartTime(courseTimeEntity.getStartTime());
 | 
	
		
			
				|  |  | +            schedule.setEndTime(courseTimeEntity.getEndTime());
 | 
	
		
			
				|  |  | +            schedule.setLock(0);
 | 
	
		
			
				|  |  | +            schedule.setStatus(CourseScheduleEnum.NOT_START.getCode());
 | 
	
		
			
				|  |  | +            schedule.setCreatedBy(teacherId);
 | 
	
		
			
				|  |  | +            schedule.setSingleCourseTime(singleClssTime);
 | 
	
		
			
				|  |  | +            baseMapper.insert(schedule);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            //添加course_schedule_student
 | 
	
		
			
				|  |  | +            List<CourseScheduleStudent> list = new ArrayList<>();
 | 
	
		
			
				|  |  | +            for (Long studentId : studentIds) {
 | 
	
		
			
				|  |  | +                CourseScheduleStudent teacherTime = new CourseScheduleStudent();
 | 
	
		
			
				|  |  | +                teacherTime.setStudentId(studentId);
 | 
	
		
			
				|  |  | +                teacherTime.setCourseId(schedule.getId());
 | 
	
		
			
				|  |  | +                list.add(teacherTime);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            courseScheduleStudentDao.insertBatch(list);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //扣减pinao_room_time
 | 
	
		
			
				|  |  | +        PinaoRoomTime roomTime = new PinaoRoomTime();
 | 
	
		
			
				|  |  | +        roomTime.setRemainTime(remainTime - consumTime);
 | 
	
		
			
				|  |  | +        roomTime.setFrozenTime(frozenTime + consumTime);
 | 
	
		
			
				|  |  | +        pinaoRoomTimeDao.update(roomTime, Wrappers.<PinaoRoomTime>lambdaQuery().eq(PinaoRoomTime::getTeacherId, teacherId));
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |