|
@@ -5233,4 +5233,44 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
|
System.out.println("需调整课程数量:" + needAdjustCourseNum);
|
|
|
System.out.println("重复课程数量:" + courseRepeatIdMap.size());
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void courseMerge(CourseMergeDto courseMergeInfo) {
|
|
|
+ if(CollectionUtils.isEmpty(courseMergeInfo.getMergeCourseIds())){
|
|
|
+ throw new BizException("请选择需要合并的课程");
|
|
|
+ }
|
|
|
+ List<Long> allCourseIds = new ArrayList<>();
|
|
|
+ allCourseIds.add(courseMergeInfo.getId());
|
|
|
+ allCourseIds.addAll(courseMergeInfo.getMergeCourseIds());
|
|
|
+ List<CourseSchedule> allCourses = courseScheduleDao.findByCourseScheduleIds(allCourseIds);
|
|
|
+ for (CourseSchedule courseSchedule : allCourses) {
|
|
|
+ if(VIP.equals(courseSchedule.getGroupType())||PRACTICE.equals(courseSchedule.getGroupType())){
|
|
|
+ throw new BizException("VIP课、网管课暂不支持课程合并");
|
|
|
+ }
|
|
|
+ if(CourseScheduleType.MUSIC_NETWORK.equals(courseSchedule.getType())||CourseScheduleType.HIGH_ONLINE.equals(courseSchedule.getType())){
|
|
|
+ throw new BizException("乐团网管课、线上基础技能课暂不支持课程合并");
|
|
|
+ }
|
|
|
+ if(Objects.isNull(courseMergeInfo.getClassGroupId())&&courseMergeInfo.getId().equals(courseSchedule.getId())){
|
|
|
+ courseMergeInfo.setClassGroupId(courseSchedule.getClassGroupId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<CourseScheduleStudentPayment> courseScheduleStudentPayments = courseScheduleStudentPaymentDao.findByCourseScheduleIds(allCourseIds);
|
|
|
+// Map<Long, Set<Integer>> courseStudentIdsMap = courseScheduleStudentPayments.stream().collect(Collectors.groupingBy(CourseScheduleStudentPayment::getCourseScheduleId, Collectors.mapping(CourseScheduleStudentPayment::getUserId, Collectors.toSet())));
|
|
|
+ Set<Integer> allStudentIds = courseScheduleStudentPayments.stream().map(CourseScheduleStudentPayment::getUserId).collect(Collectors.toSet());
|
|
|
+ if(courseScheduleStudentPayments.size()!=allStudentIds.size()){
|
|
|
+ throw new BizException("所选课程中学员重复");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<CourseSchedule> courseSchedules=new ArrayList<>();
|
|
|
+ courseSchedules.add(courseMergeInfo);
|
|
|
+ courseAdjust(courseSchedules);
|
|
|
+
|
|
|
+ List<CourseSchedule> mergeCourses = allCourses.stream().filter(c->courseMergeInfo.getMergeCourseIds().contains(c.getId())).collect(Collectors.toList());
|
|
|
+ for (CourseSchedule courseSchedule : mergeCourses) {
|
|
|
+ courseSchedule.setNewCourseId(courseMergeInfo.getId());
|
|
|
+ }
|
|
|
+ courseScheduleDao.batchUpdate(mergeCourses);
|
|
|
+ }
|
|
|
}
|