Browse Source

活动排课

zouxuan 3 years ago
parent
commit
8d117ea2c0

+ 7 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -926,8 +926,15 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		if(StringUtils.isBlank(studentIds)){
 			throw new BizException("请选择学员");
 		}
+		VipGroupCategory vipGroupCategory = vipGroupCategoryDao.get(applyBaseInfo.getVipGroupCategoryId());
+		if(Objects.isNull(vipGroupCategory)){
+			throw new BizException("课程形式不存在");
+		}
 		Boolean giveFlag = vipGroup.getGiveFlag();
 		List<Integer> studentIdList = Arrays.stream(studentIds.split(",")).map(id->Integer.valueOf(id)).collect(Collectors.toList());
+		if(studentIdList.size() > vipGroupCategory.getStudentNum()){
+			throw new BizException("{}课程最多支持{}人",vipGroupCategory.getName(),vipGroupCategory.getStudentNum());
+		}
 		//获取学员排课资格
 		List<ActivityUserMapper> activityUserMappers = activityUserMapperService.findByStudentIdList(activity.getId(),studentIds,giveFlag?"GIVE_VIP":"VIP");
 		if(studentIdList.size() != activityUserMappers.size()){
@@ -1000,10 +1007,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			throw new BizException("{}课程时间冲突({}-{})", sysUser.getRealName(), DateUtil.dateToString(firstCourseSchedule.getStartClassTime(), "yyyy-MM-dd HH:mm:ss"), DateUtil.dateToString(latestCourseSchedule.getEndClassTime(), "HH:mm:ss"));
 		}
 
-		VipGroupCategory vipGroupCategory = vipGroupCategoryDao.get(applyBaseInfo.getVipGroupCategoryId());
-		if(Objects.isNull(vipGroupCategory)){
-			throw new BizException("课程形式不存在");
-		}
 		List<String> studentNames = studentDao.getStudentNames(canBuyStudentIds);
 
 		//生成vip课信息