| 
					
				 | 
			
			
				@@ -10,21 +10,8 @@ import java.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.text.SimpleDateFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.LocalDate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.LocalDateTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Arrays; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Calendar; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Collection; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Collections; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Comparator; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.HashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.HashSet; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Iterator; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Objects; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Set; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.TreeSet; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.time.LocalTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.stream.Stream; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2832,10 +2819,15 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		//未更新课程列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		List<CourseSchedule> oldCourses = courseScheduleDao.findByCourseScheduleIds(courseAdjustInfo.getCourseScheduleIds()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		//需要变更课酬的教师类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Set<TeachTypeEnum> changeSalaryTeachTypes = new HashSet<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if(courseAdjustInfo.getChangeMainTeacher()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			changeSalaryTeachTypes.add(TeachTypeEnum.BISHOP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			courseScheduleTeacherSalaryDao.deleteWithCourseAndTeachRole(courseAdjustInfo.getCourseScheduleIds(), TeachTypeEnum.BISHOP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if(courseAdjustInfo.getChangeMainTeacher()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if(courseAdjustInfo.getChangeTeachingTeacher()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			changeSalaryTeachTypes.add(TeachTypeEnum.TEACHING); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			courseScheduleTeacherSalaryDao.deleteWithCourseAndTeachRole(courseAdjustInfo.getCourseScheduleIds(), TeachTypeEnum.TEACHING); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2848,8 +2840,12 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if(Objects.nonNull(courseAdjustInfo.getPauseDate())&&Objects.nonNull(courseAdjustInfo.getPauseDate())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			Set<String> holidayDays = new HashSet<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		//上课日期变更 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		//间隔天数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		int betweenDays = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		//节假日 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Set<String> holidayDays = new HashSet<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if(Objects.nonNull(courseAdjustInfo.getPauseDate())&&Objects.nonNull(courseAdjustInfo.getRecoveryDate())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			if (courseAdjustInfo.getHoliday()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				SysConfig holidaySetting = sysConfigService.findByParamName(SysConfigService.HOLIDAY_SETTING); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if(Objects.nonNull(holidaySetting)&&StringUtils.isNotBlank(holidaySetting.getParanValue())){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2857,9 +2853,97 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			LocalDate pauseDate = LocalDate.parse(courseAdjustInfo.getPauseDate(), DateUtil.dateFormatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			LocalDate recoveryDate = LocalDate.parse(courseAdjustInfo.getRecoveryDate(), DateUtil.dateFormatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			betweenDays = (int) (recoveryDate.toEpochDay()-pauseDate.toEpochDay()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		//上课时间变更 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		LocalTime startTime = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if(Objects.nonNull(courseAdjustInfo.getStartTime())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			startTime = LocalTime.parse(courseAdjustInfo.getStartTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Date now = new Date(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		List<CourseScheduleTeacherSalary> courseScheduleTeacherSalaries = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		oldCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		for (int i = 0; i < oldCourses.size(); i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//上课日期变更 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if(betweenDays>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				LocalDate classDate = LocalDateTime.ofInstant(oldCourses.get(i).getClassDate().toInstant(), DateUtil.zoneId).toLocalDate(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				classDate = classDate.plusDays(betweenDays); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if (courseAdjustInfo.getHoliday() && holidayDays.contains(classDate.toString())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					betweenDays=betweenDays+7; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					i=i-1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//上课时间变更 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if(Objects.nonNull(startTime)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				//课程时长 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				int minutes = DateUtil.minutesBetween(oldCourses.get(i).getStartClassTime(), oldCourses.get(i).getEndClassTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				LocalTime endTime = startTime.plusMinutes(minutes); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				String courseStartTimeStr = DateUtil.dateToString(oldCourses.get(i).getClassDate(), "yyyy-MM-dd") + " " + startTime.toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				String courseEndTimeStr = DateUtil.dateToString(oldCourses.get(i).getClassDate(), "yyyy-MM-dd") + " " + endTime.toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				oldCourses.get(i).setStartClassTime(DateUtil.stringToDate(courseStartTimeStr)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				oldCourses.get(i).setEndClassTime(DateUtil.stringToDate(courseEndTimeStr)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if(Objects.nonNull(courseAdjustInfo.getTeachMode())&&!courseAdjustInfo.getTeachMode().equals(oldCourses.get(i).getTeachMode())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				oldCourses.get(i).setTeachMode(courseAdjustInfo.getTeachMode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if(VIP.equals(oldCourses.get(i).getGroupType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					changeSalaryTeachTypes.add(TeachTypeEnum.BISHOP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					courseScheduleTeacherSalaryDao.deleteWithCourseAndTeachRole(Arrays.asList(oldCourses.get(i).getId()), TeachTypeEnum.BISHOP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//主教变更 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if(Objects.nonNull(mainTeacherId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				oldCourses.get(i).setActualTeacherId(mainTeacherId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			for (ClassGroupTeacherMapper classGroupTeacherMapper : courseAdjustInfo.getClassGroupTeacherMapperList()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if(!changeSalaryTeachTypes.contains(classGroupTeacherMapper.getTeacherRole())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				CourseScheduleTeacherSalary courseScheduleTeacherSalary = new CourseScheduleTeacherSalary(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				courseScheduleTeacherSalary.setCourseScheduleId(oldCourses.get(i).getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				courseScheduleTeacherSalary.setGroupType(oldCourses.get(i).getGroupType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				courseScheduleTeacherSalary.setMusicGroupId(oldCourses.get(i).getMusicGroupId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				courseScheduleTeacherSalary.setTeacherRole(classGroupTeacherMapper.getTeacherRole()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				courseScheduleTeacherSalary.setUserId(classGroupTeacherMapper.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				courseScheduleTeacherSalary.setClassGroupId(oldCourses.get(i).getClassGroupId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				courseScheduleTeacherSalary.setCreateTime(now); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				courseScheduleTeacherSalary.setUpdateTime(now); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				courseScheduleTeacherSalaryService.createMusicGroupCourseTeacherSalary(null, oldCourses.get(i), courseScheduleTeacherSalary); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				courseScheduleTeacherSalaries.add(courseScheduleTeacherSalary); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if (courseAdjustInfo.getConfirmGenerate() && !courseAdjustInfo.getAllowZeroSalary() && BigDecimal.ZERO.compareTo(courseScheduleTeacherSalary.getExpectSalary()) == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					return BaseController.failed(HttpStatus.MULTI_STATUS, "当前课程课酬预计为0,是否继续"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		//老师结算表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if (courseScheduleTeacherSalaries.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			courseScheduleTeacherSalaryService.batchInsert(courseScheduleTeacherSalaries); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		checkNewCourseSchedules(oldCourses, false, false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if (!courseAdjustInfo.getConfirmGenerate()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			oldCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			return BaseController.failed(HttpStatus.PARTIAL_CONTENT, oldCourses, ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		courseScheduleDao.batchUpdate(oldCourses); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return BaseController.succeed(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |