From c98534f39fda2229825aec323026f54995774788 Mon Sep 17 00:00:00 2001 From: zhangrui Date: Fri, 10 Apr 2026 15:17:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=99=BA=E4=BA=AB=E6=83=A0=E7=94=9F=E6=B4=BB?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../constant/ColumnFormTypeEnum.java | 25 + .../manage/SmartBenefitsAdjustController.java | 179 +++++ .../manage/SmartBenefitsApplyController.java | 504 ++++++++++++++ .../manage/SmartBenefitsManageController.java | 238 +++++++ .../manage/SmartBenefitsMineController.java | 220 +++++++ .../manage/SmartBenefitsTypeController.java | 167 +++++ .../SmartBenefitsUserManageController.java | 350 ++++++++++ ...tBenefitsActivityStatisticsController.java | 307 +++++++++ .../models/SmartBenefitsActivity.java | 144 ++++ .../models/SmartBenefitsActivityCourse.java | 54 ++ .../models/SmartBenefitsBlackList.java | 31 + .../models/SmartBenefitsCourse.java | 178 +++++ .../models/SmartBenefitsMobileSignColumn.java | 84 +++ .../models/SmartBenefitsType.java | 65 ++ .../models/SmartBenefitsTypeLimit.java | 40 ++ .../models/SmartBenefitsUser.java | 91 +++ .../models/SmartBenefitsUserCourse.java | 87 +++ .../service/SmartBenefitsActivityService.java | 135 ++++ ...martBenefitsActivityStatisticsService.java | 67 ++ .../SmartBenefitsBlackListService.java | 43 ++ .../SmartBenefitsActivityServiceImpl.java | 583 +++++++++++++++++ ...BenefitsActivityStatisticsServiceImpl.java | 253 ++++++++ .../impl/SmartBenefitsUserServiceImpl.java | 111 ++++ .../manage/TrainSignUpAdjustController.java | 2 +- .../manage/TrainSignUpApplyController.java | 4 +- .../manage/TrainSignUpManageController.java | 2 +- .../manage/TrainSignUpTypeController.java | 2 +- .../TrainSignUpUserManageController.java | 2 +- .../manage/TrainsignUpMineController.java | 2 +- ...ainSignUpActivityStatisticsController.java | 2 +- .../models/TrainMobileSignColumn.java | 2 +- .../models/TrainSignUpActivity.java | 2 +- .../models/TrainSignUpActivityCourse.java | 2 +- .../models/TrainSignUpBlackList.java | 2 +- .../trainSignUp/models/TrainSignUpCourse.java | 2 +- .../trainSignUp/models/TrainSignUpType.java | 2 +- .../models/TrainSignUpTypeLimit.java | 2 +- .../trainSignUp/models/TrainSignUpUser.java | 2 +- .../models/TrainSignUpUserCourse.java | 2 +- .../activity/smartbenefits/apply/applyForm.js | 210 ++++++ .../smartbenefits/apply/courseList.js | 340 ++++++++++ .../activity/smartbenefits/apply/index.html | 180 +++++ .../smartbenefits/manage/basicForm.js | 613 ++++++++++++++++++ .../smartbenefits/manage/courseTime.js | 215 ++++++ .../smartbenefits/manage/customForm.js | 240 +++++++ .../activity/smartbenefits/manage/index.html | 212 ++++++ .../activity/smartbenefits/manage/info.js | 111 ++++ .../smartbenefits/manage/makeQrcode.js | 85 +++ .../smartbenefits/manage/unionForm.js | 221 +++++++ .../smartbenefits/statistics/index.html | 158 +++++ .../activity/smartbenefits/statistics/info.js | 160 +++++ .../activity/smartbenefits/type/basicForm.js | 350 ++++++++++ .../activity/smartbenefits/type/index.html | 120 ++++ .../smartbenefits/userAdjust/applyForm.js | 246 +++++++ .../smartbenefits/userAdjust/index.html | 162 +++++ .../smartbenefits/userAdjust/userInfo.js | 229 +++++++ .../smartbenefits/userManage/index.html | 242 +++++++ .../activity/smartbenefits/apply/index.html | 170 +++++ .../activity/smartbenefits/common/times.js | 229 +++++++ .../activity/smartbenefits/list/applyForm.js | 159 +++++ .../activity/smartbenefits/list/index.html | 255 ++++++++ .../activity/smartbenefits/mine/index.html | 132 ++++ .../activity/smartbenefits/scan/index.html | 149 +++++ 63 files changed, 9161 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/constant/ColumnFormTypeEnum.java create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsAdjustController.java create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsApplyController.java create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsManageController.java create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsMineController.java create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsTypeController.java create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsUserManageController.java create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/statistics/SmartBenefitsActivityStatisticsController.java create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsActivity.java create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsActivityCourse.java create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsBlackList.java create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsCourse.java create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsMobileSignColumn.java create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsType.java create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsTypeLimit.java create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsUser.java create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsUserCourse.java create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/SmartBenefitsActivityService.java create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/SmartBenefitsActivityStatisticsService.java create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/SmartBenefitsBlackListService.java create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/impl/SmartBenefitsActivityServiceImpl.java create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/impl/SmartBenefitsActivityStatisticsServiceImpl.java create mode 100644 src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/impl/SmartBenefitsUserServiceImpl.java create mode 100644 src/main/resources/views/platform/zhgh/activity/smartbenefits/apply/applyForm.js create mode 100644 src/main/resources/views/platform/zhgh/activity/smartbenefits/apply/courseList.js create mode 100644 src/main/resources/views/platform/zhgh/activity/smartbenefits/apply/index.html create mode 100644 src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/basicForm.js create mode 100644 src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/courseTime.js create mode 100644 src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/customForm.js create mode 100644 src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/index.html create mode 100644 src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/info.js create mode 100644 src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/makeQrcode.js create mode 100644 src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/unionForm.js create mode 100644 src/main/resources/views/platform/zhgh/activity/smartbenefits/statistics/index.html create mode 100644 src/main/resources/views/platform/zhgh/activity/smartbenefits/statistics/info.js create mode 100644 src/main/resources/views/platform/zhgh/activity/smartbenefits/type/basicForm.js create mode 100644 src/main/resources/views/platform/zhgh/activity/smartbenefits/type/index.html create mode 100644 src/main/resources/views/platform/zhgh/activity/smartbenefits/userAdjust/applyForm.js create mode 100644 src/main/resources/views/platform/zhgh/activity/smartbenefits/userAdjust/index.html create mode 100644 src/main/resources/views/platform/zhgh/activity/smartbenefits/userAdjust/userInfo.js create mode 100644 src/main/resources/views/platform/zhgh/activity/smartbenefits/userManage/index.html create mode 100644 src/main/resources/views/platform/zhghh5/activity/smartbenefits/apply/index.html create mode 100644 src/main/resources/views/platform/zhghh5/activity/smartbenefits/common/times.js create mode 100644 src/main/resources/views/platform/zhghh5/activity/smartbenefits/list/applyForm.js create mode 100644 src/main/resources/views/platform/zhghh5/activity/smartbenefits/list/index.html create mode 100644 src/main/resources/views/platform/zhghh5/activity/smartbenefits/mine/index.html create mode 100644 src/main/resources/views/platform/zhghh5/activity/smartbenefits/scan/index.html diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/constant/ColumnFormTypeEnum.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/constant/ColumnFormTypeEnum.java new file mode 100644 index 00000000..868675de --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/constant/ColumnFormTypeEnum.java @@ -0,0 +1,25 @@ +package com.budwk.app.zhgh.activity.smartbenefits.constant; + +import com.budwk.app.base.annotation.DictEnum; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @Author JyuHsin + * @Date 2022/11/18 + * @Description + */ +@Getter +@DictEnum(key = "ColumnFormTypeEnum", name = "控件类型") +@AllArgsConstructor +public enum ColumnFormTypeEnum { + + INPUT("INPUT", "输入框"), + SELECT("SELECT", "选择框"), + STEPPER("STEPPER", "步进器"), + //RADIO("RADIO", "单选框"),//选项数组 + FILE("FILE", "文件"); + + private String code; + private String description; +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsAdjustController.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsAdjustController.java new file mode 100644 index 00000000..a94ecdfd --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsAdjustController.java @@ -0,0 +1,179 @@ +package com.budwk.app.zhgh.activity.smartbenefits.controller.manage; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.hutool.core.date.DateUtil; +import com.budwk.app.base.annotation.SLog; +import com.budwk.app.base.page.Pagination; +import com.budwk.app.base.param.PageForm; +import com.budwk.app.base.result.Result; +import com.budwk.app.base.service.BaseService; +import com.budwk.app.zhgh.activity.smartbenefits.models.SmartBenefitsActivity; +import com.budwk.app.zhgh.activity.smartbenefits.models.SmartBenefitsActivityCourse; +import com.budwk.app.zhgh.activity.smartbenefits.models.SmartBenefitsUser; +import com.budwk.app.zhgh.activity.smartbenefits.models.SmartBenefitsUserCourse; +import com.budwk.app.zhgh.activity.smartbenefits.service.SmartBenefitsActivityService; +import com.budwk.app.zhgh.activity.smartbenefits.service.SmartBenefitsActivityStatisticsService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.nutz.dao.Cnd; +import org.nutz.dao.Dao; +import org.nutz.dao.Sqls; +import org.nutz.dao.sql.Sql; +import org.nutz.ioc.loader.annotation.Inject; +import org.nutz.ioc.loader.annotation.IocBean; +import org.nutz.lang.util.NutMap; +import org.nutz.mvc.annotation.At; +import org.nutz.mvc.annotation.Ok; +import org.nutz.mvc.annotation.Param; + +import java.util.ArrayList; +import java.util.List; + +/** + * @Author JyuHsin + * @Date 2022/9/21 + * @Description 人员调整 + */ +@Slf4j +@IocBean +@Ok("json:full") +@Api(tags = "品牌活动人员调整(智享惠生活)") +@At("/platform/smartbenefits/adjust") +public class SmartBenefitsAdjustController { + + @Inject + private Dao dao; + @Inject + private BaseService baseService; + @Inject + private SmartBenefitsActivityService smartBenefitsActivityManageService; + @Inject + private SmartBenefitsActivityStatisticsService smartBenefitsActivityStatisticsService; + + @At("") + @SaCheckPermission("smartbenefits.adjust") + @Ok("beetl:/platform/zhgh/activity/smartbenefits/userAdjust/index.html") + public void index() { + } + + /** + * 活动list + * @param year 年度 + * @return + */ + @At + @ApiOperation("活动列表") + @SaCheckPermission("smartbenefits.adjust") + public Result activityList(@Param(value = "year") Integer year) { + List activityList = dao.query(SmartBenefitsActivity.class, Cnd.NEW().andEX("year", "=", year).andEX("isDisabled", "=", false).desc("activityStartTime")); + return Result.success(activityList); + } + + @At + @ApiOperation("分页查询") + @SaCheckPermission("smartbenefits.adjust") + public Result pageData(PageForm pageForm, + @Param(value = "activityId") String activityId) { + Pagination pagination = smartBenefitsActivityStatisticsService.pageData(pageForm, activityId); + return Result.success(pagination); + } + + @At + @ApiOperation("子活动查询") + @SaCheckPermission("smartbenefits.adjust") + public Result getCourse(String activityId) { + Sql sql = Sqls.create(""" + SELECT + tsuc.id, + tsuc.courseName, + tsuc.coursePeopleNumber, + tsuc.courseType, + tsuc.courseLocation, + tsuc.courseInstructor, + tsuc.courseReservedNumber, + tsuc.waitingNum, + tsuc.reserveMode + FROM + `smart_benefits_course` tsuc + WHERE + tsuc.activityId = @activityId + ORDER BY courseName asc + """); + sql.setParam("activityId", activityId); + List courseList = baseService.listMap(sql); + courseList.forEach(c -> { + c.put("registerNum", smartBenefitsActivityStatisticsService.queryCourseCount(c.getString("id"), c.getString("courseType"))); + c.put("hasWaitingNum", smartBenefitsActivityStatisticsService.queryCourseWaitCount(c.getString("id"), c.getString("courseType"))); + }); + return Result.success(courseList); + } + + @At + @ApiOperation("报名用户列表") + @SaCheckPermission("smartbenefits.adjust") + public Result registerUserList(@Param("courseId") String courseId, + @Param(value = "unionId") String unionId, + @Param(value = "unitId") String unitId, + @Param(value = "searchName") String searchName, + @Param(value = "searchKeyword") String searchKeyword) { + List list = smartBenefitsActivityStatisticsService.registerUserList(courseId, unionId, unitId, searchName, searchKeyword); + return Result.success(list); + } + + @At + @ApiOperation("人员调整") + @SaCheckPermission("smartbenefits.adjust") + @SLog(tag = "品牌活动-人员调整", msg = "人员调整") + public Result adjust(String activityId, String oldCourseId, String newCourseId, String userId) { + + Cnd oldCnd = Cnd.where("activityId", "=", activityId) + .and("courseId", "=", oldCourseId).and("userId", "=", userId); + + Cnd newCnd = Cnd.where("activityId", "=", activityId) + .and("courseId", "=", newCourseId).and("userId", "=", userId); + + //旧的报名信息 + SmartBenefitsUser oldSmartBenefitsUser = dao.fetch(SmartBenefitsUser.class, oldCnd); + oldSmartBenefitsUser.setCourseId(newCourseId); + oldSmartBenefitsUser.setSignUpTime(DateUtil.date()); + dao.update(oldSmartBenefitsUser); + + //新的课程的信息,上课时间 + List activityCourseList = dao.query(SmartBenefitsActivityCourse.class, Cnd.where("activityId", "=", activityId) + .and("courseId", "=", newCourseId)); + //先清楚旧的信息 + dao.clear(SmartBenefitsUserCourse.class, oldCnd); + //添加新的信息 + List smartBenefitsUserCourseList = new ArrayList<>(); + activityCourseList.forEach(item -> { + SmartBenefitsUserCourse course = new SmartBenefitsUserCourse(); + course.setActivityCourseId(activityId); + course.setCourseId(newCourseId); + course.setUserId(userId); + course.setCourseStartTime(item.getCourseStartTime()); + course.setCourseEndTime(item.getCourseEndTime()); + course.setActivityCourseId(item.getId()); + smartBenefitsUserCourseList.add(course); + }); + dao.insert(smartBenefitsUserCourseList); + return Result.success(); + } + + @At + @ApiOperation("删除报名人员") + @SaCheckPermission("smartbenefits.adjust") + @SLog(tag = "品牌活动-人员调整", msg = "删除报名人员") + public Result deleteSignUser(String activityId, String courseId, String userId) { + + //删除 + Cnd cnd = Cnd.NEW(); + cnd.and("activityId", "=", activityId); + cnd.and("courseId", "=", courseId); + cnd.and("userId", "=", userId); + + dao.clear(SmartBenefitsUser.class, cnd); + dao.clear(SmartBenefitsUserCourse.class, cnd); + return Result.success(); + } +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsApplyController.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsApplyController.java new file mode 100644 index 00000000..387c9d4c --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsApplyController.java @@ -0,0 +1,504 @@ +package com.budwk.app.zhgh.activity.smartbenefits.controller.manage; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.dev33.satoken.annotation.SaMode; +import cn.hutool.core.date.DateField; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; +import com.budwk.app.base.annotation.SLog; +import com.budwk.app.base.constant.RoleConstant; +import com.budwk.app.base.page.Pagination; +import com.budwk.app.base.param.PageForm; +import com.budwk.app.base.result.Result; +import com.budwk.app.sys.models.Sys_dict; +import com.budwk.app.sys.models.Sys_user; +import com.budwk.app.sys.services.SysDictService; +import com.budwk.app.web.commons.auth.utils.AuthUtil; +import com.budwk.app.web.commons.auth.utils.SecurityUtil; +import com.budwk.app.zhgh.activity.basic.models.ActivityUserScope; +import com.budwk.app.zhgh.activity.smartbenefits.models.*; +import com.budwk.app.zhgh.activity.smartbenefits.service.SmartBenefitsActivityService; +import com.budwk.app.zhgh.activity.smartbenefits.service.SmartBenefitsActivityStatisticsService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.nutz.dao.Cnd; +import org.nutz.dao.Dao; +import org.nutz.dao.Sqls; +import org.nutz.dao.sql.Sql; +import org.nutz.dao.util.cri.Static; +import org.nutz.ioc.loader.annotation.Inject; +import org.nutz.ioc.loader.annotation.IocBean; +import org.nutz.json.Json; +import org.nutz.lang.Lang; +import org.nutz.lang.util.NutMap; +import org.nutz.mvc.annotation.At; +import org.nutz.mvc.annotation.Ok; +import org.nutz.mvc.annotation.Param; + +import java.util.*; +import java.util.concurrent.locks.ReentrantLock; +import java.util.stream.Collectors; + +@Slf4j +@IocBean +@Ok("json:full") +@Api(tags = "活动报名(智享惠生活)") +@At("/platform/smartbenefits/apply") +public class SmartBenefitsApplyController { + + private final ReentrantLock lock = new ReentrantLock(true); + + @Inject + private SmartBenefitsActivityService smartBenefitsActivityService; + @Inject + private SysDictService dictService; + @Inject + private SmartBenefitsActivityStatisticsService statisticsService; + @Inject + private Dao dao; + + @At("/") + @SaCheckPermission("smartbenefits.apply") + @Ok("beetl:/platform/zhgh/activity/smartbenefits/apply/index.html") + public void index() { + } + + @At("/h5") + @SaCheckPermission("h5.smartbenefits.apply") + @Ok("beetl:/platform/zhghh5/activity/smartbenefits/apply/index.html") + public void h5Index() { + } + + @At("/list/h5") + @SaCheckPermission("h5.smartbenefits.apply") + @Ok("beetl:/platform/zhghh5/activity/smartbenefits/list/index.html") + public void listIndex() { + } + + @At + @ApiOperation("活动查询") + @SaCheckPermission(value = {"smartbenefits.apply", "h5.smartbenefits.apply"}, mode = SaMode.OR) + public Result activityPageData(PageForm pageForm, + @Param(value = "year") Integer year, + @Param(value = "activityType") Integer activityType, + @Param(value = "id") String id, + @Param(value = "dataType") String dataType) { + Cnd cnd = Cnd.NEW(); + cnd.andEX("id", "=", id); + cnd.andEX("`year`", "=", year); + //查询报名中 + if (activityType == 2) { + cnd.and(new Static("now() < activitySignUpEndTime")); + }//查询已结束的 + else if (activityType == 3) { + cnd.and(new Static("now() >= activityEndTime")); + } + + if (AuthUtil.hasRole("H04") && !AuthUtil.hasRoleOr("sysadmin, A06")) { + cnd.and("activityMode", "=", 2).and("createdBy", "=", SecurityUtil.getUserId()); + } + + if ("mine".equals(dataType)) { + cnd.and(new Static("id in (select activityId from smart_benefits_user where userId = '%s')".formatted(SecurityUtil.getUserId()))); + } + + Pagination pagination = smartBenefitsActivityService.listPage(pageForm.getPageNumber(), pageForm.getPageSize(), cnd); + List smartBenefitsActivities = pagination.getList(); + Map smartBenefitsTypeMap = dictService.getSubListByCode("TRAIN_SIGNUP_TYPE").stream().collect(Collectors.toMap(Sys_dict::getCode, Sys_dict::getName)); + smartBenefitsActivities.forEach(v -> v.setTrainType(smartBenefitsTypeMap.get(v.getTrainType()))); + return Result.success(pagination); + } + + @At + @ApiOperation("分活动查询") + @SaCheckPermission(value = {"smartbenefits.apply", "h5.smartbenefits.apply"}, mode = SaMode.OR) + public Result pageData(PageForm pageForm, + @Param(value = "courseTypeId") String courseTypeId, + @Param(value = "activityId") String activityId, + @Param(value = "assortTypes") String[] assortTypes, + @Param(value = "dataType") String dataType) { + Sql sql = Sqls.create(""" + SELECT + tsuc.id, + tsuc.activityId, + tsuc.courseName, + tsuc.coursePeopleNumber, + tsuc.courseLocation, + tsuc.courseType, + tsuc.courseLocationCoordinates, + tsuc.courseReservedNumber, + tsuc.courseInstructor, + tsuc.campus, + tsuc.unionLimit, + tsuc.isMobileSign, + tsuc.signType, + tsuc.isReceiveGift, + tsuc.giftType, + tsuc.reserveMode, + tsuc.waitingNum, + tsuc.assort, + tsuc.introduce, + type.typeName, + tsuc.courseIsLimitApply + FROM + `smart_benefits_course` tsuc + LEFT JOIN smart_benefits_type type ON type.id = tsuc.courseType + $condition + """); + Cnd cnd = Cnd.NEW(); + cnd.andEX("type.id", "=", courseTypeId); + cnd.and("tsuc.activityId", "=", activityId); + + if (Lang.isNotEmpty(assortTypes)) { + cnd.and("tsuc.assort", "in", assortTypes); + } + + if ("mine".equals(dataType)) { + cnd.and(new Static("tsuc.id in (select courseId from smart_benefits_user where userId = '%s')".formatted(SecurityUtil.getUserId()))); + } + + List courseArray = smartBenefitsActivityService.dao().query(SmartBenefitsCourse.class, Cnd.where("activityId", "=", activityId)); + courseArray = smartBenefitsActivityService.filterCourseByHostUnion(courseArray); + cnd.and("tsuc.id", "in", courseArray.stream().map(SmartBenefitsCourse::getId).toList()); + + cnd.asc("tsuc.orderNum"); + cnd.asc("type.code"); + sql.setCondition(cnd); + + Pagination pagination = smartBenefitsActivityService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql); + List courseList = pagination.getList(); + + courseList.forEach(c -> { + List courseTimes = dao.query(SmartBenefitsActivityCourse.class, Cnd.where("courseId", "=", c.getString("id")).asc("courseDate")); + c.put("courseTimes", courseTimes); + + c.put("hasRegisterNum", statisticsService.queryCourseCount(c.getString("id"), c.getString("courseType"))); + c.put("hasWaitingNum", statisticsService.queryCourseWaitCount(c.getString("id"), c.getString("courseType"))); + //当前用户是否报过 + c.put("isSign", smartBenefitsActivityService.isSignCourseByUser(c.getString("id"), SecurityUtil.getUserId())); + + if (StrUtil.isNotBlank(c.getString("unionLimit"))) { + List unionLimit = Json.fromJsonAsList(NutMap.class, c.getString("unionLimit")); + if (Lang.isNotEmpty(unionLimit)) { + NutMap nutMap = unionLimit.stream().filter(o -> o.getString("id").equals(SecurityUtil.getUnionId())).findFirst().orElse(null); + if (nutMap != null) { + c.put("coursePeopleNumber", nutMap.getInt("limitCount")); + } + } + } + }); + return Result.success(pagination); + } + + @At + @ApiOperation("获取分活动时间") + @SaCheckPermission(value = {"smartbenefits.apply", "h5.smartbenefits.apply"}, mode = SaMode.OR) + public Result getCourseTime(String id) { + List list = smartBenefitsActivityService.dao().query(SmartBenefitsActivityCourse.class, Cnd.where("courseId", "=", id)); + return Result.success(list); + } + + @At + @ApiOperation("查询分类标识集合") + @SaCheckPermission(value = {"smartbenefits.apply", "h5.smartbenefits.apply"}, mode = SaMode.OR) + public Result queryCourseAssort(String activityId) { + List courseList = smartBenefitsActivityService.dao().query(SmartBenefitsCourse.class, Cnd.where(SmartBenefitsCourse::getActivityId, "=", activityId).asc(SmartBenefitsCourse::getOrderNum)); + if (Lang.isEmpty(courseList)) { + return Result.success(new ArrayList<>()); + } + List assortList = courseList.stream().map(SmartBenefitsCourse::getAssort).filter(StrUtil::isNotBlank).distinct().toList(); + return Result.success(assortList); + } + + @At + @ApiOperation("验证是否能报名") + @SaCheckPermission(value = {"smartbenefits.apply", "h5.smartbenefits.apply"}, mode = SaMode.OR) + public Result validateSignUp(String courseId, + @Param(value = "currentFamilyNumber") Integer currentFamilyNumber,String IsVerifyUserApply) { + try { + lock.lock(); + if (StrUtil.isBlank(courseId)) { + return Result.error("报名信息为空"); + } + + currentFamilyNumber = currentFamilyNumber != null ? currentFamilyNumber : 0; + SmartBenefitsCourse course = dao.fetch(SmartBenefitsCourse.class, courseId); + SmartBenefitsActivity activity = dao.fetch(SmartBenefitsActivity.class, course.getActivityId()); + + //判断时间 + if (DateUtil.compare(new Date(), activity.getActivitySignUpStartTime(), "yyyy-MM-dd HH:mm:ss") < 0) { + return Result.error("报名未开始"); + } + if (DateUtil.compare(new Date(), activity.getActivitySignUpEndTime(), "yyyy-MM-dd HH:mm:ss") > 0) { + return Result.error("报名已结束"); + } + + //判断活动组别 + int count = dao.count(ActivityUserScope.class, Cnd.where("groupId", "=", activity.getActivityGroupId()).and("userId", "=", SecurityUtil.getUserId())); + if (count == 0) { + return Result.error("抱歉,您没有此次活动的权限"); + } + + //判断是否报名 + if(StringUtils.defaultString(IsVerifyUserApply,"0").equals("0")){ + boolean courseByUser = smartBenefitsActivityService.isSignCourseByUser(courseId, SecurityUtil.getUserId()); + if (courseByUser) { + return Result.error("抱歉,您已经报名"); + } + } + + //判断活动人数 + boolean signFull = smartBenefitsActivityService.isSignFull(course, currentFamilyNumber); + if (signFull) { + return Result.error("名额剩余数量不足"); + } + + //判断活动限制 + boolean signCourse = smartBenefitsActivityService.isSignCourse(course, activity); + if (!signCourse) { + if (activity.getRestrictLimit() != 3) { + return Result.error("您选择的类型已达上限,不能再报该类型的了"); + } else { + return Result.error(activity.getActivityName() + "限制报" + activity.getLimitNum() + "个活动,已达上限"); + } + } + + //判断分工会人数限制 + boolean signFullByUnionId = smartBenefitsActivityService.isSignFullByUnionId(course, currentFamilyNumber); + if (signFullByUnionId) { + return Result.error("您所在的分工会名额不足"); + } + + return Result.success(); + } catch (Exception e) { + e.printStackTrace(); + return Result.error("报名失败"); + } finally { + lock.unlock(); + } + } + + @At + @ApiOperation("查询子活动时间段") + @SaCheckPermission(value = {"smartbenefits.apply", "h5.smartbenefits.apply"}, mode = SaMode.OR) + public Result getCourseTimeSelectList(String courseId) { + // 查课程的时间段 + List courseList = dao.query(SmartBenefitsActivityCourse.class, Cnd.where("courseId", "=", courseId).asc("courseStartTime")); + + // 查课程的报名人数 + List applyUserList = dao.query(SmartBenefitsUserCourse.class, Cnd.where("courseId", "=", courseId)); + + List userList = dao.query(SmartBenefitsUser.class, Cnd.where("courseId", "=", courseId).and("state", "=", 1)); + List idList = userList.stream().map(SmartBenefitsUser::getUserId).toList(); + + applyUserList = applyUserList.stream().filter(o -> idList.contains(o.getUserId())).toList(); + + // 按照课程下面时间段去分组 + Map> collectMap = applyUserList.stream().collect(Collectors.groupingBy(SmartBenefitsUserCourse::getActivityCourseId)); + List list = courseList.stream().map(v -> { + String id = v.getId(); + NutMap nutMap = NutMap.NEW(); + List smartBenefitsUserCourses = collectMap.get(id); + int remainingNum = v.getCourseLimitNum() != null ? v.getCourseLimitNum() : 0; + if (Lang.isNotEmpty(smartBenefitsUserCourses)) { + remainingNum = v.getCourseLimitNum() - smartBenefitsUserCourses.size(); + } + nutMap.put("remainingNum", remainingNum); + nutMap.put("text", DateUtil.format(v.getCourseStartTime(), "MM月dd日 HH:mm") + "至" + DateUtil.format(v.getCourseEndTime(), "HH:mm") + "段(剩" + remainingNum + ")"); + nutMap.put("value", id); + nutMap.put("disabled", remainingNum == 0); + return nutMap; + }).toList(); + return Result.success(list); + } + + @At + @ApiOperation("验证子活动是否能报名") + @SaCheckPermission(value = {"smartbenefits.apply", "h5.smartbenefits.apply"}, mode = SaMode.OR) + public Result validateSourceSignUp(String activityCourseId, String courseId) { + try { + lock.lock(); + + List userList = dao.query(SmartBenefitsUser.class, Cnd.where("courseId", "=", courseId).and("state", "=", 1)); + List isList = userList.stream().map(SmartBenefitsUser::getUserId).toList(); + + // 该时间段下已报名的人数 + int count = dao.count(SmartBenefitsUserCourse.class, Cnd.where("activityCourseId", "=", activityCourseId) + .and("courseId", "=", courseId).and("userId", "in", isList)); + // 获取该时间段下的活动课程限制报名人数 + SmartBenefitsActivityCourse course = dao.fetch(SmartBenefitsActivityCourse.class, activityCourseId); + Integer courseLimitNum = course.getCourseLimitNum(); + // 报名加上自己,如果大于了限制人数,那就无法报名 + if (count + 1 > courseLimitNum) { + return Result.error("该时间段名额已报满,请选择其他时段报名"); + } else { + return Result.success(); + } + } catch (Exception e) { + e.printStackTrace(); + return Result.error("报名失败"); + } finally { + lock.unlock(); + } + } + + @At + @ApiOperation("活动报名") + @SaCheckPermission(value = {"smartbenefits.apply", "h5.smartbenefits.apply"}, mode = SaMode.OR) + @SLog(tag = "品牌活动-活动报名", msg = "活动报名") + public Result doSignUp(SmartBenefitsUser smartBenefitsUser) { + try { + lock.lock(); + boolean courseByUser = smartBenefitsActivityService.isSignCourseByUser(smartBenefitsUser.getCourseId(), SecurityUtil.getUserId()); + if (courseByUser) { + return Result.error("您已报过该活动"); + } + //判断人数 + int number = 0; + SmartBenefitsCourse course = smartBenefitsActivityService.dao().fetch(SmartBenefitsCourse.class, smartBenefitsUser.getCourseId()); + SmartBenefitsType type = smartBenefitsActivityService.dao().fetch(SmartBenefitsType.class, course.getCourseType()); + if (type != null) { + if (type.getIsBringFamily() && type.getIsAddFamily()) { + List mobileColumnsValue = smartBenefitsUser.getMobileColumnsValue(); + NutMap map = mobileColumnsValue.stream().filter(o -> "xdqsrs".equals(o.getString("columnCode"))).findAny().orElse(null); + number = map != null ? map.getInt("columnValue") : 0; + } + } + boolean signFull = smartBenefitsActivityService.isSignFull(course, number); + if (signFull) { + return Result.error("当前报名人数已满"); + } + boolean signFullByUnionId = smartBenefitsActivityService.isSignFullByUnionId(course, number); + if (signFullByUnionId) { + return Result.error("该活动您所在的分工会名额不足"); + } + smartBenefitsActivityService.doSignUp(smartBenefitsUser); + return Result.success("报名成功"); + } catch (Exception e) { + e.printStackTrace(); + return Result.success("报名失败"); + } finally { + lock.unlock(); + } + } + + @At + @ApiOperation("取消报名") + @SaCheckPermission(value = {"smartbenefits.apply", "h5.smartbenefits.apply"}, mode = SaMode.OR) + @SLog(tag = "品牌活动-活动报名", msg = "取消报名") + public Result cancelSignUp(@Param("activityId") String activityId, @Param("courseId") String courseId) { + String userId = SecurityUtil.getUserId(); + //取消分两种情况 + //第一种没有设置分工会人数限制,那么将候补的人按时间倒叙往上补 + //第二种如果设置了分工会人数限制,那么只将本分工会的候补人员按照时间倒叙往上补,如果本分工会没有候补人员,则名额空出来,由校工会手动调整 + SmartBenefitsCourse course = dao.fetch(SmartBenefitsCourse.class, courseId); + SmartBenefitsType type = dao.fetch(SmartBenefitsType.class, course.getCourseType()); + //如果是正常报名取消了,将候补报名的按时间倒叙第一个改为正常报名 + Cnd cnd = Cnd.where("activityId", "=", activityId).and("courseId", "=", courseId) + .and("state", "=", 2); + //如果设置了分工会报名人数限制,则只查本分工会 + if (Lang.isNotEmpty(course.getUnionLimit())) { + 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) { + List signUpUsers = dao.query(SmartBenefitsUser.class, cnd); + int thisSignUpUserCount = dao.count(SmartBenefitsUser.class, + Cnd.where("activityId", "=", activityId) + .and("courseId", "=", courseId).and("userId", "=", userId) + .and("state", "in", List.of(1, 3))); + if (!signUpUsers.isEmpty() && thisSignUpUserCount > 0) { + SmartBenefitsUser smartBenefitsUser = signUpUsers.get(0); + smartBenefitsUser.setState(1); + dao.update(smartBenefitsUser); + Sys_user user = dao.fetch(Sys_user.class, smartBenefitsUser.getUserId()); + //msgApi.sendTextMsg("【" + activity.getActivityName() + "】已候补成功,请按时参加活动!", user.getLoginname()); + } + } + //删除报名记录 + dao.clear("smart_benefits_user_course", Cnd.where("activityId", "=", activityId) + .and("courseId", "=", courseId).and("userId", "=", userId)); + + dao.clear("smart_benefits_user", Cnd.where("activityId", "=", activityId) + .and("courseId", "=", courseId).and("userId", "=", userId)); + return Result.success(); + } + + @At + @ApiOperation("判断缺席次数") + @SaCheckPermission(value = {"smartbenefits.apply", "h5.smartbenefits.apply"}, mode = SaMode.OR) + @SLog(tag = "品牌活动-活动报名", msg = "判断缺席次数") + public Result validSignCount(@Param("activityId") String activityId) { + // 缺席2次,就1年内不能报名 + // 查询今天,然后往前推1年,这段时间有没有缺席超过2次 + DateTime today = DateUtil.date(); + DateTime lastYear = DateUtil.offset(today, DateField.YEAR, -1); + + // 找需要签到的分活动 + List activityList = dao.query(SmartBenefitsActivity.class, Cnd.where("year", "in", Lang.array(DateUtil.thisYear(), DateUtil.thisYear() - 1))); + List activityIdList = activityList.stream().map(SmartBenefitsActivity::getId).toList(); + + List courses = dao.query(SmartBenefitsCourse.class, Cnd.where("isMobileSign", "=", true).and("activityId", "in", activityIdList)); + List courseIdList = courses.stream().map(SmartBenefitsCourse::getId).toList(); + + int count = dao.count( + SmartBenefitsUserCourse.class, + Cnd.where("userId", "=", SecurityUtil.getUserId()) + .and("courseStartTime", ">", DateUtil.format(lastYear, "yyyy-MM-dd HH:mm:ss")) + .and("courseEndTime", "<", DateUtil.format(today, "yyyy-MM-dd HH:mm:ss")) + .and("isAttend", "=", false) + .and("courseId", "in", courseIdList) + ); + + if(count >= 2) { + return Result.error(99, "您已连续2次未签到活动,不能报名,请联系校工会"); + } + return Result.success(); + } + + @At + @ApiOperation("活动代人报名") + @SaCheckPermission(value = {"smartbenefits.apply"}, mode = SaMode.OR) + public Result doSignUpInsteadApply(SmartBenefitsUser smartBenefitsUser) { + try { + lock.lock(); + if (!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name())) { + return Result.error("您没有操作此按钮的权限"); + } + boolean courseByUser = smartBenefitsActivityService.isSignCourseByUser(smartBenefitsUser.getCourseId(), smartBenefitsUser.getUserId()); + if (courseByUser) { + return Result.error("该用户已报过该活动"); + } + //判断人数 + int number = 0; + SmartBenefitsCourse course = smartBenefitsActivityService.dao().fetch(SmartBenefitsCourse.class, smartBenefitsUser.getCourseId()); + SmartBenefitsType type = smartBenefitsActivityService.dao().fetch(SmartBenefitsType.class, course.getCourseType()); + if (type != null) { + if (type.getIsBringFamily() && type.getIsAddFamily()) { + List mobileColumnsValue = smartBenefitsUser.getMobileColumnsValue(); + NutMap map = mobileColumnsValue.stream().filter(o -> "xdqsrs".equals(o.getString("columnCode"))).findAny().orElse(null); + number = map != null ? map.getInt("columnValue") : 0; + } + } + boolean signFull = smartBenefitsActivityService.isSignFull(course, number); + if (signFull) { + return Result.error("当前报名人数已满"); + } + boolean signFullByUnionId = smartBenefitsActivityService.isSignFullByUnionId(course, number); + if (signFullByUnionId) { + return Result.error("该活动您所在的分工会名额不足"); + } + smartBenefitsActivityService.doSignUpInsteadApply(smartBenefitsUser); + return Result.success("报名成功"); + } catch (Exception e) { + e.printStackTrace(); + return Result.success("报名失败"); + } finally { + lock.unlock(); + } + } + +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsManageController.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsManageController.java new file mode 100644 index 00000000..d85998d2 --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsManageController.java @@ -0,0 +1,238 @@ +package com.budwk.app.zhgh.activity.smartbenefits.controller.manage; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; +import com.budwk.app.base.annotation.SLog; +import com.budwk.app.base.param.PageForm; +import com.budwk.app.base.result.Result; +import com.budwk.app.flow.entity.ProcessInstance; +import com.budwk.app.flow.enums.ProcessInstanceStateEnum; +import com.budwk.app.sys.models.Sys_home_activity; +import com.budwk.app.sys.models.Sys_unit; +import com.budwk.app.zhgh.activity.smartbenefits.models.*; +import com.budwk.app.zhgh.activity.smartbenefits.service.SmartBenefitsActivityService; +import com.budwk.app.zhgh.club.model.SysClub; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.nutz.dao.Chain; +import org.nutz.dao.Cnd; +import org.nutz.dao.Dao; +import org.nutz.dao.Sqls; +import org.nutz.dao.sql.Sql; +import org.nutz.ioc.loader.annotation.Inject; +import org.nutz.ioc.loader.annotation.IocBean; +import org.nutz.lang.util.NutMap; +import org.nutz.mvc.annotation.At; +import org.nutz.mvc.annotation.Ok; +import org.nutz.mvc.annotation.Param; +import org.nutz.trans.Trans; + +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author zxy + * @Description 培训报名 活动管理 + * @createTime 2022年02月23日 09:57:00 + */ +@Slf4j +@IocBean +@Ok("json:full") +@Api(tags = "活动管理(智享惠生活)") +@At("/platform/smartbenefits/manage") +public class SmartBenefitsManageController { + + @Inject + private SmartBenefitsActivityService smartBenefitsActivityManageService; + @Inject + private Dao dao; + + @At("") + @SaCheckPermission("smartbenefits.manage") + @Ok("beetl:/platform/zhgh/activity/smartbenefits/manage/index.html") + public void index() { + } + + @At + @ApiOperation("分页查询") + @SaCheckPermission("smartbenefits.manage") + public Result pageData(PageForm pageForm, + @Param(value = "year") Integer year, + @Param(value = "activityName") String activityName) { + Cnd cnd = Cnd.NEW(); + cnd.andEX("year", "=", year); + cnd.and(Cnd.likeEX("activityName", activityName)); + cnd.orderBy("createdAt", "desc"); + return Result.success().addData(smartBenefitsActivityManageService.pageData(pageForm, cnd)); + } + + @At + @ApiOperation("活动删除") + @SaCheckPermission("smartbenefits.manage") + @SLog(tag = "品牌活动-活动管理", msg = "删除活动") + public Result onDelete(String id) { + Trans.exec(() -> { + smartBenefitsActivityManageService.delete(id); + dao.clear(SmartBenefitsCourse.class, Cnd.where("activityId", "=", id)); + dao.clear(SmartBenefitsActivityCourse.class, Cnd.where("activityId", "=", id)); + dao.clear(SmartBenefitsUser.class, Cnd.where("activityId", "=", id)); + dao.clear(SmartBenefitsUserCourse.class, Cnd.where("activityId", "=", id)); + dao.clear(SmartBenefitsActivity.class, Cnd.where("id", "=", id)); + dao.clear(SmartBenefitsTypeLimit.class, Cnd.where("activityId", "=", id)); + dao.delete(Sys_home_activity.class, id); + }); + return Result.success(); + } + + @At + @ApiOperation("活动状态变更") + @SaCheckPermission("smartbenefits.manage") + public Result activityStatusChange(SmartBenefitsActivity activity) { + smartBenefitsActivityManageService.updateActivityStatus(activity); + dao.update(Sys_home_activity.class, + Chain.make("enable", !activity.isDisabled()), + Cnd.where("id", "=", activity.getId())); + return Result.success(); + } + + @At + @ApiOperation("查询单个活动") + @SaCheckPermission("smartBenefits") + public Result findOne(@Param("id") @NotNull String id) { + NutMap dataMap = smartBenefitsActivityManageService.findOne(id, null, ""); + String activityStartTime = dataMap.getString("activityStartTime"); + String activityEndTime = dataMap.getString("activityEndTime"); + if(StrUtil.isNotBlank(activityStartTime) && StrUtil.isNotBlank(activityEndTime)) { + dataMap.put("activityTime", List.of(activityStartTime, activityEndTime)); + } else { + dataMap.put("activityTime", new ArrayList<>()); + } + + String activitySignUpStartTime = dataMap.getString("activitySignUpStartTime"); + String activitySignUpEndTime = dataMap.getString("activitySignUpEndTime"); + if(StrUtil.isNotBlank(activitySignUpStartTime) && StrUtil.isNotBlank(activitySignUpEndTime)) { + dataMap.put("activitySignTime", List.of(activitySignUpStartTime, activitySignUpEndTime)); + } else { + dataMap.put("activitySignTime", new ArrayList<>()); + } + + List courseList = dataMap.getList("courseList", NutMap.class); + + //查询所有的课程类型 + List smartBenefitsTypeList = dao.query(SmartBenefitsType.class, Cnd.NEW()); + Map typeMap = smartBenefitsTypeList.stream().collect(Collectors.toMap(SmartBenefitsType::getId, SmartBenefitsType::getTypeName)); + + courseList.forEach(v -> { + + List courseTimeList = v.getList("courseTimeList", NutMap.class); + //选择课程日期 下拉框 + List setUpCourseData = courseTimeList.stream().map(cd -> cd.getString("courseDate")).distinct().collect(Collectors.toList()); + v.put("setUpCourseData", setUpCourseData); + + courseTimeList.forEach(ct -> { + String courseStartTime = DateUtil.format(ct.getTime("courseStartTime"), "HH:mm"); + String courseEndTime = DateUtil.format(ct.getTime("courseEndTime"), "HH:mm"); + ct.put("courseStartTime", courseStartTime); + ct.put("courseEndTime", courseEndTime); + }); + + v.put("courseTypeName", typeMap.get(v.getString("courseType"))); + }); + + return Result.success().addData(dataMap); + } + + @At + @Ok("json:full") + @ApiOperation("品牌活动新增/修改") + @SaCheckPermission("smartbenefits.manage") + @SLog(tag = "品牌活动-活动管理", msg = "新增/修改活动") + public Result doHandle(SmartBenefitsActivity activity) { + if (StrUtil.isBlank(activity.getId())) { + smartBenefitsActivityManageService.add(activity, null); + } else { + smartBenefitsActivityManageService.edit(activity); + } + return Result.success(); + } + + @At + @Ok("json:full") + @ApiOperation("获取分工会人数限制") + @SaCheckPermission("smartbenefits.manage") + public Result getUnionLimit(@Param(value = "activityScopeId") String activityScopeId) { + Sql sql = Sqls.create(""" + SELECT + gh.id, + gh.name, + gh.unioncode, + (select count(1) from `vw_user` where unionid = gh.id $cnd) as teacherCount, + NULL as ratio, + NULL as limitCount + FROM + sys_union gh + order by gh.unioncode + """); + if (StrUtil.isNotBlank(activityScopeId)) { + sql.setVar("cnd", "AND id in (select userId from activity_user_scope where groupId = '" + activityScopeId + "')"); + } + List list = smartBenefitsActivityManageService.listMap(sql); + return Result.success().addData(list); + } + + @At + @Ok("json:full") + @ApiOperation("获取报名人员数量") + @SaCheckPermission("smartbenefits.manage") + public Result getRegisterUserCount(@Param(value = "courseId") String courseId) { + return Result.success().addData(dao.count(SmartBenefitsUser.class, Cnd.where("courseId", "=", courseId))); + } + + @At + @Ok("json:full") + @ApiOperation("获取历史活动列表") + @SaCheckPermission("smartbenefits.manage") + public Result getHistoricalActList() { + List query = dao.query(SmartBenefitsActivity.class, Cnd.NEW().desc("activityStartTime")); + return Result.success().addData(query); + } + + @At + @Ok("json:full") + @ApiOperation("查询分工会和协会") + @SaCheckPermission("smartbenefits.manage") + public Result selectUnitAndClub() { + List result = new ArrayList<>(); + List unitList = dao.query(Sys_unit.class, Cnd.NEW().asc(Sys_unit::getUnitcode)); + for (Sys_unit unit : unitList) { + NutMap map = new NutMap(); + map.put("id", unit.getId()); + map.put("name", unit.getName()); + map.put("type", "unit"); + result.add(map); + } + List clubList = dao.query(SysClub.class, Cnd.NEW().asc(SysClub::getClubCode)); + + List instanceList = dao.query( + ProcessInstance.class, + Cnd.where(ProcessInstance::getBusinessNo, "in", clubList.stream().map(SysClub::getId).toList()) + .and(ProcessInstance::getState, "=", ProcessInstanceStateEnum.FINISHED.getCode()) + ); + List passList = instanceList.stream().map(ProcessInstance::getBusinessNo).toList(); + List passClubList = clubList.stream().filter(o -> passList.contains(o.getId())).toList(); + + for (SysClub sysClub : passClubList) { + NutMap map = new NutMap(); + map.put("id", sysClub.getId()); + map.put("name", sysClub.getClubName()); + map.put("type", "club"); + result.add(map); + } + return Result.success(result); + } +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsMineController.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsMineController.java new file mode 100644 index 00000000..96a01144 --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsMineController.java @@ -0,0 +1,220 @@ +package com.budwk.app.zhgh.activity.smartbenefits.controller.manage; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.dev33.satoken.annotation.SaMode; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUnit; +import cn.hutool.core.date.DateUtil; +import com.budwk.app.base.annotation.SLog; +import com.budwk.app.base.result.Result; +import com.budwk.app.base.utils.DistanceUtil; +import com.budwk.app.web.commons.auth.utils.SecurityUtil; +import com.budwk.app.zhgh.activity.smartbenefits.models.SmartBenefitsCourse; +import com.budwk.app.zhgh.activity.smartbenefits.models.SmartBenefitsUserCourse; +import com.budwk.app.zhgh.activity.smartbenefits.service.SmartBenefitsActivityService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.nutz.aop.interceptor.ioc.TransAop; +import org.nutz.dao.Cnd; +import org.nutz.dao.Dao; +import org.nutz.dao.Sqls; +import org.nutz.dao.sql.Sql; +import org.nutz.ioc.aop.Aop; +import org.nutz.ioc.loader.annotation.Inject; +import org.nutz.ioc.loader.annotation.IocBean; +import org.nutz.lang.util.NutMap; +import org.nutz.mvc.annotation.At; +import org.nutz.mvc.annotation.Ok; + +import java.util.Date; +import java.util.List; + +/** + * @ClassName SmartBenefitsMineController + * @Author JyuHsin + * @Date 2025/9/13 16:56 + * @Version 1.0 + * @Description TODO + */ +@Slf4j +@IocBean +@Ok("json:full") +@Api(tags = "活动报名(智享惠生活)") +@At("/platform/smartbenefits/mine") +public class SmartBenefitsMineController { + + @Inject + private Dao dao; + @Inject + private SmartBenefitsActivityService activityService; + + @At("/") + @SaCheckPermission("smartbenefits.mine") + @Ok("beetl:/platform/zhgh/activity/smartbenefits/mine/index.html") + public void index() { + } + + @At("/h5") + @SaCheckPermission("h5.smartbenefits.mine") + @Ok("beetl:/platform/zhghh5/activity/smartbenefits/mine/index.html") + public void h5Index() { + } + + @At("/scan") + @SaCheckPermission("h5.smartbenefits.mine") + @Ok("beetl:/platform/zhghh5/activity/smartbenefits/scan/index.html") + public void scan() { + } + + @At + @ApiOperation("主动扫码签到") + @Aop(TransAop.READ_COMMITTED) + @SaCheckPermission(value = {"smartbenefits.mine", "h5.smartbenefits.mine"}, mode = SaMode.OR) + @SLog(tag = "品牌活动-活动签到", msg = "主动扫码签到") + public Result drivingScan(String courseId, Double lat, Double lng) { + + // 主动扫码签到是用户自己打开扫一扫,扫二维码签到 + int count = dao.count(SmartBenefitsUserCourse.class, Cnd.where("courseId", "=", courseId).and("userId", "=", SecurityUtil.getUserId())); + if (count == 0) { + return Result.error(99, "未查询到您的报名记录"); + } + + SmartBenefitsCourse course = dao.fetch(SmartBenefitsCourse.class, courseId); + List coordinates = course.getTransPosition(); + int minute = course.getSignUnit() != null ? course.getSignUnit() : 0; + int radius = course.getRadius() != null ? course.getRadius() : 100; + + boolean flag = true; + // 获取现在的日期,并根据设置的数据 + List timeList = dao.query(SmartBenefitsUserCourse.class, Cnd.where("courseId", "=", courseId).and("userId", "=", SecurityUtil.getUserId())); + for (SmartBenefitsUserCourse userCourse : timeList) { + DateTime startTime = DateUtil.offsetMinute(userCourse.getCourseStartTime(), -minute); + DateTime endTime = DateUtil.offsetMinute(userCourse.getCourseEndTime(), minute); + if(DateUtil.isIn(DateUtil.date(), startTime, endTime)) { + userCourse.setAttend(true); + userCourse.setAttendTime(DateUtil.date()); + flag = false; + } + } + if(flag) { + return Result.error(99, "未到签到时间"); + } + + double distance = DistanceUtil.getDistance(coordinates.get(0), coordinates.get(1), lat, lng); + if(distance > radius) { + return Result.error(99, "签到失败,您距离签到点还有%.1f米".formatted(distance - radius)); + } + + dao.update(timeList); + + return Result.success("签到成功"); + } + + @At + @ApiOperation("被动扫码签到") + @Aop(TransAop.READ_COMMITTED) + @SaCheckPermission(value = {"smartbenefits.mine", "h5.smartbenefits.mine"}, mode = SaMode.OR) + @SLog(tag = "品牌活动-活动签到", msg = "被动扫码签到") + public Result passiveScan(String id) { + + // id表示课程的某个时间段,userId表示是谁出示的二维码 + SmartBenefitsUserCourse userCourse = dao.fetch(SmartBenefitsUserCourse.class, id); + if (userCourse == null) { + return Result.error("未查询到报名记录"); + } + int isAfter = DateUtil.compare(new Date(), userCourse.getCourseStartTime()); + if (isAfter > 0) { + return Result.error("抱歉,已经开始,无法签到"); + } + long diffMillis = Math.abs(DateUtil.between(new Date(), userCourse.getCourseStartTime(), DateUnit.MS)); + long oneHourInMs = 3600 * 1000; + if (diffMillis > oneHourInMs) { + return Result.error("签到时间为开始前1个小时"); + } + + userCourse.setAttend(true); + userCourse.setAttendTime(DateUtil.date()); + dao.update(userCourse); + + return Result.success(); + } + + @At + @ApiOperation("定位签到") + @Aop(TransAop.READ_COMMITTED) + @SaCheckPermission(value = {"smartbenefits.mine", "h5.smartbenefits.mine"}, mode = SaMode.OR) + @SLog(tag = "品牌活动-定位签到", msg = "定位签到") + public Result positionSign(String courseId, String timeId, Double lat, Double lng) { + SmartBenefitsCourse course = dao.fetch(SmartBenefitsCourse.class, courseId); + List coordinates = course.getTransPosition(); + int minute = course.getSignUnit() != null ? course.getSignUnit() : 0; + int radius = course.getRadius() != null ? course.getRadius() : 100; + + SmartBenefitsUserCourse userCourse = dao.fetch(SmartBenefitsUserCourse.class, timeId); + + DateTime startTime = DateUtil.offsetMinute(userCourse.getCourseStartTime(), -minute); + DateTime endTime = DateUtil.offsetMinute(userCourse.getCourseEndTime(), minute); + if(!DateUtil.isIn(DateUtil.date(), startTime, endTime)) { + return Result.error(99, "未到签到时间"); + } + + double distance = DistanceUtil.getDistance(coordinates.get(0), coordinates.get(1), lat, lng); + if(distance > radius) { + return Result.error(99, "签到失败,您距离签到点还有%.1f米".formatted(distance - radius)); + } + + userCourse.setAttend(true); + userCourse.setAttendTime(DateUtil.date()); + dao.update(userCourse); + return Result.success(); + } + + @At + @ApiOperation("分活动查询") + @SaCheckPermission(value = {"smartbenefits.mine", "h5.smartbenefits.mine"}, mode = SaMode.OR) + public Result queryCourseSign(String courseId) { + Sql sql = Sqls.create(""" + SELECT + uc.*, + date(uc.courseStartTime) as courseDate + FROM + `smart_benefits_user_course` uc + WHERE + courseId = @courseId and userId = @userId + """); + sql.setParam("userId", SecurityUtil.getUserId()); + sql.setParam("courseId", courseId); + List listMap = activityService.listMap(sql); + return Result.success(listMap); + } + + @At + @ApiOperation("获取我报名的课程") + @SaCheckPermission(value = {"smartbenefits.mine", "h5.smartbenefits.mine"}, mode = SaMode.OR) + public Result queryMineCourse(String activityId) { + + Sql sql = Sqls.create(""" + SELECT + c.*, + u.mobileColumnsValue + FROM + smart_benefits_user u + LEFT JOIN smart_benefits_course c ON c.id = u.courseId + $condition + """); + Cnd cnd = Cnd.NEW(); + cnd.and("u.activityId", "=", activityId); + cnd.and("u.userId", "=", SecurityUtil.getUserId()); + sql.setCondition(cnd); + List listMap = activityService.listMap(sql); + return Result.success(listMap); + } + + @At + @SaCheckPermission(value = {"smartbenefits.mine", "h5.smartbenefits.mine"}, mode = SaMode.OR) + public Result fetchCourse(String courseId) { + SmartBenefitsCourse course = dao.fetch(SmartBenefitsCourse.class, courseId); + return Result.success(course); + } +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsTypeController.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsTypeController.java new file mode 100644 index 00000000..46e91c48 --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsTypeController.java @@ -0,0 +1,167 @@ +package com.budwk.app.zhgh.activity.smartbenefits.controller.manage; + +import cn.dev33.satoken.annotation.SaCheckLogin; +import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.hutool.core.util.EnumUtil; +import com.budwk.app.base.annotation.SLog; +import com.budwk.app.base.page.Pagination; +import com.budwk.app.base.param.PageForm; +import com.budwk.app.base.result.Result; +import com.budwk.app.base.service.BaseService; +import com.budwk.app.base.utils.PageUtil; +import com.budwk.app.zhgh.activity.smartbenefits.models.SmartBenefitsMobileSignColumn; +import com.budwk.app.zhgh.activity.smartbenefits.models.SmartBenefitsType; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.nutz.aop.interceptor.ioc.TransAop; +import org.nutz.dao.Chain; +import org.nutz.dao.Cnd; +import org.nutz.dao.Dao; +import org.nutz.dao.Sqls; +import org.nutz.dao.entity.annotation.ColType; +import org.nutz.dao.sql.Sql; +import org.nutz.ioc.aop.Aop; +import org.nutz.ioc.loader.annotation.Inject; +import org.nutz.ioc.loader.annotation.IocBean; +import org.nutz.json.Json; +import org.nutz.lang.Strings; +import org.nutz.lang.util.NutMap; +import org.nutz.mvc.annotation.At; +import org.nutz.mvc.annotation.Ok; +import org.nutz.mvc.annotation.Param; + +import java.util.List; + +/** + * @Author JyuHsin + * @Date 2022/9/22 + * @Description + */ +@Slf4j +@IocBean +@Ok("json:full") +@Api(tags = "活动类型管理(智享惠生活)") +@At("/platform/smartbenefits/type") +public class SmartBenefitsTypeController { + + @Inject + private Dao dao; + @Inject + private BaseService baseService; + + @At("") + @SaCheckPermission("smartbenefits.type") + @Ok("beetl:/platform/zhgh/activity/smartbenefits/type/index.html") + public void index() { + } + + @At + @ApiOperation("分页查询") + @SaCheckPermission("smartbenefits.type") + public Result pageData(PageForm pageForm, + @Param(value = "typeName") String typeName) { + Cnd cnd = Cnd.NEW(); + Sql sql = Sqls.create(""" + select * from smart_benefits_type $condition + """); + if (Strings.isNotBlank(typeName)) { + cnd.and("typeName", "like", "%" + typeName + "%"); + } + if(Strings.isNotBlank(pageForm.getPageOrderName()) && Strings.isNotBlank(pageForm.getPageOrderBy())){ + cnd.orderBy(pageForm.getPageOrderName(), PageUtil.getOrder(pageForm.getPageOrderBy())); + } else { + cnd.asc("xh"); + } + sql.setCondition(cnd); + Pagination pagination = baseService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql); + List list = pagination.getList(); + list.forEach(item -> { + Cnd c = Cnd.NEW(); + c.and("typeId", "=", item.getString("id")); + c.asc("columnIndex"); + List signColumns = dao.query(SmartBenefitsMobileSignColumn.class, c); + item.put("smartBenefitsMobileSignColumnList", signColumns); + + }); + return Result.success().addData(pagination); + } + + @At + @ApiOperation("活动类型新增") + @SaCheckPermission("smartbenefits.type") + @SLog(tag = "品牌活动-类型管理", msg = "活动类型新增") + public Result doAdd(@Param("data") String data) throws Exception { + SmartBenefitsType type = Json.fromJson(SmartBenefitsType.class, data); + int count = dao.count(SmartBenefitsType.class, Cnd.where("code", "=", type.getCode())); + if (count > 0) { + return Result.error("编码重复!"); + } + int totalCount = dao.count(SmartBenefitsType.class); + type.setXh(totalCount + 1); + dao.insertWith(type, "smartBenefitsMobileSignColumnList"); + return Result.success(); + } + + @At + @ApiOperation("活动类型修改") + @SaCheckPermission("smartbenefits.type") + @SLog(tag = "品牌活动-类型管理", msg = "活动类型修改") + public Result doEdit(SmartBenefitsType type) { + int count = dao.count(SmartBenefitsType.class, Cnd.where("code", "=", type.getCode()).and("id", "!=", type.getId())); + if (count > 0) { + return Result.error("编码重复!"); + } + dao.update(type); + dao.clear(SmartBenefitsMobileSignColumn.class, Cnd.where("typeId", "=", type.getId())); + dao.insertLinks(type, "smartBenefitsMobileSignColumnList"); + return Result.success(); + } + + @At + @ApiOperation("活动类型删除") + @SaCheckPermission("smartbenefits.type") + @SLog(tag = "品牌活动-类型管理", msg = "活动类型删除") + public Object doDelete(@Param(value = "id") String id) { + dao.clear(SmartBenefitsType.class, Cnd.where("id", "=", id)); + dao.clear(SmartBenefitsMobileSignColumn.class, Cnd.where("typeId", "=", id)); + return Result.success(); + } + + @At + @Aop(TransAop.READ_COMMITTED) + @ApiOperation("排序号变更") + @SaCheckPermission("smartbenefits.type") + public Object xhChange(String id, Integer xh, boolean toDown) { + if (toDown) { + SmartBenefitsType next = dao.fetch(SmartBenefitsType.class, Cnd.where("xh", "=", xh + 1)); + next.setXh(next.getXh() - 1); + dao.update(next); + dao.update(SmartBenefitsType.class, Chain.make("xh", xh + 1), Cnd.where("id", "=", id)); + } else { + SmartBenefitsType pre = dao.fetch(SmartBenefitsType.class, Cnd.where("xh", "=", xh - 1)); + pre.setXh(pre.getXh() + 1); + dao.update(pre); + dao.update(SmartBenefitsType.class, Chain.make("xh", xh - 1), Cnd.where("id", "=", id)); + } + return Result.success(); + } + + @At + @ApiOperation("获取所有类型") + @SaCheckLogin + public Result getAllType(@Param(value = "id") String id) { + List smartBenefitsTypeList = dao.query(SmartBenefitsType.class, Cnd.NEW().andEX("id", "=", id).asc("xh")); + dao.fetchLinks(smartBenefitsTypeList, "smartBenefitsMobileSignColumnList", Cnd.NEW().asc("columnIndex")); + return Result.success().addData(smartBenefitsTypeList); + } + + @At + @ApiOperation("自定义表单字段类型") + @SaCheckPermission("smartbenefits.type") + public Result getColumnType() { + List names = EnumUtil.getNames(ColType.class); + names.add("JSON"); + return Result.success(names); + } +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsUserManageController.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsUserManageController.java new file mode 100644 index 00000000..1845bfeb --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/manage/SmartBenefitsUserManageController.java @@ -0,0 +1,350 @@ +package com.budwk.app.zhgh.activity.smartbenefits.controller.manage; + +import cn.afterturn.easypoi.excel.entity.ExportParams; +import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity; +import cn.afterturn.easypoi.excel.export.ExcelExportService; +import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.hutool.core.util.StrUtil; +import com.budwk.app.base.annotation.SLog; +import com.budwk.app.base.page.Pagination; +import com.budwk.app.base.param.PageForm; +import com.budwk.app.base.result.Result; +import com.budwk.app.base.utils.PageUtil; +import com.budwk.app.zhgh.activity.smartbenefits.models.SmartBenefitsActivity; +import com.budwk.app.zhgh.activity.smartbenefits.models.SmartBenefitsCourse; +import com.budwk.app.zhgh.activity.smartbenefits.models.SmartBenefitsUser; +import com.budwk.app.zhgh.activity.smartbenefits.service.SmartBenefitsBlackListService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; +import org.nutz.dao.Chain; +import org.nutz.dao.Cnd; +import org.nutz.dao.Dao; +import org.nutz.dao.Sqls; +import org.nutz.dao.sql.Sql; +import org.nutz.dao.util.cri.SqlExpressionGroup; +import org.nutz.ioc.loader.annotation.Inject; +import org.nutz.ioc.loader.annotation.IocBean; +import org.nutz.lang.Strings; +import org.nutz.lang.util.NutMap; +import org.nutz.mvc.annotation.At; +import org.nutz.mvc.annotation.Ok; +import org.nutz.mvc.annotation.Param; + +import javax.servlet.http.HttpServletResponse; +import java.net.URLEncoder; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author zxy + * @Description 人员管理 + * @createTime 2022年03月07日 14:27:00 + */ +@IocBean +@Ok("json:full") +@Api(tags = "品牌活动人员黑名单(智享惠生活)") +@At("/platform/smartbenefits/userManage") +public class SmartBenefitsUserManageController { + + @Inject + private Dao dao; + @Inject + private SmartBenefitsBlackListService smartBenefitsBlackListService; + + @At("") + @SaCheckPermission("smartbenefits.userManage") + @Ok("beetl:/platform/zhgh/activity/smartbenefits/userManage/index.html") + public void index() { + } + + @At + @ApiOperation("分页查询") + @SaCheckPermission("smartbenefits.userManage") + public Result pageData(PageForm pageForm, + @Param(value = "activityId") String activityId, + @Param(value = "courseId") String courseId, + @Param(value = "year") Integer year, + @Param(value = "userKeyWord") String userKeyWord) { + Cnd cnd = Cnd.NEW(); + cnd.andEX("tsuu.activityId", "=", activityId); + cnd.andEX("tsuu.courseId", "=", courseId); + cnd.andEX("act.year", "=", year); + if (StrUtil.isNotBlank(userKeyWord)) { + SqlExpressionGroup seg = new SqlExpressionGroup(); + cnd.and(seg.andLike("u.username", userKeyWord).orLike("u.loginname", userKeyWord)); + } + if(Strings.isNotBlank(pageForm.getPageOrderName()) && Strings.isNotBlank(pageForm.getPageOrderBy())){ + cnd.orderBy(pageForm.getPageOrderName(), PageUtil.getOrder(pageForm.getPageOrderBy())); + } + + Pagination pagination = smartBenefitsBlackListService.pageData(pageForm, cnd, activityId, courseId); + return Result.success(pagination); + } + + @At + @ApiOperation("报名人员处理") + @SaCheckPermission("smartbenefits.userManage") + @SLog(tag = "品牌活动-人员管理", msg = "报名人员处理") + public Result doHandleUser(@Param("userId") String userId) { + smartBenefitsBlackListService.doHandleUser(userId); + return Result.success(); + } + + @At + @ApiOperation("根据活动Id获取子活动") + @SaCheckPermission("smartbenefits.userManage") + public Result getCourseByActivityId(@Param("activityId") String activityId) { + List list = dao.query(SmartBenefitsCourse.class, Cnd.where("activityId", "=", activityId)); + return Result.success(list); + } + + @At + @ApiOperation("获取子活动具体时间") + @SaCheckPermission("smartbenefits.userManage") + public Result attendClassRecord(String userId) { + smartBenefitsBlackListService.attendClassRecord(userId); + return Result.success(); + } + + @At + @ApiOperation("获取候补人员") + @SaCheckPermission("smartbenefits.userManage") + public Result getReserveUser(String courseId) { + Sql sql = Sqls.create(""" + SELECT + uc.* , + (select signUpTime from smart_benefits_user su where su.activityId=uc.activityId and su.courseId = uc.courseId and su.userId=uc.userId) as signUpTime, + (select state from smart_benefits_user su where su.activityId=uc.activityId and su.courseId = uc.courseId and su.userId=uc.userId) as state, + u.username, + u.loginname, + u.mobile, + u.unitName, + u.unionName + FROM + smart_benefits_user_course uc LEFT JOIN `vw_user` u on uc.userId = u.id + WHERE uc.courseId = @courseId and uc.isAttend = false HAVING state = 2 order by signUpTime desc + """).setParam("courseId", courseId); + return Result.success(smartBenefitsBlackListService.listMap(sql)); + } + + @At + @ApiOperation("补充人员") + @SaCheckPermission("smartbenefits.userManage") + @SLog(tag = "品牌活动-人员管理", msg = "补充人员") + public Result reserveSingUp(String[] ids, String courseId) { + //先查询这个课程有多少个未签到的人员 + Sql sql = Sqls.create(""" + SELECT + uc.* , + (select signUpTime from smart_benefits_user su where su.activityId=uc.activityId and su.courseId = uc.courseId and su.userId=uc.userId) as signUpTime, + (select state from smart_benefits_user su where su.activityId=uc.activityId and su.courseId = uc.courseId and su.userId=uc.userId) as state + FROM + smart_benefits_user_course uc + WHERE uc.courseId = @courseId and uc.isAttend = false HAVING state = 1 order by signUpTime desc + """).setParam("courseId", courseId); + List list = smartBenefitsBlackListService.listMap(sql); + if(ids.length > list.size()) { + return Result.error("您选择了" + ids.length + "位,未签到人员只有" + list.size() + "位"); + } + //ids的长度为几,就搞几个 + List mapList = list.subList(0, ids.length); + List idList = mapList.stream().map(o -> o.getString("userId")).collect(Collectors.toList()); + //将这几个没签到的设置为4 + dao.update(SmartBenefitsUser.class, Chain.make("state", 4), Cnd.where("courseId", "=", courseId) + .and("userId", "in", idList)); + //将补充的设置为1 + dao.update(SmartBenefitsUser.class, Chain.make("state", 1), Cnd.where("courseId", "=", courseId) + .and("userId", "in", ids)); + return Result.success(); + } + + @At + @Ok("void") + @ApiOperation("导出签到人员") + public void exportSignPerson(@Param(value = "activityId") String activityId, + HttpServletResponse response) { + SmartBenefitsActivity activity = dao.fetch(SmartBenefitsActivity.class, activityId); + + Sql sql = Sqls.create(""" + SELECT + uc.*, + DATE_FORMAT(uc.courseStartTime, '%Y-%m-%d %H:%i:%s') as courseStartTimeExcel, + DATE_FORMAT(uc.courseEndTime, '%Y-%m-%d %H:%i:%s') as courseEndTimeExcel, + DATE_FORMAT(uc.attendTime, '%Y-%m-%d %H:%i:%s') as attendTimeExcel, + u.username, + u.loginname, + u.unitName, + u.unionName, + u.sex + FROM + smart_benefits_user_course uc + left join smart_benefits_course course on uc.courseId = course.id + left join `vw_user` u on u.id = uc.userId + $condition + """); + Cnd cnd = Cnd.NEW(); + cnd.and("uc.activityId", "=", activityId); + cnd.and("course.isMobileSign", "=", true); + cnd.desc("isAttend").desc("attendTime"); + sql.setCondition(cnd); + + List userList = smartBenefitsBlackListService.listMap(sql); + + List courseList = dao.query(SmartBenefitsCourse.class, Cnd.where("activityId", "=", activityId)); + + List> sheetsList = new ArrayList<>(); + + List excelCommonExportEntity = new ArrayList<>(); + excelCommonExportEntity.add(new ExcelExportEntity("姓名", "username", 20)); + excelCommonExportEntity.add(new ExcelExportEntity("工号", "loginname", 20)); + excelCommonExportEntity.add(new ExcelExportEntity("单位", "unitName", 20)); + excelCommonExportEntity.add(new ExcelExportEntity("分工会", "unionName", 20)); + excelCommonExportEntity.add(new ExcelExportEntity("性别", "sex", 20)); + excelCommonExportEntity.add(new ExcelExportEntity("开始时间", "courseStartTimeExcel", 22)); + excelCommonExportEntity.add(new ExcelExportEntity("结束时间", "courseEndTimeExcel", 22)); + excelCommonExportEntity.add(new ExcelExportEntity("是否签到", "isAttend", 20)); + excelCommonExportEntity.add(new ExcelExportEntity("签到时间", "attendTimeExcel", 22)); + + for (SmartBenefitsCourse c : courseList) { + if(!c.isMobileSign()) { + continue; + } + String courseId = c.getId(); + String courseName = c.getCourseName(); + List v = userList.stream().filter(x -> x.getString("courseId").equals(courseId)).collect(Collectors.toList()); + ExportParams userExportParams = new ExportParams(); + userExportParams.setSheetName(courseName); + + List currentEntities = new ArrayList<>(excelCommonExportEntity); + for (NutMap userSignData : v) { + if(!userSignData.getBoolean("isAttend")) { + userSignData.put("isAttend", "未签到"); + userSignData.put("attendTimeExcel", "未签到"); + }else { + userSignData.put("isAttend", "已签到"); + } + } + + Map userExportMap = new HashMap<>(); + userExportMap.put("name", courseName); + userExportMap.put("title", userExportParams); + userExportMap.put("entity", currentEntities); + userExportMap.put("data", v); + + sheetsList.add(userExportMap); + } + try { + String fileName = activity.getActivityName() + "签到人员名单.xls"; + String disposition = "attachment;filename=" + URLEncoder.encode(fileName, "utf-8"); + response.setCharacterEncoding("utf-8"); + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", disposition); + + Workbook workbook = new HSSFWorkbook(); + for (Map map : sheetsList) { + ExcelExportService service = new ExcelExportService(); + service.createSheetForMap(workbook,(ExportParams) map.get("title"),(List) map.get("entity"),(Collection) map.get("data")); + } + + workbook.write(response.getOutputStream()); + workbook.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @At + @Ok("void") + @ApiOperation("导出领取人员") + public void exportGiftPerson(@Param(value = "activityId") String activityId, + HttpServletResponse response) { + SmartBenefitsActivity activity = dao.fetch(SmartBenefitsActivity.class, activityId); + + Sql sql = Sqls.create(""" + SELECT + uc.*, + DATE_FORMAT(uc.courseStartTime, '%Y-%m-%d %H:%i:%s') as courseStartTimeExcel, + DATE_FORMAT(uc.courseEndTime, '%Y-%m-%d %H:%i:%s') as courseEndTimeExcel, + DATE_FORMAT(uc.receiveTime, '%Y-%m-%d %H:%i:%s') as receiveTimeExcel, + u.username, + u.loginname, + u.unitName, + u.unionName, + u.sex + FROM + smart_benefits_user_course uc + left join smart_benefits_course course on uc.courseId = course.id + left join `vw_user` u on u.id = uc.userId + $condition + """); + Cnd cnd = Cnd.NEW(); + cnd.and("uc.activityId", "=", activityId); + cnd.and("course.isReceiveGift", "=", true).and("course.giftType" ,"=", 1); + cnd.desc("isReceive").desc("receiveTime"); + sql.setCondition(cnd); + + List userList = smartBenefitsBlackListService.listMap(sql); + + List courseList = dao.query(SmartBenefitsCourse.class, Cnd.where("activityId", "=", activityId)); + + List> sheetsList = new ArrayList<>(); + + List excelCommonExportEntity = new ArrayList<>(); + excelCommonExportEntity.add(new ExcelExportEntity("姓名", "username", 20)); + excelCommonExportEntity.add(new ExcelExportEntity("工号", "loginname", 20)); + excelCommonExportEntity.add(new ExcelExportEntity("单位", "unitName", 20)); + excelCommonExportEntity.add(new ExcelExportEntity("分工会", "unionName", 20)); + excelCommonExportEntity.add(new ExcelExportEntity("性别", "sex", 20)); + excelCommonExportEntity.add(new ExcelExportEntity("开始时间", "courseStartTimeExcel", 22)); + excelCommonExportEntity.add(new ExcelExportEntity("结束时间", "courseEndTimeExcel", 22)); + excelCommonExportEntity.add(new ExcelExportEntity("是否领取", "isReceive", 20)); + excelCommonExportEntity.add(new ExcelExportEntity("领取时间", "receiveTimeExcel", 22)); + + for (SmartBenefitsCourse c : courseList) { + String courseId = c.getId(); + String courseName = c.getCourseName(); + List v = userList.stream().filter(x -> x.getString("courseId").equals(courseId)).collect(Collectors.toList()); + ExportParams userExportParams = new ExportParams(); + userExportParams.setSheetName(courseName); + + List currentEntities = new ArrayList<>(excelCommonExportEntity); + for (NutMap userSignData : v) { + if(!userSignData.getBoolean("isReceive")) { + userSignData.put("isReceive", "未领取"); + userSignData.put("receiveTimeExcel", "未领取"); + }else { + userSignData.put("isReceive", "已领取"); + } + } + + Map userExportMap = new HashMap<>(); + userExportMap.put("name", courseName); + userExportMap.put("title", userExportParams); + userExportMap.put("entity", currentEntities); + userExportMap.put("data", v); + + sheetsList.add(userExportMap); + } + try { + String fileName = activity.getActivityName() + "礼品领取人员名单.xls"; + String disposition = "attachment;filename=" + URLEncoder.encode(fileName, "utf-8"); + response.setCharacterEncoding("utf-8"); + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", disposition); + + Workbook workbook = new HSSFWorkbook(); + for (Map map : sheetsList) { + ExcelExportService service = new ExcelExportService(); + service.createSheetForMap(workbook,(ExportParams) map.get("title"),(List) map.get("entity"),(Collection) map.get("data")); + } + + workbook.write(response.getOutputStream()); + workbook.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/statistics/SmartBenefitsActivityStatisticsController.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/statistics/SmartBenefitsActivityStatisticsController.java new file mode 100644 index 00000000..d4f2314e --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/controller/statistics/SmartBenefitsActivityStatisticsController.java @@ -0,0 +1,307 @@ +package com.budwk.app.zhgh.activity.smartbenefits.controller.statistics; + +import cn.afterturn.easypoi.excel.entity.ExportParams; +import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; +import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity; +import cn.afterturn.easypoi.excel.export.ExcelExportService; +import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.hutool.core.util.StrUtil; +import com.budwk.app.base.constant.RoleConstant; +import com.budwk.app.base.page.Pagination; +import com.budwk.app.base.param.PageForm; +import com.budwk.app.base.result.Result; +import com.budwk.app.base.utils.CommonDownloadUtil; +import com.budwk.app.sys.models.Sys_file; +import com.budwk.app.sys.utils.SysFileMinIoUtil; +import com.budwk.app.web.commons.auth.utils.AuthUtil; +import com.budwk.app.web.commons.auth.utils.SecurityUtil; +import com.budwk.app.zhgh.activity.smartbenefits.models.*; +import com.budwk.app.zhgh.activity.smartbenefits.service.SmartBenefitsActivityService; +import com.budwk.app.zhgh.activity.smartbenefits.service.SmartBenefitsActivityStatisticsService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; +import org.nutz.dao.Chain; +import org.nutz.dao.Cnd; +import org.nutz.dao.Dao; +import org.nutz.dao.Sqls; +import org.nutz.dao.sql.Sql; +import org.nutz.ioc.loader.annotation.Inject; +import org.nutz.ioc.loader.annotation.IocBean; +import org.nutz.json.Json; +import org.nutz.lang.Lang; +import org.nutz.lang.util.NutMap; +import org.nutz.mvc.annotation.At; +import org.nutz.mvc.annotation.Ok; +import org.nutz.mvc.annotation.Param; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.*; +import java.util.stream.Collectors; + + +/** + * @author zxy + * @Description 培训报名 统计 + * @createTime 2022年02月23日 09:57:00 + */ +@Slf4j +@IocBean +@Ok("json:full") +@Api(tags = "品牌活动统计(智享惠生活)") +@At("/platform/smartbenefits/statistics") +public class SmartBenefitsActivityStatisticsController { + + @Inject + private SmartBenefitsActivityService smartBenefitsActivityManageService; + @Inject + private SmartBenefitsActivityStatisticsService smartBenefitsActivityStatisticsService; + @Inject + private Dao dao; + + @At("") + @SaCheckPermission("smartbenefits.statistics") + @Ok("beetl:/platform/zhgh/activity/smartbenefits/statistics/index.html") + public void index() { + } + + @At + @ApiOperation("分页查询") + @SaCheckPermission("smartbenefits.statistics") + public Result pageData(PageForm pageForm, + @Param(value = "activityId") String activityId) { + Pagination pagination = smartBenefitsActivityStatisticsService.pageData(pageForm, activityId); + return Result.success(pagination); + } + + /** + * 活动list + * + * @param year 年度 + * @return + */ + @At + @ApiOperation("活动列表") + @SaCheckPermission("smartbenefits.statistics") + public Result activityList(@Param(value = "year") Integer year) { + List list = dao.query(SmartBenefitsActivity.class, Cnd.NEW().andEX("year", "=", year).desc("activityStartTime")); + if (!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_CHAIRMAN.name())) { + // 获取当前登录用户的工会 + String unionId = SecurityUtil.getUnionId(); + // 获取当前登录用户的协会 + List clubIds = SecurityUtil.getClubIds(); + + List result = new ArrayList<>(); + for (SmartBenefitsActivity activity : list) { + if (AuthUtil.hasRole(RoleConstant.BRANCH_UNION_CHAIRMAN.name())) { + if (activity.getHostUnits().contains(unionId) || activity.getHelpUnits().contains(unionId)) { + result.add(activity); + } + } + if (AuthUtil.hasRoleOr(RoleConstant.CLUB_PRESIDENT.name(), RoleConstant.CLUB_OPERATOR.name())) { + if (clubIds.stream().anyMatch(activity.getHostUnits()::contains) || clubIds.stream().anyMatch(activity.getHelpUnits()::contains)) { + result.add(activity); + } + } + } + return Result.success(result); + } + return Result.success(list); + } + + /** + * 培训班报名人员list + * + * @param courseId + * @return + */ + @At + @ApiOperation("报名人员列表") + @SaCheckPermission("smartbenefits.statistics") + public Result registerUserList(@Param(value = "courseId") String courseId) { + return Result.success(smartBenefitsActivityStatisticsService.registerUserList(courseId)); + } + + @At + @ApiOperation("报名动态列") + @SaCheckPermission("smartbenefits.statistics") + public Object getTaleColumnInfo(@Param(value = "courseId") String courseId) { + return Result.success(smartBenefitsActivityStatisticsService.getTaleColumnInfo(courseId)); + } + + @At + @ApiOperation("获取时间信息") + @SaCheckPermission("smartbenefits.statistics") + public Result selectTimes(@Param("courseId") String courseId) { + List activityCourses = dao.query(SmartBenefitsActivityCourse.class, Cnd.where("courseId", "=", courseId).asc("courseStartTime")); + return Result.success(activityCourses); + } + + /** + * 培训班上课签到信息 + * + * @param courseId + * @return + */ + @At + @ApiOperation("获取签到信息") + @SaCheckPermission("smartbenefits.statistics") + public Result getSignInfo(PageForm pageForm, + @Param("courseId") String courseId, + String timeId) { + return Result.success(smartBenefitsActivityStatisticsService.getSignInfo(pageForm, courseId, timeId)); + } + + @At + @ApiOperation("开放报名") + @SaCheckPermission("smartbenefits.statistics") + public Result signChange(@Param("courseId") String courseId, @Param("openOtherUnion") Boolean openOtherUnion) { + dao.update(SmartBenefitsCourse.class, Chain.make("openOtherUnion", openOtherUnion) + , Cnd.where("id", "=", courseId)); + return Result.success(); + } + + @At + @ApiOperation("设置签到") + @SaCheckPermission("smartbenefits.statistics") + public Result adjustSign(@Param("id") String id) { + SmartBenefitsUserCourse userCourse = dao.fetch(SmartBenefitsUserCourse.class, id); + Date courseStartTime = userCourse.getCourseStartTime(); + Date courseEndTime = userCourse.getCourseEndTime(); + Date now = new Date(); + if (courseStartTime == null || courseStartTime.after(now)) { + return Result.error("签到时间未开始!"); + } + if (courseEndTime != null && courseEndTime.before(now)) { + return Result.error("签到已结束!"); + } + if (userCourse.isAttend()) { + userCourse.setAttend(false); + userCourse.setAttendTime(null); + } else { + userCourse.setAttend(true); + userCourse.setAttendTime(userCourse.getCourseStartTime()); + } + dao.update(userCourse); + return Result.success(); + } + + @At + @Ok("void") + @ApiOperation("导出签到名单") + @SaCheckPermission("smartbenefits.statistics") + public void exportSignUser(@Param(value = "activityId") String activityId, + HttpServletResponse response) throws IOException { + try { + SmartBenefitsActivity activity = dao.fetch(SmartBenefitsActivity.class, activityId); + Sql sql = Sqls.create(""" + SELECT + ts.*, + CONCAT(DATE_FORMAT(ac.courseStartTime, '%H:%i:%s'),'至',DATE_FORMAT(ac.courseEndTime, '%H:%i:%s')) AS courseTime, + u.username, + u.loginname, + u.sex, + ifnull(ts.mobile, u.mobile) as mobile, + u.birthday, + tsc.courseName + FROM + smart_benefits_user ts + left join smart_benefits_activity_course ac on ts.activityCourseId = ac.id + left join `vw_user` u on u.id = ts. userId + left join smart_benefits_course tsc on tsc.id = ts.courseId + WHERE + ts.activityId = @activityId + """).setParam("activityId", activityId); + List userList = smartBenefitsActivityManageService.listMap(sql); + + List courseList = dao.query(SmartBenefitsCourse.class, Cnd.where("activityId", "=", activityId)); + + List smartBenefitsTypeList = dao.query(SmartBenefitsType.class, Cnd.NEW()); + dao.fetchLinks(smartBenefitsTypeList, "smartBenefitsMobileSignColumnList", Cnd.NEW().asc("columnIndex")); + Map typeMap = smartBenefitsTypeList.stream().collect(Collectors.toMap(SmartBenefitsType::getId, o -> o)); + + List> sheetsList = new ArrayList<>(); + + List excelCommonExportEntity = new ArrayList<>(); + excelCommonExportEntity.add(new ExcelExportEntity("姓名", "username", 20)); + excelCommonExportEntity.add(new ExcelExportEntity("工号", "loginname", 20)); + excelCommonExportEntity.add(new ExcelExportEntity("单位", "unitName", 20)); + excelCommonExportEntity.add(new ExcelExportEntity("分工会", "unionName", 20)); + excelCommonExportEntity.add(new ExcelExportEntity("性别", "sex", 20)); + excelCommonExportEntity.add(new ExcelExportEntity("手机号", "mobile", 20)); + excelCommonExportEntity.add(new ExcelExportEntity("生日", "birthday", 20)); + excelCommonExportEntity.add(new ExcelExportEntity("报名时段", "courseTime", 20)); + + for (SmartBenefitsCourse c : courseList) { + String k = c.getCourseName(); + List v = userList.stream().filter(x -> StrUtil.isNotBlank(x.getString("courseName")) && x.getString("courseName").equals(k)).collect(Collectors.toList()); + ExportParams userExportParams = new ExportParams(); + userExportParams.setSheetName(k); + userExportParams.setType(ExcelType.HSSF); + + List currentEntities = new ArrayList<>(); + currentEntities.addAll(excelCommonExportEntity); + + SmartBenefitsType signUpType = typeMap.get(c.getCourseType()); + if (Lang.isNotEmpty(signUpType.getSmartBenefitsMobileSignColumnList())) { + for (SmartBenefitsMobileSignColumn column : signUpType.getSmartBenefitsMobileSignColumnList()) { + ExcelExportEntity entity = new ExcelExportEntity(); + entity.setName(column.getColumnName()); + entity.setKey(column.getColumnCode()); + entity.setWidth(20); + if ("FILE".equals(column.getColumnFormType())) { + entity.setType(2); + entity.setExportImageType(2); + } + currentEntities.add(entity); + } + } + for (NutMap userSignData : v) { + String mobileColumnsValueStr = userSignData.getString("mobileColumnsValue"); + if (StrUtil.isNotBlank(mobileColumnsValueStr)) { + List mobileColumnsValue = Json.fromJsonAsList(NutMap.class, mobileColumnsValueStr); + for (NutMap cv : mobileColumnsValue) { + if (!"FILE".equals(cv.getString("columnFormType"))) { + userSignData.put(cv.getString("columnCode"), cv.getString("columnValue")); + } else { + if (StrUtil.isNotBlank(cv.getString("columnValue"))) { + List columnValue = cv.getAsList("columnValue", NutMap.class); + if (columnValue.size() == 1) { + NutMap sysFile = columnValue.get(0); + Sys_file file = dao.fetch(Sys_file.class, Cnd.where(Sys_file::getDownloadPath, "=", sysFile.get("url"))); + byte[] imageBytes = SysFileMinIoUtil.getFileBytes(file.getBucket(), file.getStoragePath()); + if (imageBytes.length > 0) { + userSignData.put(cv.getString("columnCode"), imageBytes); + } + } + } + } + } + + } + } + + Map userExportMap = new HashMap<>(); + userExportMap.put("name", k); + userExportParams.setType(ExcelType.HSSF); + userExportMap.put("title", userExportParams); + userExportMap.put("entity", currentEntities); + userExportMap.put("data", v); + + sheetsList.add(userExportMap); + } + + Workbook workbook = new HSSFWorkbook(); + for (Map map : sheetsList) { + ExcelExportService service = new ExcelExportService(); + service.createSheetForMap(workbook, (ExportParams) map.get("title"), (List) map.get("entity"), (Collection) map.get("data")); + } + CommonDownloadUtil.download(activity.getActivityName() + "报名人员名单" + ".xls", workbook, response); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsActivity.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsActivity.java new file mode 100644 index 00000000..500d9df2 --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsActivity.java @@ -0,0 +1,144 @@ +package com.budwk.app.zhgh.activity.smartbenefits.models; + +import com.budwk.app.base.model.BaseModel; +import com.budwk.app.sys.models.Sys_home_activity; +import com.budwk.app.sys.services.SysHomeConvert; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.nutz.dao.entity.annotation.*; +import org.nutz.dao.interceptor.annotation.PrevInsert; +import org.nutz.lang.Lang; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +@Data +@Accessors(chain = true) +@Comment("品牌活动(智享惠生活)") +@Table +@EqualsAndHashCode(callSuper = false) +public class SmartBenefitsActivity extends BaseModel implements Serializable, SysHomeConvert { + + @Name + @PrevInsert(uu32 = true) + private String id; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 50) + @Comment("活动名称") + private String activityName; + + @Column + @ColDefine(type = ColType.INT) + @Comment("年度") + private Integer year; + + @Column + @ColDefine(type = ColType.DATETIME) + @Comment("活动报名开始时间") + private Date activitySignUpStartTime; + + @Column + @ColDefine(type = ColType.DATETIME) + @Comment("活动报名开始时间") + private Date activitySignUpEndTime; + + @Column + @ColDefine(type = ColType.DATETIME) + @Comment("活动开始时间") + private Date activityStartTime; + + @Column + @ColDefine(type = ColType.DATETIME) + @Comment("活动结束时间") + private Date activityEndTime; + + @Column + @ColDefine(type = ColType.BOOLEAN) + @Comment("是否禁用") + private boolean isDisabled; + + @Column + @ColDefine(customType = "longtext") + @Comment("活动介绍") + private String introduce; + + @Column + @ColDefine(type = ColType.INT, width = 10) + @Comment("活动限制标识") + private Integer restrictLimit; + + @Column + @ColDefine(type = ColType.INT, width = 10) + @Comment("活动限制报名个数") + private Integer limitNum; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 100) + @Comment("活动封面") + private String cover; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 100) + @Comment("微信群二维码") + private String wechat; + + @Column + @ColDefine(type = ColType.BOOLEAN) + @Comment("上课前是否通知") + private boolean notice; + + @Column + @Comment("活动范围Id") + @ColDefine(type = ColType.INT, width = 32) + private Integer activityGroupId; + + @Column + @Comment("活动范围名称") + @ColDefine(type = ColType.VARCHAR, width = 40) + private String activityGroupName; + + /** + * 所有的培训班 + */ + @Many(field = "activityId") + private List courseList; + + @Many(field = "activityId") + private List typeLimits; + + @Column + @Comment("活动类型") + @ColDefine(type = ColType.VARCHAR, width = 20) + private String trainType; + + @Column + @Comment("主办单位") + @ColDefine(type = ColType.MYSQL_JSON) + private List hostUnits; + + @Column + @Comment("协办单位") + @ColDefine(type = ColType.MYSQL_JSON) + private List helpUnits; + + @Override + public Sys_home_activity covertToSysHomeActivity() { + Sys_home_activity sysHomeActivity = new Sys_home_activity(); + sysHomeActivity.setId(this.getId()); + sysHomeActivity.setName(this.getActivityName()); + sysHomeActivity.setCover(this.getCover()); + sysHomeActivity.setUrl("/platform/smartbenefits/apply?id=" + this.getId()); + sysHomeActivity.setH5Url("/platform/smartbenefits/apply/h5?id=" + this.getId()); + if (Lang.isNotEmpty(this.getActivitySignUpStartTime())) { + sysHomeActivity.setStartDate(this.getActivitySignUpStartTime()); + sysHomeActivity.setEndDate(this.getActivitySignUpEndTime()); + } + sysHomeActivity.setAllowUserGroupId(this.getActivityGroupId()); + sysHomeActivity.setEnable(!this.isDisabled()); + sysHomeActivity.setClassPath(this.getClass().getPackageName() + this.getClass().getName()); + return sysHomeActivity; + } +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsActivityCourse.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsActivityCourse.java new file mode 100644 index 00000000..e090672b --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsActivityCourse.java @@ -0,0 +1,54 @@ +package com.budwk.app.zhgh.activity.smartbenefits.models; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.nutz.dao.entity.annotation.*; +import org.nutz.dao.interceptor.annotation.PrevInsert; + +import java.util.Date; + +@Data +@Accessors(chain = true) +@Comment("品牌活动下的子活动(智享惠生活)") +@Table +@EqualsAndHashCode(callSuper = false) +public class SmartBenefitsActivityCourse { + + @Name + @PrevInsert(uu32 = true) + private String id; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 32) + @Comment("活动ID") + private String activityId; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 32) + @Comment("课程ID") + private String courseId; + + @Column + @ColDefine(type = ColType.DATETIME) + @Comment("课程开始时间") + private Date courseStartTime; + + @Column + @ColDefine(type = ColType.DATETIME) + @Comment("课程结束时间") + private Date courseEndTime; + + @Column + @ColDefine(type = ColType.DATE) + @Comment("课程时间") + private Date courseDate; + + @Column + @ColDefine(type = ColType.INT, width = 4) + @Comment("限制人数") + private Integer courseLimitNum; + + private Integer hasRegisterNum; + +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsBlackList.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsBlackList.java new file mode 100644 index 00000000..3875f35e --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsBlackList.java @@ -0,0 +1,31 @@ +package com.budwk.app.zhgh.activity.smartbenefits.models; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.nutz.dao.entity.annotation.*; +import org.nutz.dao.interceptor.annotation.PrevInsert; + +@Data +@Accessors(chain = true) +@Comment("品牌活动黑名单(智享惠生活)") +@Table +@EqualsAndHashCode(callSuper = false) +public class SmartBenefitsBlackList { + + @Name + @ColDefine(type = ColType.VARCHAR, width = 32) + @PrevInsert(uu32 = true) + private String id; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 32) + @Comment("用户id") + private String userId; + + @Column + @ColDefine(type = ColType.BOOLEAN) + @Comment("是否禁用") + private Boolean isDisabled; + +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsCourse.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsCourse.java new file mode 100644 index 00000000..e9a89960 --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsCourse.java @@ -0,0 +1,178 @@ +package com.budwk.app.zhgh.activity.smartbenefits.models; + +import com.budwk.app.base.model.BaseModel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.nutz.dao.entity.annotation.*; +import org.nutz.dao.interceptor.annotation.PrevInsert; +import org.nutz.lang.util.NutMap; + +import java.io.Serializable; +import java.util.List; + +@Data +@Accessors(chain = true) +@Comment("品牌活动的子活动(智享惠生活)") +@Table +@EqualsAndHashCode(callSuper = false) +public class SmartBenefitsCourse extends BaseModel implements Serializable { + + @Name + @PrevInsert(uu32 = true) + private String id; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 50) + @Comment("活动ID") + private String activityId; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 50) + @Comment("课程名称") + private String courseName; + + @Column + @ColDefine(type = ColType.INT) + @Comment("课程人数") + private int coursePeopleNumber; + + @Column + @ColDefine(type = ColType.INT) + @Default(value = "0") + @Comment("预留名额") + private int courseReservedNumber; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 50) + @Comment("课程地点") + private String courseLocation; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 32) + @Comment("课程类型") + private String courseType; + + @Column + @ColDefine(type = ColType.MYSQL_JSON) + @Comment("课程地点坐标") + private List courseLocationCoordinates; + + @Column + @ColDefine(type = ColType.MYSQL_JSON) + @Comment("转换课程地点坐标") + private List transPosition; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 20) + @Comment("课程讲师") + private String courseInstructor; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 32) + @Comment("校区") + private String campus; + + @Column + @ColDefine(type = ColType.BOOLEAN) + @Comment("报名人数是否限制") + private Boolean courseIsLimitApply; + + @Column + @ColDefine(type = ColType.INT) + @Comment("序号") + private int orderNum; + + @Column + @ColDefine(customType = "longtext") + @Comment("详细信息") + private String introduce; + + @Many(field = "courseId") + private List courseTimeList; + + //已报人数 + private Integer hasRegisterNum; + + private Boolean isBringFamily; + + private Boolean isAddFamily; + + //是否报过该课程 + private Boolean isSign; + + //还能报该类型的课程吗 + private Boolean canSignThisCourseType; + + @Column + @Comment("分工会人数限制") + @ColDefine(type = ColType.MYSQL_JSON) + private List unionLimit; + + @Column + @ColDefine(type = ColType.BOOLEAN) + @Comment("移动端是否签到") + private boolean isMobileSign; + + @Column + @ColDefine(type = ColType.INT) + @Comment("签到方式 1.扫描二维码签到 2.被扫 3.gps签到") + private Integer signType; + + @Column + @ColDefine(type = ColType.INT) + @Comment("签到时间误差") + private Integer signUnit; + + @Column + @ColDefine(type = ColType.INT) + @Comment("签到半径") + private Integer radius; + + @Column + @ColDefine(type = ColType.BOOLEAN) + @Comment("移动端是否签收礼品") + private boolean isReceiveGift; + + @Column + @ColDefine(type = ColType.INT) + @Comment("领取礼品方式 1.扫描二维码 2.线下") + private Integer giftType; + + @Column + @ColDefine(type = ColType.INT) + @Comment("预留名额方式 1.报名人员减少模式 2.报名人数不变模式") + private Integer reserveMode; + + @Column + @Comment("承办工会") + @ColDefine(type = ColType.VARCHAR, width = 32) + private String hostUnionId; + + @Column + @Comment("对内报名时间") + @ColDefine(type = ColType.VARCHAR, width = 32) + private String interTime; + + @Column + @Comment("是否开放给其他工会") + @ColDefine(type = ColType.BOOLEAN, width = 4) + private Boolean openOtherUnion; + + @Column + @Comment("分类标识") + @ColDefine(type = ColType.VARCHAR, width = 30) + private String assort; + + @Column + @ColDefine(type = ColType.INT) + @Default(value = "0") + @Comment("候补名额数") + private Integer waitingNum; + + //候补已报人数 + private Integer hasWaitingNum; + + private String courseTimeName; + +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsMobileSignColumn.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsMobileSignColumn.java new file mode 100644 index 00000000..af24a765 --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsMobileSignColumn.java @@ -0,0 +1,84 @@ +package com.budwk.app.zhgh.activity.smartbenefits.models; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.nutz.dao.entity.annotation.*; +import org.nutz.dao.interceptor.annotation.PrevInsert; + +import java.util.List; + +@Data +@Accessors(chain = true) +@Comment("品牌活动移动端动态表单(智享惠生活)") +@Table("smart_benefits_mobile_sign_column") +@EqualsAndHashCode(callSuper = false) +public class SmartBenefitsMobileSignColumn { + + private static final long serialVersionUID = 1L; + + @Name + @Comment("id") + @ColDefine(type = ColType.VARCHAR, width = 32) + @PrevInsert(uu32 = true) + private String id; + + /** + * smart_benefits_type id + */ + @Column + @Comment("类型id") + @ColDefine(type = ColType.VARCHAR, width = 32) + private String typeId; + + @Column + @Comment("字段名称") + @ColDefine(type = ColType.VARCHAR, width = 50) + private String columnName; + + @Column + @Comment("字段编码") + @ColDefine(type = ColType.VARCHAR, width = 50) + private String columnCode; + + @Column + @Comment("字段值") + @ColDefine(type = ColType.VARCHAR, width = 50) + private String columnValue; + + @Column + @Comment("字段类型") + @ColDefine(type = ColType.VARCHAR, width = 50) + private String columnType; + + @Column + @Comment("下拉框的值") + @ColDefine(type = ColType.MYSQL_JSON) + private List selectValues; + + @Column + @Comment("是否必填") + @ColDefine(type = ColType.BOOLEAN) + private Boolean isRequired; + + @Column + @Comment("控件类型") + @ColDefine(type = ColType.VARCHAR, width = 50) + private String columnFormType; + + @Column + @Comment("文件个数") + @ColDefine(type = ColType.INT) + private Integer fileNumber; + + @Column + @Comment("文件类型") + @ColDefine(type = ColType.MYSQL_JSON) + private List fileType; + + @Column + @Comment("序号") + @ColDefine(type = ColType.INT, width = 1) + private Integer columnIndex; + +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsType.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsType.java new file mode 100644 index 00000000..af925740 --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsType.java @@ -0,0 +1,65 @@ +package com.budwk.app.zhgh.activity.smartbenefits.models; + +import com.budwk.app.base.model.BaseModel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.nutz.dao.entity.annotation.*; +import org.nutz.dao.interceptor.annotation.PrevInsert; + +import java.io.Serial; +import java.io.Serializable; +import java.util.List; + +@Data +@Accessors(chain = true) +@Comment("品牌活动的子活动类型(智享惠生活)") +@Table("smart_benefits_type") +@EqualsAndHashCode(callSuper = false) +public class SmartBenefitsType extends BaseModel implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @Name + @Comment("id") + @ColDefine(type = ColType.VARCHAR, width = 32) + @PrevInsert(uu32 = true) + private String id; + + @Column + @Comment("类型编码") + @ColDefine(type = ColType.VARCHAR, width = 80) + private String code; + + @Column + @Comment("类型名称") + @ColDefine(type = ColType.VARCHAR, width = 80) + private String typeName; + + @Column + @Comment("序号") + @ColDefine(type = ColType.INT, width = 1) + private Integer xh; + + @Column + @Comment("是否携带家属") + @ColDefine(type = ColType.BOOLEAN) + @Default("0") + private Boolean isBringFamily; + + @Column + @Comment("家属纳入总人数") + @ColDefine(type = ColType.BOOLEAN) + @Default("0") + private Boolean isAddFamily; + + @Column + @Comment("本人纳入总人数") + @ColDefine(type = ColType.BOOLEAN) + @Default("1") + private Boolean selfAddFamily; + + @Many(field = "typeId") + private List smartBenefitsMobileSignColumnList; +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsTypeLimit.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsTypeLimit.java new file mode 100644 index 00000000..0aea9c36 --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsTypeLimit.java @@ -0,0 +1,40 @@ +package com.budwk.app.zhgh.activity.smartbenefits.models; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.nutz.dao.entity.annotation.*; +import org.nutz.dao.interceptor.annotation.PrevInsert; + +import java.io.Serializable; + +@Data +@Accessors(chain = true) +@Comment("品牌活动类型限制条件(智享惠生活)") +@Table("smart_benefits_type_limit") +@EqualsAndHashCode(callSuper = false) +public class SmartBenefitsTypeLimit implements Serializable { + + private static final long serialVersionUID = 1L; + + @Name + @Comment("id") + @ColDefine(type = ColType.VARCHAR, width = 32) + @PrevInsert(uu32 = true) + private String id; + + @Column + @Comment("活动id") + @ColDefine(type = ColType.VARCHAR, width = 32) + private String activityId; + + @Column + @Comment("活动类型id") + @ColDefine(type = ColType.VARCHAR, width = 32) + private String typeId; + + @Column + @Comment("限制个数") + @ColDefine(type = ColType.INT, width = 10) + private int limitNum; +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsUser.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsUser.java new file mode 100644 index 00000000..e4facbfa --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsUser.java @@ -0,0 +1,91 @@ +package com.budwk.app.zhgh.activity.smartbenefits.models; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.nutz.dao.entity.annotation.*; +import org.nutz.dao.interceptor.annotation.PrevInsert; +import org.nutz.lang.util.NutMap; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +@Data +@Accessors(chain = true) +@Comment("品牌活动报名人员(智享惠生活)") +@Table +@EqualsAndHashCode(callSuper = false) +@TableIndexes({@Index(name = "INDEX_SMART_BENEFITS_USER_COURSEID", fields = {"courseId"}, unique = false)}) +public class SmartBenefitsUser implements Serializable { + + @Name + @PrevInsert(uu32 = true) + private String id; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 32) + @Comment("活动ID") + private String activityId; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 32) + @Comment("课程ID") + private String courseId; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 32) + @Comment("用户ID") + private String userId; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 32) + @Comment("工会ID") + private String unionId; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 32) + @Comment("单位ID") + private String unitId; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 100) + @Comment("工会") + private String unionName; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 100) + @Comment("单位") + private String unitName; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 32) + @Comment("联系方式") + private String mobile; + + @Column + @ColDefine(type = ColType.DATETIME) + @Comment("报名时间") + private Date signUpTime; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 32) + @Comment("活动课程时段id") + private String activityCourseId; + + @Column + @ColDefine(type = ColType.MYSQL_JSON) + @Comment("手机端报名字段和值") + private List mobileColumnsValue; + + @Column + @ColDefine(type = ColType.INT) + @Comment("用户报名状态(1.正常 2.待报名成功 3.也是正常,但是是从2变为1的 4.废弃[就是没签到的意思])") + private Integer state; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 32) + @Comment("操作人(代人报表)") + private String operatorUserId; + +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsUserCourse.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsUserCourse.java new file mode 100644 index 00000000..6085e07f --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/models/SmartBenefitsUserCourse.java @@ -0,0 +1,87 @@ +package com.budwk.app.zhgh.activity.smartbenefits.models; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.nutz.dao.entity.annotation.*; +import org.nutz.dao.interceptor.annotation.PrevInsert; + +import java.io.Serializable; +import java.util.Date; + +@Data +@Accessors(chain = true) +@Comment("品牌活动报名人员子活动表(智享惠生活)") +@Table +@EqualsAndHashCode(callSuper = false) +@TableIndexes({ + @Index(name = "INDEX_SMART_BENEFITS_USER_COURSE_USERID", fields = {"userId"}, unique = false), + @Index(name = "INDEX_SMART_BENEFITS_USER_COURSE_COURSEID", fields = {"courseId"}, unique = false) +}) +public class SmartBenefitsUserCourse implements Serializable { + + @Name + @PrevInsert(uu32 = true) + private String id; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 32) + @Comment("活动ID") + private String activityId; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 32) + @Comment("课程ID") + private String courseId; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 32) + @Comment("用户ID") + private String userId; + + @Column + @ColDefine(type = ColType.DATETIME) + @Comment("课程开始时间") + private Date courseStartTime; + + @Column + @ColDefine(type = ColType.DATETIME) + @Comment("课程结束时间") + private Date courseEndTime; + + @Column + @ColDefine(type = ColType.BOOLEAN) + @Comment("是否上课") + private boolean isAttend; + + @Column + @ColDefine(type = ColType.DATETIME) + @Comment("上课打卡时间") + private Date attendTime; + + @Column + @ColDefine(type = ColType.BOOLEAN) + @Comment("是否领取礼品") + private Boolean isReceive; + + @Column + @ColDefine(type = ColType.DATETIME) + @Comment("领取礼品时间") + private Date receiveTime; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 32) + @Comment("签到扫码人员id(二维码模式)") + private String signScannerCodeUserId; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 32) + @Comment("礼品扫码人员id(二维码模式)") + private String giftScannerCodeUserId; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 32) + @Comment("关联smart_benefits_activity_course表的id") + private String activityCourseId; + +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/SmartBenefitsActivityService.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/SmartBenefitsActivityService.java new file mode 100644 index 00000000..bed73cb6 --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/SmartBenefitsActivityService.java @@ -0,0 +1,135 @@ +package com.budwk.app.zhgh.activity.smartbenefits.service; + +import com.budwk.app.base.page.Pagination; +import com.budwk.app.base.param.PageForm; +import com.budwk.app.base.service.BaseService; +import com.budwk.app.zhgh.activity.smartbenefits.models.SmartBenefitsActivity; +import com.budwk.app.zhgh.activity.smartbenefits.models.SmartBenefitsCourse; +import com.budwk.app.zhgh.activity.smartbenefits.models.SmartBenefitsUser; +import org.nutz.dao.Cnd; +import org.nutz.lang.util.NutMap; + +import java.util.List; + +/** + * @author zxy + * @Description TODO + * @createTime 2022年02月23日 17:14:00 + */ +public interface SmartBenefitsActivityService extends BaseService { + + /** + * 添加活动 + * + * @param activity 活动信息 + * @param course 培训班信息 + */ + void add(SmartBenefitsActivity activity, SmartBenefitsCourse course); + + /** + * 编辑活动 + * + * @param activity 活动信息 + */ + void edit(SmartBenefitsActivity activity); + + /** + * 更新活动状态 + * + * @param activity 活动信息 + */ + void updateActivityStatus(SmartBenefitsActivity activity); + + /** + * 查询单条活动信息 + * + * @param id 活动ID + * @return 返回的数据与前端符合 + */ + NutMap findOne(String id, Cnd cnd, String fromMode); + + /** + * pc分页查询 + * + * @param pageForm + * @param cnd + * @return + */ + Pagination pageData(PageForm pageForm, Cnd cnd); + + + /** + * 手机端分页查询 + * + * @param pageForm 分页 + * @param year 年度 + * @param activityStatus 报名状态 0全部 1进行中 2结束 + * @return + */ + Pagination mPageData(PageForm pageForm, Integer year, int activityStatus, Integer activityType); + + /** + * 手机端报名 + * + * @param smartBenefitsUser 活动ID + */ + void doSignUp(SmartBenefitsUser smartBenefitsUser) throws Exception; + + /** + * 异步插入每个报名成功人员的课程数据 + * + * @param activityId + * @param courseId + * @param userId + */ + void asyncInsertUserCourse(String activityId, String courseId, String userId); + + /** + * 该培训班每个分工会名额是否报满 + * @return + */ + boolean isSignFullByUnionId(SmartBenefitsCourse course, Integer currentFamilyNumber); + + /** + * 该培训班是否报满 + */ + boolean isSignFull(SmartBenefitsCourse course, Integer currentFamilyNumber); + + /** + * 还能报该类型的培训班吗 比如书画班最多报一项 健身班两项 + * @return + */ + boolean isSignCourse(SmartBenefitsCourse course, SmartBenefitsActivity activity); + + /** + * 当前用户是否已报过该培训班 + * + * @param courseId + * @param userId + * @return + */ + boolean isSignCourseByUser(String courseId, String userId); + + /** + * 手机端签到 + * + * @param id 每个培训班每节课每个用户的记录ID + */ + void doQd(String id); + + /** + * 某个用户的签到信息 + * + * @param userId 用户id + * @param activityId 活动id + */ + List qdInfoByUserId(String userId, String activityId); + + List filterCourseByHostUnion(List courseList); + + /** + * 活动代人报名 + * @param smartBenefitsUser + */ + void doSignUpInsteadApply(SmartBenefitsUser smartBenefitsUser); +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/SmartBenefitsActivityStatisticsService.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/SmartBenefitsActivityStatisticsService.java new file mode 100644 index 00000000..5fd13991 --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/SmartBenefitsActivityStatisticsService.java @@ -0,0 +1,67 @@ +package com.budwk.app.zhgh.activity.smartbenefits.service; + +import com.budwk.app.base.page.Pagination; +import com.budwk.app.base.param.PageForm; +import com.budwk.app.base.service.BaseService; +import com.budwk.app.zhgh.activity.smartbenefits.models.SmartBenefitsUser; +import org.nutz.lang.util.NutMap; + +import java.util.List; + +/** + * @author zxy + * @Description 报名统计service + * @createTime 2022年03月03日 10:00:00 + */ +public interface SmartBenefitsActivityStatisticsService extends BaseService { + + /** + * 统计分页 + * + * @param pageForm + * @param activityId + * @return + */ + Pagination pageData(PageForm pageForm, String activityId); + + /** + * 该课程下的报名人员信息 + * + * @param courseId + * @return + */ + List registerUserList(String courseId); + + List getTaleColumnInfo(String courseId); + + /** + * 该课程下的报名人员信息 + * + * @param courseId + * @return + */ + List registerUserList(String courseId, String unionId, String unitId, String searchName, String searchKeyword); + + /** + * 获取每个课程的签到情况 + * + * @param courseId + * @return k->每个培训班每节课的上课时间 v->上课记录list + */ + Pagination getSignInfo(PageForm pageForm, String courseId, String timeId); + + /** + * 报名人员list 导出 + * @param activityId + * @return + */ + List baoMingUserList(String activityId); + + int queryCourseCount(String courseId, String courseType); + + int queryCourseWaitCount(String courseId, String courseType); + + int queryCourseCount(String courseId, String courseType, String unionId); + + int queryCourseWaitCount(String courseId, String courseType, String unionId); +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/SmartBenefitsBlackListService.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/SmartBenefitsBlackListService.java new file mode 100644 index 00000000..fb5b6db9 --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/SmartBenefitsBlackListService.java @@ -0,0 +1,43 @@ +package com.budwk.app.zhgh.activity.smartbenefits.service; + +import com.budwk.app.base.page.Pagination; +import com.budwk.app.base.param.PageForm; +import com.budwk.app.base.service.BaseService; +import com.budwk.app.zhgh.activity.smartbenefits.models.SmartBenefitsBlackList; +import org.nutz.dao.Cnd; +import org.nutz.lang.util.NutMap; + +import java.util.List; + +/** + * @author zxy + * @Description TODO + * @createTime 2022年03月07日 14:29:00 + */ +public interface SmartBenefitsBlackListService extends BaseService { + + /** + * 分页 + * + * @param pageForm 分页 + * @return Pagination + */ + Pagination pageData(PageForm pageForm, Cnd cnd, String activityId, String courseId); + + /** + * 拉黑、解封用户 + * + * @param userId + */ + void doHandleUser(String userId); + + /** + * 上课记录 + * + * @param userId + * @return + */ + List attendClassRecord(String userId); + + +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/impl/SmartBenefitsActivityServiceImpl.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/impl/SmartBenefitsActivityServiceImpl.java new file mode 100644 index 00000000..776145bd --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/impl/SmartBenefitsActivityServiceImpl.java @@ -0,0 +1,583 @@ +package com.budwk.app.zhgh.activity.smartbenefits.service.impl; + +import cn.hutool.core.util.StrUtil; +import com.budwk.app.base.page.Pagination; +import com.budwk.app.base.param.PageForm; +import com.budwk.app.base.service.impl.BaseServiceImpl; +import com.budwk.app.sys.models.Sys_home_activity; +import com.budwk.app.sys.views.View_user; +import com.budwk.app.web.commons.auth.utils.SecurityUtil; +import com.budwk.app.zhgh.activity.smartbenefits.models.*; +import com.budwk.app.zhgh.activity.smartbenefits.service.SmartBenefitsActivityService; +import com.budwk.app.zhgh.activity.smartbenefits.service.SmartBenefitsActivityStatisticsService; +import com.google.common.collect.Sets; +import lombok.extern.slf4j.Slf4j; +import org.nutz.aop.interceptor.async.Async; +import org.nutz.aop.interceptor.ioc.TransAop; +import org.nutz.dao.Chain; +import org.nutz.dao.Cnd; +import org.nutz.dao.Dao; +import org.nutz.dao.Sqls; +import org.nutz.dao.sql.Sql; +import org.nutz.dao.util.cri.Static; +import org.nutz.ioc.aop.Aop; +import org.nutz.ioc.loader.annotation.Inject; +import org.nutz.ioc.loader.annotation.IocBean; +import org.nutz.lang.Lang; +import org.nutz.lang.util.NutMap; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author zxy + * @Description TODO + * @createTime 2022年02月23日 17:14:00 + */ +@Slf4j +@IocBean(args = {"refer:dao"}) +public class SmartBenefitsActivityServiceImpl extends BaseServiceImpl implements SmartBenefitsActivityService { + + @Inject + private SmartBenefitsActivityStatisticsService statisticsService; + + public SmartBenefitsActivityServiceImpl(Dao dao) { + super(dao); + } + + @Override + @Aop(TransAop.READ_COMMITTED) + public void add(SmartBenefitsActivity activity, SmartBenefitsCourse course) { + + dao().insert(activity); + + //插入类型限制 + List typeLimits = activity.getTypeLimits(); + typeLimits.forEach(v -> v.setActivityId(activity.getId())); + dao().insert(typeLimits); + + List courseList = activity.getCourseList(); + for (SmartBenefitsCourse v : courseList) { + v.setActivityId(activity.getId()); + v.setOpenOtherUnion(false); + dao().insert(v); + this.setCourseTimeAndInsert(v); + } + + if (!activity.isDisabled()) { + Sys_home_activity sysHomeActivity = activity.covertToSysHomeActivity(); + dao().insertOrUpdate(sysHomeActivity); + } + } + + @Override + @Aop(TransAop.READ_COMMITTED) + public void edit(SmartBenefitsActivity activity) { + // 1. 更新主活动 + update(activity); + // 2. 处理类型限制 + List typeLimits = activity.getTypeLimits(); + if (Lang.isNotEmpty(typeLimits)) { + typeLimits.forEach(limit -> limit.setActivityId(activity.getId())); + insertOrUpdate(typeLimits); + } + // 3. 处理课程列表 + List courseList = activity.getCourseList(); + if (Lang.isEmpty(courseList)) { + return; + } + + Set newIds = courseList.stream() + .map(SmartBenefitsCourse::getId) + .filter(StrUtil::isNotBlank) + .collect(Collectors.toSet()); + + List oldCourses = dao().query(SmartBenefitsCourse.class, Cnd.where("activityId", "=", activity.getId())); + + Set oldIds = oldCourses.stream() + .map(SmartBenefitsCourse::getId) + .filter(StrUtil::isNotBlank) + .collect(Collectors.toSet()); + + Set deletedIds = Sets.difference(oldIds, newIds).immutableCopy(); + if(Lang.isNotEmpty(deletedIds)) { + dao().clear(SmartBenefitsCourse.class, Cnd.where("id", "in", deletedIds)); + } + + for (SmartBenefitsCourse course : courseList) { + course.setActivityId(activity.getId()); + dao().insertOrUpdate(course); + + if (Lang.isNotEmpty(course.getCourseTimeList())) { + handleCourseTimes(activity, course); + } + } + // 4. 同步首页活动 + if (!activity.isDisabled()) { + Sys_home_activity sysHomeActivity = activity.covertToSysHomeActivity(); + dao().insertOrUpdate(sysHomeActivity); + } else { + dao().delete(Sys_home_activity.class, activity.getId()); + } + } + + private void handleCourseTimes(SmartBenefitsActivity activity, SmartBenefitsCourse course) { + String courseId = course.getId(); + String activityId = activity.getId(); + + // 1. 获取新旧时间 ID 集合 + Set newTimeIds = course.getCourseTimeList().stream() + .map(SmartBenefitsActivityCourse::getId) + .filter(StrUtil::isNotBlank) + .collect(Collectors.toSet()); + + List oldAcList = dao().query(SmartBenefitsActivityCourse.class, + Cnd.where("courseId", "=", courseId)); + Set oldTimeIds = oldAcList.stream() + .map(SmartBenefitsActivityCourse::getId) + .filter(StrUtil::isNotBlank) + .collect(Collectors.toSet()); + + // 2. 删除已移除的时间段及其关联用户课程 + Set deletedTimeIds = Sets.difference(oldTimeIds, newTimeIds).immutableCopy(); + if (!deletedTimeIds.isEmpty()) { + dao().clear(SmartBenefitsActivityCourse.class, Cnd.where("id", "in", deletedTimeIds)); + dao().clear(SmartBenefitsUserCourse.class, Cnd.where("activityCourseId", "in", deletedTimeIds)); + } + + // 3. 插入/更新课程时间段(假设 setCourseTimeAndInsert 是插入新时间段) + setCourseTimeAndInsert(course); + + // 4. 批量处理用户课程关联 + // 查询当前课程下的所有用户 + List users = dao().query(SmartBenefitsUser.class, Cnd.where("courseId", "=", courseId)); + if (users.isEmpty()) { + return; + } + + // 查询已存在的用户课程记录(按 activityCourseId 分组) + List existingUserCourses = dao().query(SmartBenefitsUserCourse.class, + Cnd.where("courseId", "=", courseId)); + Set existingActivityCourseIds = existingUserCourses.stream() + .map(SmartBenefitsUserCourse::getActivityCourseId) + .collect(Collectors.toSet()); + + List toUpdate = new ArrayList<>(); + List toInsert = new ArrayList<>(); + + for (SmartBenefitsActivityCourse timeSlot : course.getCourseTimeList()) { + String timeId = timeSlot.getId(); + if (StrUtil.isBlank(timeId)) continue; + + if (existingActivityCourseIds.contains(timeId)) { + // 更新时间 + toUpdate.add(buildUserCourseForUpdate(timeId, timeSlot.getCourseStartTime(), timeSlot.getCourseEndTime())); + } else { + // 为每个用户新增记录 + for (SmartBenefitsUser user : users) { + toInsert.add(buildNewUserCourse(activityId, courseId, user.getUserId(), timeId, timeSlot)); + } + } + } + + // 批量更新(可根据 DAO 能力合并为 batchUpdate) + for (SmartBenefitsUserCourse item : toUpdate) { + dao().update(SmartBenefitsUserCourse.class, + Chain.make("courseStartTime", item.getCourseStartTime()) + .add("courseEndTime", item.getCourseEndTime()), + Cnd.where("activityCourseId", "=", item.getActivityCourseId())); + } + + // 批量插入 + if (!toInsert.isEmpty()) { + dao().insert(toInsert); + } + } + + private SmartBenefitsUserCourse buildUserCourseForUpdate(String activityCourseId, Date startTime, Date endTime) { + SmartBenefitsUserCourse u = new SmartBenefitsUserCourse(); + u.setActivityCourseId(activityCourseId); + u.setCourseStartTime(startTime); + u.setCourseEndTime(endTime); + return u; + } + + private SmartBenefitsUserCourse buildNewUserCourse(String activityId, String courseId, String userId, + String activityCourseId, SmartBenefitsActivityCourse timeSlot) { + SmartBenefitsUserCourse u = new SmartBenefitsUserCourse(); + u.setActivityId(activityId); + u.setCourseId(courseId); + u.setUserId(userId); + u.setActivityCourseId(activityCourseId); + u.setCourseStartTime(timeSlot.getCourseStartTime()); + u.setCourseEndTime(timeSlot.getCourseEndTime()); + u.setAttend(false); + u.setAttendTime(null); + return u; + } + + private void setCourseTimeAndInsert(SmartBenefitsCourse course) { + course.getCourseTimeList().forEach(courseTime -> { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(courseTime.getCourseDate()); + int year = calendar.get(Calendar.YEAR); + int month = calendar.get(Calendar.MONTH); + int day = calendar.get(Calendar.DATE); + + Calendar startCalendar = Calendar.getInstance(); + startCalendar.setTime(courseTime.getCourseStartTime()); + startCalendar.set(year, month, day); + courseTime.setCourseStartTime(startCalendar.getTime()); + + Calendar endCalendar = Calendar.getInstance(); + endCalendar.setTime(courseTime.getCourseEndTime()); + endCalendar.set(year, month, day); + courseTime.setCourseEndTime(endCalendar.getTime()); + + courseTime.setActivityId(course.getActivityId()); + courseTime.setCourseId(course.getId()); + dao().insertOrUpdate(courseTime); + }); + } + + @Override + @Aop(TransAop.READ_COMMITTED) + public void updateActivityStatus(SmartBenefitsActivity activity) { + updateIgnoreNull(activity); + } + + @Override + public NutMap findOne(String id, Cnd cnd, String fromMode) { + if (Lang.isEmpty(cnd)) { + cnd = Cnd.NEW(); + } + + cnd.asc("orderNum").asc("campus").desc("courseLocation").asc("courseType").asc("courseName"); + List courseArray = dao().query(SmartBenefitsCourse.class, cnd.and("activityId", "=", id)); + + if (StrUtil.isNotBlank(fromMode) && "mobile".equals(fromMode)) { + courseArray = this.filterCourseByHostUnion(courseArray); + } + + SmartBenefitsActivity activity = fetchLinks(dao().fetch(SmartBenefitsActivity.class, id), "^(conditionStructure|typeLimits)$"); + activity.setCourseList(courseArray); + + List courseList = activity.getCourseList(); + + courseList.forEach(c -> { + if (StrUtil.isNotBlank(c.getCourseType())) { + dao().fetchLinks(c, "^(courseTimeList)$", Cnd.NEW().asc("courseStartTime")); + int courseCount = statisticsService.queryCourseCount(c.getId(), c.getCourseType()); + c.setHasRegisterNum(courseCount); + int courseWaitCount = statisticsService.queryCourseWaitCount(c.getId(), c.getCourseType()); + c.setHasWaitingNum(courseWaitCount); + //当前用户是否报过 + c.setIsSign(isSignCourseByUser(c.getId(), SecurityUtil.getUserId())); + } + }); + return Lang.obj2nutmap(activity); + } + + @Override + public Pagination pageData(PageForm pageForm, Cnd cnd) { + Pagination pagination = listPageLinks(pageForm.getPageNumber(), pageForm.getPageSize(), cnd, "^(courseList)$"); + return pagination; + } + + @Override + public Pagination mPageData(PageForm pageForm, Integer year, int activityStatus, Integer activityType) { + Cnd cnd = Cnd.NEW(); + cnd.andEX("year", "=", year); + switch (activityStatus) { + case 2 -> { + cnd.and(new Static("activitySignUpStartTime < now()")); + cnd.and(new Static("activitySignUpEndTime > now()")); + } + case 3 -> { + cnd.and(new Static("activityStartTime < now()")); + cnd.and(new Static("activityEndTime > now()")); + } + case 4 -> cnd.and(new Static("activityEndTime < now()")); + case 5 -> cnd.and(new Static("activityStartTime < now()")); + case 6 -> cnd.and(new Static("activityStartTime > now()")); + } + if (activityType != null && activityType == 1) { + cnd.and(new Static("id in (select activityId from smart_benefits_user where userId = '%s')".formatted(SecurityUtil.getUserId()))); + } + cnd.and("isDisabled", "=", 0); + cnd.orderBy("activityEndTime", "desc"); + cnd.orderBy("isDisabled", "desc"); + cnd.orderBy("createdAt", "desc"); + return listPage(pageForm.getPageNumber(), pageForm.getPageSize(), cnd); + } + + @Override + @Aop(TransAop.READ_COMMITTED) + public void doSignUp(SmartBenefitsUser smartBenefitsUser) throws Exception { + String userId = SecurityUtil.getUserId(); + + //查询课程 + SmartBenefitsCourse course = dao().fetch(SmartBenefitsCourse.class, smartBenefitsUser.getCourseId()); + SmartBenefitsType type = dao().fetch(SmartBenefitsType.class, course.getCourseType()); + //如果这个课程的预留名额方式为报名人数不变 + if (course.getReserveMode() == 2) { + //如果当前报名+已报小于这个课程限制人数 + //课程已报人数 + int normalCount = statisticsService.queryCourseCount(course.getId(), course.getCourseType()); + //+1是算自己 + int hasRegisterNum = type.getSelfAddFamily() ? normalCount + 1 : 0; + smartBenefitsUser.setState((hasRegisterNum + course.getCourseReservedNumber()) > course.getCoursePeopleNumber() ? 2 : 1); + } else { + smartBenefitsUser.setState(1); + } + + View_user user = dao().fetch(View_user.class, Cnd.where("id", "=", SecurityUtil.getUserId())); + smartBenefitsUser.setUnionId(SecurityUtil.getUnionId()); + smartBenefitsUser.setUnionName(user.getUnionName()); + smartBenefitsUser.setUnitId(SecurityUtil.getUnitId()); + smartBenefitsUser.setUnitName(user.getUnitName()); + smartBenefitsUser.setUserId(userId); + smartBenefitsUser.setSignUpTime(new Date()); + + dao().insert(smartBenefitsUser); + + if (StrUtil.isNotBlank(smartBenefitsUser.getActivityCourseId())) { + SmartBenefitsActivityCourse fetch = dao().fetch(SmartBenefitsActivityCourse.class, smartBenefitsUser.getActivityCourseId()); + SmartBenefitsUserCourse userCourse = new SmartBenefitsUserCourse(); + userCourse.setActivityId(smartBenefitsUser.getActivityId()); + userCourse.setCourseId(smartBenefitsUser.getCourseId()); + userCourse.setUserId(smartBenefitsUser.getUserId()); + userCourse.setCourseStartTime(fetch.getCourseStartTime()); + userCourse.setCourseEndTime(fetch.getCourseEndTime()); + userCourse.setAttend(false); + userCourse.setAttendTime(null); + userCourse.setActivityCourseId(fetch.getId()); + dao().insert(userCourse); + } else { + asyncInsertUserCourse(smartBenefitsUser.getActivityId(), smartBenefitsUser.getCourseId(), smartBenefitsUser.getUserId()); + } + } + + @Async + @Override + public void asyncInsertUserCourse(String activityId, String courseId, String userId) { + log.info("异步插入{}的上课信息,课程ID为{},活动ID为{}", userId, courseId, activityId); + List courseList = dao().query(SmartBenefitsActivityCourse.class, Cnd.where("courseId", "=", courseId)); + List list = new ArrayList<>(); + courseList.forEach(v -> { + SmartBenefitsUserCourse userCourse = new SmartBenefitsUserCourse(); + userCourse.setActivityId(activityId); + userCourse.setCourseId(courseId); + userCourse.setUserId(userId); + userCourse.setCourseStartTime(v.getCourseStartTime()); + userCourse.setCourseEndTime(v.getCourseEndTime()); + userCourse.setAttend(false); + userCourse.setAttendTime(null); + userCourse.setActivityCourseId(v.getId()); + list.add(userCourse); + }); + dao().insert(list); + } + + /** + * 该培训班每个分工会名额是否报满 + * @return + */ + @Override + public boolean isSignFullByUnionId(SmartBenefitsCourse course, Integer currentFamilyNumber) { + List unionLimit = course.getUnionLimit(); + if (Lang.isEmpty(unionLimit)) { + return false; + } + String unionId = SecurityUtil.getUnionId(); + NutMap unionLimitMap = unionLimit.stream().filter(v -> v.getString("id").equals(unionId)).findAny().orElse(null); + if (Lang.isEmpty(unionLimitMap)) { + return true; + } + + SmartBenefitsType type = dao().fetch(SmartBenefitsType.class, course.getCourseType()); + //分工会限制人数 + int limitCount = unionLimitMap.getInt("limitCount"); + + //该课程已经报名的总人数 + int hasSignCount = statisticsService.queryCourseCount(course.getId(), course.getCourseType(), unionId); + int hasWaitCount = statisticsService.queryCourseWaitCount(course.getId(), course.getCourseType()); + + //+1是算自己 + int current = type.getSelfAddFamily() ? 1 : 0; + currentFamilyNumber = type.getIsBringFamily() && type.getIsAddFamily() ? currentFamilyNumber : 0; + //如果还有正常名额 + if(limitCount - hasSignCount > 0) { + return (hasSignCount + current + currentFamilyNumber) > limitCount; + } else { + return (hasWaitCount + current + currentFamilyNumber) > course.getWaitingNum(); + } + } + + @Override + public boolean isSignFull(SmartBenefitsCourse course, Integer currentFamilyNumber) { + //课程限制人数 + int coursePeopleNumber = course.getCoursePeopleNumber(); + if (coursePeopleNumber == 0) { + return true; + } + //查询课程对应的类型 + SmartBenefitsType type = dao().fetch(SmartBenefitsType.class, course.getCourseType()); + //课程已报人数 + int hasSignCount = statisticsService.queryCourseCount(course.getId(), course.getCourseType()); + int hasWaitCount = statisticsService.queryCourseWaitCount(course.getId(), course.getCourseType()); + + //+1是算自己 + int current = type.getSelfAddFamily() ? 1 : 0; + currentFamilyNumber = type.getIsBringFamily() && type.getIsAddFamily() ? currentFamilyNumber : 0; + //如果还有正常名额 + if(coursePeopleNumber - hasSignCount > 0) { + return (hasSignCount + current + currentFamilyNumber + course.getCourseReservedNumber()) > coursePeopleNumber; + } else { + return (hasWaitCount + current + currentFamilyNumber) > course.getWaitingNum(); + } + } + + @Override + public boolean isSignCourse(SmartBenefitsCourse course, SmartBenefitsActivity activity) { + //培训班类型 + String courseType = course.getCourseType(); + + Sql sql = Sqls.create(""" + SELECT + count( tsus.id ) + FROM + `smart_benefits_user` tsus + LEFT JOIN smart_benefits_course tsuc ON tsuc.id = tsus.courseId + WHERE + tsuc.courseType = @courseType + AND tsus.userId = @userId + AND tsus.activityId = @activityId + """); + sql.setParam("courseType", courseType); + sql.setParam("activityId", activity.getId()); + sql.setParam("userId", SecurityUtil.getUserId()); + int hasRegisterNum = count(sql); + + //第一种无限制报名 + if (activity.getRestrictLimit() == null || activity.getRestrictLimit() == 1) { + return true; + } else if (activity.getRestrictLimit() == 2) { + SmartBenefitsTypeLimit smartBenefitsTypeLimit = dao().fetch(SmartBenefitsTypeLimit.class, Cnd.where("typeId", "=", courseType).and("activityId", "=", activity.getId())); + if (smartBenefitsTypeLimit == null) { + return true; + } + //此类型的班最多可报几项 + int personMaxRegisterNum = smartBenefitsTypeLimit.getLimitNum(); + if (personMaxRegisterNum == 0) { + return true; + } + return hasRegisterNum < personMaxRegisterNum; + } else if (activity.getRestrictLimit() == 3) { + //第三种,限制报几个,不跟类型挂钩 + int aCount = dao().count(SmartBenefitsUser.class, Cnd.where("activityId", "=", activity.getId()).and("userId", "=", SecurityUtil.getUserId())); + return aCount < activity.getLimitNum(); + } + return false; + } + + @Override + public boolean isSignCourseByUser(String courseId, String userId) { + return dao().count(SmartBenefitsUser.class, Cnd.where("courseId", "=", courseId).and("userId", "=", userId)) > 0; + } + + @Override + public void doQd(String id) { + NutMap updateMap = NutMap.NEW(); + updateMap.put("isAttend", true); + updateMap.put("attendTime", new Date()); + dao().update(SmartBenefitsUserCourse.class, Chain.from(updateMap), Cnd.where("id", "=", id)); + } + + @Override + public List qdInfoByUserId(String userId, String activityId) { + Sql sql = Sqls.create(""" + SELECT + c.*, + t.courseLocationCoordinates, + t.isMobileSign, + t.signType, + t.isReceiveGift, + t.giftType, + (select state from smart_benefits_user su where su.activityId = c.activityId and su.courseId = c.courseId and su.userId = c.userId) as state + FROM + `smart_benefits_user_course` c + LEFT JOIN smart_benefits_course t ON t.id = c.courseId + $condition + """); + Cnd cnd = Cnd.NEW(); + cnd.and("c.activityId", "=", activityId); + cnd.and("c.userId", "=", userId); + cnd.asc("c.courseStartTime"); + + sql.setCondition(cnd); + return listMap(sql); + } + + @Override + public List filterCourseByHostUnion(List courseList) { + if (Lang.isEmpty(courseList)) { + return new ArrayList<>(); + } + return courseList.stream().filter(o -> { + if (StrUtil.isBlank(o.getInterTime()) || o.getOpenOtherUnion() == null || o.getOpenOtherUnion()) { + return true; + } else { + if (SecurityUtil.getUnionId().equals(o.getHostUnionId())) { + return true; + } else { + int compare = cn.hutool.core.date.DateUtil.compare(cn.hutool.core.date.DateUtil.date(), cn.hutool.core.date.DateUtil.parse(o.getInterTime()), "yyyy-MM-dd HH:mm"); + return compare >= 0; + } + } + }).toList(); + } + + public void doSignUpInsteadApply(SmartBenefitsUser smartBenefitsUser){ + //查询课程 + SmartBenefitsCourse course = dao().fetch(SmartBenefitsCourse.class, smartBenefitsUser.getCourseId()); + SmartBenefitsType type = dao().fetch(SmartBenefitsType.class, course.getCourseType()); + //如果这个课程的预留名额方式为报名人数不变 + if (course.getReserveMode() == 2) { + //如果当前报名+已报小于这个课程限制人数 + //课程已报人数 + int normalCount = statisticsService.queryCourseCount(course.getId(), course.getCourseType()); + //+1是算自己 + int hasRegisterNum = type.getSelfAddFamily() ? normalCount + 1 : 0; + smartBenefitsUser.setState((hasRegisterNum + course.getCourseReservedNumber()) > course.getCoursePeopleNumber() ? 2 : 1); + } else { + smartBenefitsUser.setState(1); + } + + View_user user = dao().fetch(View_user.class, Cnd.where("id", "=", smartBenefitsUser.getUserId())); + smartBenefitsUser.setUnionId(user.getUnionId()); + smartBenefitsUser.setUnionName(user.getUnionName()); + smartBenefitsUser.setUnitId(user.getUnitId()); + smartBenefitsUser.setUnitName(user.getUnitName()); + smartBenefitsUser.setUserId(smartBenefitsUser.getUserId()); + smartBenefitsUser.setSignUpTime(new Date()); + smartBenefitsUser.setOperatorUserId(SecurityUtil.getUserId()); + dao().insert(smartBenefitsUser); + + if (StrUtil.isNotBlank(smartBenefitsUser.getActivityCourseId())) { + SmartBenefitsActivityCourse fetch = dao().fetch(SmartBenefitsActivityCourse.class, smartBenefitsUser.getActivityCourseId()); + SmartBenefitsUserCourse userCourse = new SmartBenefitsUserCourse(); + userCourse.setActivityId(smartBenefitsUser.getActivityId()); + userCourse.setCourseId(smartBenefitsUser.getCourseId()); + userCourse.setUserId(smartBenefitsUser.getUserId()); + userCourse.setCourseStartTime(fetch.getCourseStartTime()); + userCourse.setCourseEndTime(fetch.getCourseEndTime()); + userCourse.setAttend(false); + userCourse.setAttendTime(null); + userCourse.setActivityCourseId(fetch.getId()); + dao().insert(userCourse); + } else { + asyncInsertUserCourse(smartBenefitsUser.getActivityId(), smartBenefitsUser.getCourseId(), smartBenefitsUser.getUserId()); + } + } +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/impl/SmartBenefitsActivityStatisticsServiceImpl.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/impl/SmartBenefitsActivityStatisticsServiceImpl.java new file mode 100644 index 00000000..c802e110 --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/impl/SmartBenefitsActivityStatisticsServiceImpl.java @@ -0,0 +1,253 @@ +package com.budwk.app.zhgh.activity.smartbenefits.service.impl; + +import cn.hutool.core.util.StrUtil; +import com.budwk.app.base.page.Pagination; +import com.budwk.app.base.param.PageForm; +import com.budwk.app.base.service.impl.BaseServiceImpl; +import com.budwk.app.zhgh.activity.smartbenefits.models.SmartBenefitsMobileSignColumn; +import com.budwk.app.zhgh.activity.smartbenefits.models.SmartBenefitsCourse; +import com.budwk.app.zhgh.activity.smartbenefits.models.SmartBenefitsType; +import com.budwk.app.zhgh.activity.smartbenefits.models.SmartBenefitsUser; +import com.budwk.app.zhgh.activity.smartbenefits.service.SmartBenefitsActivityStatisticsService; +import lombok.extern.slf4j.Slf4j; +import org.nutz.dao.Cnd; +import org.nutz.dao.Dao; +import org.nutz.dao.Sqls; +import org.nutz.dao.sql.Sql; +import org.nutz.dao.util.cri.SqlExpressionGroup; +import org.nutz.ioc.loader.annotation.IocBean; +import org.nutz.json.Json; +import org.nutz.lang.Lang; +import org.nutz.lang.util.NutMap; + +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; + +/** + * @author zxy + * @Description TODO + * @createTime 2022年03月03日 10:02:00 + */ +@IocBean(args = {"refer:dao"}) +@Slf4j +public class SmartBenefitsActivityStatisticsServiceImpl extends BaseServiceImpl implements SmartBenefitsActivityStatisticsService { + + public SmartBenefitsActivityStatisticsServiceImpl(Dao dao) { + super(dao); + } + + @Override + public Pagination pageData(PageForm pageForm, String activityId) { + Sql sql = Sqls.create(""" + SELECT + tsuc.id, + tsuc.courseName, + tsuc.coursePeopleNumber, + tsuc.courseReservedNumber, + type.typeName as courseType, + tsuc.courseType as courseTypeId, + tsuc.courseLocation, + tsuc.courseInstructor, + tsuc.reserveMode, + tsuc.isMobileSign, + tsuc.hostUnionId, + tsuc.interTime, + tsuc.waitingNum, + tsuc.openOtherUnion, + tsuc.courseType as cType + FROM + `smart_benefits_course` tsuc + LEFT JOIN + smart_benefits_type type on tsuc.courseType = type.id + WHERE + tsuc.activityId = @activityId + ORDER BY tsuc.orderNum + """); + sql.setParam("activityId", activityId); + Pagination pagination = listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql); + List courseList = pagination.getList(); + courseList.forEach(c -> { + c.put("registerNum", queryCourseCount(c.getString("id"), c.getString("cType"))); + c.put("hasWaitingNum", queryCourseWaitCount(c.getString("id"), c.getString("cType"))); + }); + return pagination; + } + + @Override + public List registerUserList(String courseId) { + Sql sql = Sqls.create(""" + SELECT + u.loginname, + u.username, + u.sex, + tsuu.unionId, + tsuu.unionName, + tsuu.unitId, + tsuu.unitName, + ifnull(tsuu.mobile, u.mobile) as mobile, + tsuu.signUpTime, + tsuu.state, + tsuu.mobileColumnsValue + FROM + smart_benefits_user tsuu + LEFT JOIN `vw_user` u ON u.id = tsuu.userId + $condition + ORDER BY FIELD( tsuu.state, 1, 3, 2, 4 ),tsuu.signUpTime desc,u.unionid desc, u.unitid desc + """); + Cnd cnd = Cnd.NEW(); + cnd.andEX("tsuu.courseId", "=", courseId); + sql.setCondition(cnd); + List list = listMap(sql); + for (NutMap o : list) { + if(StrUtil.isBlank(o.getString("mobileColumnsValue"))) { + continue; + } + List mobileColumnsValue = Json.fromJsonAsList(NutMap.class, o.getString("mobileColumnsValue")); + if(Lang.isNotEmpty(mobileColumnsValue)) { + mobileColumnsValue.forEach(m -> { + o.put(m.getString("columnCode"), m.getString("columnValue")); + }); + } + } + return list; + } + + @Override + public List getTaleColumnInfo(String courseId) { + SmartBenefitsCourse course = dao().fetch(SmartBenefitsCourse.class, courseId); + SmartBenefitsType upType = dao().fetch(SmartBenefitsType.class, course.getCourseType()); + dao().fetchLinks(upType, "smartBenefitsMobileSignColumnList", Cnd.NEW().asc("columnIndex")); + + List columnList = upType.getSmartBenefitsMobileSignColumnList(); + List columnTableList = columnList.stream().filter(o -> StrUtil.isNotBlank(o.getColumnCode())).map(o -> NutMap.NEW().setv("label", o.getColumnName()).setv("prop", o.getColumnCode())).collect(Collectors.toList()); + return columnTableList; + } + + @Override + public List registerUserList(String courseId, String unionId, String unitId, String searchName, String searchKeyword) { + Sql sql = Sqls.create(""" + SELECT + tsuu.id, + u.id as userId, + u.loginname, + u.username, + u.unitName, + u.unionName, + u.sex, + ifnull(tsuu.mobile, u.mobile) as mobile, + tsuu.signUpTime, + tsuu.state + FROM + smart_benefits_user tsuu + LEFT JOIN `vw_user` u ON u.id = tsuu.userId + $condition + ORDER BY FIELD( tsuu.state, 1, 3, 2, 4 ),tsuu.signUpTime desc,u.unionid desc, u.unitid desc + """); + Cnd cnd = Cnd.NEW(); + cnd.andEX("tsuu.courseId", "=", courseId); + cnd.andEX("u.unionid", "=", unionId); + cnd.andEX("u.unitid", "=", unitId); + if (StrUtil.isNotBlank(searchKeyword)) { + SqlExpressionGroup group = new SqlExpressionGroup(); + group.andLike("username", searchKeyword).orLike("loginname", searchKeyword); + cnd.and(group); + } + sql.setCondition(cnd); + return listMap(sql); + } + + @Override + public Pagination getSignInfo(PageForm pageForm, String courseId, String timeId) { + Sql sql = Sqls.create(""" + SELECT + tsuuc.id, + tsuuc.courseStartTime, + tsuuc.courseEndTime, + tsuuc.isAttend, + tsuuc.attendTime, + u.username, + u.loginname, + u.unitname, + u.unionname + FROM + `smart_benefits_user_course` tsuuc + LEFT JOIN `vw_user` u ON u.id = tsuuc.userId + $condition + """); + Cnd cnd = Cnd.NEW(); + cnd.and("tsuuc.courseId", "=", courseId); + cnd.and("tsuuc.activityCourseId", "=", timeId); + cnd.desc("isAttend"); + cnd.desc("attendTime"); + sql.setCondition(cnd); + return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql); + } + + @Override + public List baoMingUserList(String activityId) { + Sql sql = Sqls.create(""" + SELECT + u.loginname, + u.username, + u.unitname, + u.unionname, + u.sex, + u.mobile, + uc.courseName, + uc.campus + FROM + `smart_benefits_user` uu + RIGHT JOIN smart_benefits_course uc ON uc.id = uu.courseId + LEFT JOIN `vw_user` u ON u.id = uu.userId + WHERE + uc.activityId = @activityId + ORDER BY u.unitCode,u.unioncode,u.sex + """); + sql.setParam("activityId", activityId); + return listMap(sql); + } + + @Override + public int queryCourseCount(String courseId, String courseType) { + return this.queryCourseCount(courseId, courseType, null); + } + + @Override + public int queryCourseWaitCount(String courseId, String courseType) { + return this.queryCourseWaitCount(courseId, courseType, null); + } + + @Override + public int queryCourseCount(String courseId, String courseType, String unionId) { + return this.calcSignCount(courseId, courseType, unionId, List.of(1, 3)); + } + + @Override + public int queryCourseWaitCount(String courseId, String courseType, String unionId) { + return this.calcSignCount(courseId, courseType, unionId, List.of(2)); + } + + private int calcSignCount(String courseId, String courseType, String unionId, List stateList) { + if(StrUtil.isBlank(courseId) || StrUtil.isBlank(courseType)) { + return 0; + } + SmartBenefitsType type = dao().fetch(SmartBenefitsType.class, courseType); + AtomicInteger hasRegisterNum = new AtomicInteger(); + List signUpUsers = dao().query(SmartBenefitsUser.class, Cnd.where("courseId", "=", courseId) + .and("state", "in", stateList) + .andEX("unionId", "=", unionId)); + signUpUsers.forEach(item -> { + if (type.getSelfAddFamily()) { + hasRegisterNum.getAndIncrement(); + } + if(type.getIsBringFamily() && type.getIsAddFamily()) { + List 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; + hasRegisterNum.addAndGet(number); + } + }); + return hasRegisterNum.get(); + } +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/impl/SmartBenefitsUserServiceImpl.java b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/impl/SmartBenefitsUserServiceImpl.java new file mode 100644 index 00000000..28fbe7a0 --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/smartbenefits/service/impl/SmartBenefitsUserServiceImpl.java @@ -0,0 +1,111 @@ +package com.budwk.app.zhgh.activity.smartbenefits.service.impl; + +import cn.hutool.core.util.StrUtil; +import com.budwk.app.base.page.Pagination; +import com.budwk.app.base.param.PageForm; +import com.budwk.app.base.service.impl.BaseServiceImpl; +import com.budwk.app.base.utils.PageUtil; +import com.budwk.app.zhgh.activity.smartbenefits.models.SmartBenefitsBlackList; +import com.budwk.app.zhgh.activity.smartbenefits.service.SmartBenefitsBlackListService; +import org.nutz.dao.Cnd; +import org.nutz.dao.Dao; +import org.nutz.dao.Sqls; +import org.nutz.dao.sql.Criteria; +import org.nutz.dao.sql.Sql; +import org.nutz.ioc.loader.annotation.IocBean; +import org.nutz.lang.Lang; +import org.nutz.lang.util.NutMap; + +import java.util.List; + +/** + * @author zxy + * @Description TODO + * @createTime 2022年03月07日 14:29:00 + */ +@IocBean(args = {"refer:dao"}) +public class SmartBenefitsUserServiceImpl extends BaseServiceImpl implements SmartBenefitsBlackListService { + + public SmartBenefitsUserServiceImpl(Dao dao) { + super(dao); + } + + @Override + public Pagination pageData(PageForm pageForm, Cnd cnd, String activityId, String courseId) { + Sql sql = Sqls.create(""" + SELECT + u.id AS userId, + u.username, + u.loginname, + ifnull(tsuu.mobile, u.mobile) as mobile, + u.unitName, + u.unionName, + tsuc.courseName, + tsuu.state, + ( SELECT count( 1 ) FROM smart_benefits_user_course WHERE userId = tsuu.userId $var) courseTotal, + ( SELECT count( 1 ) FROM smart_benefits_user_course WHERE userId = tsuu.userId AND isAttend = 0 and tsuu.state!=2 AND now()> courseEndTime $var) AS absentCount, + ( SELECT count( 1 ) FROM smart_benefits_user_course WHERE userId = tsuu.userId AND isAttend = 1 and tsuu.state!=2 AND now()> courseEndTime $var) AS signCount, + ( SELECT count( 1 ) FROM smart_benefits_user_course WHERE userId = tsuu.userId and tsuu.state!=2 $var) AS totalCount, + if(tsubl.isDisabled=1,true,false) isDisabled, + group_CONCAT( tsuc.courseName ) AS courseNames + FROM + `smart_benefits_user` tsuu + LEFT JOIN `vw_user` u ON u.id = tsuu.userId + LEFT JOIN smart_benefits_activity act on act.id = tsuu.activityId + LEFT JOIN smart_benefits_course tsuc ON tsuc.id = tsuu.courseId + LEFT JOIN smart_benefits_black_list tsubl on tsubl.userId = tsuu.userId + $condition + """); + cnd.groupBy("tsuu.userId"); + Criteria varCnd = Cnd.cri(); + varCnd.where().setTop(false); + varCnd.where().andEX("activityId", "=", activityId); + varCnd.where().andEX("courseId", "=", courseId); + if (!varCnd.where().isEmpty()) { + sql.vars().set("var", "and " + varCnd.toSql(null)); + } + if (StrUtil.isAllBlank(pageForm.getPageOrderName(), pageForm.getPageOrderBy())) { + cnd.desc("tsuu.unitId"); + } else { + cnd.orderBy(pageForm.getPageOrderName(), PageUtil.getOrder(pageForm.getPageOrderBy())); + } + sql.setCondition(cnd); + return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql); + } + + + @Override + public void doHandleUser(String userId) { + SmartBenefitsBlackList blackRecord = dao().fetch(SmartBenefitsBlackList.class, Cnd.where("userId", "=", userId)); + if (Lang.isEmpty(blackRecord)) { + SmartBenefitsBlackList blackList = new SmartBenefitsBlackList(); + blackList.setUserId(userId); + blackList.setIsDisabled(true); + dao().insert(blackList); + } else { +// blackRecord.setIsDisabled(!blackRecord.getIsDisabled()); +// dao().update(blackRecord); + dao().delete(blackRecord); + } + + } + + @Override + public List attendClassRecord(String userId) { + Sql sql = Sqls.create(""" + SELECT + c.courseName, + uc.courseStartTime, + courseEndTime, + uc.isAttend, + uc.attendTime + FROM + `smart_benefits_user_course` uc + LEFT JOIN smart_benefits_course c ON c.id = uc.courseId + WHERE + uc.userId = @userId + """); + sql.setParam("userId", userId); + return listMap(sql); + } +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainSignUpAdjustController.java b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainSignUpAdjustController.java index 227ee92e..65e62da3 100644 --- a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainSignUpAdjustController.java +++ b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainSignUpAdjustController.java @@ -38,7 +38,7 @@ import java.util.List; @Slf4j @IocBean @Ok("json:full") -@Api(tags = "品牌活动人员调整") +@Api(tags = "品牌活动人员调整(香樟工会)") @At("/platform/trainSignUp/adjust") public class TrainSignUpAdjustController { diff --git a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainSignUpApplyController.java b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainSignUpApplyController.java index 2aaa3d90..9c1c38e3 100644 --- a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainSignUpApplyController.java +++ b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainSignUpApplyController.java @@ -45,7 +45,7 @@ import java.util.stream.Collectors; @Slf4j @IocBean @Ok("json:full") -@Api(tags = "活动报名") +@Api(tags = "活动报名(香樟工会)") @At("/platform/trainSignUp/apply") public class TrainSignUpApplyController { @@ -461,7 +461,7 @@ public class TrainSignUpApplyController { @At @ApiOperation("活动代人报名") - @SaCheckPermission(value = {"h5.trainSignUp.apply"}, mode = SaMode.OR) + @SaCheckPermission(value = {"trainSignUp.apply"}, mode = SaMode.OR) public Result doSignUpInsteadApply(TrainSignUpUser trainSignUpUser) { try { lock.lock(); diff --git a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainSignUpManageController.java b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainSignUpManageController.java index 6b61a079..343e43ff 100644 --- a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainSignUpManageController.java +++ b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainSignUpManageController.java @@ -43,7 +43,7 @@ import java.util.stream.Collectors; @Slf4j @IocBean @Ok("json:full") -@Api(tags = "活动管理") +@Api(tags = "活动管理(香樟工会)") @At("/platform/trainSignUp/manage") public class TrainSignUpManageController { diff --git a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainSignUpTypeController.java b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainSignUpTypeController.java index 3061d769..eedf80c1 100644 --- a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainSignUpTypeController.java +++ b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainSignUpTypeController.java @@ -41,7 +41,7 @@ import java.util.List; @Slf4j @IocBean @Ok("json:full") -@Api(tags = "活动类型管理") +@Api(tags = "活动类型管理(香樟工会)") @At("/platform/trainSignUp/type") public class TrainSignUpTypeController { diff --git a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainSignUpUserManageController.java b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainSignUpUserManageController.java index ec712120..e5dcd61d 100644 --- a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainSignUpUserManageController.java +++ b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainSignUpUserManageController.java @@ -44,7 +44,7 @@ import java.util.stream.Collectors; */ @IocBean @Ok("json:full") -@Api(tags = "品牌活动人员黑名单") +@Api(tags = "品牌活动人员黑名单(香樟工会)") @At("/platform/trainSignUp/userManage") public class TrainSignUpUserManageController { diff --git a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainsignUpMineController.java b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainsignUpMineController.java index 267ed5ea..40d845f5 100644 --- a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainsignUpMineController.java +++ b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/manage/TrainsignUpMineController.java @@ -40,7 +40,7 @@ import java.util.List; @Slf4j @IocBean @Ok("json:full") -@Api(tags = "活动报名") +@Api(tags = "活动报名(香樟工会)") @At("/platform/trainSignUp/mine") public class TrainsignUpMineController { diff --git a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/statistics/TrainSignUpActivityStatisticsController.java b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/statistics/TrainSignUpActivityStatisticsController.java index 9d8d1ea7..8c4d5f79 100644 --- a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/statistics/TrainSignUpActivityStatisticsController.java +++ b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/controller/statistics/TrainSignUpActivityStatisticsController.java @@ -51,7 +51,7 @@ import java.util.stream.Collectors; @Slf4j @IocBean @Ok("json:full") -@Api(tags = "品牌活动统计") +@Api(tags = "品牌活动统计(香樟工会)") @At("/platform/trainSignUp/statistics") public class TrainSignUpActivityStatisticsController { diff --git a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainMobileSignColumn.java b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainMobileSignColumn.java index 26860d25..48b4922d 100644 --- a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainMobileSignColumn.java +++ b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainMobileSignColumn.java @@ -10,7 +10,7 @@ import java.util.List; @Data @Accessors(chain = true) -@Comment("品牌活动移动端动态表单") +@Comment("品牌活动移动端动态表单(香樟工会)") @Table("train_mobile_sign_column") @EqualsAndHashCode(callSuper = false) public class TrainMobileSignColumn { diff --git a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpActivity.java b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpActivity.java index 2e7809c5..d11857ee 100644 --- a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpActivity.java +++ b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpActivity.java @@ -16,7 +16,7 @@ import java.util.List; @Data @Accessors(chain = true) -@Comment("品牌活动") +@Comment("品牌活动(香樟工会)") @Table @EqualsAndHashCode(callSuper = false) public class TrainSignUpActivity extends BaseModel implements Serializable, SysHomeConvert { diff --git a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpActivityCourse.java b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpActivityCourse.java index e9244f4f..6ccf3f6f 100644 --- a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpActivityCourse.java +++ b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpActivityCourse.java @@ -10,7 +10,7 @@ import java.util.Date; @Data @Accessors(chain = true) -@Comment("品牌活动下的子活动") +@Comment("品牌活动下的子活动(香樟工会)") @Table @EqualsAndHashCode(callSuper = false) public class TrainSignUpActivityCourse { diff --git a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpBlackList.java b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpBlackList.java index b08196c1..735fe501 100644 --- a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpBlackList.java +++ b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpBlackList.java @@ -8,7 +8,7 @@ import org.nutz.dao.interceptor.annotation.PrevInsert; @Data @Accessors(chain = true) -@Comment("品牌活动黑名单") +@Comment("品牌活动黑名单(香樟工会)") @Table @EqualsAndHashCode(callSuper = false) public class TrainSignUpBlackList { diff --git a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpCourse.java b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpCourse.java index ed6a4535..c152f360 100644 --- a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpCourse.java +++ b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpCourse.java @@ -13,7 +13,7 @@ import java.util.List; @Data @Accessors(chain = true) -@Comment("品牌活动的子活动") +@Comment("品牌活动的子活动(香樟工会)") @Table @EqualsAndHashCode(callSuper = false) public class TrainSignUpCourse extends BaseModel implements Serializable { diff --git a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpType.java b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpType.java index 4e8f31fd..db095754 100644 --- a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpType.java +++ b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpType.java @@ -13,7 +13,7 @@ import java.util.List; @Data @Accessors(chain = true) -@Comment("品牌活动的子活动类型") +@Comment("品牌活动的子活动类型(香樟工会)") @Table("train_sign_up_type") @EqualsAndHashCode(callSuper = false) public class TrainSignUpType extends BaseModel implements Serializable { diff --git a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpTypeLimit.java b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpTypeLimit.java index bc7b8f89..b7cc970d 100644 --- a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpTypeLimit.java +++ b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpTypeLimit.java @@ -10,7 +10,7 @@ import java.io.Serializable; @Data @Accessors(chain = true) -@Comment("品牌活动类型限制条件") +@Comment("品牌活动类型限制条件(香樟工会)") @Table("train_sign_up_type_limit") @EqualsAndHashCode(callSuper = false) public class TrainSignUpTypeLimit implements Serializable { diff --git a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpUser.java b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpUser.java index 13c61a8c..5e1e677b 100644 --- a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpUser.java +++ b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpUser.java @@ -13,7 +13,7 @@ import java.util.List; @Data @Accessors(chain = true) -@Comment("品牌活动报名人员") +@Comment("品牌活动报名人员(香樟工会)") @Table @EqualsAndHashCode(callSuper = false) @TableIndexes({@Index(name = "INDEX_TRAIN_SIGN_UP_USER_COURSEID", fields = {"courseId"}, unique = false)}) diff --git a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpUserCourse.java b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpUserCourse.java index 1dde65f6..a8ae86cd 100644 --- a/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpUserCourse.java +++ b/src/main/java/com/budwk/app/zhgh/activity/trainSignUp/models/TrainSignUpUserCourse.java @@ -11,7 +11,7 @@ import java.util.Date; @Data @Accessors(chain = true) -@Comment("品牌活动报名人员子活动表") +@Comment("品牌活动报名人员子活动表(香樟工会)") @Table @EqualsAndHashCode(callSuper = false) @TableIndexes({ diff --git a/src/main/resources/views/platform/zhgh/activity/smartbenefits/apply/applyForm.js b/src/main/resources/views/platform/zhgh/activity/smartbenefits/apply/applyForm.js new file mode 100644 index 00000000..954c7271 --- /dev/null +++ b/src/main/resources/views/platform/zhgh/activity/smartbenefits/apply/applyForm.js @@ -0,0 +1,210 @@ +const applyForm = { + template: /*language=HTML*/ ` +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 取 消 + 提 交 + + +
+ `, + store, + dicts: ["TRAIN_SIGNUP_TYPE"], + data() { + return { + signDialog: false, + formData: {}, + courseRow: {}, + courseTimeSelectList: [], + } + }, + methods: { + async getCourseTimeSelectList(o) { + const resp = await $.post('/platform/smartbenefits/apply/getCourseTimeSelectList',{ courseId: o.id }) + if (resp.code === 0) { + this.courseTimeSelectList = resp.data + } else { + this.$message.warning('获取时段信息失败,请联系管理员') + } + }, + async onOpen(row, course) { + this.initData(row, course) + if (row.courseIsLimitApply) { + await this.getCourseTimeSelectList(row) + } + this.courseRow = row + this.signDialog = true + this.$nextTick(() => { + this.$refs.form.clearValidate() + }) + }, + async validateSignUp() { + // 获取家属人数 + let familyCount = this.formData.smartBenefitsMobileSignColumnList.filter(o => o.columnCode === 'xdqsrs').reduce((sum, item) => { + return sum + (Number(item.columnValue) || 0) + }, 0) + const res = await this.$axios.post("/platform/smartbenefits/apply/validateSignUp", { + courseId: this.formData.courseId, + currentFamilyNumber: familyCount + }) + return res.code === 0 + }, + async validateCourseTime() { + const res = await this.$axios.post('/platform/smartbenefits/apply/validateSourceSignUp', { + activityCourseId: this.formData.activityCourseId, + courseId: this.courseRow.id + }) + return res.code === 0 + }, + async onSubmit() { + if(!await this.validateSignUp()) return + + this.$refs["form"].validate(async (valid) => { + if (valid) { + if(this.courseRow.courseIsLimitApply && !await this.validateCourseTime()) return + this.$confirm("您确定要提交吗?", "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning" + }).then(async () => { + const mobileColumnsValue = this.formData.smartBenefitsMobileSignColumnList.map((v) => { + return { + columnName: v.columnName, + columnValue: v.columnValue, + columnCode: v.columnCode, + columnFormType: v.columnFormType + } + }) + this.formData.mobileColumnsValue = JSON.stringify(mobileColumnsValue) + const resp = await this.$axios.post("/platform/smartbenefits/apply/doSignUp", this.formData) + if (resp.code === 0) { + this.signDialog = false + this.$message.success(resp.msg) + this.$emit('refresh') + } else { + this.$message.warning(resp.msg) + } + }) + } + }) + }, + initData(row, course) { + this.$set(this.formData, 'username', this.$store.state.user.username) + this.$set(this.formData, 'loginname', this.$store.state.user.loginname) + this.$set(this.formData, 'unionName', this.$store.state.user.union.name) + this.$set(this.formData, 'unitName', this.$store.state.user.unit.name) + this.$set(this.formData, 'sex', this.$store.state.user.sex) + this.$set(this.formData, 'activityId', row.activityId) + this.$set(this.formData, 'courseId', row.id) + this.$set(this.formData, 'smartBenefitsMobileSignColumnList', course.smartBenefitsMobileSignColumnList) + this.formData.smartBenefitsMobileSignColumnList.forEach((item) => { + item.columnValue = this.$store.state.user[item.columnCode] || "" + }) + + }, + }, + style: /*language=CSS*/ ` + + ` +} diff --git a/src/main/resources/views/platform/zhgh/activity/smartbenefits/apply/courseList.js b/src/main/resources/views/platform/zhgh/activity/smartbenefits/apply/courseList.js new file mode 100644 index 00000000..7c19e2d4 --- /dev/null +++ b/src/main/resources/views/platform/zhgh/activity/smartbenefits/apply/courseList.js @@ -0,0 +1,340 @@ + +const courseList = { + template: /*language=HTML*/ ` +
+ + + + + 类  型: + + + + + + + + 分类标识: + + + {{ item }} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 取 消 + + + + +
+ + 取 消 + +
+ + +
+ + 取 消 + +
+ + +
+ `, + dicts: ["TRAIN_SIGNUP_TYPE"], + mixins: [initTableMixins], + components: { + "apply-form": applyForm, + }, + data() { + return { + pageForm: { + assortTypes: [], + }, + assortList: [], + courseTimeListDialog: false, + viewMapDialog: false, + courseTimeList: [], + tableColumns: [ + { prop: "courseName", label: "名称" }, + { prop: "typeName", label: "类型", width: 130}, + { prop: "campus", label: "校区", width: 160 }, + { prop: "courseLocationCoordinates", label: "地点", width: 200 }, + { prop: "courseInstructor", label: "联系人", width: 100 }, + { prop: "courseTime", label: "时间", width: 160 }, + { prop: "introduce", label: "详细信息", width: 100 }, + { prop: "applyNum", label: "已报名人数", width: 200 } + ], + activity: {}, + courseTypeList: [], + + trainType: '', + pdf: false, + infoVisible: false, + introduce: '', + } + }, + methods: { + async onPreview(introduce) { + try { + const parser = new DOMParser(); + const doc = parser.parseFromString(introduce, 'text/html'); + const link = doc.querySelector('a'); + const href = link.getAttribute('href'); + + const id = href.substring(href.indexOf("=") + 1) + const res = await this.$axios.post("/platform/sys/file/previewFileData", { ids: JSON.stringify([id]) }) + + this.pdf = true + window.open("/assets/platform/plugins/pdfJs/web/viewer.html?file=" + encodeURIComponent(res.data[0].downloadPath), res.data[0].name) + } catch (e) { + this.introduce = introduce + this.pdf = false + this.infoVisible = true + } + }, + tagClick(key, val) { + let idx = this.pageForm[key].indexOf(val) + if (idx !== -1) { + this.pageForm[key].splice(idx, 1) + } else { + this.pageForm[key].push(val) + } + this.doSearch() + }, + async onOpen(row) { + this.activity = row + this.$set(this.pageForm, 'activityId', row.id) + await this.pageData() + await this.getCourseTypeList() + this.queryCourseAssort() + }, + onSign(row) { + const course = this.courseTypeList.find((v) => v.id === row.courseType) + this.$axios.post("/platform/smartbenefits/apply/validateSignUp", {courseId: row.id}) + .then((res) => { + if (res.code !== 0) { + this.$alert(res.msg, "提示", { + confirmButtonText: "确定", + type: "warning" + }) + } else { + let lave = row.coursePeopleNumber - (row.hasRegisterNum + row.courseReservedNumber) + if(row.reserveMode === 2 && lave <= 0) { + this.$alert('您当前的报名为候补报名状态', "提示", { + confirmButtonText: "确定", + type: "warning" + }) + } + this.$refs.formRef.onOpen(row, course) + } + }) + }, + onCancel(row) { + this.$confirm("您确定要取消吗?", "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "info" + }).then(async () => { + const resp = await this.$axios.post("/platform/smartbenefits/apply/cancelSignUp", { + activityId: row.activityId, + courseId: row.id + }) + if (resp.code === 0) { + await this.pageData() + this.$message.success(resp.msg) + } else { + this.$message.warning(resp.msg) + } + }) + }, + async getCourseTypeList() { + const resp = await this.$axios.post("/platform/smartbenefits/type/getAllType") + if (resp.code === 0) { + this.courseTypeList = resp.data + } + }, + async openViewCourseTime(id) { + const resp = await this.$axios.post(loc() + "/getCourseTime", { id: id }) + this.courseTimeList = resp.data + this.courseTimeListDialog = true + }, + openViewMap(point) { + if (!Array.isArray(point)) { + this.$message.warning("没有设置点位,无法通过地图查看") + return + } + this.viewMapDialog = true + this.$nextTick(() => { + const viewMap = new AMap.Map("viewMap", { + resizeEnable: true, + center: point, + zoom: 16 + }) + if (viewMarker) { + viewMap.remove(viewMarker) + } + viewMarker = new AMap.Marker({ + position: point, + offset: new AMap.Pixel(-13, -30) + }) + viewMap.add(viewMarker) + viewMap.setFitView(null, false, [150, 60, 100, 60]) + }) + }, + calcSignUpCount(o) { + let lave = o.coursePeopleNumber - (o.hasRegisterNum + o.courseReservedNumber) + if(o.reserveMode === 2) { + let lave2 = o.waitingNum - o.hasWaitingNum + return "余" + lave +"/" + o.coursePeopleNumber + "人" + + ",候补余" + lave2 + "/" + o.waitingNum + "人" + } else { + return "余" + lave +"/" + o.coursePeopleNumber + "人" + } + }, + async pageData() { + const pageForm = clone({...this.pageForm}) + pageForm.assortTypes = JSON.stringify(pageForm.assortTypes) + const resp = await this.$axios.post(loc() + "/pageData", pageForm) + if (resp.code === 0) { + this.tableData = resp.data.list + this.pageForm.totalCount = resp.data.totalCount + } else { + this.$message.warning(resp.msg) + } + }, + queryCourseAssort() { + this.$axios.post(loc() + "/queryCourseAssort", {activityId: this.activity.id}) + .then((resp) => { + this.assortList = resp.data + }) + }, + }, + created() { + + }, + style: /*language=CSS*/ ` + /deep/ .glow-box { + min-height: calc(100vh - 56px - 40px - 50px - 80px); + max-height: calc(100vh - 56px - 40px - 50px - 80px); + overflow-y: auto; + background: #F0F2F5; + } + /deep/ img { + width: 100%; + height: 180px; + } + /deep/ .title { + background: white; + height: 20px; + } + /deep/ .query-row { + display: flex; + align-items: center; + padding: 6px 0; + } + /deep/ .query-row:not(:last-child) { + border-bottom: 1px dashed rgb(230, 230, 230); + } + /deep/ .query-row > .query-title { + width: 100px; + max-width: 100px; + min-width: 100px; + overflow: hidden; + } + /deep/ .query-row > .query-content { + min-width: 200px; + overflow: hidden; + } + /deep/ .query-row > .query-content > .el-tag { + margin-bottom: 5px; + margin-top: 5px; + } + /deep/ @media screen and (max-width: 992px) { + .query-row:nth-child(4) .query-content .el-col:not(:last-child) { + margin-bottom: 5px; + } + + .query-title { + display: none; + } + } + ` +} diff --git a/src/main/resources/views/platform/zhgh/activity/smartbenefits/apply/index.html b/src/main/resources/views/platform/zhgh/activity/smartbenefits/apply/index.html new file mode 100644 index 00000000..1383377f --- /dev/null +++ b/src/main/resources/views/platform/zhgh/activity/smartbenefits/apply/index.html @@ -0,0 +1,180 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + diff --git a/src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/basicForm.js b/src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/basicForm.js new file mode 100644 index 00000000..079353a1 --- /dev/null +++ b/src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/basicForm.js @@ -0,0 +1,613 @@ + + +const basicForm = { + template: /*language=HTML*/ ` +
+ +
+ + + + + 沿用之前活动 + 不沿用之前活动 + + + + + + + + + + + + + + + + + + + + + 通知 + 不通知 + + + + + + + + + + + + + + + + + + + +
+
+ + + +
+
+ 设置 +
+
+
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
{{trainType + '信息(温馨提示:如不需要人数限制,下方人数框填写0或者不填)'}}
+
+ 添加{{ trainType }} +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
个人报名数量限制
+ + + 无限制 + 按类型限制 + 按活动限制 + +
+
注:无限制指对报名的个数不做任何限制
+
+
+ 设置报名限制 + 注:按类型限制指对每个类型下的个数进行限制 +
+
+
+
+ + 注:按活动限制指只能报{{formData.limitNum}}个,不与类型关联 +
+
+
+
+
+
+
+ 取消 + 上一步 + 下一步 + 保存 + 提交 +
+ + + + + + + + + + + 取消 + 确定 + + + + + + + + +
+ `, + dicts: ["USER_CAMPUS", "TRAIN_SIGNUP_TYPE"], + data() { + return { + signUpDialog: false, + step: 1, + formData: { + notice: false, + courseList: [ + { orderNum: 1, courseName: "", courseTimeList: [], isMobileSign: false, isReceiveGift: false, reserveMode: 1, courseIsLimitApply: false }, + ], + conditionStructure: { + method: "AND", + conditions: [{}] + }, + restrictLimit: 1, + limitNum: 1, + typeLimits: [], + hostUnits: [], + helpUnits: [], + }, + historicalActList: [], + trainTypeList: [], + trainType: "培训班", + activityGroupList: [], + pickerOptions: { + disabledDate(time) { + return time.getTime() < Date.now() - 24 * 60 * 60 * 1000 + } + }, + campusList: [], + courseTypeList: [], + undertakeOptions: [], + } + }, + components: { + "drawer-user-scope": httpVueLoader("/components/module/activity/DrawerUserScope.vue"), + "course-time": courseTime, + "custom-form": customForm, + }, + methods: { + async validNumber(row, old) { + if (GetQueryString("id") === "") { + if (row.courseReservedNumber > row.coursePeopleNumber && row.reserveMode === 1) { + this.$alert("预留人数不能大于" + this.trainType + "人数!", "提示", { + confirmButtonText: "确定" + }) + row.courseReservedNumber = 0 + } + } else { + const registerUserCount = await this.getRegisterUserCount(row.id) + if (row.courseReservedNumber + registerUserCount > row.coursePeopleNumber) { + if (row.reserveMode === 1) { + let num = row.coursePeopleNumber - registerUserCount + let str = + "您设置的" + + this.trainType + + "人数为" + + row.coursePeopleNumber + + "人,当前报名人数为" + + registerUserCount + + "人,预留名额上限为" + + num + + "人!" + this.$alert(str, "提示", { + confirmButtonText: "确定" + }) + row.courseReservedNumber = 0 + } + } + } + }, + async getRegisterUserCount(courseId) { + const resp = await this.$axios.post("/platform/smartbenefits/manage/getRegisterUserCount", { courseId }) + return resp.code === 0 ? resp.data : 0 + }, + courseTypeChange(val, row) { + row.reserveMode = 1 + }, + setSignUpCondition() { + if (this.formData.courseList !== undefined && this.formData.courseList.length > 0) { + const courseValid = this.formData.courseList.some((item, index) => { + if (item.courseType === undefined) { + this.$message.warning("请在" + (index + 1) + "行" + this.trainType + "信息中选择类型!") + return true + } + return false + }) + if (courseValid) { + return + } + const array = [...new Set(this.formData.courseList.map((o) => o.courseType))] + const typeArray = clone([...this.courseTypeList].filter((x) => array.some((y) => x.id === y))) + const arr = [] + typeArray.forEach((item) => { + const t = this.formData.typeLimits.find(o => o.typeId === item.id) + if (t) { + const type = this.courseTypeList.find(o => o.id === t.typeId) + t.code = type.code + t.typeName = type.typeName + arr.push(t) + } else { + arr.push({ + code: item.code, + typeName: item.typeName, + typeId: item.id, + limitNum: 0 + }) + } + }) + this.formData.typeLimits = arr + this.signUpDialog = true + } else { + this.$message.warning("请在" + this.trainType + "信息中选择类型!") + } + }, + doLimitNum() { + this.signUpDialog = false + }, + openMoreInfo(row, index) { + this.$refs.customFormRef.onOpen(this.formData, row, index) + }, + async removeTableCourse(index) { + const confirm = await this.$confirm( + "请确认是否删除此" + this.trainType + "?如果该" + this.trainType + "已有报名人员,会随之一起删除!确定吗?", + "提示", + { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning" + } + ) + if (confirm) { + this.formData.courseList.splice(index, 1) + } + }, + openSetUpCourseTime(index) { + this.$refs.courseTimeRef.onOpen(this.formData, index) + }, + courseOrderNumChange() { + this.formData.courseList = this.formData.courseList.sort((a, b) => a.orderNum - b.orderNum) + }, + addCourse() { + this.formData.courseList.push({ courseTimeList: [], isMobileSign: false, isReceiveGift: false, reserveMode: 1, courseIsLimitApply: false }) + }, + async historicalActChange(val) { + const resp = await this.$axios.post("/platform/smartbenefits/manage/findOne", {id: val}) + if (resp.code === 0) { + this.formData = resp.data + this.typeChange(this.formData.trainType) + this.formData.id = "" + } + }, + typeChange(val) { + const type = this.dict.type.TRAIN_SIGNUP_TYPE.find(o => o.code === val) + this.trainType = type?.name || "培训班" + }, + changeActivity(val) { + if (val) { + const group = this.activityGroupList.find(v => v.groupId === val) + this.$set(this.formData, "activityGroupName", group.groupName) + } else { + this.$set(this.formData, "activityGroupName", "全部教职工") + } + }, + async getActivityGroup() { + const { data } = await this.$axios.post("/platform/activity/basic/scope/getActivityUserScopeGroup") + return data + }, + async getHistoricalActList() { + const resp = await this.$axios.post("/platform/smartbenefits/manage/getHistoricalActList", {}) + return resp.data + }, + async onSave() { + let valid = false + this.$refs.form.validateField("activityName", (errMsg) => { + valid = errMsg === "" + }) + if (!valid) { + this.$message.warning("请输入活动名称") + return + } + await this.doHandle('保存') + }, + onSubmit() { + this.$refs["form"].validate(async (valid, errMsg) => { + if (valid) { + const courseValid = this.formData.courseList.some((v, i) => { + const basicValid = v.courseName && v.coursePeopleNumber && v.courseLocation && v.courseInstructor && v.courseType + const timeValid = + v.courseTimeList.length > 0 && + v.courseTimeList.every((x) => { + return x.courseStartTime && x.courseEndTime && x.courseStartTime < x.courseEndTime + }) + if (!timeValid) { + this.$message.warning("第" + (i + 1) + "行时间填写有误,请核查") + return true + } + if (!basicValid) { + this.$message.warning("第" + (i + 1) + "行信息填写有误,请核查") + return true + } + if (v.isMobileSign === true && v.signType === 3 && (v.courseLocationCoordinates === undefined || v.courseLocationCoordinates.length < 2)) { + this.$message.warning("第" + (i + 1) + "行地点坐标填写有误,请核查") + return true + } + if (v.isMobileSign === true && v.signType === 3 && (v.signType === "" || v.signType === undefined)) { + this.$message.warning("第" + (i + 1) + "行签到方式填写有误,请核查") + return true + } + return false + }) + if (courseValid) return + if (this.formData.restrictLimit === 2 && this.formData.typeLimits.length === 0) { + this.$message.warning("请设置报名限制") + return + } + this.formData.isDisabled = false + await this.doHandle('提交') + } + }) + }, + async doHandle(type) { + const cloneData = clone(this.formData) + cloneData.activitySignUpStartTime = cloneData.activitySignTime !== undefined ? cloneData.activitySignTime[0] : null + cloneData.activitySignUpEndTime = cloneData.activitySignTime !== undefined ? cloneData.activitySignTime[1] : null + cloneData.activityStartTime = cloneData.activityTime !== undefined ? cloneData.activityTime[0] : null + cloneData.activityEndTime = cloneData.activityTime !== undefined ? cloneData.activityTime[1] : null + if (cloneData.activitySignUpStartTime !== undefined && cloneData.activitySignUpStartTime !== null) { + cloneData.year = new Date(cloneData.activitySignUpStartTime).getFullYear() + } + cloneData.typeLimits = JSON.stringify(this.formData.typeLimits) + cloneData.courseList = JSON.stringify(cloneData.courseList) + cloneData.hostUnits = JSON.stringify(cloneData.hostUnits) + cloneData.helpUnits = JSON.stringify(cloneData.helpUnits) + const confirm = await this.$confirm("您确定要" + type + "吗?", "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning" + }) + if (confirm !== "confirm") return + const resp = await this.$axios.post("/platform/smartbenefits/manage/doHandle", cloneData) + if (resp.code === 0) { + this.$message.success(resp.msg) + this.step = 1 + this.$emit('refresh') + this.$emit('back') + } else { + this.$message.warning(resp.msg) + } + }, + async getAllType() { + const resp = await this.$axios.post("/platform/smartbenefits/type/getAllType", {}) + return resp.data + }, + async init(row) { + if (row && row.id) { + const resp = await this.$axios.post("/platform/smartbenefits/manage/findOne", {id: row.id}) + if (resp.code === 0) { + this.formData = resp.data + this.typeChange(this.formData.trainType) + } + } + }, + async initData(row) { + this.activityGroupList = await this.getActivityGroup() + this.historicalActList = await this.getHistoricalActList() + this.courseTypeList = await this.getAllType() + await this.selectUnitAndClub() + await this.init(row) + }, + async selectUnitAndClub() { + const resp = await this.$axios.post("/platform/smartbenefits/manage/selectUnitAndClub") + this.undertakeOptions = resp.data + }, + }, + watch: { + 'formData.restrictLimit'(val) { + if (!this.formData.id) { + this.formData.limitNum = val === 3 ? 1 : '' + } + }, + 'formData.activityGroupId': { + async handler(newVal, oldVal) { + this.activityGroupList = await this.getActivityGroup() + this.userScopeDialog = false + }, + deep: true + }, + }, + style: /*language=CSS*/ ` + + ` +} diff --git a/src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/courseTime.js b/src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/courseTime.js new file mode 100644 index 00000000..56f2a29f --- /dev/null +++ b/src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/courseTime.js @@ -0,0 +1,215 @@ +const courseTime = { + template: /*language=HTML*/ ` +
+ +
温馨提示:有人员报名后,禁止修改下列时间,如有修改,请联系管理员
+
选择日期
+ +
设置时间
+ + + + 一键设置开始/结束时间 + 报名人数是否限制: + + + + + + + + + + + + + + + + + + + + + + + 确定 + +
+
+ `, + dicts: ["TRAIN_SIGNUP_TYPE"], + data() { + const that = this + return { + setUpCourseDialog: false, + courseIndex: 0, + formData: {}, + courseTimeOneKeySet: { + startTime: "", + endTime: "" + }, + setUpCoursePickerOptions: { + disabledDate(time) { + return ( + time.getTime() < Date.parse(that.$moment(that.formData.activityTime[0]).format("YYYY-MM-DD") + " 00:00:00") || + time.getTime() > Date.parse(that.$moment(that.formData.activityTime[1]).format("YYYY-MM-DD") + " 00:00:00") + ) + } + }, + } + }, + methods: { + removeSetUpTableCourseRow(row, index) { + this.formData.courseList[this.courseIndex].courseTimeList.splice(index, 1) + //培训时间列表日期数组 + const courseDateArray = this.formData.courseList[this.courseIndex].courseTimeList.map((v) => + this.$moment(v.courseDate).format("YYYY-MM-DD") + ) + //选择课程日期数组 + const scdList = this.formData.courseList[this.courseIndex].setUpCourseData + + this.formData.courseList[this.courseIndex].setUpCourseData = scdList.filter((v) => { + return courseDateArray.includes(this.$moment(v).format("YYYY-MM-DD")) + }) + }, + oneKeySetStartEndTime() { + const { startTime, endTime } = this.courseTimeOneKeySet + this.formData.courseList[this.courseIndex].courseTimeList.forEach((v) => { + this.$set(v, "courseStartTime", startTime) + this.$set(v, "courseEndTime", endTime) + }) + this.$forceUpdate() + }, + setUpCourseDataChange(val) { + if (!val) { + this.formData.courseList[this.courseIndex].courseTimeList = [] + return + } + //培训时间日期Set + if (this.formData.courseList[this.courseIndex].courseTimeList === undefined) { + this.$set(this.formData.courseList[this.courseIndex], "courseTimeList", []) + } + const ctList = new Set( + this.formData.courseList[this.courseIndex].courseTimeList.map((v) => this.$moment(v.courseDate).format("YYYY-MM-DD")) + ) + val.forEach((v) => { + if (!ctList.has(v)) { + this.formData.courseList[this.courseIndex].courseTimeList.push({ + courseDate: v, + courseTime: null + }) + } + }) + this.formData.courseList[this.courseIndex].courseTimeList = this.formData.courseList[this.courseIndex].courseTimeList.filter((v) => { + return val.includes(this.$moment(v.courseDate).format("YYYY-MM-DD")) + }) + this.formData.courseList[this.courseIndex].courseTimeList.sort((a, b) => { + return Date.parse(a["courseDate"]) - Date.parse(b["courseDate"]) + }) + }, + //设置课程时间确定 + doConfirmSetUpCourse() { + const courseTableData = this.formData.courseList[this.courseIndex].courseTimeList + if (courseTableData.length === 0) { + this.$message.warning("请填写时间!") + return + } + if (courseTableData && courseTableData.length > 0) { + const valid = courseTableData.every((v) => v.courseStartTime && v.courseEndTime && v.courseStartTime < v.courseEndTime) + if (!valid) { + this.$message.warning("时间填写不完整或者有误!") + return + } + this.setUpCourseDialog = false + } + }, + onOpen(formData, index) { + this.formData = formData + this.courseIndex = index + if (!this.formData.activityTime || this.formData.activityTime.length === 0) { + this.$message.warning("请先设置活动起止时间") + return + } + this.courseIndex = index + this.setUpCourseDialog = true + }, + }, + created() { + if(!this.formData.courseList) { + this.formData = {courseList: [{unionLimit: []}]} + } + }, + style: /*language=CSS*/ ` + + ` +} diff --git a/src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/customForm.js b/src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/customForm.js new file mode 100644 index 00000000..c7ad6931 --- /dev/null +++ b/src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/customForm.js @@ -0,0 +1,240 @@ + +const customForm = { + template: /*language=HTML*/ ` +
+ + + + 分工会人数限制 + + + + 设置分工会人数限制 + + + 已设置 + + 未设置 + + + + + + 承办工会 + + + + + + + + + + + 对内报名时间 + + + + + + + + + 是否签到 + + + + 签到 + 不签到 + + + + + + + 签到方式 + + + + 扫描二维码 + 被扫 + GPS定位签到 + + + + + + + 签到时间误差 + + + + + + + + + + + 签到半径 + + + + + + + + + + + 地点坐标 + + + 设置签到点 + + + + + + 是否领取礼品 + + + + 领取 + 不领取 + + + + + + + 领取方式 + + + + 扫描二维码 + 面对面确认 + + + + + + + 报名方式 + + + + 报名人员减少模式 + 候补模式 + + + + + + 候补数量 + + + + + + + + + 详细信息 + + + + + + +
+ 取 消 + 保 存 +
+
+ + + + + 确 定 + + + + +
+ `, + dicts: ["TRAIN_SIGNUP_TYPE"], + data() { + return { + moreInfoDrawer: false, + unionList: [], + formData: {}, + moreInfoRow: {}, + moreInfoIndex: 0, + + mapDialog: false, + mapIndex: 0, + } + }, + components: { + "union-form": unionForm, + "map-container": httpVueLoader("/components/plugins/mapContainer/TMap.vue?v=1.0.6") + }, + methods: { + openMap(index) { + this.mapIndex = index + this.mapDialog = true + }, + openSetUpUnionLimit(index) { + this.$refs.unionFormRef.onOpen(this.formData, index) + }, + async onOpen(formData, chooseRow, index) { + this.formData = formData + this.moreInfoRow = chooseRow + this.moreInfoIndex = index + this.unionList = await this.$businessTool.listUnion() + this.moreInfoDrawer = true + }, + onMap() { + const posi = this.formData.courseList[this.mapIndex].courseLocationCoordinates + if(posi && posi.length > 1) { + this.formData.courseList[this.mapIndex].transPosition = this.$coordinateUtil.gcj02ToWgs84(posi[1], posi[0]) + } + this.mapDialog = false + } + }, + created() { + if(!this.formData.courseList) { + this.formData = {courseList: [{unionLimit: []}]} + } + }, + style: /*language=CSS*/ ` + + ` +} diff --git a/src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/index.html b/src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/index.html new file mode 100644 index 00000000..d425b760 --- /dev/null +++ b/src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/index.html @@ -0,0 +1,212 @@ + + + + +
+ + + + + + + + + + + + + + + + 新建活动 + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + 关 闭 + +
+
+
+ + + + diff --git a/src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/info.js b/src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/info.js new file mode 100644 index 00000000..35903fb9 --- /dev/null +++ b/src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/info.js @@ -0,0 +1,111 @@ +const info = { + template: /*language=HTML*/ ` +
+ + + + {{viewData.activityName}} + {{viewData.year}} + {{$moment(viewData.createdAt).format('YYYY-MM-DD HH:mm:ss')}} + {{viewData.activityStartTime}} + {{viewData.activityEndTime}} + {{viewData.activitySignUpStartTime}} + {{viewData.activitySignUpEndTime}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 关 闭 + + + + +
+
+
+ `, + dicts: ["TRAIN_SIGNUP_TYPE"], + data() { + return { + trainType: '', + viewData: {}, + courseTimeListDialog: false, + courseTimeList: [], + + viewMapDialog: false, + } + }, + methods: { + initData(id) { + this.$axios.post("/platform/smartbenefits/manage/findOne", { id: id }) + .then((resp) => { + if (resp.code === 0) { + this.viewData = resp.data + const type = this.dict.type.TRAIN_SIGNUP_TYPE.find((o) => o.code === resp.data.trainType) + this.trainType = type?.name || "培训班" + } + }) + }, + openViewCourseTime(courseTimeList) { + this.courseTimeList = courseTimeList + this.courseTimeListDialog = true + }, + openViewMap(point) { + if (!Array.isArray(point)) { + this.$message.warning("没有设置点位,无法通过地图查看") + return + } + this.viewMapDialog = true + this.$nextTick(() => { + viewMap = new AMap.Map("viewMap", { + resizeEnable: true, + center: point, + zoom: 16 + }) + if (viewMarker) { + viewMap.remove(viewMarker) + } + viewMarker = new AMap.Marker({ + position: point, + offset: new AMap.Pixel(-13, -30) + }) + viewMap.add(viewMarker) + viewMap.setFitView(null, false, [150, 60, 100, 60]) + }) + }, + }, + style: /*language=CSS*/ ` + /deep/ .el-button--text { + padding: 0; + } + ` +} diff --git a/src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/makeQrcode.js b/src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/makeQrcode.js new file mode 100644 index 00000000..09fbfcb4 --- /dev/null +++ b/src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/makeQrcode.js @@ -0,0 +1,85 @@ +const makeQrcode = { + template: /*language=HTML*/ ` +
+ + + + + + + + + + + + + + + + + + + + + + 关 闭 + + +
+ `, + dicts: ["TRAIN_SIGNUP_TYPE"], + data() { + return { + courseDialog: false, + trainType: "", + courseList: [], + } + }, + methods: { + initData(row) { + this.courseList = row.courseList + const type = this.dict.type.TRAIN_SIGNUP_TYPE.find((o) => o.code === row.trainType) + this.trainType = type?.name || "培训班" + this.courseDialog = true + }, + makeCourseCode(row) { + //const url = '${AppDomain!}/platform/smartbenefits/mine/drivingScan' + const url = '${AppDomain!}/platform/smartbenefits/mine/scan' + const data = url + '?courseId=' + row.id + console.log(data) + const content = jrQrcode.getQrBase64(data) + let image = new Image() + image.src = content + let viewer = new Viewer(image, { + zIndex: 999999, + }) + viewer.show() + }, + }, + style: /*language=CSS*/ ` + + ` +} diff --git a/src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/unionForm.js b/src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/unionForm.js new file mode 100644 index 00000000..72cecfe7 --- /dev/null +++ b/src/main/resources/views/platform/zhgh/activity/smartbenefits/manage/unionForm.js @@ -0,0 +1,221 @@ +const unionForm = { + template: /*language=HTML*/ ` +
+ +
+
分段设置
+
+ 应用分段设置 +
+
+ + + + + + + + + + + + + + + + + +
+ ({{index+1}}). + {{item}} +
+
+ +
+
比例设置
+
+ 一键比例: + + 应用比例设置 +
+
+ + + + + + + + + + + + +
+ 限制总人数:{{summaryCount}}人 +
+ 清空分工会人数限制 + 取消 + 确定 +
+
+
+ `, + dicts: ["TRAIN_SIGNUP_TYPE"], + data() { + return { + formData: {}, + unionLimitIndex: 0, + setUpUnionLimitDialog: false, + unionList: [], + unionUserNumCalc: [{}], + unionUserNumOneKeyRatio: null, + summaryCount: 0, + } + }, + computed: { + unionUserNumCalcTips() { + return this.unionUserNumCalc.map((v) => { + return ( + (v.startNum ? v.startNum : "?") + + "-" + + (v.endNum ? v.endNum : "?") + + "人的分工会,限报" + + (v.resultNum ? v.resultNum : "?") + + "人" + ) + }) + } + }, + methods: { + calSummaryCount() { + const array = this.formData.courseList[this.unionLimitIndex].unionLimit + if (array) { + this.summaryCount = array.reduce((prev, curr) => { + const value = Number(curr.limitCount) + if (!isNaN(value)) { + return prev + curr.limitCount + } else { + return prev + } + }, 0) + } + }, + async onOpen(formData, index) { + this.unionList = await this.$businessTool.listUnion() + this.formData = formData + this.unionLimitIndex = index + this.setUpUnionLimitDialog = true + if ( + !this.formData.courseList[this.unionLimitIndex].unionLimit || + this.formData.courseList[this.unionLimitIndex].unionLimit.length === 0 + ) { + const resp = await this.$axios.get("/platform/smartbenefits/manage/getUnionLimit", { + activityScopeId: this.formData.activityGroupId + }) + if (resp.code === 0) { + this.$set(this.formData.courseList[this.unionLimitIndex], "unionLimit", resp.data) + } + } + this.summaryCount = this.formData.courseList[this.unionLimitIndex].unionLimit.reduce((prev, curr) => { + const value = Number(curr.limitCount) + if (!isNaN(value)) { + return prev + curr.limitCount + } else { + return prev + } + }, 0) + }, + unionLimitQuickSetting() { + this.unionUserNumCalc.forEach((v, i) => { + const startNum = v.startNum + const endNum = v.endNum + const resultNum = v.resultNum + if (startNum > endNum) { + this.$message.warning("第" + (i + 1) + "行设置错误") + } else { + this.formData.courseList[this.unionLimitIndex].unionLimit.forEach((x) => { + if (x.teacherCount >= startNum && x.teacherCount <= endNum) { + x.limitCount = resultNum + } + }) + this.calSummaryCount() + } + }) + }, + doConfirmSetUpUnionLimit() { + this.setUpUnionLimitDialog = false + }, + //应用比例设置 + applyScaleSettings() { + this.formData.courseList[this.unionLimitIndex].unionLimit.forEach((v) => { + v.limitCount = parseFloat(((v.teacherCount * this.unionUserNumOneKeyRatio) / 100).toFixed(0)) + if (v.ratio) { + v.limitCount = parseFloat(((v.teacherCount * v.ratio) / 100).toFixed(0)) + } + }) + this.calSummaryCount() + }, + async clearUnionLimit() { + const confirm = await this.$confirm("确定要清空分工会人数限制吗, 是否继续?", "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning" + }) + if ("confirm" === confirm) { + this.formData.courseList[this.unionLimitIndex].unionLimit = [] + this.unionUserNumOneKeyRatio = null + this.unionUserNumCalc = [{}] + this.setUpUnionLimitDialog = false + } + }, + }, + created() { + if(!this.formData.courseList) { + this.formData = {courseList: [{unionLimit: []}]} + } + }, + style: /*language=CSS*/ ` + + ` +} diff --git a/src/main/resources/views/platform/zhgh/activity/smartbenefits/statistics/index.html b/src/main/resources/views/platform/zhgh/activity/smartbenefits/statistics/index.html new file mode 100644 index 00000000..bb7dad2f --- /dev/null +++ b/src/main/resources/views/platform/zhgh/activity/smartbenefits/statistics/index.html @@ -0,0 +1,158 @@ + + + + +
+ + + + + + + + + + + + + + + + 导出报名人员 + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + diff --git a/src/main/resources/views/platform/zhgh/activity/smartbenefits/statistics/info.js b/src/main/resources/views/platform/zhgh/activity/smartbenefits/statistics/info.js new file mode 100644 index 00000000..9daa441b --- /dev/null +++ b/src/main/resources/views/platform/zhgh/activity/smartbenefits/statistics/info.js @@ -0,0 +1,160 @@ +const info = { + template: /*language=HTML*/ ` +
+ + + + + + + + + + + + + + {{item.courseStartTime + ' 至 ' + item.courseEndTime}} + + + + + + + + + + + + + + + + + +
+ `, + dicts: ["TRAIN_SIGNUP_TYPE"], + mixins: [initTableMixins], + data() { + return { + registerUserTableData: [], + registerUserTableColumns: [ + { label: "姓名", prop: "username" }, + { label: "工号", prop: "loginname" }, + { label: "单位", prop: "unitName" }, + { label: "分工会", prop: "unionName" }, + { label: "联系方式", prop: "mobile" }, + { label: "报名时间", prop: "signUpTime" }, + { label: "报名状态", prop: "state" } + ], + cloneTableColumns: [ + {label: '姓名', prop: 'username'}, + {label: '工号', prop: 'loginname'}, + {label: '单位', prop: 'unitName'}, + {label: '分工会', prop: 'unionName'}, + {label: '联系方式', prop: 'mobile'}, + {label: '报名时间', prop: 'signUpTime'}, + {label: '报名状态', prop: 'state'}, + ], + clickRow: {}, + timeList: [], + signUserList: [], + timeId: '', + pageForm: {}, + } + }, + methods: { + async onOpen(row) { + this.clickRow = row + await this.registerUserList() + await this.selectTimes() + await this.getTaleColumnInfo() + }, + async doSearch() { + this.pageForm.pageNumber = 1 + await this.selectSignUsers(this.timeId) + }, + async pageNumberChange(val) { + this.pageForm.pageNumber = val + await this.selectSignUsers(this.timeId) + }, + async pageSizeChange(val) { + this.pageForm.pageSize = val + await this.selectSignUsers(this.timeId) + }, + onSign(row) { + this.$confirm("您确定要设置吗?", "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "info" + }).then(() => { + this.$axios.post("/platform/smartbenefits/statistics/adjustSign", { id: row.id }).then(async (res) => { + if (res.code === 0) { + this.$message.success(res.msg) + await this.selectSignUsers(this.timeId) + } + }) + }) + }, + async tabClick(val) { + await this.selectSignUsers(this.timeList[val.index].id) + }, + async registerUserList() { + const res = await this.$axios.post(loc() + "/registerUserList", { courseId: this.clickRow.id }) + this.registerUserTableData = res.data + }, + async selectTimes() { + const res = await this.$axios.post(loc() + "/selectTimes", { courseId: this.clickRow.id }) + this.timeList = res.data + if(this.timeList.length > 0) { + await this.selectSignUsers(this.timeList[0].id) + } + }, + async selectSignUsers(timeId) { + this.timeId = timeId + this.$set(this.pageForm, 'courseId', this.clickRow.id) + this.$set(this.pageForm, 'timeId', timeId) + const res = await this.$axios.post(loc() + "/getSignInfo", this.pageForm) + if (res.code === 0) { + this.signUserList = res.data.list + this.pageForm.totalCount = res.data.totalCount + } + }, + async getTaleColumnInfo() { + const res = await $.get(loc() + '/getTaleColumnInfo', { courseId: this.clickRow.id }) + if (res.data) { + this.registerUserTableColumns = [] + this.registerUserTableColumns = this.cloneTableColumns.concat(res.data) + } + }, + }, + style: /*language=CSS*/ ` + + ` +} diff --git a/src/main/resources/views/platform/zhgh/activity/smartbenefits/type/basicForm.js b/src/main/resources/views/platform/zhgh/activity/smartbenefits/type/basicForm.js new file mode 100644 index 00000000..0c1d6a88 --- /dev/null +++ b/src/main/resources/views/platform/zhgh/activity/smartbenefits/type/basicForm.js @@ -0,0 +1,350 @@ +const basicForm = { + template: /*language=HTML*/ ` +
+ + + + + + + + + + 携带 + 不携带 + + + + + 纳入 + 不纳入 + + + + + 纳入 + 不纳入 + + + + +
+
+ 报名填写字段 + + 注:移动端报名时字段的显示顺序会按照下面表格中的序号进行排列、字段编码不能重复 + +
+
+ + + 添加 + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 取 消 + 确 定 +
+ + + + + + + + + + + +
+ 取 消 + 确 定 +
+
+
+ `, + dicts: ["TRAIN_SIGNUP_TYPE"], + data() { + return { + formData: { + smartBenefitsMobileSignColumnList: [{ isRequired: false }], + isBringFamily: false, + isAddFamily: false, + selfAddFamily: true, + }, + rules: { + typeName: [{ required: true, message: "请输入类型名称", trigger: ["change", "blur"] }], + code: [{ required: true, message: "请输入类型编码", trigger: ["change", "blur"] }], + isBringFamily: [{ required: true, message: "请选择是否携带家属", trigger: ["blur", "change"] }], + isAddFamily: [{ required: true, message: "请选择家属是否纳入总人数", trigger: ["blur", "change"] }] + }, + columnTypeOptions: [], + columnFormTypeList: [], + clickRow: {}, + paramFormRules: { + selectValues: [{ required: true, message: "请选择选项列表", trigger: ["blur"] }], + fileType: [{ required: true, message: "请选择文件类型", trigger: ["blur"] }], + fileNumber: [{ required: true, message: "请输入文件个数", trigger: ["blur", "change"] }] + }, + detailedParamsVisible: false, + } + }, + methods: { + isBringFamilyInput(o) { + this.$set(this.formData, "isAddFamily", o === true ? false : null) + if (o === true) { + this.formData.smartBenefitsMobileSignColumnList.unshift({ + columnName: "携带亲属人数", + columnCode: "xdqsrs", + columnFormType: "INPUT", + columnType: "INT", + isRequired: true + }) + } else { + this.formData.smartBenefitsMobileSignColumnList?.forEach((item, index) => { + if (item.columnCode === "xdqsrs" && this.formData.isBringFamily === false) { + this.formData.smartBenefitsMobileSignColumnList.splice(index, 1) + } + }) + } + }, + columnFormTypeChange(val, index) { + if (val === "FILE") { + this.formData.smartBenefitsMobileSignColumnList[index].columnType = "JSON" + this.formData.smartBenefitsMobileSignColumnList[index].isDisabled = true + } else { + this.formData.smartBenefitsMobileSignColumnList[index].columnType = "" + this.formData.smartBenefitsMobileSignColumnList[index].isDisabled = false + } + }, + doHandle() { + if (this.formData.id) { + this.doEdit() + } else { + this.doAdd() + } + }, + async doDetailParams() { + const isValid = await this.$refs["paramForm"].validate() + if (isValid) { + this.detailedParamsVisible = false + } + }, + openDetailedParams(row, index) { + this.clickRow = row + this.detailedParamsVisible = true + if (this.$refs["paramForm"]) this.$refs["paramForm"].clearValidate() + }, + doAdd() { + this.$refs["addForm"].validate((valid) => { + if (valid) { + const newListLength = new Set(this.formData.smartBenefitsMobileSignColumnList.map((item) => item.columnCode)).size + const listLength = this.formData.smartBenefitsMobileSignColumnList.length + if (listLength > newListLength) { + this.$message.warning('字段编码不能重复') + return + } + const cloneData = clone(this.formData) + this.$axios.post(loc() + "/doAdd", { data: JSON.stringify(cloneData) }).then((res) => { + if (res.code === 0) { + this.$message.success(res.msg) + this.$emit('refresh') + } else { + this.$message.error(res.msg) + } + }) + } + }) + }, + doEdit() { + this.$refs["addForm"].validate((valid) => { + if (valid) { + const newListLength = new Set(this.formData.smartBenefitsMobileSignColumnList.map((item) => item.columnCode)).size + const listLength = this.formData.smartBenefitsMobileSignColumnList.length + if (listLength > newListLength) { + this.$message.warning('字段编码不能重复') + return + } + const cloneData = clone(this.formData) + cloneData.smartBenefitsMobileSignColumnList = JSON.stringify(cloneData.smartBenefitsMobileSignColumnList) + this.$axios.post(loc() + "/doEdit", cloneData).then((res) => { + if (res.code === 0) { + this.$message.success(res.msg) + this.$emit('refresh') + } else { + this.$message.error(res.msg) + } + }) + } + }) + }, + async getColTypeOptions() { + const resp = await this.$axios.get(loc() + "/getColumnType") + this.columnTypeOptions = resp.data + }, + async getEnumOptions() { + const resp = await this.$axios.post("/open/common/dictEnumOptions", { name: "ColumnFormTypeEnum" }) + return resp.data + }, + initData(row) { + if(row && row.id) { + this.formData = JSON.parse(JSON.stringify(row)) + this.formData.smartBenefitsMobileSignColumnList?.forEach((item) => { + item.isDisabled = item.columnFormType === "FILE" + }) + } else { + this.formData = { + smartBenefitsMobileSignColumnList: [{ isRequired: false }], + isBringFamily: false, + isAddFamily: false, + selfAddFamily: true, + } + if (this.$refs["addForm"]) this.$refs["addForm"].resetFields() + } + }, + }, + async created() { + await this.getColTypeOptions() + this.columnFormTypeList = await this.getEnumOptions() + }, + style: /*language=CSS*/ ` + + ` +} diff --git a/src/main/resources/views/platform/zhgh/activity/smartbenefits/type/index.html b/src/main/resources/views/platform/zhgh/activity/smartbenefits/type/index.html new file mode 100644 index 00000000..cd84b021 --- /dev/null +++ b/src/main/resources/views/platform/zhgh/activity/smartbenefits/type/index.html @@ -0,0 +1,120 @@ + + + + +
+ + + + + + +
+ + diff --git a/src/main/resources/views/platform/zhgh/activity/smartbenefits/userAdjust/applyForm.js b/src/main/resources/views/platform/zhgh/activity/smartbenefits/userAdjust/applyForm.js new file mode 100644 index 00000000..12a02af7 --- /dev/null +++ b/src/main/resources/views/platform/zhgh/activity/smartbenefits/userAdjust/applyForm.js @@ -0,0 +1,246 @@ +const applyForm = { + template: /*language=HTML*/ ` +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 取 消 + 提 交 + + +
+ `, + store, + dicts: ["TRAIN_SIGNUP_TYPE"], + data() { + return { + signDialog: false, + formData: {}, + courseRow: {}, + courseTimeSelectList: [], + } + }, + methods: { + async getCourseTimeSelectList(o) { + const resp = await $.post('/platform/smartbenefits/apply/getCourseTimeSelectList',{ courseId: o.id }) + if (resp.code === 0) { + this.courseTimeSelectList = resp.data + } else { + this.$message.warning('获取时段信息失败,请联系管理员') + } + }, + async onOpen(row, course) { + this.initData(row, course) + if (row.courseIsLimitApply) { + await this.getCourseTimeSelectList(row) + } + this.courseRow = row + this.signDialog = true + this.$nextTick(() => { + this.$refs.form.clearValidate() + }) + }, + async validateSignUp() { + // 获取家属人数 + let familyCount = this.formData.smartBenefitsMobileSignColumnList.filter(o => o.columnCode === 'xdqsrs').reduce((sum, item) => { + return sum + (Number(item.columnValue) || 0) + }, 0) + const res = await this.$axios.post("/platform/smartbenefits/apply/validateSignUp", { + courseId: this.formData.courseId, + currentFamilyNumber: familyCount, + IsVerifyUserApply: "1" + }) + return res.code === 0 + }, + async validateCourseTime() { + const res = await this.$axios.post('/platform/smartbenefits/apply/validateSourceSignUp', { + activityCourseId: this.formData.activityCourseId, + courseId: this.courseRow.id + }) + return res.code === 0 + }, + async onSubmit() { + if(!await this.validateSignUp()) return + + if(!this.formData.username) { + this.$message.warning("请选择参加人员") + return ; + } + + this.$refs["form"].validate(async (valid) => { + if (valid) { + if(this.courseRow.courseIsLimitApply && !await this.validateCourseTime()) return + this.$confirm("您确定要提交吗?", "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning" + }).then(async () => { + const mobileColumnsValue = this.formData.smartBenefitsMobileSignColumnList.map((v) => { + return { + columnName: v.columnName, + columnValue: v.columnValue, + columnCode: v.columnCode, + columnFormType: v.columnFormType + } + }) + this.formData.mobileColumnsValue = JSON.stringify(mobileColumnsValue) + const resp = await this.$axios.post("/platform/smartbenefits/apply/doSignUpInsteadApply", this.formData) + if (resp.code === 0) { + this.signDialog = false + this.$message.success(resp.msg) + this.$emit('refresh') + this.formData.userId = ''; + this.formData.username = ''; + this.formData.loginname = ''; + this.formData.unionName = ''; + this.formData.unitName = ''; + this.formData.sex = ''; + } else { + this.$message.warning(resp.msg) + } + }) + } + }) + }, + initData(row, course) { + + this.$set(this.formData, 'activityId', row.activityId) + this.$set(this.formData, 'courseId', row.id) + this.$set(this.formData, 'smartBenefitsMobileSignColumnList', course.smartBenefitsMobileSignColumnList) + + this.formData.smartBenefitsMobileSignColumnList.forEach((item) => { + item.columnValue = this.$store.state.user[item.columnCode] || "" + }) + }, + selectUserFun() { + if(this.$refs.useRef.options){ + let event = this.$refs.useRef.options.find(item => item.id === this.formData.userId); + if(event){ + this.$set(this.formData, 'username', event.username) + this.$set(this.formData, 'loginname', event.loginname) + this.$set(this.formData, 'unionName', event.unionName) + this.$set(this.formData, 'unitName', event.unitName) + this.$set(this.formData, 'sex', event.sex) + } + } + } + }, + style: /*language=CSS*/ ` + + ` +} diff --git a/src/main/resources/views/platform/zhgh/activity/smartbenefits/userAdjust/index.html b/src/main/resources/views/platform/zhgh/activity/smartbenefits/userAdjust/index.html new file mode 100644 index 00000000..7416783d --- /dev/null +++ b/src/main/resources/views/platform/zhgh/activity/smartbenefits/userAdjust/index.html @@ -0,0 +1,162 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + diff --git a/src/main/resources/views/platform/zhgh/activity/smartbenefits/userAdjust/userInfo.js b/src/main/resources/views/platform/zhgh/activity/smartbenefits/userAdjust/userInfo.js new file mode 100644 index 00000000..1c336158 --- /dev/null +++ b/src/main/resources/views/platform/zhgh/activity/smartbenefits/userAdjust/userInfo.js @@ -0,0 +1,229 @@ +const userInfo = { + template: /*language=HTML*/ ` +
+
{{ registerCourse.courseName + '报名人员' }}
+
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + 注:如单选为灰色选择不了,则表示对应的{{ trainType }}人数已满!候补报名不做调整。 + + + + + + + + + + + + + 取 消 + 确 定 + + +
+ `, + dicts: ["TRAIN_SIGNUP_TYPE"], + data() { + return { + afterAdjustCourse: "", + adjustDialogVisible: false, + unionList: [], + unitList: [], + registerForm: { + unionId: "", + unitId: "" + }, + registerCourse: {}, + courseList: [], + userInfo: {}, + chooseRow: {}, + registerUserTableData: [], + registerUserTableColumns: [ + { label: "姓名", prop: "username" }, + { label: "工号", prop: "loginname" }, + { label: "单位", prop: "unitName" }, + { label: "分工会", prop: "unionName" }, + { label: "联系方式", prop: "mobile" }, + { label: "报名时间", prop: "signUpTime" }, + { label: "报名状态", prop: "state" } + ], + trainType: '', + activity: {}, + } + }, + methods: { + async onOpen(row, activity) { + this.registerCourse = row + this.registerForm.courseId = row.id + this.activity = activity + const resp_register = await this.$axios.post(loc() + "/registerUserList", this.registerForm) + this.registerUserTableData = resp_register.data + + const type = this.dict.type.TRAIN_SIGNUP_TYPE.find(o => o.code === activity.trainType) + this.trainType = type?.name || "培训班" + }, + getCurrentRow(row) { + this.chooseRow = row + }, + async doAdjust() { + if (!this.afterAdjustCourse) { + this.$message.warning("请选择要调整的" + this.trainType + "!") + return + } + this.$confirm( + "您确定要将" + + "" + + this.userInfo.username + + "" + + "的报名信息调整到" + + "" + + this.chooseRow.courseName + + "" + + "中吗?", + "提示", + { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning", + dangerouslyUseHTMLString: true + } + ) + .then(async () => { + const loading = this.$loading({ + lock: true, + text: "努力调整中,感谢您的耐心等待。。。", + spinner: "el-icon-loading", + background: "rgba(0, 0, 0, 0.7)" + }) + const resp = await this.$axios.post(loc() + "/adjust", { + activityId: this.activity.id, + oldCourseId: this.registerCourse.id, + newCourseId: this.afterAdjustCourse, + userId: this.userInfo.userId + }) + loading.close() + if (resp.code === 0) { + this.$message.success(resp.msg) + this.adjustDialogVisible = false + await this.registerSearch() + this.$emit("refresh", null) + } else { + this.$message.warning(resp.msg) + } + }) + .catch(() => {}) + }, + async adjust(o) { + this.userInfo = o + this.afterAdjustCourse = "" + await this.getCourse(this.activity.id) + this.adjustDialogVisible = true + }, + deleteSignUser(o) { + this.$confirm("您确定要删除" + "" + o.username + "" + "的报名信息吗?", "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning", + dangerouslyUseHTMLString: true + }) + .then(async () => { + const resp = await this.$axios.post(loc() + "/deleteSignUser", { + activityId: this.activity.id, + courseId: this.registerCourse.id, + userId: o.userId + }) + if (resp.code === 0) { + this.$message.success(resp.msg) + await this.registerSearch() + this.$emit("refresh", null) + } else { + this.$message.warning(resp.msg) + } + }) + .catch(() => {}) + }, + async registerSearch() { + this.registerForm.courseId = this.registerCourse.id + const resp_register = await $.get(loc() + "/registerUserList", this.registerForm) + this.registerUserTableData = resp_register.data + }, + async getCourse(val) { + const {data} = await this.$axios.post(loc() + "/getCourse", {activityId: val}) + this.courseList = data + }, + async getUnitList() { + this.unitList = await this.$businessTool.listUnit(this.registerForm.unionId) + } + }, + async created() { + this.unionList = await this.$businessTool.listUnion() + this.unitList = await this.$businessTool.listUnit(this.registerForm.unionId) + }, + style: /*language=CSS*/ ` + /deep/ .adjustDialog .el-radio__label { + display: none; + } + /deep/ .adjustDialog .el-dialog__body { + max-height: 600px; + overflow-y: auto; + } + ` +} diff --git a/src/main/resources/views/platform/zhgh/activity/smartbenefits/userManage/index.html b/src/main/resources/views/platform/zhgh/activity/smartbenefits/userManage/index.html new file mode 100644 index 00000000..b2f818ba --- /dev/null +++ b/src/main/resources/views/platform/zhgh/activity/smartbenefits/userManage/index.html @@ -0,0 +1,242 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + 补充人员 + 导出签到名单 + 导出领取名单 + + + + + + + + + + + + + + + + + + + + + + + + + + + + 取 消 + 确 定 + + +
+ + + + diff --git a/src/main/resources/views/platform/zhghh5/activity/smartbenefits/apply/index.html b/src/main/resources/views/platform/zhghh5/activity/smartbenefits/apply/index.html new file mode 100644 index 00000000..8dff10f1 --- /dev/null +++ b/src/main/resources/views/platform/zhghh5/activity/smartbenefits/apply/index.html @@ -0,0 +1,170 @@ + + + + +
+ + + + + + + + + + + + + + + + +
+
+ +
{{infoRow.activityName}}
+ +
+
+ + + 去报名 + + + +
+
+
+ +
+ + + + diff --git a/src/main/resources/views/platform/zhghh5/activity/smartbenefits/common/times.js b/src/main/resources/views/platform/zhghh5/activity/smartbenefits/common/times.js new file mode 100644 index 00000000..7a84d091 --- /dev/null +++ b/src/main/resources/views/platform/zhghh5/activity/smartbenefits/common/times.js @@ -0,0 +1,229 @@ +const times = { + template: + /*language=HTML*/ + ` +
+ +
+ +
+ + + + +
+ `, + store, + data() { + return { + visible: false, + row: null, + weekdayCNMap: {0: '周日', 1: '周一', 2: '周二', 3: '周三', 4: '周四', 5: '周五', 6: '周六'}, + + selectCourseTime: {}, + signVisible: false, + + markerLayer: null, + map: null, + circle: null, + } + }, + components: { + "scan-code": httpVueLoader("/components/plugins/sysScanCode/index.vue?v=" + new Date().getTime()) + }, + methods: { + onSignClose() { + this.$refs.scanCodeRef.closeScan() + }, + onOpen(row) { + this.row = row + this.visible = true + this.$nextTick(() => { + if (this.row.signType === 3) { + if (this.map) this.map.destroy() + this.initMap() + this.getLocation((coords) => { + if (coords) { + const center = new TMap.LatLng(coords.lat, coords.lng) + this.markerLayer.remove(["current"]) + this.createMarker(center, 'current', 'current') + } + }) + } + }) + }, + async onSign(courseTime) { + this.selectCourseTime = courseTime + if (this.row.signType === 1) { + this.signVisible = true + this.$nextTick(() => { + this.$refs.scanCodeRef.init() + }) + } + if (this.row.signType === 2) { + this.makeCode() + } + if (this.row.signType === 3) { + this.getLocation((coords) => { + if (coords) { + this.$axios.post('/platform/smartbenefits/mine/positionSign', { + timeId: courseTime.id, + courseId: this.row.id, + lat: coords.lat, + lng: coords.lng + }).then(res => { + if (res.code === 0) { + this.$toast('签到成功') + this.visible = false + } else { + this.$toast(res.msg) + this.markerLayer.remove(["current"]) + this.getLocation((coords) => { + if (coords) { + const center = new TMap.LatLng(coords.lat, coords.lng) + this.createMarker(center, 'current', 'current') + } + }) + } + }) + } + }) + } + }, + getLocation(callback) { + if (typeof callback !== 'function') { + callback = () => { + }; + } + if (!navigator.geolocation) { + this.$toast('当前浏览器不支持定位功能'); + callback(null); + return; + } + const loading = vant.Toast.loading({ + message: "获取定位中...", + forbidClick: false, + loadingType: "spinner", + duration: 0, + }) + navigator.geolocation.getCurrentPosition( + (position) => { + callback({ + lat: position.coords.latitude, + lng: position.coords.longitude + }); + loading.close() + }, + (error) => { + let msg = '定位失败,请稍后重试'; + switch (error.code) { + case error.PERMISSION_DENIED: + msg = '请允许浏览器获取位置信息'; + break; + case error.POSITION_UNAVAILABLE: + msg = '无法获取当前位置'; + break; + case error.TIMEOUT: + msg = '定位超时,请重试'; + break; + } + this.$toast(msg); + callback(null); + loading.close() + }, + { + enableHighAccuracy: true, + timeout: 10000, + maximumAge: 60000 + } + ); + }, + initMap() { + if (!this.row.courseLocationCoordinates) { + this.$toast('未设置签到点') + return + } + const posi = JSON.parse(this.row.courseLocationCoordinates) + const center = new TMap.LatLng(posi[0], posi[1]) + this.map = new TMap.Map('mapContainer', { + resizeEnable: true, + zoom: 16, + center: center + }) + this.markerLayer = new TMap.MultiMarker({ + map: this.map, + styles: { + "current": new TMap.MarkerStyle({ + "src": "https://mapapi.qq.com/web/bundles/lbs-home/prod/assets/markerActive-NhH9NoBV.png", + "width": 40, // 点标记样式宽度(像素) + }) + }, + geometries: [] + }) + this.createMarker(center) + this.createCircle(center) + }, + createMarker(position, styleId = 'marker', id = 'marker_' + Date.now()) { + this.markerLayer.add([ + { + id: id, + position: position, + styleId: styleId + } + ]); + }, + createCircle(position) { + this.circle = new TMap.MultiCircle({ + map: this.map, + geometries: [{ + center: position, + radius: this.row.radius || 100, + }], + }); + }, + makeCode() { + const url = '/platform/smartbenefits/mine/passiveScan' + const data = url + '?id=' + this.selectCourseTime.id + console.log(data) + const content = jrQrcode.getQrBase64(data) + vant.ImagePreview([content]) + }, + onClose() { + this.visible = false + }, + }, + style: /*language=CSS*/ ` + + ` +} diff --git a/src/main/resources/views/platform/zhghh5/activity/smartbenefits/list/applyForm.js b/src/main/resources/views/platform/zhghh5/activity/smartbenefits/list/applyForm.js new file mode 100644 index 00000000..b046af28 --- /dev/null +++ b/src/main/resources/views/platform/zhghh5/activity/smartbenefits/list/applyForm.js @@ -0,0 +1,159 @@ +const applyForm = { + template: + /*language=HTML*/ + ` +
+ + + + + + + + + + + + + + + + + +
+ 提交 +
+
+
+
+ `, + data() { + return { + row: {}, + activity: {}, + dynamicColumnsData: [], + visible: false, + formData: {}, + showCoursePicker: false, + courseTimeSelectList: [], + } + }, + components: { + "train-dynamic-form": httpVueLoader("/components/module/smartBenefits/TrainDynamicForm.vue") + }, + methods: { + async onOpen(row, courseType) { + this.row = row + this.init(row, courseType) + if(row.courseIsLimitApply) { + await this.getCourseTimeSelectList(row) + } + this.visible = true + }, + init(row, courseType) { + this.$set(this.formData, 'username', this.$store.state.user.username) + this.$set(this.formData, 'loginname', this.$store.state.user.loginname) + this.$set(this.formData, 'unionName', this.$store.state.user.union.name) + this.$set(this.formData, 'unitName', this.$store.state.user.unit.name) + this.$set(this.formData, 'sex', this.$store.state.user.sex) + this.$set(this.formData, 'activityId', row.activityId) + this.$set(this.formData, 'courseId', row.id) + + this.dynamicColumnsData = courseType ? courseType.trainMobileSignColumnList : [] + this.dynamicColumnsData.forEach((item) => { + item.columnValue = this.$store.state.user[item.columnCode] || "" + }) + }, + onCourseConfirm(val){ + this.formData.activityCourseId = val.value + this.$set(this.formData, "activityCourseId", val.value) + this.$set(this.formData, "courseTimeName", val.text.substring(0, 12)) + this.showCoursePicker = false + }, + async getCourseTimeSelectList(o) { + const resp = await this.$axios.post('/platform/smartbenefits/apply/getCourseTimeSelectList',{courseId: o.id}) + if (resp.code === 0) { + this.courseTimeSelectList = resp.data + } else { + this.$toast.fail("获取时段信息失败,请联系管理员") + } + }, + async validateSignUp() { + // 验证自定义表单 + await this.$refs.dynamicForm.$refs.form.validate() + // 获取家属人数 + let familyCount = this.dynamicColumnsData.filter(o => o.columnCode === 'xdqsrs').reduce((sum, item) => { + return sum + (Number(item.columnValue) || 0) + }, 0) + + const res = await this.$axios.post("/platform/smartbenefits/apply/validateSignUp", { + courseId: this.formData.courseId, + currentFamilyNumber: familyCount + }) + return res.code === 0 + }, + async validateCourseTime() { + const res = await this.$axios.post('/platform/smartbenefits/apply/validateSourceSignUp', { + activityCourseId: this.formData.activityCourseId, + courseId: this.row.id + }) + return res.code === 0 + }, + async onSubmit() { + if(!await this.validateSignUp()) return + + this.$refs.formRef.validate().then(() => { + this.$dialog.confirm({ + title: "提示", + message: "您确定要提交吗?" + }).then(async () => { + if (this.row.courseIsLimitApply) { + if(!await this.validateCourseTime()) return + } + + const mobileColumnsValue = this.dynamicColumnsData.map((v) => { + return { + columnName: v.columnName, + columnValue: v.columnValue, + columnCode: v.columnCode, + columnFormType: v.columnFormType + } + }) + this.formData.mobileColumnsValue = JSON.stringify(mobileColumnsValue) + this.$axios.post("/platform/smartbenefits/apply/doSignUp", this.formData).then(res => { + if (res.code === 0) { + this.$toast(res.msg) + this.visible = false + this.$emit('refresh') + } + }) + }) + }) + }, + }, + style: /*language=CSS*/ ` + /deep/ .button { + position: fixed; + bottom: 0; + width: 100%; + } + ` +} diff --git a/src/main/resources/views/platform/zhghh5/activity/smartbenefits/list/index.html b/src/main/resources/views/platform/zhghh5/activity/smartbenefits/list/index.html new file mode 100644 index 00000000..297eff2f --- /dev/null +++ b/src/main/resources/views/platform/zhghh5/activity/smartbenefits/list/index.html @@ -0,0 +1,255 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + diff --git a/src/main/resources/views/platform/zhghh5/activity/smartbenefits/mine/index.html b/src/main/resources/views/platform/zhghh5/activity/smartbenefits/mine/index.html new file mode 100644 index 00000000..d17ead9e --- /dev/null +++ b/src/main/resources/views/platform/zhghh5/activity/smartbenefits/mine/index.html @@ -0,0 +1,132 @@ + + + + +
+ + + + + + + + + + + + + + + + +
+
+ +
{{infoRow.activityName}}
+ +
+
+
+ +
+ + + + diff --git a/src/main/resources/views/platform/zhghh5/activity/smartbenefits/scan/index.html b/src/main/resources/views/platform/zhghh5/activity/smartbenefits/scan/index.html new file mode 100644 index 00000000..9d3d606b --- /dev/null +++ b/src/main/resources/views/platform/zhghh5/activity/smartbenefits/scan/index.html @@ -0,0 +1,149 @@ + + + + +
+ + +
+
+
+ + +
+
+
温馨提醒
+
+
+ +
+
+ + + +