Explorar el Código

feat:vip课活动购买限制

Joburgess hace 4 años
padre
commit
0106be5958

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

@@ -244,13 +244,17 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupApplyBaseInfo().getVipGroupActivityId());
 		if(Objects.nonNull(vipGroupActivity)&&Objects.nonNull(vipGroupActivity.getStudentMaxUsedTimes())&&vipGroupActivity.getStudentMaxUsedTimes()!=-1&&StringUtils.isNotBlank(vipGroupApplyBaseInfoDto.getStudentIdList())){
 			List<String> tempStudentIds = Arrays.asList(vipGroupApplyBaseInfoDto.getStudentIdList().split(","));
+			List<Integer> errStudentIds = new ArrayList<>();
 			for (String studentIdStr : tempStudentIds) {
 				int useNum = vipGroupDao.countStudentUserActivityNum(vipGroup.getVipGroupApplyBaseInfo().getVipGroupActivityId(), Integer.valueOf(studentIdStr));
 				if(useNum>=vipGroupActivity.getStudentMaxUsedTimes()){
-					SysUser student = teacherDao.getUser(Integer.valueOf(studentIdStr));
-					throw new BizException("{}学员已超过该活动购买次数限制", student.getUsername());
+					errStudentIds.add(Integer.valueOf(studentIdStr));
 				}
 			}
+			if(errStudentIds.size()>0){
+				List<SimpleUserDto> students = teacherDao.getUsersSimpleInfo(errStudentIds);
+				throw new BizException("学员{}已超过该活动购买次数限制", StringUtils.join(students.stream().map(SimpleUserDto::getNickName).collect(Collectors.toList()), "、"));
+			}
 		}
 		//判断课程安排是否超出范围
 		if(Objects.nonNull(vipGroupActivity)&&(Objects.nonNull(vipGroupActivity.getCoursesEndTime())||Objects.nonNull(vipGroupActivity.getCoursesStartTime()))){
@@ -2911,13 +2915,17 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		}
 
 		if(Objects.nonNull(vipGroupActivity)&&Objects.nonNull(vipGroupActivity.getStudentMaxUsedTimes())&&vipGroupActivity.getStudentMaxUsedTimes()!=-1&&!CollectionUtils.isEmpty(studentIds)){
+			List<Integer> errStudentIds = new ArrayList<>();
 			for (Integer studentId : studentIds) {
 				int useNum = vipGroupDao.countStudentUseingActivityNum(vipGroup.getVipGroupActivityId(), Integer.valueOf(studentId));
 				if(useNum>=vipGroupActivity.getStudentMaxUsedTimes()){
-					SysUser student = teacherDao.getUser(studentId);
-					throw new BizException("{}学员已超过该活动购买次数限制", student.getUsername());
+					errStudentIds.add(studentId);
 				}
 			}
+			if(errStudentIds.size()>0){
+				List<SimpleUserDto> students = teacherDao.getUsersSimpleInfo(errStudentIds);
+				throw new BizException("学员{}已超过该活动购买次数限制", StringUtils.join(students.stream().map(SimpleUserDto::getNickName).collect(Collectors.toList()), ","));
+			}
 		}
 
 		Date now=new Date();