This commit is contained in:
=
2026-08-28 15:26:54 +08:00
parent d08587f08d
commit a069324006
4 changed files with 60 additions and 25 deletions
@@ -398,7 +398,7 @@ public class TrainSignUpApplyController {
}
TrainSignUpType type = trainSignUpActivityService.dao().fetch(TrainSignUpType.class, course.getCourseType());
if (type != null) {
if (type.getIsBringFamily() && type.getIsAddFamily()) {
if (Boolean.TRUE.equals(type.getIsBringFamily()) && Boolean.TRUE.equals(type.getIsAddFamily())) {
List<NutMap> mobileColumnsValue = trainSignUpUser.getMobileColumnsValue();
NutMap map = mobileColumnsValue.stream().filter(o -> "xdqsrs".equals(o.getString("columnCode"))).findAny().orElse(null);
number = map != null ? map.getInt("columnValue") : 0;
@@ -441,7 +441,7 @@ public class TrainSignUpApplyController {
cnd.and(new Static(" userId in (select id from user where unionid = '%s')".formatted(SecurityUtil.getUnionId())));
}
cnd.asc("signUpTime");
if (!type.getIsBringFamily() && course.getReserveMode() == 2) {
if (!Boolean.TRUE.equals(type.getIsBringFamily()) && course.getReserveMode() == 2) {
List<TrainSignUpUser> signUpUsers = dao.query(TrainSignUpUser.class, cnd);
int thisSignUpUserCount = dao.count(TrainSignUpUser.class,
Cnd.where("activityId", "=", activityId)
@@ -384,7 +384,8 @@ public class TrainSignUpActivityServiceImpl extends BaseServiceImpl<TrainSignUpA
//课程已报人数
int normalCount = statisticsService.queryCourseCount(course.getId(), course.getCourseType());
//+1是算自己
int hasRegisterNum = type.getSelfAddFamily() ? normalCount + 1 : 0;
// 兼容历史数据中人数开关为空的情况,空值按未纳入人数处理,避免 Boolean 自动拆箱异常。
int hasRegisterNum = Boolean.TRUE.equals(type.getSelfAddFamily()) ? normalCount + 1 : 0;
trainSignUpUser.setState((hasRegisterNum + course.getCourseReservedNumber()) > course.getCoursePeopleNumber() ? 2 : 1);
} else {
trainSignUpUser.setState(1);
@@ -463,8 +464,8 @@ public class TrainSignUpActivityServiceImpl extends BaseServiceImpl<TrainSignUpA
int hasWaitCount = statisticsService.queryCourseWaitCount(course.getId(), course.getCourseType());
//+1是算自己
int current = type.getSelfAddFamily() ? 1 : 0;
currentFamilyNumber = type.getIsBringFamily() && type.getIsAddFamily() ? currentFamilyNumber : 0;
int current = Boolean.TRUE.equals(type.getSelfAddFamily()) ? 1 : 0;
currentFamilyNumber = Boolean.TRUE.equals(type.getIsBringFamily()) && Boolean.TRUE.equals(type.getIsAddFamily()) ? currentFamilyNumber : 0;
//如果还有正常名额
if(limitCount - hasSignCount > 0) {
return (hasSignCount + current + currentFamilyNumber) > limitCount;
@@ -487,8 +488,8 @@ public class TrainSignUpActivityServiceImpl extends BaseServiceImpl<TrainSignUpA
int hasWaitCount = statisticsService.queryCourseWaitCount(course.getId(), course.getCourseType());
//+1是算自己
int current = type.getSelfAddFamily() ? 1 : 0;
currentFamilyNumber = type.getIsBringFamily() && type.getIsAddFamily() ? currentFamilyNumber : 0;
int current = Boolean.TRUE.equals(type.getSelfAddFamily()) ? 1 : 0;
currentFamilyNumber = Boolean.TRUE.equals(type.getIsBringFamily()) && Boolean.TRUE.equals(type.getIsAddFamily()) ? currentFamilyNumber : 0;
//如果还有正常名额
if(coursePeopleNumber - hasSignCount > 0) {
return (hasSignCount + current + currentFamilyNumber + course.getCourseReservedNumber()) > coursePeopleNumber;
@@ -237,10 +237,11 @@ public class TrainSignUpActivityStatisticsServiceImpl extends BaseServiceImpl<Tr
.and("state", "in", stateList)
.andEX("unionId", "=", unionId));
signUpUsers.forEach(item -> {
if (type.getSelfAddFamily()) {
// 兼容历史数据中人数开关为空的情况,空值按未纳入人数处理,避免 Boolean 自动拆箱异常。
if (Boolean.TRUE.equals(type.getSelfAddFamily())) {
hasRegisterNum.getAndIncrement();
}
if(type.getIsBringFamily() && type.getIsAddFamily()) {
if (Boolean.TRUE.equals(type.getIsBringFamily()) && Boolean.TRUE.equals(type.getIsAddFamily())) {
List<NutMap> mobileColumnsValue = item.getMobileColumnsValue();
NutMap map = mobileColumnsValue.stream().filter(o -> "xdqsrs".equals(o.getString("columnCode"))).findAny().orElse(null);
int number = map != null ? map.getInt("columnValue") : 0;
@@ -13,15 +13,16 @@ layout("/layouts/platform.html"){
style="width: 100%"
v-model="pageForm.year"
value-format="yyyy"
@change="yearChange"
></el-date-picker>
</search-item>
<search-item label="活动名称">
<el-select @change="activityChange" style="width: 100%" v-model="pageForm.activityId" filterable>
<el-select @change="activityChange" clearable style="width: 100%" v-model="pageForm.activityId" filterable>
<el-option :label="item.activityName" :value="item.id" v-for="item in activityList" :key="item.id"></el-option>
</el-select>
</search-item>
<search-item :label="trainType + ''">
<el-select @change="courseChange" :placeholder="'请选择' + trainType" style="width: 100%" v-model="pageForm.courseId" filterable>
<el-select @change="courseChange" clearable :placeholder="'请选择' + trainType" style="width: 100%" v-model="pageForm.courseId" filterable>
<el-option :label="item.courseName" :value="item.id" v-for="item in courseList" :key="item.id"></el-option>
</el-select>
</search-item>
@@ -164,15 +165,27 @@ layout("/layouts/platform.html"){
.catch(() => {})
},
courseChange(val) {
if (!val) {
// 清除子活动时同步清空当前课程和状态,避免后续操作继续使用旧课程对象。
this.$set(this, "course", {})
this.$set(this, "reserveMode", 1)
const stateColumnIndex = this.tableColumns.findIndex((o) => o.prop === "state")
if (stateColumnIndex > -1) {
this.tableColumns.splice(stateColumnIndex, 1)
}
this.$refs.tool.app = this
this.doSearch()
return
}
const course = this.courseList.find((o) => o.id === val)
this.course = course
this.reserveMode = course.reserveMode
this.$set(this, "course", course || {})
this.$set(this, "reserveMode", course ? course.reserveMode : 1)
if (this.reserveMode === 2) {
this.tableColumns.push({ label: "报名状态", prop: "state", sortable: true })
} else {
const o = this.tableColumns.find((o) => o.label === "报名状态")
if (o !== null && o !== undefined) {
this.tableColumns.splice(this.tableColumns.length - 1, 1)
const stateColumnIndex = this.tableColumns.findIndex((o) => o.prop === "state")
if (stateColumnIndex > -1) {
this.tableColumns.splice(stateColumnIndex, 1)
}
}
this.$refs.tool.app = this
@@ -193,17 +206,29 @@ layout("/layouts/platform.html"){
},
async activityChange(val) {
this.$nextTick(async () => {
if (!val) {
// 清除活动时同步清空子活动和相关状态,避免页面显示上一个活动的数据。
this.$set(this.pageForm, "courseId", null)
this.$set(this, "courseList", [])
this.$set(this, "course", {})
this.$set(this, "trainType", "培训班")
this.$set(this, "reserveMode", 1)
this.doSearch()
return
}
const activity = this.activityList.find((o) => o.id === val)
const type = this.dict.type.TRAIN_SIGNUP_TYPE?.find(o => o.code === activity.trainType)
this.trainType = type?.name || "培训班"
this.$set(this, "trainType", type?.name || "培训班")
const resp = await this.$axios.post(loc() + "/getCourseByActivityId", { activityId: val })
this.courseList = resp.data
this.$set(this, "courseList", resp.data || [])
if(this.courseList.length > 0) {
this.$set(this.pageForm, "courseId", this.courseList[0].id)
await this.courseChange(this.courseList[0].id)
} else {
this.pageForm.courseId = ""
this.$set(this.pageForm, "courseId", null)
this.$set(this, "course", {})
this.$set(this, "reserveMode", 1)
this.doSearch()
}
this.doSearch()
})
},
async handleUser(userId) {
@@ -214,15 +239,23 @@ layout("/layouts/platform.html"){
}
},
async yearChange() {
this.pageForm.activityId = null
this.$set(this.pageForm, "activityId", null)
this.$set(this.pageForm, "courseId", null)
this.$set(this, "activityList", [])
this.$set(this, "courseList", [])
this.$set(this, "course", {})
this.$set(this, "trainType", "培训班")
this.$set(this, "reserveMode", 1)
await this.getActivityList()
await this.doSearch()
if (!this.activityList || this.activityList.length === 0) {
this.doSearch()
}
},
async getActivityList() {
const resp = await this.$axios.post("/platform/trainSignUp/statistics/activityList", { year: this.pageForm.year })
this.activityList = resp.data
this.$set(this, "activityList", resp.data || [])
if (this.activityList && this.activityList.length > 0) {
this.pageForm.activityId = this.activityList[0].id
this.$set(this.pageForm, "activityId", this.activityList[0].id)
await this.activityChange(this.activityList[0].id)
}
},