|  | @@ -25,6 +25,7 @@ import com.ym.mec.biz.event.source.SendSeoMessageSource;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.service.*;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.controller.BaseController;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.entity.HttpResponseResult;
 | 
	
		
			
				|  |  | +import com.ym.mec.common.page.WrapperUtil;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.tenant.TenantContextHolder;
 | 
	
		
			
				|  |  |  import org.apache.commons.collections.ListUtils;
 | 
	
		
			
				|  |  |  import org.apache.commons.lang3.StringUtils;
 | 
	
	
		
			
				|  | @@ -167,6 +168,10 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 | 
	
		
			
				|  |  |  	private PracticeGroupSellPriceDao practiceGroupSellPriceDao;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |  	private TenantAssetsInfoService tenantAssetsInfoService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +	private TenantConfigService tenantConfigService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +	private VipGroupCategoryDao vipGroupCategoryDao;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private final Logger LOGGER = LoggerFactory
 | 
	
		
			
				|  |  |              .getLogger(this.getClass());
 | 
	
	
		
			
				|  | @@ -2391,6 +2396,8 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 | 
	
		
			
				|  |  |                  .stream().map(Long::parseLong).collect(Collectors.toList());
 | 
	
		
			
				|  |  |          //所有的课程
 | 
	
		
			
				|  |  |          List<CourseSchedule> courseSchedules = courseScheduleDao.findByCourseScheduleIds(courseScheduleIds);
 | 
	
		
			
				|  |  | +        //校验机构线上课人数上限
 | 
	
		
			
				|  |  | +		this.checkOnlineCategory(courseSchedules,vipGroupCourseAdjustInfo.getTeachMode());
 | 
	
		
			
				|  |  |          courseSchedules.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
 | 
	
		
			
				|  |  |  		//获取操作日志
 | 
	
		
			
				|  |  |  		List<CourseScheduleModifyLog> modifyLogs = getModifyLogs(courseScheduleIds, courseSchedules, user.getId(), now);
 | 
	
	
		
			
				|  | @@ -3068,6 +3075,9 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |      public HttpResponseResult courseAdjust(List<CourseSchedule> newCourseSchedules, Boolean allowZeroSalary) {
 | 
	
		
			
				|  |  | +    	//校验分部线上课排课人数上线
 | 
	
		
			
				|  |  | +		this.checkOnlineCategory(newCourseSchedules);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          Date date = new Date();
 | 
	
		
			
				|  |  |  		// 课程信息处理
 | 
	
		
			
				|  |  |  		List<Long> courseScheduleIds = newCourseSchedules.stream().map(CourseSchedule::getId).distinct().collect(Collectors.toList());
 | 
	
	
		
			
				|  | @@ -3897,10 +3907,6 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 | 
	
		
			
				|  |  |          courseAdjust(courseSchedules, true);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    @Override
 | 
	
		
			
				|  |  | -    public void courseSwapWithDay(Date day1, Date day2) {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public List<CourseSchedule> findClassGroupNoStartCourseSchedules(List<Integer> classGroupIds, GroupType groupType) {
 | 
	
	
		
			
				|  | @@ -4356,21 +4362,6 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public void teacherSignInRemind() {
 | 
	
		
			
				|  |  | -        List<Mapper> mapperList = courseScheduleDao.queryTeacherNotStartCourseScheduleIn30Mins();
 | 
	
		
			
				|  |  | -        for (Mapper mapper : mapperList) {
 | 
	
		
			
				|  |  | -            Integer userId = (Integer) mapper.getKey();
 | 
	
		
			
				|  |  | -            String scheduleName = (String) mapper.getValue();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            Map<Integer, String> receivers = new HashMap<Integer, String>();
 | 
	
		
			
				|  |  | -            receivers.put(userId, userId + "");
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            sysMessageService.batchSendMessage(MessageSender.JIGUANG, MessageTypeEnum.TEACHER_PUSH_ATTEND_CLASS_MESSAGE,
 | 
	
		
			
				|  |  | -                    receivers, null, 0, "2","TEACHER", scheduleName);
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    @Override
 | 
	
		
			
				|  |  |      public List<CourseSchedule> findCourseScheduleByClassGroup(Integer classGroupId) {
 | 
	
		
			
				|  |  |          if (Objects.isNull(classGroupId)) {
 | 
	
		
			
				|  |  |              throw new BizException("请指定班级");
 | 
	
	
		
			
				|  | @@ -5450,38 +5441,6 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 | 
	
		
			
				|  |  |  		System.out.println("重复课程数量:" + courseRepeatIdMap.size());
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -//	@Override
 | 
	
		
			
				|  |  | -//	public List<CourseSchedule> classGroupNotStartMergeCourseReplace(Long classGroupId) {
 | 
	
		
			
				|  |  | -//		List<CourseSchedule> courseSchedules = courseScheduleDao.getClassGroupCourses(classGroupId);
 | 
	
		
			
				|  |  | -//		Set<Long> newCourseIds = courseSchedules.stream().filter(c -> Objects.nonNull(c.getNewCourseId())).map(CourseSchedule::getNewCourseId).collect(Collectors.toSet());
 | 
	
		
			
				|  |  | -//		if(CollectionUtils.isEmpty(newCourseIds)){
 | 
	
		
			
				|  |  | -//			return Collections.EMPTY_LIST;
 | 
	
		
			
				|  |  | -//		}
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//		Date now = new Date();
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//		List<CourseSchedule> mainCourses = courseScheduleDao.findByCourseScheduleIds(new ArrayList<>(newCourseIds));
 | 
	
		
			
				|  |  | -//		Map<Long, CourseSchedule> idCourseMap = mainCourses.stream().collect(Collectors.toMap(CourseSchedule::getId, c -> c, (c1, c2) -> c1));
 | 
	
		
			
				|  |  | -//		Iterator<CourseSchedule> iterator = courseSchedules.iterator();
 | 
	
		
			
				|  |  | -//		while (iterator.hasNext()){
 | 
	
		
			
				|  |  | -//			CourseSchedule next = iterator.next();
 | 
	
		
			
				|  |  | -//			if(Objects.isNull(next.getNewCourseId())){
 | 
	
		
			
				|  |  | -//				continue;
 | 
	
		
			
				|  |  | -//			}
 | 
	
		
			
				|  |  | -//			CourseSchedule mainCourse = idCourseMap.get(next.getNewCourseId());
 | 
	
		
			
				|  |  | -//			if(next.getClassGroupId().equals(mainCourse.getClassGroupId())||mainCourse.getStartClassTime().compareTo(now)<0){
 | 
	
		
			
				|  |  | -//				iterator.remove();
 | 
	
		
			
				|  |  | -//			}
 | 
	
		
			
				|  |  | -//		}
 | 
	
		
			
				|  |  | -//		for (CourseSchedule courseSchedule : courseSchedules) {
 | 
	
		
			
				|  |  | -//			if(Objects.isNull(courseSchedule.getNewCourseId())){
 | 
	
		
			
				|  |  | -//				continue;
 | 
	
		
			
				|  |  | -//			}
 | 
	
		
			
				|  |  | -//			courseSchedule = idCourseMap.get(courseSchedule.getId());
 | 
	
		
			
				|  |  | -//		}
 | 
	
		
			
				|  |  | -//		return courseSchedules;
 | 
	
		
			
				|  |  | -//	}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  	@Override
 | 
	
		
			
				|  |  |  	@Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |  	public HttpResponseResult courseMerge(CourseMergeDto courseMergeInfo) {
 | 
	
	
		
			
				|  | @@ -5526,8 +5485,8 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 | 
	
		
			
				|  |  |  			courseSchedule.setNote("课程合并");
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		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());
 | 
	
		
			
				|  |  | +//		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());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		Map<Integer, CourseScheduleStudentPayment> mainStudentCourseMap = courseScheduleStudentPayments.stream().filter(c -> courseMergeInfo.getId().equals(c.getCourseScheduleId())).collect(Collectors.toMap(CourseScheduleStudentPayment::getUserId, c -> c, (c1, c2) -> c1));
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -5538,7 +5497,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		for (Map.Entry<Integer, List<CourseScheduleStudentPayment>> otherStudentCourseMapEntry : otherStudentCourseMap.entrySet()) {
 | 
	
		
			
				|  |  |  			List<CourseScheduleStudentPayment> studentCoursePayments = otherStudentCourseMapEntry.getValue();
 | 
	
		
			
				|  |  | -			BigDecimal salary = studentCoursePayments.stream().map(CourseScheduleStudentPayment::getExpectPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
 | 
	
		
			
				|  |  | +//			BigDecimal salary = studentCoursePayments.stream().map(CourseScheduleStudentPayment::getExpectPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
 | 
	
		
			
				|  |  |  			if(mainStudentCourseMap.containsKey(otherStudentCourseMapEntry.getKey())){
 | 
	
		
			
				|  |  |  //				CourseScheduleStudentPayment updatePayment = mainStudentCourseMap.get(otherStudentCourseMapEntry.getKey());
 | 
	
		
			
				|  |  |  //				updatePayment.setExpectPrice(updatePayment.getExpectPrice().add(salary));
 | 
	
	
		
			
				|  | @@ -5706,4 +5665,53 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 | 
	
		
			
				|  |  |  	public int endCountCourseSchedules(Map<String, Object> params) {
 | 
	
		
			
				|  |  |  		return courseScheduleDao.endCountCourseSchedules(params);
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public void checkOnlineCategory(Integer studentNum) {
 | 
	
		
			
				|  |  | +		Integer tenantId = TenantContextHolder.getTenantId();
 | 
	
		
			
				|  |  | +		//查询云教室扣费标准
 | 
	
		
			
				|  |  | +		TenantConfig tenantConfig = tenantConfigService.getOne(new WrapperUtil<TenantConfig>()
 | 
	
		
			
				|  |  | +				.hasEq("tenant_id_", tenantId).queryWrapper());
 | 
	
		
			
				|  |  | +		if (Objects.isNull(tenantConfig)) {
 | 
	
		
			
				|  |  | +			return;
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		//云教室人数上限(含老师)
 | 
	
		
			
				|  |  | +		Integer cloudRoomUpLimit = Optional.ofNullable(tenantConfig.getConfig())
 | 
	
		
			
				|  |  | +				.map(c -> JSON.parseObject(c, TenantConfigDetail.class))
 | 
	
		
			
				|  |  | +				.map(TenantConfigDetail::getCloud_room_rule)
 | 
	
		
			
				|  |  | +				.map(TenantConfigDetail.CloudRoomRule::getCloud_room_up_limit).orElse(null);
 | 
	
		
			
				|  |  | +		if(studentNum >= cloudRoomUpLimit){
 | 
	
		
			
				|  |  | +			throw new BizException("当前机构只允许{}人以内的线上课",cloudRoomUpLimit);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	@Override
 | 
	
		
			
				|  |  | +	public void checkOnlineCategory(List<CourseSchedule> courseSchedules) {
 | 
	
		
			
				|  |  | +		List<CourseSchedule> collect = courseSchedules.stream().filter(e -> e.getTeachMode() == TeachModeEnum.ONLINE).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +		if(collect != null && collect.size() > 0){
 | 
	
		
			
				|  |  | +			checkMaxStudentNum(collect);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	private void checkMaxStudentNum(List<CourseSchedule> courseSchedules){
 | 
	
		
			
				|  |  | +		Set<Long> vipGroupIds = courseSchedules.stream().filter(e->e.getGroupType() == VIP).map(e -> Long.parseLong(e.getMusicGroupId())).collect(Collectors.toSet());
 | 
	
		
			
				|  |  | +		if(vipGroupIds != null && vipGroupIds.size() > 0){
 | 
	
		
			
				|  |  | +			List<VipGroup> vipGroupList = vipGroupDao.getVipGroupByIds(vipGroupIds);
 | 
	
		
			
				|  |  | +			if(vipGroupList != null && vipGroupList.size() > 0){
 | 
	
		
			
				|  |  | +				Set<Integer> categoryIds = vipGroupList.stream().map(e -> e.getVipGroupCategoryId()).collect(Collectors.toSet());
 | 
	
		
			
				|  |  | +				List<VipGroupCategory> categories = vipGroupCategoryDao.findByIds(categoryIds);
 | 
	
		
			
				|  |  | +				if(categories != null && categories.size() > 0){
 | 
	
		
			
				|  |  | +					Integer maxStudentNum = categories.stream().max(Comparator.comparing(VipGroupCategory::getStudentNum)).map(e->e.getStudentNum()).get();
 | 
	
		
			
				|  |  | +					this.checkOnlineCategory(maxStudentNum);
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	@Override
 | 
	
		
			
				|  |  | +	public void checkOnlineCategory(List<CourseSchedule> courseSchedules, TeachModeEnum teachMode) {
 | 
	
		
			
				|  |  | +		if(teachMode == TeachModeEnum.ONLINE){
 | 
	
		
			
				|  |  | +			checkMaxStudentNum(courseSchedules);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  |  }
 |