From e0ecdda40045ba9b5f10a2f0f93d6607660b2588 Mon Sep 17 00:00:00 2001 From: zhangrui Date: Thu, 10 Sep 2026 10:57:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=B2=E5=AD=90=E6=B4=BB=E5=8A=A8=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E6=95=B4=E6=94=B9-1.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/FamilyActivityServiceImpl.java | 64 +++++++++++-------- .../zhgh/activity/family/apply/signForm.js | 8 ++- .../zhghh5/activity/family/list/applyForm.js | 8 ++- 3 files changed, 49 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/budwk/app/zhgh/activity/family/service/impl/FamilyActivityServiceImpl.java b/src/main/java/com/budwk/app/zhgh/activity/family/service/impl/FamilyActivityServiceImpl.java index b5d0a94..85fa906 100644 --- a/src/main/java/com/budwk/app/zhgh/activity/family/service/impl/FamilyActivityServiceImpl.java +++ b/src/main/java/com/budwk/app/zhgh/activity/family/service/impl/FamilyActivityServiceImpl.java @@ -617,10 +617,17 @@ public class FamilyActivityServiceImpl extends BaseServiceImpl i } FamilyActivity activity = dao().fetch(FamilyActivity.class, course.getActivityId()); validateSignUpTimeAndScope(activity, SecurityUtil.getUserId(), true); + FamilyType type = dao().fetch(FamilyType.class, course.getCourseType()); + if (type == null) { + throw new BaseException("报名类型不存在或已变更"); + } if (Lang.isEmpty(familyUser.getMobileColumnsValue())) { throw new BaseException("请填写" + activity.getKeyWord() + "信息"); } + // 修改报名与新增报名使用同一套子活动类型字段及家属人数上限,防止绕过前端提交超额数据。 + familyUser.setMobileColumnsValue(normalizeAndValidateFamilyColumns( + familyUser.getMobileColumnsValue(), type, course, activity)); // 修改校验必须排除本人原报名,否则人数、唯一标识及报名限制都会重复计算。 familyUser.setActivityId(currentSignUp.getActivityId()); @@ -630,10 +637,6 @@ public class FamilyActivityServiceImpl extends BaseServiceImpl i throw new BaseException(familyCountResult.get(false)); } - FamilyType type = dao().fetch(FamilyType.class, course.getCourseType()); - if (type == null) { - throw new BaseException("报名类型不存在或已变更"); - } int currentFamilyNumber = Boolean.TRUE.equals(type.getIsBringFamily()) && Boolean.TRUE.equals(type.getIsAddFamily()) ? familyUser.getMobileColumnsValue().size() : 0; if (isSignFullForUpdate(course, type, currentFamilyNumber, currentSignUp, null)) { @@ -745,14 +748,14 @@ public class FamilyActivityServiceImpl extends BaseServiceImpl i if (StrUtil.isBlank(activity.getOnlyKey())) { throw new BaseException("活动未配置家属唯一标识,请联系管理员"); } - if (activity.getFamilyMaxCount() == null) { - throw new BaseException("活动未配置家属最多人数,请联系管理员"); + if (type.getFamilyMaxCount() == null) { + throw new BaseException("子活动类型未配置家属最多人数,请联系管理员"); } if (Lang.isEmpty(submittedFamilies)) { throw new BaseException("请填写" + activity.getKeyWord() + "信息"); } - if (activity.getFamilyMaxCount() != null && submittedFamilies.size() > activity.getFamilyMaxCount()) { - throw new BaseException(activity.getKeyWord() + "人数最多为" + activity.getFamilyMaxCount()); + if (submittedFamilies.size() > type.getFamilyMaxCount()) { + throw new BaseException(activity.getKeyWord() + "人数最多为" + type.getFamilyMaxCount()); } dao().fetchLinks(type, "familyMobileSignColumnList", Cnd.NEW().asc("columnIndex")); List columnConfigs = type.getFamilyMobileSignColumnList(); @@ -1110,14 +1113,6 @@ public class FamilyActivityServiceImpl extends BaseServiceImpl i @Override public Map validFamilyCount(FamilyUser user) { String activityId = user.getActivityId(); - // 查询报名记录 - Cnd signUpCnd = Cnd.where(FamilyUser::getActivityId, "=", activityId) - .and(FamilyUser::getUserId, "=", SecurityUtil.getUserId()); - if (StrUtil.isNotBlank(user.getId())) { - signUpCnd.and(FamilyUser::getId, "!=", user.getId()); - } - List list = dao().query(FamilyUser.class, signUpCnd); - FamilyActivity activity = dao().fetch(FamilyActivity.class, activityId); if (activity == null) { return Map.of(false, "报名活动不存在或已删除"); @@ -1125,14 +1120,35 @@ public class FamilyActivityServiceImpl extends BaseServiceImpl i if (StrUtil.isBlank(activity.getOnlyKey())) { return Map.of(false, "活动未配置家属唯一标识,请联系管理员"); } - if (activity.getFamilyMaxCount() == null) { - return Map.of(false, "活动未配置家属最多人数,请联系管理员"); - } if (Lang.isEmpty(user.getMobileColumnsValue())) { return Map.of(false, "请填写" + activity.getKeyWord() + "信息"); } + FamilyCourse currentCourse = dao().fetch(FamilyCourse.class, user.getCourseId()); + if (currentCourse == null || !Objects.equals(currentCourse.getActivityId(), activityId)) { + return Map.of(false, "报名课程不存在或已变更"); + } + FamilyType currentType = dao().fetch(FamilyType.class, currentCourse.getCourseType()); + if (currentType == null) { + return Map.of(false, "子活动类型不存在或已变更"); + } + if (currentType.getFamilyMaxCount() == null) { + return Map.of(false, "子活动类型未配置家属最多人数,请联系管理员"); + } + // 查询本人本活动的其他报名,修改报名时排除当前记录,后续冲突校验仍覆盖全部子活动类型。 + Cnd signUpCnd = Cnd.where(FamilyUser::getActivityId, "=", activityId) + .and(FamilyUser::getUserId, "=", SecurityUtil.getUserId()); + if (StrUtil.isNotBlank(user.getId())) { + signUpCnd.and(FamilyUser::getId, "!=", user.getId()); + } + List list = dao().query(FamilyUser.class, signUpCnd); + List courseList = dao().query(FamilyCourse.class, Cnd.where("activityId", "=", activityId)); + Map courseMap = courseList.stream() + .collect(Collectors.toMap(FamilyCourse::getId, FamilyCourse::getCourseType)); + + // 家属最多数按当前子活动类型独立累计,同类型多个子活动按家属唯一标识去重。 List> allMobileColumnsValue = new ArrayList<>(list.stream() + .filter(item -> Objects.equals(currentCourse.getCourseType(), courseMap.get(item.getCourseId()))) .map(FamilyUser::getMobileColumnsValue) .filter(Objects::nonNull) .flatMap(List::stream) @@ -1140,9 +1156,6 @@ public class FamilyActivityServiceImpl extends BaseServiceImpl i allMobileColumnsValue.addAll(user.getMobileColumnsValue()); - // 后面搞活动,用这行代码吧,因为这次活动1个人可以报2个孩子,但是同一个孩子又可以报2个场地,草 - //return allMobileColumnsValue.size() > activity.getFamilyMaxCount(); - long count = allMobileColumnsValue.stream() .filter(Objects::nonNull) .flatMap(List::stream) @@ -1153,13 +1166,10 @@ public class FamilyActivityServiceImpl extends BaseServiceImpl i .distinct() .count(); - if(count > activity.getFamilyMaxCount()) { - return Map.of(false, activity.getKeyWord() + "人数最多为" + activity.getFamilyMaxCount()); + if(count > currentType.getFamilyMaxCount()) { + return Map.of(false, activity.getKeyWord() + "人数最多为" + currentType.getFamilyMaxCount()); } - List courseList = dao().query(FamilyCourse.class, Cnd.where("activityId", "=", activityId)); - Map courseMap = courseList.stream().collect(Collectors.toMap(FamilyCourse::getId, FamilyCourse::getCourseType)); - List typeList = dao().query(FamilyType.class, Cnd.NEW()); Map typeMap = typeList.stream().collect(Collectors.toMap(FamilyType::getId, FamilyType::getTypeName)); diff --git a/src/main/resources/views/platform/zhgh/activity/family/apply/signForm.js b/src/main/resources/views/platform/zhgh/activity/family/apply/signForm.js index 13047bd..536fa44 100644 --- a/src/main/resources/views/platform/zhgh/activity/family/apply/signForm.js +++ b/src/main/resources/views/platform/zhgh/activity/family/apply/signForm.js @@ -165,8 +165,12 @@ const signForm = { }, methods: { addFamily() { - if(this.formData.mobileColumnsValue.length >= this.activity.familyMaxCount) { - this.$message.warning('家属最多人数为' + this.activity.familyMaxCount) + if(this.courseTypeRow.familyMaxCount === null || this.courseTypeRow.familyMaxCount === undefined || this.courseTypeRow.familyMaxCount === '') { + this.$message.warning('当前子活动类型未配置家属最多人数') + return + } + if(this.formData.mobileColumnsValue.length >= Number(this.courseTypeRow.familyMaxCount)) { + this.$message.warning('家属最多人数为' + this.courseTypeRow.familyMaxCount) return } const list = clone(this.courseTypeRow.familyMobileSignColumnList) diff --git a/src/main/resources/views/platform/zhghh5/activity/family/list/applyForm.js b/src/main/resources/views/platform/zhghh5/activity/family/list/applyForm.js index 0a56153..9eb4c9c 100644 --- a/src/main/resources/views/platform/zhghh5/activity/family/list/applyForm.js +++ b/src/main/resources/views/platform/zhghh5/activity/family/list/applyForm.js @@ -103,8 +103,12 @@ const applyForm = { }, methods: { addFamily() { - if(this.formData.mobileColumnsValue.length >= this.activity.familyMaxCount) { - this.$toast(this.activity.keyWord + '最多人数为' + this.activity.familyMaxCount) + if(this.courseType.familyMaxCount === null || this.courseType.familyMaxCount === undefined || this.courseType.familyMaxCount === '') { + this.$toast('当前子活动类型未配置家属最多人数') + return + } + if(this.formData.mobileColumnsValue.length >= Number(this.courseType.familyMaxCount)) { + this.$toast(this.activity.keyWord + '最多人数为' + this.courseType.familyMaxCount) return } const list = clone(this.courseType.familyMobileSignColumnList)