zouxuan 2 jaren geleden
bovenliggende
commit
5dcd6824a0

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupStudentMapperDao.java

@@ -478,7 +478,7 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
 
     Integer countByUserIdsAndClassIds(@Param("studentIds") String studentIds, @Param("oldClassId") Integer oldClassId);
     
-    List<VipGroupClassGroupMapper> queryWaitCancelVipGroup(@Param("groupType") String groupType);
+    List<VipGroupClassGroupMapper> queryWaitCancelVipGroup();
 
     List<ClassGroupStudentMapper> findByVipGroups(@Param("groupIds") List<Long> groupIds);
 

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/VipGroupDao.java

@@ -317,7 +317,7 @@ public interface VipGroupDao extends BaseDAO<Long, VipGroup> {
      *
      * @return
      */
-    List<VipGroup> queryRequiredOverList(@Param("groupType") String groupType);
+    List<VipGroup> queryRequiredOverList();
 
     /**
      * @return java.util.List<com.ym.mec.biz.dal.entity.VipGroup>

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleService.java

@@ -314,6 +314,7 @@ public interface CourseScheduleService extends BaseService<Long, CourseSchedule>
 	 */
 	boolean courseTimeRevise(CourseSchedule courseSchedule, List<CourseSchedule> sameDayCourses);
 
+
 	/**
 	 * @describe 检测数据库不存在的课程是否存在错误
 	 * @author Joburgess
@@ -324,6 +325,17 @@ public interface CourseScheduleService extends BaseService<Long, CourseSchedule>
 	 */
 	Boolean checkNewCourseSchedules(List<CourseSchedule> courseSchedules,boolean checkExistCourseSchedule,Boolean postponeFlag);
 
+
+	/**
+	 * @describe 检测数据库不存在的课程是否存在错误
+	 * @author Joburgess
+	 * @date 2019/10/31
+	 * @param courseSchedules: 课程列表
+	 * @param postponeFlag: 如果冲突是否顺延
+	 * @return void
+	 */
+	Boolean checkNewCourseSchedules(List<CourseSchedule> courseSchedules,boolean checkExistCourseSchedule,Boolean postponeFlag,ClassGroupStudentMapper classGroupStudentMapper);
+
 	/**
 	 * @describe
 	 * @author Joburgess

+ 149 - 139
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -1798,54 +1798,49 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		return true;
 	}
 
-	@Override
 	@Transactional(rollbackFor = Exception.class)
-    public Boolean checkNewCourseSchedules(List<CourseSchedule> courseSchedules, boolean checkExistCourseSchedule,Boolean postponeFlag) {
-        if (CollectionUtils.isEmpty(courseSchedules)) {
-            return false;
-        }
-        //
-
-        List<String> classDates = courseSchedules.stream().map(courseSchedule -> DateUtil.dateToString(courseSchedule.getClassDate(), "yyyy-MM-dd"))
-                .collect(Collectors.toList());
-
-        List<CourseSchedule> existCourseSchedules = courseScheduleDao.findByClassDate(classDates, TenantContextHolder.getTenantId());
-
-        //只需要调整课程信息的课程编号列表
-        List<Long> updateCourseScheduleIds = courseSchedules
-                .stream()
-                .filter(courseSchedule -> Objects.nonNull(courseSchedule.getId()))
-                .map(CourseSchedule::getId)
-                .collect(Collectors.toList());
-
-        //排除只需调整的课程
-        existCourseSchedules = existCourseSchedules.stream()
-                .filter(courseSchedule -> !updateCourseScheduleIds.contains(courseSchedule.getId()))
-                .collect(Collectors.toList());
-        //新课程对应的班级编号列表
-        List<Integer> newCourseScheduleClassGroupIds = courseSchedules
-                .stream()
-                .map(CourseSchedule::getClassGroupId)
-                .distinct()
-                .collect(Collectors.toList());
-
-        List<Long> existCourseScheduleIds = existCourseSchedules.stream()
-                .map(CourseSchedule::getId)
-                .collect(Collectors.toList());
-
-//        HashSet<Long> courseScheduleIdsSet = new HashSet<>(existCourseScheduleIds);
-
-        //合并新课程和已存在的课程
-        List<CourseSchedule> allCourseSchedules;
-        if (!CollectionUtils.isEmpty(existCourseSchedules)) {
-            allCourseSchedules = ListUtils.sum(courseSchedules, existCourseSchedules);
-        } else {
-            allCourseSchedules = courseSchedules;
-        }
+    public Boolean checkCourseSchedules(List<CourseSchedule> courseSchedules, boolean checkExistCourseSchedule,Boolean postponeFlag,ClassGroupStudentMapper classGroupStudentMapper) {
+		if (CollectionUtils.isEmpty(courseSchedules)) {
+			return false;
+		}
+		List<String> classDates = courseSchedules.stream().map(courseSchedule -> DateUtil.dateToString(courseSchedule.getClassDate(), "yyyy-MM-dd"))
+				.collect(Collectors.toList());
+
+		List<CourseSchedule> existCourseSchedules = courseScheduleDao.findByClassDate(classDates, TenantContextHolder.getTenantId());
+
+		//只需要调整课程信息的课程编号列表
+		List<Long> updateCourseScheduleIds = courseSchedules
+				.stream()
+				.filter(courseSchedule -> Objects.nonNull(courseSchedule.getId()))
+				.map(CourseSchedule::getId)
+				.collect(Collectors.toList());
+
+		//排除只需调整的课程
+		existCourseSchedules = existCourseSchedules.stream()
+				.filter(courseSchedule -> !updateCourseScheduleIds.contains(courseSchedule.getId()))
+				.collect(Collectors.toList());
+		//新课程对应的班级编号列表
+		List<Integer> newCourseScheduleClassGroupIds = courseSchedules
+				.stream()
+				.map(CourseSchedule::getClassGroupId)
+				.distinct()
+				.collect(Collectors.toList());
+
+		List<Long> existCourseScheduleIds = existCourseSchedules.stream()
+				.map(CourseSchedule::getId)
+				.collect(Collectors.toList());
+
+		//合并新课程和已存在的课程
+		List<CourseSchedule> allCourseSchedules;
+		if (!CollectionUtils.isEmpty(existCourseSchedules)) {
+			allCourseSchedules = ListUtils.sum(courseSchedules, existCourseSchedules);
+		} else {
+			allCourseSchedules = courseSchedules;
+		}
 
-        //所有课程编号
+		//所有课程编号
 		Set<Long> allCourseScheduleIds = allCourseSchedules.stream().map(CourseSchedule::getId).collect(Collectors.toSet());
-        //所有课程学员签到记录
+		//所有课程学员签到记录
 		List<StudentAttendance> studentAttendances = studentAttendanceDao.findByCourseIds(new ArrayList<>(allCourseScheduleIds));
 		//课程请假学员字典
 		Map<Long, Set<Integer>> courseLeaveStudentMap = studentAttendances.stream()
@@ -1853,45 +1848,48 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 				.collect(Collectors.groupingBy(StudentAttendance::getCourseScheduleId, Collectors.mapping(StudentAttendance::getUserId, Collectors.toSet())));
 
 		//所有课程的班级编号
-        List<Integer> classGroupIds = allCourseSchedules
-                .stream()
-                .map(CourseSchedule::getClassGroupId)
-                .distinct()
-                .collect(Collectors.toList());
-        //班级与学生的关联记录
-        List<ClassGroupStudentMapper> classGroupStudentMappers = classGroupStudentMapperDao.findByClassGroups(classGroupIds);
-        Map<Integer, List<ClassGroupStudentMapper>> classGroupStudentsMap = classGroupStudentMappers
-                .stream()
-                .collect(Collectors.groupingBy(ClassGroupStudentMapper::getClassGroupId));
-
-        //根据课程获取助教id关联集合
-        List<IntegerAndIntegerListDto> courseScheduleTeachingTeacherIdList = new ArrayList<>();
-        if (!CollectionUtils.isEmpty(allCourseScheduleIds)) {
-            courseScheduleTeachingTeacherIdList = courseScheduleDao.findCourseScheduleIdAndUserIdsMap(new ArrayList<>(allCourseScheduleIds), TeachTypeEnum.TEACHING.getCode());
-        }
-        Map<Long, IntegerAndIntegerListDto> courseScheduleTeachingTeacherMap = courseScheduleTeachingTeacherIdList.stream()
-                .collect(Collectors.toMap(IntegerAndIntegerListDto::getId, integerAndIntegerListDto -> integerAndIntegerListDto));
-
-        //班级助教关联ID集合
-        List<IntegerAndIntegerListDto> classGroupAndUserIdsMap = courseScheduleDao.findClassGroupAndUserIdsMap(newCourseScheduleClassGroupIds, TeachTypeEnum.TEACHING.getCode());
-        Map<Long, IntegerAndIntegerListDto> classGroupTeachingTeacherMap = classGroupAndUserIdsMap.stream()
-                .collect(Collectors.toMap(IntegerAndIntegerListDto::getId, integerAndIntegerListDto -> integerAndIntegerListDto));
+		List<Integer> classGroupIds = allCourseSchedules
+				.stream()
+				.map(CourseSchedule::getClassGroupId)
+				.distinct()
+				.collect(Collectors.toList());
+		//班级与学生的关联记录
+		List<ClassGroupStudentMapper> classGroupStudentMappers = classGroupStudentMapperDao.findByClassGroups(classGroupIds);
+		if(Objects.nonNull(classGroupStudentMapper)){
+			classGroupStudentMappers.add(classGroupStudentMapper);
+		}
+		Map<Integer, List<ClassGroupStudentMapper>> classGroupStudentsMap = classGroupStudentMappers
+				.stream()
+				.collect(Collectors.groupingBy(ClassGroupStudentMapper::getClassGroupId));
+
+		//根据课程获取助教id关联集合
+		List<IntegerAndIntegerListDto> courseScheduleTeachingTeacherIdList = new ArrayList<>();
+		if (!CollectionUtils.isEmpty(allCourseScheduleIds)) {
+			courseScheduleTeachingTeacherIdList = courseScheduleDao.findCourseScheduleIdAndUserIdsMap(new ArrayList<>(allCourseScheduleIds), TeachTypeEnum.TEACHING.getCode());
+		}
+		Map<Long, IntegerAndIntegerListDto> courseScheduleTeachingTeacherMap = courseScheduleTeachingTeacherIdList.stream()
+				.collect(Collectors.toMap(IntegerAndIntegerListDto::getId, integerAndIntegerListDto -> integerAndIntegerListDto));
+
+		//班级助教关联ID集合
+		List<IntegerAndIntegerListDto> classGroupAndUserIdsMap = courseScheduleDao.findClassGroupAndUserIdsMap(newCourseScheduleClassGroupIds, TeachTypeEnum.TEACHING.getCode());
+		Map<Long, IntegerAndIntegerListDto> classGroupTeachingTeacherMap = classGroupAndUserIdsMap.stream()
+				.collect(Collectors.toMap(IntegerAndIntegerListDto::getId, integerAndIntegerListDto -> integerAndIntegerListDto));
 
 //        Set<Long> existCourseScheduleIdsSet=new HashSet<>(existCourseScheduleIds);
 
-        Map<String, List<CourseSchedule>> existClassDateCoursesMap = allCourseSchedules.stream().collect(Collectors.groupingBy(c -> DateUtil.dateToString(c.getClassDate(), "yyyy-MM-dd")));
-        Map<String, List<CourseSchedule>> newClassDateCoursesMap = courseSchedules.stream().collect(Collectors.groupingBy(c -> DateUtil.dateToString(c.getClassDate(), "yyyy-MM-dd")));
-        if (allCourseSchedules.size() > 1) {
-            for (Map.Entry<String, List<CourseSchedule>> classDateCourseEntry : newClassDateCoursesMap.entrySet()) {
-                List<CourseSchedule> existClassDateCourses = existClassDateCoursesMap.get(classDateCourseEntry.getKey());
-                if(CollectionUtils.isEmpty(existClassDateCourses)){
-                    continue;
-                }
-                List<CourseSchedule> newClassDateCourses=classDateCourseEntry.getValue();
-                existClassDateCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
-                newClassDateCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
-                for (CourseSchedule preCourseSchedule : newClassDateCourses) {
-                	//调整后的课程截止日期不能超过学期时间
+		Map<String, List<CourseSchedule>> existClassDateCoursesMap = allCourseSchedules.stream().collect(Collectors.groupingBy(c -> DateUtil.dateToString(c.getClassDate(), "yyyy-MM-dd")));
+		Map<String, List<CourseSchedule>> newClassDateCoursesMap = courseSchedules.stream().collect(Collectors.groupingBy(c -> DateUtil.dateToString(c.getClassDate(), "yyyy-MM-dd")));
+		if (allCourseSchedules.size() > 1) {
+			for (Map.Entry<String, List<CourseSchedule>> classDateCourseEntry : newClassDateCoursesMap.entrySet()) {
+				List<CourseSchedule> existClassDateCourses = existClassDateCoursesMap.get(classDateCourseEntry.getKey());
+				if(CollectionUtils.isEmpty(existClassDateCourses)){
+					continue;
+				}
+				List<CourseSchedule> newClassDateCourses=classDateCourseEntry.getValue();
+				existClassDateCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
+				newClassDateCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
+				for (CourseSchedule preCourseSchedule : newClassDateCourses) {
+					//调整后的课程截止日期不能超过学期时间
 					if(preCourseSchedule.getValidEndTime() != null){
 						if(preCourseSchedule.getValidEndTime().compareTo(preCourseSchedule.getClassDate()) < 0){
 							throw new BizException("操作失败:不允许跨学期调整");
@@ -1902,33 +1900,33 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 							throw new BizException("操作失败:不允许跨学期调整");
 						}
 					}
-                    for (CourseSchedule backCourseSchedule : existClassDateCourses) {
+					for (CourseSchedule backCourseSchedule : existClassDateCourses) {
 
-                        //判断前后两节课是否存在冲突
-                        if (!preCourseSchedule.getStartClassTime().before(backCourseSchedule.getEndClassTime())
-                                ||!preCourseSchedule.getEndClassTime().after(backCourseSchedule.getStartClassTime())) {
-                            continue;
-                        }
-                        if (preCourseSchedule.equals(backCourseSchedule)) {
-                            continue;
-                        }
+						//判断前后两节课是否存在冲突
+						if (!preCourseSchedule.getStartClassTime().before(backCourseSchedule.getEndClassTime())
+								||!preCourseSchedule.getEndClassTime().after(backCourseSchedule.getStartClassTime())) {
+							continue;
+						}
+						if (preCourseSchedule.equals(backCourseSchedule)) {
+							continue;
+						}
 
-                        //如果存在时间重叠,则需要判断前后两节课的教师和学生是否存在冲突
-                        //主教冲突检测
-                        if (Objects.nonNull(preCourseSchedule.getActualTeacherId())
-                                && preCourseSchedule.getActualTeacherId().equals(backCourseSchedule.getActualTeacherId())) {
+						//如果存在时间重叠,则需要判断前后两节课的教师和学生是否存在冲突
+						//主教冲突检测
+						if (Objects.nonNull(preCourseSchedule.getActualTeacherId())
+								&& preCourseSchedule.getActualTeacherId().equals(backCourseSchedule.getActualTeacherId())) {
 							if(postponeFlag){
 								return false;
 							}else {
 								throw new BizException(courseCheckInfo(preCourseSchedule, backCourseSchedule, existCourseScheduleIds, 1));
 							}
-                        }
+						}
 
 //                        if(Objects.isNull(preCourseSchedule.getId())){
 //                            continue;
 //                        }
 
-                        //助教冲突检测
+						//助教冲突检测
 						List<Integer> preTeachingTeacherIdList = new ArrayList<>();
 						List<Integer> backTeachingTeacherIdList = new ArrayList<>();
 						if (allCourseScheduleIds.contains(preCourseSchedule.getId())) {
@@ -1937,12 +1935,12 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 								preTeachingTeacherIdList.addAll(integerAndIntegerListDto.getIds());
 							}
 						}
-                        if (CollectionUtils.isEmpty(preTeachingTeacherIdList)&&Objects.isNull(preCourseSchedule.getId())) {
-                            IntegerAndIntegerListDto integerAndIntegerListDto = classGroupTeachingTeacherMap.get(preCourseSchedule.getClassGroupId().longValue());
-                            if (Objects.nonNull(integerAndIntegerListDto)) {
+						if (CollectionUtils.isEmpty(preTeachingTeacherIdList)&&Objects.isNull(preCourseSchedule.getId())) {
+							IntegerAndIntegerListDto integerAndIntegerListDto = classGroupTeachingTeacherMap.get(preCourseSchedule.getClassGroupId().longValue());
+							if (Objects.nonNull(integerAndIntegerListDto)) {
 								preTeachingTeacherIdList.addAll(integerAndIntegerListDto.getIds());
-                            }
-                        }
+							}
+						}
 
 						if (allCourseScheduleIds.contains(backCourseSchedule.getId())) {
 							IntegerAndIntegerListDto integerAndIntegerListDto = courseScheduleTeachingTeacherMap.get(backCourseSchedule.getId());
@@ -1960,39 +1958,39 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 						preTeachingTeacherIdList.add(preCourseSchedule.getActualTeacherId());
 						backTeachingTeacherIdList.add(backCourseSchedule.getActualTeacherId());
 
-                        if (!CollectionUtils.isEmpty(preTeachingTeacherIdList)
-                                && !CollectionUtils.isEmpty(backTeachingTeacherIdList)) {
-                            List<Integer> repeatIds = preTeachingTeacherIdList
-                                    .stream().filter(backTeachingTeacherIdList::contains)
-                                    .collect(Collectors.toList());
-                            if (!CollectionUtils.isEmpty(repeatIds)) {
+						if (!CollectionUtils.isEmpty(preTeachingTeacherIdList)
+								&& !CollectionUtils.isEmpty(backTeachingTeacherIdList)) {
+							List<Integer> repeatIds = preTeachingTeacherIdList
+									.stream().filter(backTeachingTeacherIdList::contains)
+									.collect(Collectors.toList());
+							if (!CollectionUtils.isEmpty(repeatIds)) {
 								if(postponeFlag){
 									return false;
 								}else {
 									throw new BizException(courseCheckInfo(preCourseSchedule, backCourseSchedule, existCourseScheduleIds, 2));
 								}
-                            }
-                        }
-                        //学生冲突检测
-                        if (preCourseSchedule.getClassGroupId().equals(backCourseSchedule.getClassGroupId())) {
-                            //如果班级相同,则学生肯定存在冲突
+							}
+						}
+						//学生冲突检测
+						if (preCourseSchedule.getClassGroupId().equals(backCourseSchedule.getClassGroupId())) {
+							//如果班级相同,则学生肯定存在冲突
 							if(postponeFlag){
 								return false;
 							}else {
 								throw new BizException(courseCheckInfo(preCourseSchedule, backCourseSchedule, existCourseScheduleIds, 3));
 							}
-                        }
-                        //如果班级不同,则需要检测两个班级是否存在重复的学生
-                        List<ClassGroupStudentMapper> preClassGroupStudents = classGroupStudentsMap.get(preCourseSchedule.getClassGroupId());
-                        List<ClassGroupStudentMapper> backClassGroupStudents = classGroupStudentsMap.get(backCourseSchedule.getClassGroupId());
-                        //如果有一个存在没有学生的班级则不存在冲突
-                        if (CollectionUtils.isEmpty(preClassGroupStudents) || CollectionUtils.isEmpty(backClassGroupStudents)) {
-                            continue;
-                        }
-                        //课程对应请假学员编号集合
+						}
+						//如果班级不同,则需要检测两个班级是否存在重复的学生
+						List<ClassGroupStudentMapper> preClassGroupStudents = classGroupStudentsMap.get(preCourseSchedule.getClassGroupId());
+						List<ClassGroupStudentMapper> backClassGroupStudents = classGroupStudentsMap.get(backCourseSchedule.getClassGroupId());
+						//如果有一个存在没有学生的班级则不存在冲突
+						if (CollectionUtils.isEmpty(preClassGroupStudents) || CollectionUtils.isEmpty(backClassGroupStudents)) {
+							continue;
+						}
+						//课程对应请假学员编号集合
 						Set<Integer> preLeaveStudentIds = courseLeaveStudentMap.get(preCourseSchedule.getId());
-                        if(null == preLeaveStudentIds){
-                        	preLeaveStudentIds = Collections.EMPTY_SET;
+						if(null == preLeaveStudentIds){
+							preLeaveStudentIds = Collections.EMPTY_SET;
 						}
 						Set<Integer> backLeaveStudentIds = courseLeaveStudentMap.get(backCourseSchedule.getId());
 						if(null == backLeaveStudentIds){
@@ -2003,29 +2001,41 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 						Set<Integer> finalPreLeaveStudentIds = preLeaveStudentIds;
 						List<Integer> preClassGroupStudentIds = preClassGroupStudents.stream()
 								.filter(e->!finalPreLeaveStudentIds.contains(e.getUserId()))
-                                .map(ClassGroupStudentMapper::getUserId)
-                                .collect(Collectors.toList());
-                        //后面一节课程所在班级的学生编号列表
+								.map(ClassGroupStudentMapper::getUserId)
+								.collect(Collectors.toList());
+						//后面一节课程所在班级的学生编号列表
 						Set<Integer> finalBackLeaveStudentIds = backLeaveStudentIds;
 						Set<Integer> backClassGroupStudentIds = backClassGroupStudents.stream()
 								.filter(e->!finalBackLeaveStudentIds.contains(e.getUserId()))
-                                .map(ClassGroupStudentMapper::getUserId)
-                                .collect(Collectors.toSet());
-                        List<Integer> repeatStudentIds = preClassGroupStudentIds.stream()
-                                .filter(backClassGroupStudentIds::contains)
-                                .collect(Collectors.toList());
-                        if (!CollectionUtils.isEmpty(repeatStudentIds)) {
+								.map(ClassGroupStudentMapper::getUserId)
+								.collect(Collectors.toSet());
+						List<Integer> repeatStudentIds = preClassGroupStudentIds.stream()
+								.filter(backClassGroupStudentIds::contains)
+								.collect(Collectors.toList());
+						if (!CollectionUtils.isEmpty(repeatStudentIds)) {
 							if(postponeFlag){
 								return false;
 							}else {
 								throw new BizException(courseCheckInfo(preCourseSchedule, backCourseSchedule, existCourseScheduleIds, 3));
 							}
-                        }
-                    }
-                }
-            }
-        }
-        return true;
+						}
+					}
+				}
+			}
+		}
+		return true;
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+    public Boolean checkNewCourseSchedules(List<CourseSchedule> courseSchedules, boolean checkExistCourseSchedule,Boolean postponeFlag,ClassGroupStudentMapper classGroupStudentMapper) {
+		return this.checkCourseSchedules(courseSchedules,checkExistCourseSchedule,postponeFlag,classGroupStudentMapper);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+    public Boolean checkNewCourseSchedules(List<CourseSchedule> courseSchedules, boolean checkExistCourseSchedule,Boolean postponeFlag) {
+		return this.checkCourseSchedules(courseSchedules,checkExistCourseSchedule,postponeFlag,null);
     }
 
     private String courseCheckInfo(CourseSchedule preCourseSchedule, CourseSchedule backCourseSchedule, List<Long> existCourseScheduleIds, Integer type) {
@@ -3294,7 +3304,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 						map.put(tdms.getCourseScheduleType(), tdms);
 						musicGroupSalaryMap.put(tdms.getUserId(), map);
 					}
-				} else if (newCourseSchedule.getGroupType() == GroupType.VIP) {
+				} else if (newCourseSchedule.getGroupType() == GroupType.VIP || newCourseSchedule.getGroupType() == GroupType.LIVE) {
 					// 所有老师默认vip课酬
 					List<TeacherDefaultVipGroupSalary> teacherDefaultVipGroupSalaries = teacherDefaultVipGroupSalaryDao.queryByUserIdList(newTeacherIdList);
 					for (TeacherDefaultVipGroupSalary tdvs : teacherDefaultVipGroupSalaries) {

+ 31 - 19
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -2686,9 +2686,16 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
             //增加学员数
             classGroupDao.modifyStudentNum(classGroup.getId(),1);
         }
+        ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
+        classGroupStudentMapper.setClassGroupId(classGroup.getId());
+        classGroupStudentMapper.setGroupType(classGroup.getGroupType());
+        classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
+        classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
+        classGroupStudentMapper.setUserId(userId);
+        classGroupStudentMapper.setTenantId(classGroup.getTenantId());
 
         List<CourseSchedule> courseSchedules = JSON.parseArray(vipGroup.getCourseSchedulesJson(), CourseSchedule.class);
-        courseScheduleService.checkNewCourseSchedules(courseSchedules, false, false);
+        courseScheduleService.checkNewCourseSchedules(courseSchedules, false, false,classGroupStudentMapper);
 
         //校验优惠券
         String[] checkCoupon = CouponDetailTypeEnum.getAllowType(couponDetailTypeEnum);
@@ -2969,7 +2976,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
                 }
             }
         } else {
-            if("VIP".equals(vipGroup.getGroupType())){
+            if("VIP".equals(classGroup.getGroupType().getCode())){
                 classGroupDao.modifyStudentNum(classGroup.getId(),-1);
             }
             if (order.getBalancePaymentAmount() != null && order.getBalancePaymentAmount().doubleValue() > 0) {
@@ -3137,35 +3144,40 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
         }
         VipGroupCategory vipGroupCategory = vipGroupCategoryService.get(vipGroup.getVipGroupCategoryId());
 
-        List<StudentApplyRefunds> studentApplyRefunds = studentApplyRefundsDao.findByGroupAndUser(vipGroupId.toString(), vipGroup.getGroupType(), studentId);
-        if (!CollectionUtils.isEmpty(studentApplyRefunds)) {
-            return;
-        }
-
         ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId, vipGroup.getGroupType());
 
-        ClassGroupStudentMapper classStudentMapperByUserIdAndClassGroupId = classGroupStudentMapperDao.query(classGroup.getId(),
+        ClassGroupStudentMapper classStudentMapperByUserIdAndClassGroupId = classGroupStudentMapperDao.findClassGroupStudent(classGroup.getId(),
                 studentId);
 
         if (Objects.isNull(classStudentMapperByUserIdAndClassGroupId)) {
             return;
         }
-
+        GroupType groupType = GroupType.VIP;
+        ReturnFeeEnum returnFeeEnum = ReturnFeeEnum.VIP;
+        if("LIVE".equals(vipGroup.getGroupType())){
+            groupType = GroupType.LIVE;
+            returnFeeEnum = ReturnFeeEnum.LIVE;
+        }
+        BigDecimal amount = returnFeeDto.getAmount();
         if (classStudentMapperByUserIdAndClassGroupId.getStatus().equals(ClassGroupStudentStatusEnum.QUIT)) {
+            //记录日志
+            SysUserCashAccountLog sysUserCashAccountLog = new SysUserCashAccountLog();
+            sysUserCashAccountLog.setUserId(studentId);
+            sysUserCashAccountLog.setGroupType(groupType);
+            sysUserCashAccountLog.setOrganId(vipGroup.getOrganId());
+            sysUserCashAccountLog.setGroupId(vipGroupId.toString());
+            sysUserCashAccountLog.setAmount(amount);
+            sysUserCashAccountLog.setReturnFeeType(returnFeeEnum);
+            sysUserCashAccountLog.setComment("OA审批" + groupType.getDesc() + "退学");
+            sysUserCashAccountLogDao.insert(sysUserCashAccountLog);
             return;
         }
-        BigDecimal amount = returnFeeDto.getAmount();
+
         if (!classStudentMapperByUserIdAndClassGroupId.getStatus().equals(ClassGroupStudentStatusEnum.QUIT_SCHOOL)) {
             if (Objects.isNull(amount)) {
                 return;
             }
         }
-        GroupType groupType = GroupType.VIP;
-        ReturnFeeEnum returnFeeEnum = ReturnFeeEnum.VIP;
-        if("LIVE".equals(vipGroup.getGroupType())){
-            groupType = GroupType.LIVE;
-            returnFeeEnum = ReturnFeeEnum.LIVE;
-        }
         //记录日志
         SysUserCashAccountLog sysUserCashAccountLog = new SysUserCashAccountLog();
         sysUserCashAccountLog.setUserId(studentId);
@@ -4599,7 +4611,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
         courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
 
         imGroupService.create(classGroup.getId().toString(), null, classGroup.getName(), classGroup.getName(),
-                vipGroup.getName(), null, null, vipGroup.getGroupType(), ImGroup.GroupTypeEnum.valueOf(vipGroup.getGroupType()));
+                vipGroup.getName(), null, "https://gyt.ks3-cn-beijing.ksyuncs.com/icon_live_class_group_avatar.png", vipGroup.getGroupType(), ImGroup.GroupTypeEnum.valueOf(vipGroup.getGroupType()));
         imGroupMemberService.join(classGroup.getId().toString(), userRoleMap);
         imUserFriendService.refreshGroupImUserFriend(classGroup.getMusicGroupId(), classGroup.getGroupType());
         classGroupDao.update(classGroup);
@@ -4612,7 +4624,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
     public void updateVipGroupStatusToFinished() {
         Date now = new Date();
         //更新至已结束
-        List<VipGroup> vipGroupList = vipGroupDao.queryRequiredOverList("VIP");
+        List<VipGroup> vipGroupList = vipGroupDao.queryRequiredOverList();
         if (vipGroupList != null && vipGroupList.size() > 0) {
             for (VipGroup vipGroup : vipGroupList) {
                 if (Objects.nonNull(vipGroup.getCoursesExpireDate()) && (vipGroup.getCoursesExpireDate().compareTo(now) > 0 || DateUtil.isSameDay(vipGroup.getCoursesExpireDate(), now))) {
@@ -4633,7 +4645,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
         }
         
         //关闭没有学生的课程组
-        List<VipGroupClassGroupMapper> vipGroupClassGroupMapperList = classGroupStudentMapperDao.queryWaitCancelVipGroup("VIP");
+        List<VipGroupClassGroupMapper> vipGroupClassGroupMapperList = classGroupStudentMapperDao.queryWaitCancelVipGroup();
         if(vipGroupClassGroupMapperList != null && vipGroupClassGroupMapperList.size() > 0){
             vipGroupList = vipGroupDao.queryByIds(vipGroupClassGroupMapperList.stream().map(t -> t.getId().toString()).collect(Collectors.joining(",")));
             for(VipGroup vipGroup : vipGroupList){

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/ClassGroupStudentMapperMapper.xml

@@ -715,7 +715,7 @@
 		select vg.id_,cgsm.class_group_id_,count(cgsm.user_id_) total_student_num_,sum(case when cgsm.status_ = 'QUIT' then 1 else 0 end ) quit_student_num_ 
 		from class_group_student_mapper cgsm LEFT JOIN class_group cg on cgsm.class_group_id_ = cg.id_
 		LEFT JOIN vip_group vg on vg.id_ = cgsm.music_group_id_
-		WHERE cgsm.group_type_ = #{groupType} and vg.group_status_ in (2,6) and cg.del_flag_ != 1 GROUP BY cgsm.class_group_id_
+		WHERE vg.group_status_ in (2,6) and cg.del_flag_ != 1 GROUP BY cgsm.class_group_id_
 		) a WHERE a.total_student_num_ = a.quit_student_num_
     </select>
     <select id="findByVipGroups" resultMap="ClassGroupStudentMapper">

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/VipGroupMapper.xml

@@ -1075,7 +1075,7 @@
             vip_group vg
             LEFT JOIN course_schedule cs ON cs.group_type_ = vg.group_type_ AND CONCAT(vg.id_, '') = cs.music_group_id_
         WHERE
-            vg.group_status_ = 2 AND vg.group_type_ = #{groupType}
+            vg.group_status_ = 2
             GROUP BY vg.id_
         HAVING COUNT( CASE WHEN cs.status_ != 'OVER' THEN 1 ELSE NULL END )&lt;=0
     </select>

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/CourseScheduleController.java

@@ -179,7 +179,7 @@ public class CourseScheduleController extends BaseController {
         if(Objects.nonNull(oldCourseSchedule.getNewCourseId())&&!oldCourseSchedule.getNewCourseId().equals(oldCourseSchedule.getId())){
             return failed("被合并课程禁止调整");
         }
-        if(GroupType.VIP.equals(oldCourseSchedule.getGroupType())){
+        if(GroupType.VIP.equals(oldCourseSchedule.getGroupType()) || GroupType.LIVE.equals(oldCourseSchedule.getGroupType())){
             VipGroup vipGroup = vipGroupDao.findByCourseSchedule(courseSchedule.getId());
             if(Objects.nonNull(vipGroup)
                     &&!VipGroupStatusEnum.PROGRESS.equals(vipGroup.getStatus())

+ 0 - 6
mec-web/src/main/java/com/ym/mec/web/controller/VipGroupManageController.java

@@ -431,8 +431,6 @@ public class VipGroupManageController extends BaseController {
         return succeed(vipGroupService.updateLiveGroup(vipGroupApplyDto));
     }
 
-
-
     @ApiOperation(value = "直播课学生列表")
     @PostMapping(value = "/liveStudentList")
     public HttpResponseResult<PageInfo<LiveGroupWrapper.LiveGroupStudentList>> liveStudentList(@Validated @RequestBody LiveGroupWrapper.LiveGroupStudentQuery query){
@@ -441,8 +439,6 @@ public class VipGroupManageController extends BaseController {
         return succeed(PageUtil.pageInfo(iPage));
     }
 
-
-
     @ApiOperation(value = "课程列表")
     @PostMapping(value = "/liveCourseList")
     public HttpResponseResult<Object> liveCourseList(@Validated @RequestBody LiveGroupWrapper.LiveGroupStudentQuery query){
@@ -450,8 +446,6 @@ public class VipGroupManageController extends BaseController {
         return succeed(vipGroupService.liveCourseList(query));
     }
 
-
-
     @ApiOperation(value = "删除直播课")
     @GetMapping(value = "/delLiveGroup/{id}")
     public HttpResponseResult<Object> delLiveGroup(@PathVariable Integer id){