Merge branch 'main' of http://gitea.dd3skj.com/c-zhangr1/zhgh_njnu
This commit is contained in:
+37
-27
@@ -617,10 +617,17 @@ public class FamilyActivityServiceImpl extends BaseServiceImpl<FamilyActivity> 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<FamilyActivity> 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<FamilyActivity> 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<FamilyMobileSignColumn> columnConfigs = type.getFamilyMobileSignColumnList();
|
||||
@@ -1110,14 +1113,6 @@ public class FamilyActivityServiceImpl extends BaseServiceImpl<FamilyActivity> i
|
||||
@Override
|
||||
public Map<Boolean, String> 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<FamilyUser> 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<FamilyActivity> 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<FamilyUser> list = dao().query(FamilyUser.class, signUpCnd);
|
||||
List<FamilyCourse> courseList = dao().query(FamilyCourse.class, Cnd.where("activityId", "=", activityId));
|
||||
Map<String, String> courseMap = courseList.stream()
|
||||
.collect(Collectors.toMap(FamilyCourse::getId, FamilyCourse::getCourseType));
|
||||
|
||||
// 家属最多数按当前子活动类型独立累计,同类型多个子活动按家属唯一标识去重。
|
||||
List<List<NutMap>> 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<FamilyActivity> 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<FamilyActivity> 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<FamilyCourse> courseList = dao().query(FamilyCourse.class, Cnd.where("activityId", "=", activityId));
|
||||
Map<String, String> courseMap = courseList.stream().collect(Collectors.toMap(FamilyCourse::getId, FamilyCourse::getCourseType));
|
||||
|
||||
List<FamilyType> typeList = dao().query(FamilyType.class, Cnd.NEW());
|
||||
Map<String, String> typeMap = typeList.stream().collect(Collectors.toMap(FamilyType::getId, FamilyType::getTypeName));
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user