|  | @@ -1534,7 +1534,6 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 | 
	
		
			
				|  |  |                  repliedDao.insertBatch(practiceList);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |              //更新学生最近结课时间
 | 
	
		
			
				|  |  |              List<CourseScheduleStudentVo> pianoUserList = userList.stream().filter((CourseScheduleStudentVo s) -> s.getType().equals(CourseScheduleEnum.PIANO_ROOM_CLASS.getCode())).collect(Collectors.toList());
 | 
	
		
			
				|  |  |              if (CollectionUtils.isNotEmpty(pianoUserList)) {
 | 
	
	
		
			
				|  | @@ -1578,23 +1577,14 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 | 
	
		
			
				|  |  |          //查完完成的课程
 | 
	
		
			
				|  |  |          List<CourseCompleteVo> completeList = baseMapper.selectComplete();
 | 
	
		
			
				|  |  |          if (CollectionUtils.isNotEmpty(completeList)) {
 | 
	
		
			
				|  |  | -            List<Long> gids = completeList.stream().map(CourseCompleteVo::getCourseGroupId).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -            List<CourseGroup> courseGroups = courseGroupService.getDao().selectList(Wrappers.<CourseGroup>lambdaQuery().in(CourseGroup::getId, gids));
 | 
	
		
			
				|  |  | -            if (CollectionUtils.isNotEmpty(courseGroups)) {
 | 
	
		
			
				|  |  | -                List<Long> ids = new ArrayList<>();
 | 
	
		
			
				|  |  | -                for (CourseGroup group : courseGroups) {
 | 
	
		
			
				|  |  | -                    for (CourseCompleteVo complete : completeList) {
 | 
	
		
			
				|  |  | -                        Integer courseNum = group.getCourseNum();
 | 
	
		
			
				|  |  | -                        Integer completeCount = complete.getCourseCount();
 | 
	
		
			
				|  |  | -                        if (courseNum.equals(completeCount)) {
 | 
	
		
			
				|  |  | -                            ids.add(complete.getCourseGroupId());
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                if (CollectionUtils.isNotEmpty(ids)) {
 | 
	
		
			
				|  |  | -                    //同步课程组状态
 | 
	
		
			
				|  |  | -                    courseGroupService.getDao().updateBatch(ids);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | +            List<Long> ids = completeList.stream().filter(s -> {
 | 
	
		
			
				|  |  | +                return s.getCourseCount().equals(s.getCourseNum());
 | 
	
		
			
				|  |  | +            }).map(s -> {
 | 
	
		
			
				|  |  | +                return s.getId();
 | 
	
		
			
				|  |  | +            }).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +            if (CollectionUtils.isNotEmpty(ids)) {
 | 
	
		
			
				|  |  | +                //同步课程组状态
 | 
	
		
			
				|  |  | +                courseGroupService.getDao().updateBatch(ids);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -2031,9 +2021,12 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 | 
	
		
			
				|  |  |          Integer frozenTime = pianoRoomTime.getFrozenTime();
 | 
	
		
			
				|  |  |          Integer remainTime = pianoRoomTime.getRemainTime();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        String formula = sysConfigService.findConfigValue(SysConfigConstant.PIANO_ROOM_TIME_FORMULA);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          int i = studentIds.size() - paymentList.size();//新人数-原人数
 | 
	
		
			
				|  |  |          if (i > 0) {//加人,扣时长
 | 
	
		
			
				|  |  | -            int courseTime = singleCourseTime * i;
 | 
	
		
			
				|  |  | +            Integer n = (Integer) WrapperUtil.strToFormula(formula, "n", String.valueOf(i + 1));
 | 
	
		
			
				|  |  | +            int courseTime = singleCourseTime * n;
 | 
	
		
			
				|  |  |              if (remainTime - courseTime < 0) {
 | 
	
		
			
				|  |  |                  throw new BizException("剩余时长不足");
 | 
	
		
			
				|  |  |              }
 | 
	
	
		
			
				|  | @@ -2043,7 +2036,8 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 | 
	
		
			
				|  |  |                      .set(PianoRoomTime::getFrozenTime, frozenTime + courseTime));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if (i < 0) {//减人,释放时长
 | 
	
		
			
				|  |  | -            int courseTime = singleCourseTime * (-i);
 | 
	
		
			
				|  |  | +            Integer n = (Integer) WrapperUtil.strToFormula(formula, "n", String.valueOf(-i + 1));
 | 
	
		
			
				|  |  | +            int courseTime = singleCourseTime * n;
 | 
	
		
			
				|  |  |              pianoRoomTimeDao.update(null, Wrappers.<PianoRoomTime>lambdaUpdate()
 | 
	
		
			
				|  |  |                      .eq(PianoRoomTime::getTeacherId, teacherId)
 | 
	
		
			
				|  |  |                      .set(PianoRoomTime::getRemainTime, remainTime + courseTime)
 | 
	
	
		
			
				|  | @@ -2057,8 +2051,6 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 | 
	
		
			
				|  |  |          courseTime.setStartTime(courseSchedule.getStartTime());
 | 
	
		
			
				|  |  |          courseTime.setEndTime(courseSchedule.getEndTime());
 | 
	
		
			
				|  |  |          List<CourseTimeEntity> timeList = Arrays.asList(courseTime);
 | 
	
		
			
				|  |  | -        //批量检查老师课时在数据库是否重复
 | 
	
		
			
				|  |  | -//        this.batchCheckTeacherCourseTime(teacherId, timeList, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          List<CourseScheduleStudentPayment> payments = new ArrayList<>();
 | 
	
		
			
				|  |  |          for (Long studentId : studentIds) {
 |