小程序
This commit is contained in:
@@ -29,6 +29,11 @@ public class RedisConstant {
|
||||
public final static String REDIS_KEY_API_SIGN_DEPLOY_NONCE = PLATFORM_REDIS_PREFIX + "api:sign:deploy:nonce:";
|
||||
public final static String REDIS_KEY_API_SIGN_OPEN_NONCE = PLATFORM_REDIS_PREFIX + "api:sign:open:nonce:";
|
||||
|
||||
//健步走小程序TOKEN
|
||||
public final static String REDIS_KEY_WE_APP_ACCESS_TOKEN = PLATFORM_REDIS_PREFIX + "weapp:token:";
|
||||
|
||||
// 健步走登录验证码前缀
|
||||
public final static String REDIS_KEY_FITNESS_WALK_LOGIN_CAPTCHA = PLATFORM_REDIS_PREFIX + "fitnessWalk:login:captcha:";
|
||||
|
||||
/**
|
||||
* Token 缓存前缀
|
||||
|
||||
@@ -14,6 +14,7 @@ public enum LoginType {
|
||||
WECHAT("微信"),
|
||||
PC_LOCAL("PC本地"),
|
||||
MOBILE_LOCAL("手机本地"),
|
||||
WE_APP("小程序"),
|
||||
CAS("CAS");
|
||||
|
||||
private final String value;
|
||||
|
||||
@@ -140,6 +140,45 @@ public class SysLoginController {
|
||||
return ">>:" + sysUserService.loginPlus(sysUser, LoginType.CAS, request);
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@ApiOperation("小程序账号密码登录")
|
||||
public Result weAppLogin(@Param("username") String username, @Param("password") String password, HttpServletRequest req) {
|
||||
if (StrUtil.isBlank(username)) {
|
||||
return Result.error("用户名不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(password)) {
|
||||
return Result.error("密码不能为空");
|
||||
}
|
||||
|
||||
String lockKey = RedisConstant.USER_LOGIN_LOCK_PREFIX + username;
|
||||
int errCount = Convert.toInt(StrUtil.blankToDefault(redisService.get(lockKey), "0"));
|
||||
log.info("用户名:" + username + "登录失败次数:" + errCount);
|
||||
|
||||
if (errCount > 5) {
|
||||
redisService.setex(lockKey, 5 * 60, String.valueOf(errCount + 1));
|
||||
return Result.error("登录失败次数过多,请5分钟后再试");
|
||||
}
|
||||
|
||||
try {
|
||||
Sys_user user = sysUserService.loginByIdCardLastNum(username, password);
|
||||
if (user == null) {
|
||||
throw new BaseException("用户登录失败");
|
||||
}
|
||||
|
||||
sysUserService.loginPlus(user, LoginType.WE_APP, req);
|
||||
return Result.success("login.success").addData(StpUtil.getTokenInfo());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
redisService.set(lockKey, Convert.toStr(errCount + 1));
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@At(value = "/platform/wxwork/oauth2/callback", top = true)
|
||||
@Ok("re")
|
||||
@ApiOperation("企业微信登录回调")
|
||||
|
||||
@@ -154,6 +154,17 @@ public interface SysUserService extends BaseService<Sys_user> {
|
||||
*/
|
||||
Sys_user loginByLoginName(String loginname);
|
||||
|
||||
|
||||
/**
|
||||
* 通过身份证后6位获取用户信息
|
||||
*
|
||||
* @param loginname 用户名
|
||||
* @param pwd 密码
|
||||
* @return
|
||||
* @throws BaseException
|
||||
*/
|
||||
Sys_user loginByIdCardLastNum(String loginname, String pwd);
|
||||
|
||||
/**
|
||||
* 通过用户名获取用户信息
|
||||
*
|
||||
|
||||
@@ -2,10 +2,8 @@ package com.budwk.app.sys.services.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.codec.Base64Decoder;
|
||||
import cn.hutool.core.codec.Base64Encoder;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.digest.DigestUtil;
|
||||
import com.budwk.app.base.constant.RedisConstant;
|
||||
import com.budwk.app.base.enums.LoginType;
|
||||
import com.budwk.app.base.exception.BaseException;
|
||||
@@ -19,6 +17,7 @@ import com.budwk.app.sys.services.SysRoleService;
|
||||
import com.budwk.app.sys.services.SysUserService;
|
||||
import com.budwk.app.sys.views.View_user;
|
||||
import com.budwk.app.web.commons.base.Globals;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
@@ -31,7 +30,6 @@ import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheDefaults;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheRemove;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheRemoveAll;
|
||||
@@ -341,6 +339,31 @@ public class SysUserServiceImpl extends BaseServiceImpl<Sys_user> implements Sys
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sys_user loginByIdCardLastNum(String loginname, String pwd) {
|
||||
Sys_user user = this.fetch(Cnd.where("loginname", "=", loginname));
|
||||
if (user == null) {
|
||||
// 防止暴力破解
|
||||
throw new BaseException("用户名或者密码不正确");
|
||||
}
|
||||
if (user.isDisabled()) {
|
||||
throw new BaseException("用户被禁用");
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(user.getIdCard()) || (user.getIdCard().length() < 6) ||
|
||||
(!pwd.equals(StringUtils.right(user.getIdCard(), 6)))) {
|
||||
throw new BaseException("账号或密码错误");
|
||||
}
|
||||
|
||||
user = this.fetchLinks(user, "unit");
|
||||
if (Lang.isNotEmpty(user.getUnit()) && StrUtil.isNotBlank(user.getUnit().getUnionId())) {
|
||||
Sys_union union = dao().fetch(Sys_union.class, user.getUnit().getUnionId());
|
||||
user.setUnion(union);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
|
||||
// 这里不能用缓存,因为没有 userId 没法用前缀清除,会造成缓存清除不干净
|
||||
@Override
|
||||
public Sys_user getUserByLoginname(String loginname) throws BaseException {
|
||||
|
||||
@@ -48,4 +48,6 @@ public interface TaskPlatformService {
|
||||
* @return
|
||||
*/
|
||||
List<String> getCronExeTimes(String cronExpression) throws Exception;
|
||||
|
||||
List<String> getCronExeTimesPlus(String cronExpression) throws Exception;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.nutz.integration.quartz.QuartzJob;
|
||||
import org.nutz.integration.quartz.QuartzManager;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.quartz.CronExpression;
|
||||
import org.quartz.JobKey;
|
||||
import org.quartz.TriggerUtils;
|
||||
import org.quartz.impl.triggers.CronTriggerImpl;
|
||||
@@ -96,4 +97,22 @@ public class TaskPlatformServiceImpl implements TaskPlatformService {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getCronExeTimesPlus(String cronExpression) throws Exception {
|
||||
// 创建一个列表来存储执行时间
|
||||
List<String> executionTimes = new ArrayList<>();
|
||||
// 创建 CronTriggerImpl 对象,并设置 cron 表达式
|
||||
CronTriggerImpl cronTrigger = new CronTriggerImpl();
|
||||
cronTrigger.setCronExpression(new CronExpression(cronExpression));
|
||||
// 计算未来的执行时间
|
||||
List<Date> nextExecutionTimes = TriggerUtils.computeFireTimes(cronTrigger, null, 5);
|
||||
// 格式化日期并添加到执行时间列表中
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
for (Date date : nextExecutionTimes) {
|
||||
executionTimes.add(dateFormat.format(date));
|
||||
}
|
||||
return executionTimes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,10 +95,14 @@ public class WkFailProcessor extends ViewProcessor {
|
||||
}
|
||||
return;
|
||||
} else if (e instanceof UnknownAccountException) {
|
||||
new ServerRedirectView(Globals.AppDomain + errorUnknownAccountUri).render(ac.getRequest(), ac.getResponse(), null);
|
||||
if (WebUtil.isAjax(ac.getRequest())) {
|
||||
WebUtil.rendAjaxResp(ac.getRequest(), ac.getResponse(), Result.error(ResultCode.USER_NAME_ERROR.getCode(), e.getMessage()));
|
||||
} else {
|
||||
new ServerRedirectView(Globals.AppDomain + errorUnknownAccountUri).render(ac.getRequest(), ac.getResponse(), null);
|
||||
}
|
||||
} else if (e instanceof NotLoginException) { // 如果是未登录异常
|
||||
if (WebUtil.isAjax(ac.getRequest())) {
|
||||
WebUtil.rendAjaxResp(ac.getRequest(), ac.getResponse(), Result.error(e.getMessage()));
|
||||
WebUtil.rendAjaxResp(ac.getRequest(), ac.getResponse(), Result.error(ResultCode.USER_NOT_LOGIN.getCode(), e.getMessage()));
|
||||
} else {
|
||||
ac.getRequest().setAttribute("original_request_uri", ac.getRequest().getRequestURI());
|
||||
ac.getRequest().setAttribute("error_message", Mvcs.getMessage(ac.getRequest(), e.getMessage()));
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ public class ActivityCultureServiceImpl extends BaseServiceImpl<ActivityTissue>
|
||||
SELECT
|
||||
gh.id,
|
||||
gh.name unionname,
|
||||
( SELECT count( 1 ) FROM `user` WHERE id IN ( SELECT userid FROM activity_user_scope WHERE groupId = @activityScopeGroupId ) AND unionId = gh.id ) as teacherCount
|
||||
( SELECT count( 1 ) FROM `view_user` WHERE id IN ( SELECT userid FROM activity_user_scope WHERE groupId = @activityScopeGroupId ) AND unionId = gh.id ) as teacherCount
|
||||
|
||||
FROM
|
||||
sys_union gh
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.contants;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class Cascader {
|
||||
private String value;
|
||||
private String label;
|
||||
private List<Cascader> children;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.contants;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum FitnessWalkMode {
|
||||
|
||||
PUNCH("punch", "打卡"),
|
||||
STEP_COUNT("stepCount", "计步"),
|
||||
GPS("gps", "GPS");
|
||||
|
||||
|
||||
private final String value;
|
||||
private final String desc;
|
||||
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.budwk.app.base.constant.RoleConstant;
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.web.commons.auth.utils.AuthUtil;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.utils.WeAppCloudUtil;
|
||||
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.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@IocBean
|
||||
@Ok("json")
|
||||
@At("/platform/fitnessWalk/bindingRecord")
|
||||
public class FitnessWalkActivityBindingRecordController {
|
||||
|
||||
@Inject
|
||||
private WeAppCloudUtil weAppCloudUtil;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zhgh/activity/fitnessWalk/bindingRecord.html")
|
||||
@SaCheckPermission("fitnessWalk.bindingRecord")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@At
|
||||
@SaCheckPermission("fitnessWalk.bindingRecord")
|
||||
public Result pageData(@Param(value = "keyWord") String keyWord,
|
||||
@Param(value = "unionId") String unionId,
|
||||
@Param(value = "searchName") String searchName,
|
||||
@Param(value = "searchKeyword") String searchKeyword,
|
||||
@Param("pageNumber") int pageNumber,@Param("pageSize") int pageSize,
|
||||
@Param(value = "pageOrderName") String pageOrderName,
|
||||
@Param(value = "pageOrderBy") String pageOrderBy) throws IOException {
|
||||
int skip = (pageNumber == 1 ? 0 : (pageNumber - 1)) * pageSize;
|
||||
|
||||
StringBuilder sql = new StringBuilder("db.collection('login_record')");
|
||||
if (StrUtil.isNotBlank(keyWord)) {
|
||||
sql.append(".where(");
|
||||
sql.append("_.or([");
|
||||
sql.append("{loginname:{$regex:'").append(keyWord).append("',$options:'i'}},");
|
||||
sql.append("{username:{$regex:'").append(keyWord).append("',$options:'i'}}");
|
||||
sql.append("])");
|
||||
sql.append(")");
|
||||
}
|
||||
if (!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_ADMIN.name())) {
|
||||
sql.append(".where({'data.unionid':'").append(SecurityUtil.getUnionId()).append("'})");
|
||||
} else {
|
||||
if (Strings.isNotBlank(unionId)) {
|
||||
sql.append(".where({'data.unionid':'").append(unionId).append("'})");
|
||||
}
|
||||
}
|
||||
sql.append(".field({ data: false })");
|
||||
sql.append(".skip(").append(skip).append(")");
|
||||
sql.append(".limit(").append(pageSize).append(")");
|
||||
sql.append(".get()");
|
||||
|
||||
try {
|
||||
JSONObject jsonObject = weAppCloudUtil.request(WeAppCloudUtil.CRUD.QUERY, sql.toString());
|
||||
List<NutMap> data = jsonObject.getJSONArray("data").stream().map(v -> JSONUtil.toBean((String) v, NutMap.class)).collect(Collectors.toList());
|
||||
JSONObject pager = jsonObject.getJSONObject("pager");
|
||||
return Result.success(new Pagination(pageNumber, pageSize, pager.getInt("Total"), data));
|
||||
} catch (Exception e){
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@SaCheckPermission("fitnessWalk.bindingRecord")
|
||||
public Result delete(String[] ids) {
|
||||
try {
|
||||
String sql = "db.collection('login_record').where({_id:_.in(" + Json.toJson(ids) + ")}).remove()";
|
||||
weAppCloudUtil.request(WeAppCloudUtil.CRUD.DELETE,sql);
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@SaCheckPermission("fitnessWalk.bindingRecord")
|
||||
public Result deleteAll() {
|
||||
try {
|
||||
String sql = "db.collection('login_record').where({_id: _.neq('0')}).remove()";
|
||||
weAppCloudUtil.request(WeAppCloudUtil.CRUD.DELETE,sql);
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+346
@@ -0,0 +1,346 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.budwk.app.base.constant.RoleConstant;
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.sys.models.Sys_task;
|
||||
import com.budwk.app.sys.services.SysTaskService;
|
||||
import com.budwk.app.sys.services.SysUserService;
|
||||
import com.budwk.app.task.services.TaskPlatformService;
|
||||
import com.budwk.app.web.commons.auth.utils.AuthUtil;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.FitnessWalkActivity;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.service.FitnessWalkCommonService;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.utils.WeAppCloudUtil;
|
||||
import org.nutz.dao.Cnd;
|
||||
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.Strings;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.annotation.AdaptBy;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
import org.nutz.mvc.upload.TempFile;
|
||||
import org.nutz.mvc.upload.UploadAdaptor;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@At("/platform/fitnessWalk/activityManage")
|
||||
@Ok("json")
|
||||
@IocBean
|
||||
public class FitnessWalkActivityManageController {
|
||||
private static final Log log = Logs.get();
|
||||
@Inject
|
||||
private WeAppCloudUtil weAppCloudUtil;
|
||||
@Inject
|
||||
private TaskPlatformService taskPlatformService;
|
||||
@Inject
|
||||
private SysTaskService sysTaskService;
|
||||
@Inject
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@Inject
|
||||
private FitnessWalkCommonService fitnessWalkCommonService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zhgh/activity/fitnessWalk/activityManage.html")
|
||||
@SaCheckPermission("fitnessWalk.activityManage")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@At
|
||||
@SaCheckPermission("fitnessWalk.activityManage")
|
||||
public Result pageData(@Param(value = "year") Integer year,
|
||||
@Param(value = "unionId") String unionId,
|
||||
@Param(value = "searchName") String searchName,
|
||||
@Param(value = "searchKeyword") String searchKeyword,
|
||||
@Param("pageNumber") int pageNumber,
|
||||
@Param("pageSize") int pageSize,
|
||||
@Param(value = "pageOrderName") String pageOrderName,
|
||||
@Param(value = "pageOrderBy") String pageOrderBy) {
|
||||
|
||||
int skip = (pageNumber == 1 ? 0 : (pageNumber - 1)) * pageSize;
|
||||
|
||||
long startOfYear = DateUtil.beginOfYear(DateUtil.date(DateUtil.parse(year + "-01-01"))).getTime();
|
||||
long endOfYear = DateUtil.endOfYear(DateUtil.date(DateUtil.parse(year + "-12-31"))).getTime();
|
||||
|
||||
StringBuilder sql = new StringBuilder("db.collection('activity')");
|
||||
|
||||
if (year != null) {
|
||||
sql.append(".where(");
|
||||
sql.append("{startTime:{$gte:").append(startOfYear).append(",$lte:").append(endOfYear).append("}}");
|
||||
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
|
||||
sql.append("_.or([");
|
||||
sql.append("{name:{$regex:'").append(searchKeyword).append("',$options:'i'}}");
|
||||
sql.append("{tag:{$regex:'").append(searchKeyword).append("',$options:'i'}}");
|
||||
sql.append("])");
|
||||
}
|
||||
sql.append(")");
|
||||
}
|
||||
if (!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_ADMIN.name())) {
|
||||
sql.append(".where({unionId:'").append(SecurityUtil.getUnionId()).append("'})");
|
||||
} else if (StrUtil.isNotBlank(unionId)) {
|
||||
sql.append(".where({unionId:'").append(unionId).append("'})");
|
||||
}
|
||||
sql.append(".skip(").append(skip).append(")");
|
||||
sql.append(".limit(").append(pageSize).append(")");
|
||||
sql.append(".get()");
|
||||
try {
|
||||
JSONObject jsonObject = weAppCloudUtil.request(WeAppCloudUtil.CRUD.QUERY, sql.toString());
|
||||
List<Object> data = jsonObject.getJSONArray("data").stream()
|
||||
.map(v -> JSONUtil.toBean((String) v, FitnessWalkActivity.class))
|
||||
.collect(Collectors.toList());
|
||||
JSONObject pager = jsonObject.getJSONObject("pager");
|
||||
return Result.success(new Pagination(pageNumber, pageSize, pager.getInt("Total"), data));
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
|
||||
@SaCheckPermission("fitnessWalk.activityManage")
|
||||
public Result doAdd(String data, @Param("fitnessWalkActivity") FitnessWalkActivity fitnessWalkActivity,
|
||||
@Param("file") TempFile tempFile,
|
||||
@Param("stepFiles") TempFile[] stepFiles,
|
||||
@Param(value = "certificateFile") TempFile certificateTempFile) {
|
||||
try {
|
||||
fitnessWalkActivity.set_id(R.UU32());
|
||||
//设置时间
|
||||
if ("punch".equals(fitnessWalkActivity.getActivityModel())) {
|
||||
fitnessWalkActivity.setApplyStartTime(fitnessWalkActivity.getApplyTime()[0]);
|
||||
fitnessWalkActivity.setApplyEndTime(fitnessWalkActivity.getApplyTime()[1]);
|
||||
}
|
||||
fitnessWalkActivity.setStartTime(fitnessWalkActivity.getTime()[0]);
|
||||
fitnessWalkActivity.setEndTime(fitnessWalkActivity.getTime()[1]);
|
||||
|
||||
if (tempFile != null) {
|
||||
String fileId = weAppCloudUtil.uploadFile("activity/", tempFile.getFile());
|
||||
fitnessWalkActivity.setCover(fileId);
|
||||
}
|
||||
|
||||
if (Lang.isNotEmpty(stepFiles)) {
|
||||
List<String> stepFileIdList = new ArrayList<>();
|
||||
for (TempFile file : stepFiles) {
|
||||
String fileId = weAppCloudUtil.uploadFile("activity/", file.getFile());
|
||||
stepFileIdList.add(fileId);
|
||||
}
|
||||
fitnessWalkActivity.setRandomPics(stepFileIdList);
|
||||
}
|
||||
|
||||
if (certificateTempFile != null) {
|
||||
String fileId = weAppCloudUtil.uploadFile("activity/", certificateTempFile.getFile());
|
||||
fitnessWalkActivity.setCompletionCertificateCover(fileId);
|
||||
}
|
||||
|
||||
if (AuthUtil.hasRole(RoleConstant.BRANCH_UNION_CHAIRMAN.name()) &&
|
||||
!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_ADMIN.name())) {
|
||||
fitnessWalkActivity.setUnionId(SecurityUtil.getUnionId());
|
||||
} else {
|
||||
fitnessWalkActivity.setUnionId("");
|
||||
}
|
||||
|
||||
fitnessWalkActivity.setNote(fitnessWalkActivity.getNote().replace("\"", "'"));
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("db.collection('activity').add({data:").append(Json.toJson(fitnessWalkActivity)).append("})");
|
||||
|
||||
try {
|
||||
JSONObject jsonObject = weAppCloudUtil.request(WeAppCloudUtil.CRUD.INSERT, sql.toString());
|
||||
|
||||
fitnessWalkCommonService.addLotteryTask(fitnessWalkActivity);
|
||||
fitnessWalkCommonService.addOrEditDoSaveRedis(fitnessWalkActivity, true);
|
||||
|
||||
sysUserService.dao().insert(fitnessWalkActivity);
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("json:full")
|
||||
@SaCheckPermission("fitnessWalk.activityManage")
|
||||
public Result findOne(String id) {
|
||||
return Result.success(fitnessWalkCommonService.getActivity(id));
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckPermission("fitnessWalk.activityManage")
|
||||
public Result getFile(String pic) {
|
||||
try {
|
||||
NutMap res = NutMap.NEW();
|
||||
String imgurl = weAppCloudUtil.httpFile(pic);
|
||||
HashMap<String, Object> imgmap = new HashMap<>();
|
||||
imgmap.put("status", "success");
|
||||
imgmap.put("name", imgurl.substring(imgurl.lastIndexOf("/") + 1));
|
||||
imgmap.put("id", imgurl);
|
||||
imgmap.put("url", imgurl);
|
||||
res.setv("img", imgmap);
|
||||
return Result.success().addData(res);
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
|
||||
@SaCheckPermission("fitnessWalk.activityManage")
|
||||
public Result doEdit(@Param("fitnessWalkActivity") FitnessWalkActivity fitnessWalkActivity,
|
||||
@Param(value = "file") TempFile tempFile,
|
||||
@Param("stepFiles") TempFile[] stepFiles,
|
||||
@Param(value = "certificateFile") TempFile certificateTempFile) {
|
||||
//设置时间
|
||||
if ("punch".equals(fitnessWalkActivity.getActivityModel())) {
|
||||
fitnessWalkActivity.setApplyStartTime(fitnessWalkActivity.getApplyTime()[0]);
|
||||
fitnessWalkActivity.setApplyEndTime(fitnessWalkActivity.getApplyTime()[1]);
|
||||
}
|
||||
fitnessWalkActivity.setStartTime(fitnessWalkActivity.getTime()[0]);
|
||||
fitnessWalkActivity.setEndTime(fitnessWalkActivity.getTime()[1]);
|
||||
|
||||
if (tempFile != null) {
|
||||
String fileId = weAppCloudUtil.uploadFile("activity/", tempFile.getFile());
|
||||
fitnessWalkActivity.setCover(fileId);
|
||||
}
|
||||
|
||||
if (Lang.isNotEmpty(stepFiles)) {
|
||||
List<String> stepFileIdList = new ArrayList<>();
|
||||
for (TempFile file : stepFiles) {
|
||||
String fileId = weAppCloudUtil.uploadFile("activity/", file.getFile());
|
||||
stepFileIdList.add(fileId);
|
||||
}
|
||||
fitnessWalkActivity.setRandomPics(stepFileIdList);
|
||||
}
|
||||
|
||||
if (certificateTempFile != null) {
|
||||
String fileId = weAppCloudUtil.uploadFile("activity/", certificateTempFile.getFile());
|
||||
fitnessWalkActivity.setCompletionCertificateCover(fileId);
|
||||
}
|
||||
|
||||
|
||||
if (AuthUtil.hasRole(RoleConstant.BRANCH_UNION_CHAIRMAN.name()) &&
|
||||
!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_ADMIN.name())) {
|
||||
fitnessWalkActivity.setUnionId(SecurityUtil.getUnionId());
|
||||
} else {
|
||||
fitnessWalkActivity.setUnionId("");
|
||||
}
|
||||
|
||||
fitnessWalkActivity.setNote(fitnessWalkActivity.getNote().replace("\"", "'"));
|
||||
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("db.collection('activity').doc('")
|
||||
.append(fitnessWalkActivity.get_id())
|
||||
.append("').update({data:").append(Json.toJson(fitnessWalkActivity)).append("})");
|
||||
|
||||
try {
|
||||
JSONObject jsonObject = weAppCloudUtil.request(WeAppCloudUtil.CRUD.UPDATE, sql.toString());
|
||||
fitnessWalkCommonService.addLotteryTask(fitnessWalkActivity);
|
||||
fitnessWalkCommonService.addOrEditDoSaveRedis(fitnessWalkActivity, false);
|
||||
|
||||
sysUserService.dao().update(fitnessWalkActivity);
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@SaCheckPermission("fitnessWalk.activityManage")
|
||||
public Result delete(String id) {
|
||||
try {
|
||||
weAppCloudUtil.request(WeAppCloudUtil.CRUD.DELETE, "db.collection('activity').doc('" + id + "').remove()");
|
||||
weAppCloudUtil.request(WeAppCloudUtil.CRUD.DELETE, "db.collection('register').where({activity_id:'" + id + "'}).remove()");
|
||||
weAppCloudUtil.request(WeAppCloudUtil.CRUD.DELETE, "db.collection('sign').where({activity_id:'" + id + "'}).remove()");
|
||||
weAppCloudUtil.request(WeAppCloudUtil.CRUD.DELETE, "db.collection('gift_voucher').where({activity_id:'" + id + "'}).remove()");
|
||||
|
||||
List<Sys_task> sys_tasks = sysTaskService.query(Cnd.where("note", "=", id));
|
||||
if (sys_tasks != null) {
|
||||
sys_tasks.forEach(v -> {
|
||||
taskPlatformService.delete(v.getId(), v.getId());
|
||||
sysTaskService.delete(v.getId());
|
||||
});
|
||||
|
||||
}
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 健身走健步模式通知提醒
|
||||
*
|
||||
* @param map
|
||||
*/
|
||||
private void addNotifyTask(NutMap map) {
|
||||
if (map.getBoolean("sendNotify")) {
|
||||
String id = map.getString("_id");
|
||||
String name = map.getString("name");
|
||||
String groupId = map.getString("groupId");
|
||||
|
||||
//提醒频率
|
||||
int notifyGap = 10;
|
||||
|
||||
List<Sys_task> sys_tasks = sysTaskService.query(Cnd.where("note", "=", id));
|
||||
if (Lang.isNotEmpty(sys_tasks)) {
|
||||
sys_tasks.forEach(v -> {
|
||||
taskPlatformService.delete(v.getId(), v.getId());
|
||||
sysTaskService.delete(v.getId());
|
||||
});
|
||||
}
|
||||
|
||||
DateTime startTime = DateUtil.date(map.getLong("start_time"));
|
||||
DateTime endTime = DateUtil.date(map.getLong("end_time"));
|
||||
|
||||
Set<DateTime> result = new HashSet<>();
|
||||
DateTime offsetDay = DateUtil.offsetDay(startTime, notifyGap);
|
||||
while (offsetDay.isBefore(endTime) && offsetDay.isAfter(new Date())) {
|
||||
result.add(offsetDay);
|
||||
offsetDay = DateUtil.offsetDay(offsetDay, notifyGap);
|
||||
}
|
||||
//活动结束前一天再添加一个日期提醒
|
||||
result.add(DateUtil.offsetDay(endTime, -1));
|
||||
|
||||
for (DateTime dateTime : result) {
|
||||
Sys_task sys_task = new Sys_task();
|
||||
sys_task.setName(name);
|
||||
sys_task.setNote(id);
|
||||
sys_task.setJobClass("io.v.nutz.task.job.walking.WalkingNotifyJob");
|
||||
sys_task.setData(Json.toJson(Map.of("groupId", groupId)));
|
||||
sys_task.setDisabled(false);
|
||||
|
||||
String dateFormat = "ss mm HH dd MM ? yyyy";
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
|
||||
String corn = sdf.format(dateTime);
|
||||
sys_task.setCron(corn);
|
||||
|
||||
sysTaskService.insert(sys_task);
|
||||
|
||||
taskPlatformService.add(sys_task.getId(), sys_task.getId(), sys_task.getJobClass(), sys_task.getCron(), sys_task.getNote(), sys_task.getData());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.controller;
|
||||
|
||||
import com.budwk.app.base.utils.DateUtil;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 健身走公共答题
|
||||
*/
|
||||
@IocBean
|
||||
@At("/platform/fitnessWalk/common")
|
||||
@Ok("json:full")
|
||||
public class FitnessWalkCommonController {
|
||||
|
||||
// @Inject
|
||||
// private QuestionService questionService;
|
||||
//
|
||||
// @Inject
|
||||
// private QuestionIssueService questionIssueService;
|
||||
//
|
||||
// @Inject
|
||||
// private QuestionWorService questionWorService;
|
||||
//
|
||||
// @Inject
|
||||
// private QuestionReplyService questionReplyService;
|
||||
//
|
||||
// @At
|
||||
// @ViReturn
|
||||
// @SaCheckLogin
|
||||
// public Result getQuestion() {
|
||||
// return questionService.query(Cnd.where("qflag", "=", 2));
|
||||
// }
|
||||
//
|
||||
// @At
|
||||
// @ViReturn
|
||||
// @SaCheckLogin
|
||||
// public Result getIssueById(String id) {
|
||||
// List<Question_issue> questionIssues = questionIssueService.query(Cnd.where("iqid", "=", id).asc("ipxbh"));
|
||||
// questionIssues.forEach(issue -> {
|
||||
// issue.setWors(questionWorService.query(Cnd.where("wiid", "=", issue.getIid()).asc("wpxbh")));
|
||||
// });
|
||||
// return questionIssues;
|
||||
// }
|
||||
//
|
||||
// @At
|
||||
// @ViReturn
|
||||
// @SaCheckLogin
|
||||
// public Result saveAnswer(@Param("reply") Question_reply[] replys) {
|
||||
// for (Question_reply reply : replys) {
|
||||
// reply.setSave(false);
|
||||
// reply.setRidentity(R.UU32());
|
||||
// reply.setRtime(DateUtil.getDate());
|
||||
// questionReplyService.insert(reply);
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
}
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.constant.RedisConstant;
|
||||
import com.budwk.app.base.enums.LoginType;
|
||||
import com.budwk.app.base.exception.BaseException;
|
||||
import com.budwk.app.base.exception.UnknownAccountException;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.sys.models.Sys_user;
|
||||
import com.budwk.app.sys.services.SysUserService;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.service.FitnessWalkAuthService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.integration.jedis.RedisService;
|
||||
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.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
* @author: Aaron
|
||||
* @create: 2020-09-11 13:50
|
||||
* @description: 小程序登录
|
||||
**/
|
||||
@Slf4j
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@At("/platform/fitnessWalk/login")
|
||||
public class FitnessWalkLoginController {
|
||||
|
||||
@Inject
|
||||
private RedisService redisService;
|
||||
@Inject
|
||||
private SysUserService sysUserService;
|
||||
@Inject
|
||||
private FitnessWalkAuthService fitnessWalkAuthService;
|
||||
|
||||
@At("/")
|
||||
@SaCheckLogin
|
||||
public Result index(String username, String loginname) {
|
||||
try {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.id userid,
|
||||
u.username,
|
||||
u.loginname,
|
||||
u.sex,
|
||||
u.mobile,
|
||||
u.birthday,
|
||||
unit.`name` unitname,
|
||||
u.unitid,
|
||||
u.member,
|
||||
unit.unionid,
|
||||
un.unionname,
|
||||
group_concat(sr.`code`) roles
|
||||
FROM
|
||||
sys_user u
|
||||
LEFT JOIN sys_unit unit ON u.unitid = unit.id
|
||||
LEFT JOIN sys_union un ON unit.unionid = un.id
|
||||
LEFT JOIN sys_user_role sur ON sur.userId = u.id
|
||||
LEFT JOIN sys_role sr ON sr.id = sur.roleId
|
||||
$condition
|
||||
""").setParam("loginname", loginname).setParam("username", username);
|
||||
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("LOWER(u.loginname)", "=", loginname.trim().toLowerCase());
|
||||
cnd.and("LOWER(u.username)", "=", username.trim().toLowerCase());
|
||||
sql.setCondition(cnd);
|
||||
sql.setCallback(Sqls.callback.map());
|
||||
sysUserService.dao().execute(sql);
|
||||
NutMap user = (NutMap) sql.getResult();
|
||||
if (StrUtil.isBlank(user.getString("userid"))) {
|
||||
return Result.error().addMsg("系统查询不到您的信息,请与工会管理员联系!");
|
||||
}
|
||||
// if(user.getInt("member",0)==0){
|
||||
// return Result.error().addMsg("您没有权限参加本次健步行,请与工会管理员联系!");
|
||||
// }
|
||||
/*if (user.getInt("member", 0) != 1 && !user.getString("sex", "").equals("女")) {
|
||||
return Result.error().addMsg("您没有权限参加本次健步行,请与工会管理员联系!");
|
||||
}*/
|
||||
return Result.success().addData(user);
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@SaCheckLogin
|
||||
public Result buildRecordInfo(String loginname) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.id userid,
|
||||
u.username,
|
||||
u.loginname,
|
||||
u.sex,
|
||||
u.mobile,
|
||||
u.birthday,
|
||||
unit.`name` AS unitname,
|
||||
u.unitId AS unitid,
|
||||
u.member,
|
||||
unit.unionId AS unionId,
|
||||
un.`name` AS unionname,
|
||||
group_concat(sr.`code`) roles
|
||||
FROM
|
||||
sys_user u
|
||||
LEFT JOIN sys_unit unit ON u.unitId = unit.id
|
||||
LEFT JOIN sys_union un ON unit.unionId = un.id
|
||||
LEFT JOIN sys_user_role sur ON sur.userId = u.id
|
||||
LEFT JOIN sys_role sr ON sr.id = sur.roleId
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("LOWER(u.loginname)", "=", loginname.trim().toLowerCase());
|
||||
sql.setCondition(cnd);
|
||||
sql.setCallback(Sqls.callback.map());
|
||||
sysUserService.dao().execute(sql);
|
||||
NutMap user = (NutMap) sql.getResult();
|
||||
|
||||
return Result.success().addData(user);
|
||||
}
|
||||
}
|
||||
+222
@@ -0,0 +1,222 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.controller;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.base.utils.CommonDownloadUtil;
|
||||
import com.budwk.app.sys.models.Sys_union;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.contants.FitnessWalkMode;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.service.FitnessWalkCommonService;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.service.FitnessWalkPunchStatisticsService;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.utils.WeAppCloudUtil;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.nutz.dao.Dao;
|
||||
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 javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 打卡统计
|
||||
*/
|
||||
@IocBean
|
||||
@Ok("json")
|
||||
@At("/platform/fitnessWalk/punchStatistics")
|
||||
public class FitnessWalkPunchStatisticsController {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
|
||||
@Inject
|
||||
private FitnessWalkCommonService fitnessWalkCommonService;
|
||||
|
||||
@Inject
|
||||
private WeAppCloudUtil weAppCloudUtil;
|
||||
|
||||
@Inject
|
||||
private FitnessWalkPunchStatisticsService fitnessWalkPunchStatisticsService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zhgh/activity/fitnessWalk/punchStatistics.html")
|
||||
@SaCheckPermission("fitnessWalk.punchStatistics")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 分工会统计
|
||||
*
|
||||
* @param activityId
|
||||
* @param unionId
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@Ok("json:full")
|
||||
@SaCheckPermission("fitnessWalk.punchStatistics")
|
||||
public Result pageData(String activityId, String unionId) {
|
||||
List<NutMap> list = fitnessWalkPunchStatisticsService.unionRegCheckInNum(activityId, unionId);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
@At
|
||||
@SaCheckPermission("fitnessWalk.punchStatistics")
|
||||
public Result getCascadersActivity(@Param(value = "year") int year) {
|
||||
return Result.success(fitnessWalkCommonService.cascaderActivity(year, FitnessWalkMode.PUNCH));
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json:full")
|
||||
@SaCheckPermission("fitnessWalk.punchStatistics")
|
||||
public Result unionRegistrationData(String activityId, String unionId) {
|
||||
List<JSONObject> list = fitnessWalkPunchStatisticsService.unionRegistrationData(activityId, unionId);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json:full")
|
||||
@SaCheckPermission("fitnessWalk.punchStatistics")
|
||||
public Result unionCheckInData(String activityId, String unionId) {
|
||||
List<JSONObject> list = fitnessWalkPunchStatisticsService.unionCheckInData(activityId, unionId);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出各分工会报名人数、打卡人数
|
||||
*
|
||||
* @param activityId
|
||||
*/
|
||||
@At
|
||||
@Ok("void")
|
||||
@SaCheckPermission("fitnessWalk.punchStatistics")
|
||||
public void exportUnionRegCheckInNum(HttpServletResponse response, String activityId) {
|
||||
List<NutMap> list = fitnessWalkPunchStatisticsService.unionRegCheckInNum(activityId, null);
|
||||
List<ExcelExportEntity> entities = new ArrayList<>();
|
||||
entities.add(new ExcelExportEntity("分工会", "unionname", 20));
|
||||
entities.add(new ExcelExportEntity("报名人数", "regCount", 20));
|
||||
entities.add(new ExcelExportEntity("打卡人数", "checkInCount", 20));
|
||||
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), entities, list);
|
||||
CommonDownloadUtil.download("各分工会统计人数.xlsx", workbook, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出某个分工会的报名人员
|
||||
*
|
||||
* @param response
|
||||
* @param activityId
|
||||
* @param unionId
|
||||
*/
|
||||
@At
|
||||
@Ok("void")
|
||||
@SaCheckPermission("fitnessWalk.punchStatistics")
|
||||
public void exportRegUsers(HttpServletResponse response, String activityId, String unionId) {
|
||||
Sys_union union = dao.fetch(Sys_union.class, unionId);
|
||||
String unionName = Optional.ofNullable(union).map(Sys_union::getName).orElse(null);
|
||||
|
||||
List<JSONObject> list = fitnessWalkPunchStatisticsService.unionRegistrationData(activityId, unionId);
|
||||
List<ExcelExportEntity> entities = new ArrayList<>();
|
||||
entities.add(new ExcelExportEntity("工号", "loginname", 20));
|
||||
entities.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
entities.add(new ExcelExportEntity("单位", "unitname", 20));
|
||||
entities.add(new ExcelExportEntity("手机号", "mobile", 20));
|
||||
entities.add(new ExcelExportEntity("报名时间", "register_time_str", 20));
|
||||
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), entities, list);
|
||||
CommonDownloadUtil.download(unionName + "分工会报名人员.xlsx", workbook, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出某个分工会的打卡人员
|
||||
*
|
||||
* @param response
|
||||
* @param activityId
|
||||
* @param unionId
|
||||
*/
|
||||
@At
|
||||
@Ok("void")
|
||||
@SaCheckPermission("fitnessWalk.punchStatistics")
|
||||
public void exportCheckInUsers(HttpServletResponse response, String activityId, String unionId) {
|
||||
Sys_union union = dao.fetch(Sys_union.class, unionId);
|
||||
String unionName = Optional.ofNullable(union).map(Sys_union::getName).orElse(null);
|
||||
|
||||
List<JSONObject> list = fitnessWalkPunchStatisticsService.unionCheckInData(activityId, unionId);
|
||||
|
||||
for (JSONObject jsonObject : list) {
|
||||
Boolean used = jsonObject.getBool("used");
|
||||
if (used == null) {
|
||||
jsonObject.put("used", "未取得");
|
||||
} else if (used) {
|
||||
jsonObject.put("used", "已领取");
|
||||
} else {
|
||||
jsonObject.put("used", "未领取");
|
||||
}
|
||||
}
|
||||
|
||||
List<ExcelExportEntity> entities = new ArrayList<>();
|
||||
entities.add(new ExcelExportEntity("工号", "loginname", 20));
|
||||
entities.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
entities.add(new ExcelExportEntity("单位", "unitname", 20));
|
||||
entities.add(new ExcelExportEntity("手机号", "mobile", 20));
|
||||
entities.add(new ExcelExportEntity("点位总数", "pts_size", 20));
|
||||
entities.add(new ExcelExportEntity("已打卡点位数", "sign_size", 20));
|
||||
entities.add(new ExcelExportEntity("礼品券", "used", 20));
|
||||
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), entities, list);
|
||||
CommonDownloadUtil.download(unionName + "分工会打卡人员.xlsx", workbook, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 未领取得奖品券用户
|
||||
*
|
||||
* @param response
|
||||
* @param activityId
|
||||
*/
|
||||
@At
|
||||
@Ok("void")
|
||||
@SaCheckPermission("fitnessWalk.punchStatistics")
|
||||
public void exportNotGetGiftVoucherUsers(HttpServletResponse response, String activityId) {
|
||||
List<JSONObject> list = fitnessWalkPunchStatisticsService.exportNotGetGiftVoucherUsers(activityId);
|
||||
List<ExcelExportEntity> entities = new ArrayList<>();
|
||||
entities.add(new ExcelExportEntity("工号", "loginname", 20));
|
||||
entities.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
entities.add(new ExcelExportEntity("单位", "unitname", 20));
|
||||
entities.add(new ExcelExportEntity("手机号", "mobile", 20));
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), entities, list);
|
||||
CommonDownloadUtil.download("未领取得奖品券人员.xlsx", workbook, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 未使用奖品券用户
|
||||
*
|
||||
* @param response
|
||||
* @param activityId
|
||||
*/
|
||||
@At
|
||||
@Ok("void")
|
||||
@SaCheckPermission("fitnessWalk.punchStatistics")
|
||||
public void exportNotUseGiftVoucherUsers(HttpServletResponse response, String activityId) {
|
||||
List<JSONObject> list = fitnessWalkPunchStatisticsService.exportNotUseGiftVoucherUsers(activityId);
|
||||
List<ExcelExportEntity> entities = new ArrayList<>();
|
||||
entities.add(new ExcelExportEntity("工号", "loginname", 20));
|
||||
entities.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
entities.add(new ExcelExportEntity("单位", "unitname", 20));
|
||||
entities.add(new ExcelExportEntity("手机号", "mobile", 20));
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), entities, list);
|
||||
CommonDownloadUtil.download("未使用奖品券人员.xlsx", workbook, response);
|
||||
}
|
||||
|
||||
}
|
||||
+299
@@ -0,0 +1,299 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.FitnessWalkActivity;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.FitnessWalkStep;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.service.FitnessWalkCommonService;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.utils.WeAppCloudUtil;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.integration.jedis.RedisService;
|
||||
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.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.*;
|
||||
import java.util.function.BinaryOperator;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@IocBean
|
||||
@Ok("json")
|
||||
@At("/platform/fitnessWalk/stepManage")
|
||||
public class FitnessWalkStepManageController {
|
||||
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
|
||||
@Inject
|
||||
private WeAppCloudUtil weAppCloudUtil;
|
||||
|
||||
@Inject
|
||||
private RedisService redisService;
|
||||
|
||||
@Inject
|
||||
private FitnessWalkCommonService fitnessWalkCommonService;
|
||||
|
||||
|
||||
/**
|
||||
* 用户上传一个近31天的步数
|
||||
*
|
||||
* @param activityId 活动id
|
||||
* @param monthSteps 步数(当天往前推30天)
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@Ok("json:full")
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SaCheckLogin
|
||||
public Result updateStepMonth(String activityId, String monthSteps) {
|
||||
if (StrUtil.isBlank(monthSteps) || StrUtil.isBlank(activityId)) {
|
||||
return Result.error("必要参数未传递");
|
||||
}
|
||||
|
||||
String userId = SecurityUtil.getUserId();
|
||||
// 获取到的用户的步数数据
|
||||
List<NutMap> steps = Json.fromJsonAsList(NutMap.class, monthSteps);
|
||||
|
||||
//判断数据是否完整 微信运动会在晚上10点多进行步数的更新 会导致31天前的步数获取变为0 所以这里去除掉第一个元素 即为31天前的数据 每次只保存最近30天的数据
|
||||
if (Lang.isNotEmpty(steps) && steps.size() == 31) {
|
||||
steps.remove(0);
|
||||
}
|
||||
|
||||
// 传递过来的步数数据
|
||||
List<FitnessWalkStep> wxSteps = steps.stream().map(v -> {
|
||||
FitnessWalkStep step = new FitnessWalkStep();
|
||||
step.setActivityId(activityId);
|
||||
step.setUserId(userId);
|
||||
step.setStep(v.getInt("step"));
|
||||
DateTime date = DateUtil.parse(DateUtil.format(DateUtil.date(v.getLong("timestamp") * 1000), "yyyy-MM-dd"), "yyyy-MM-dd");
|
||||
step.setApplyDate(date);
|
||||
return step;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
// 传递过来的所有日期的集合
|
||||
List<Date> dateList = wxSteps.stream().map(FitnessWalkStep::getApplyDate).collect(Collectors.toList());
|
||||
|
||||
// 去数据库查询日期,这个玩意还要保证插入到数据库的单个日期只有一条,并且这个日期数据库之前有步数,传过来没步数那就要保留数据库的步数
|
||||
// 上面日期集合数据库的步数
|
||||
List<FitnessWalkStep> stepList = baseService.dao().query(FitnessWalkStep.class, Cnd.where("activityId", "=", activityId)
|
||||
.and("userId", "=", userId).and("applyDate", "in", dateList));
|
||||
|
||||
// 这就是保留每天最大步数的集合,那这个集合里面applyDate就是唯一的了
|
||||
List<FitnessWalkStep> dupStepList = new ArrayList<>(stepList.stream()
|
||||
.collect(Collectors.toMap(FitnessWalkStep::getApplyDate, Function.identity(),
|
||||
BinaryOperator.maxBy(Comparator.comparing(FitnessWalkStep::getStep))))
|
||||
.values());
|
||||
|
||||
// 这是过滤的相同的applyDate的集合,这些数据要删除
|
||||
List<String> delStepIds = stepList.stream()
|
||||
.filter(step -> !dupStepList.contains(step))
|
||||
.map(FitnessWalkStep::getId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 数据库的数据 这个map就用于判断数据库的日期和传递过来日期的步数,两个是不是相等的,保留步数多的数据
|
||||
Map<Date, FitnessWalkStep> dateStepMap = dupStepList.stream().collect(Collectors.toMap(FitnessWalkStep::getApplyDate, v -> v));
|
||||
|
||||
List<FitnessWalkStep> resultStepList = new ArrayList<>();
|
||||
// 这里循环就是,循环的传递过来的数据
|
||||
for (FitnessWalkStep step : wxSteps) {
|
||||
// 数据库存储的步数
|
||||
FitnessWalkStep walkStep = dateStepMap.get(step.getApplyDate());
|
||||
// 如果数据库没有,那就要新增
|
||||
if (Lang.isEmpty(walkStep)) {
|
||||
resultStepList.add(step);
|
||||
} else {
|
||||
// 如果数据库有,那就要保留步数多的
|
||||
if (walkStep.getStep() < step.getStep()) {
|
||||
walkStep.setStep(step.getStep());
|
||||
resultStepList.add(walkStep);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 最后删除重复日期,更新步数数据
|
||||
if (Lang.isNotEmpty(delStepIds)) {
|
||||
baseService.dao().clear(FitnessWalkStep.class, Cnd.where("id", "in", delStepIds));
|
||||
}
|
||||
if (Lang.isNotEmpty(resultStepList)){
|
||||
baseService.dao().insertOrUpdate(resultStepList);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序获取开始时间至今的步数
|
||||
*
|
||||
* @param activityId
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@Ok("json:full")
|
||||
@SaCheckLogin
|
||||
public Result getActivityDateStep(String activityId, String userId) {
|
||||
try {
|
||||
//查询Redis中是否有该用户的步数数据
|
||||
Cnd cnd = Cnd.NEW();
|
||||
|
||||
FitnessWalkActivity activity = fitnessWalkCommonService.getActivity(activityId);
|
||||
DateTime startTime = DateUtil.date(activity.getStartTime());
|
||||
DateTime endTime = DateUtil.date(activity.getEndTime());
|
||||
|
||||
cnd.and("activityId", "=", activityId);
|
||||
cnd.and("userId", "=", userId);
|
||||
cnd.and("applyDate", ">=", startTime);
|
||||
cnd.and("applyDate", "<=", endTime);
|
||||
cnd.asc("applyDate");
|
||||
cnd.groupBy("applyDate");
|
||||
List<FitnessWalkStep> stepList = baseService.dao().query(FitnessWalkStep.class, cnd);
|
||||
|
||||
return Result.success(stepList.stream().map(v -> {
|
||||
return Map.of("step", v.getStep(), "timestamp", v.getApplyDate().getTime());
|
||||
}).toList());
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json:full")
|
||||
@SaCheckLogin
|
||||
public Result getActivityQualifyProgressBar(String activityId, String userId) {
|
||||
NutMap resultMap = NutMap.NEW();
|
||||
|
||||
FitnessWalkActivity activity = fitnessWalkCommonService.getActivity(activityId);
|
||||
//计步的抽奖模式 everyday custom
|
||||
String lotteryMode = activity.getLotteryMode();
|
||||
if ("everyday".equals(lotteryMode)) {
|
||||
FitnessWalkActivity.DayLotteryRule dayLotteryRule = activity.getDayLotteryRule();
|
||||
//每日抽奖资格步数
|
||||
Integer lotteryQualificationStep = dayLotteryRule.getLotteryQualificationStep();
|
||||
|
||||
FitnessWalkStep userWalkStep = baseService.dao().fetch(FitnessWalkStep.class, Cnd.where("userId", "=", userId)
|
||||
.and("DATE( applyDate )", "=", DateUtil.today()).and("activityId", "=", activityId));
|
||||
|
||||
int complianceDay = baseService.dao().count(FitnessWalkStep.class, Cnd.where("userId", "=", userId)
|
||||
.and("DATE( applyDate )", "=", DateUtil.today()).and("activityId", "=", activityId)
|
||||
.and("step", ">", lotteryQualificationStep));
|
||||
|
||||
Integer thisDayStep = userWalkStep.getStep();
|
||||
|
||||
BigDecimal lotteryQualificationStepBig = new BigDecimal(lotteryQualificationStep);
|
||||
BigDecimal thisDayStepBig = new BigDecimal(thisDayStep);
|
||||
//达标的小数,保留四位
|
||||
BigDecimal divide = thisDayStepBig.divide(lotteryQualificationStepBig, 4, RoundingMode.HALF_UP);
|
||||
BigDecimal percentValue = divide.multiply(new BigDecimal("100"));
|
||||
DecimalFormat decimalFormat = new DecimalFormat("#.##"); // 格式化为两位小数
|
||||
//百分数
|
||||
String formattedPercent = decimalFormat.format(percentValue);
|
||||
|
||||
long betweenDay = DateUtil.date(activity.getStartTime()).between(DateUtil.date(activity.getEndTime()), DateUnit.DAY);
|
||||
NutMap map = new NutMap();
|
||||
map.setv("mode", "everyDayLottery");
|
||||
//当前达标步数
|
||||
map.setv("userStep", thisDayStep);
|
||||
//达标总步数
|
||||
map.setv("complianceSumStep", lotteryQualificationStep);
|
||||
//达标比例
|
||||
map.setv("complianceProportion", Integer.parseInt(formattedPercent));
|
||||
//活动天数
|
||||
map.setv("betweenDay", betweenDay);
|
||||
//达标天数
|
||||
map.setv("complianceDay", complianceDay);
|
||||
resultMap.addv("everyDayLotteryMode", map);
|
||||
} else if ("custom".equals(lotteryMode)) {
|
||||
List<FitnessWalkActivity.CustomLotteryRule> customLotteryRules = activity.getCustomLotteryRules();
|
||||
List<FitnessWalkStep> userWalkSteps = baseService.dao().
|
||||
query(FitnessWalkStep.class, Cnd.where("userId", "=", userId)
|
||||
.and("activityId", "=", activityId)
|
||||
.and("DATE(applyDate)", ">=", DateUtil.format(DateUtil.date(activity.getStartTime()), "yyyy-MM-dd"))
|
||||
.and("DATE(applyDate)", "<=", DateUtil.format(DateUtil.date(activity.getEndTime()), "yyyy-MM-dd"))
|
||||
);
|
||||
|
||||
List<NutMap> result = new ArrayList<>();
|
||||
|
||||
for (FitnessWalkActivity.CustomLotteryRule rule : customLotteryRules) {
|
||||
NutMap nutMap = NutMap.NEW();
|
||||
|
||||
List<FitnessWalkStep> partSteps = userWalkSteps.stream()
|
||||
.filter(s -> (DateUtil.compare(s.getApplyDate(), rule.getStartDate()) >= 0 && DateUtil.compare(s.getApplyDate(), rule.getEndDate()) <= 0))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Integer lotteryQualificationDay = rule.getLotteryQualificationDay();
|
||||
Integer lotteryQualificationStep = rule.getLotteryQualificationStep();
|
||||
|
||||
if (lotteryQualificationDay != null && lotteryQualificationStep != null) {
|
||||
//每天步数
|
||||
nutMap.put("mode", "customLotteryEveryDayStepMode");
|
||||
//用户总达标步数
|
||||
nutMap.put("userSumStep", partSteps.stream().filter(s -> DateUtil.compare(s.getApplyDate(), new Date(), "yyyy-MM-dd") == 0).findFirst().map(s -> s.getStep()).orElse(0));
|
||||
//今天达标步数
|
||||
nutMap.put("complianceStep", lotteryQualificationStep);
|
||||
//总达标步数
|
||||
nutMap.put("complianceSumStep", lotteryQualificationDay * lotteryQualificationStep);
|
||||
//用户当前达标总天数
|
||||
nutMap.put("userComplianceSumDay", partSteps.stream().filter(s -> s.getStep() > lotteryQualificationStep).count());
|
||||
//总达标天数
|
||||
nutMap.put("complianceSumDay", lotteryQualificationDay);
|
||||
} else if (lotteryQualificationDay == null && lotteryQualificationStep != null) {
|
||||
//总步数
|
||||
nutMap.put("mode", "customLotterySumStepMode");
|
||||
//用户总达标步数
|
||||
nutMap.put("userSumStep", partSteps.stream().mapToInt(s -> s.getStep()).sum());
|
||||
//总达标步数
|
||||
nutMap.put("complianceSumStep", lotteryQualificationStep);
|
||||
|
||||
nutMap.put("title", DateUtil.format(rule.getStartDate(), "MM月dd日") + "至" + DateUtil.format(rule.getEndDate(), "MM月dd日"));
|
||||
|
||||
}
|
||||
result.add(nutMap);
|
||||
}
|
||||
resultMap.addv("customLotteryMode", result);
|
||||
}
|
||||
return Result.success(resultMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户未读的奖
|
||||
*
|
||||
* @param activityId
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@Ok("json:full")
|
||||
@SaCheckLogin
|
||||
public Result winningRecord(String activityId) {
|
||||
String userId = SecurityUtil.getUserId();
|
||||
Sql sql = Sqls.create("""
|
||||
select awardName,startDate,endDate from fitness_walk_award_user where activityId=@activityId and userId=@userId and isRead=@isRead
|
||||
""").setParam("activityId",activityId).setParam("userId", userId).setParam("isRead",true);
|
||||
|
||||
return Result.success(baseService.listMap(sql));
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json:full")
|
||||
@SaCheckLogin
|
||||
public Result hasReadAward(String activityId) {
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
+274
@@ -0,0 +1,274 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.controller;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
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.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.base.utils.CommonDownloadUtil;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.contants.FitnessWalkMode;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.FitnessWalkAwardUser;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.FitnessWalkRaffleRules;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.FitnessWalkRaffleUser;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.service.FitnessWalkCommonService;
|
||||
import com.budwk.app.base.param.PageForm;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.service.FitnessWalkStepRaffleService;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
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.SqlExpressionGroup;
|
||||
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 org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:FitnessWalkStepRaffleController
|
||||
* @Date 2024/12/27 14:43
|
||||
* @注释 健步走抽奖控制器
|
||||
*/
|
||||
@Ok("json")
|
||||
@IocBean
|
||||
@At("/platform/fitnessWalk/stepRaffle")
|
||||
public class FitnessWalkStepRaffleController {
|
||||
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
@Inject
|
||||
private FitnessWalkCommonService fitnessWalkCommonService;
|
||||
@Inject
|
||||
private FitnessWalkStepRaffleService fitnessWalkStepRaffleService;
|
||||
|
||||
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zhgh/activity/fitnessWalk/stepRaffle.html")
|
||||
@SaCheckPermission("fitnessWalk.stepRaffle")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@At
|
||||
@SaCheckPermission("fitnessWalk.stepRaffle")
|
||||
public Result pageData(PageForm pageForm,
|
||||
@Param(value = "activityId") String activityId,
|
||||
@Param(value = "unionId") String unionId,
|
||||
@Param(value = "unitId") String unitId){
|
||||
Sql sql = fitnessWalkStepRaffleService.getRaffleSql(pageForm, activityId, unionId, unitId);
|
||||
Pagination pagination = baseService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
return Result.success(pagination);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@At
|
||||
@SaCheckPermission("fitnessWalk.stepRaffle")
|
||||
public Result getCascadersActivity(@Param(value = "year") int year) {
|
||||
return Result.success(fitnessWalkCommonService.cascaderActivity(year, FitnessWalkMode.STEP_COUNT));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 手动抽奖规则
|
||||
* @param fitnessWalkRaffleRules
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SaCheckPermission("fitnessWalk.stepRaffle")
|
||||
public Result saveRaffle(FitnessWalkRaffleRules fitnessWalkRaffleRules){
|
||||
baseService.dao().insertOrUpdate(fitnessWalkRaffleRules);
|
||||
fitnessWalkStepRaffleService.manualLottery(fitnessWalkRaffleRules.getActivityId());
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@SaCheckPermission("fitnessWalk.stepRaffle")
|
||||
public Result getRaffle(String activityId){
|
||||
FitnessWalkRaffleRules fetch = baseService.dao().fetch(FitnessWalkRaffleRules.class, Cnd.where("activityId", "=", activityId));
|
||||
return Result.success(fetch);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序获取奖项信息
|
||||
* @param activityId
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@SaCheckLogin
|
||||
public Result getAwardList(String activityId){
|
||||
return Result.success(fitnessWalkStepRaffleService.getActivityAwardList(activityId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序获取自己的中奖信息
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@SaCheckLogin
|
||||
public Result getAwardInfo(String activityId){
|
||||
String userId = SecurityUtil.getUserId();
|
||||
Dao dao = fitnessWalkStepRaffleService.dao();
|
||||
FitnessWalkAwardUser awardUser = dao.fetch(FitnessWalkAwardUser.class, Cnd.where("activityId", "=", activityId).and("userId", "=", userId));
|
||||
FitnessWalkRaffleUser raffleUser = dao.fetch(FitnessWalkRaffleUser.class, Cnd.where("activityId", "=", activityId).and("userId", "=", userId));
|
||||
|
||||
NutMap map = NutMap.NEW();
|
||||
if (Lang.isNotEmpty(raffleUser) && !raffleUser.getIsRaffle()) {
|
||||
if (Lang.isNotEmpty(awardUser)) {
|
||||
map.put("awardName", awardUser.getAwardName());
|
||||
} else {
|
||||
map.put("awardName", "没有中奖");
|
||||
}
|
||||
map.put("raffleNum", 1);
|
||||
} else {
|
||||
map.put("raffleNum", 0);
|
||||
}
|
||||
return Result.success(map);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序获取查询是否可以抽奖
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@SaCheckLogin
|
||||
public Result checkRaffle(String activityId, String userId){
|
||||
Dao dao = fitnessWalkStepRaffleService.dao();
|
||||
FitnessWalkRaffleUser raffleUser = dao.fetch(FitnessWalkRaffleUser.class,
|
||||
Cnd.where("activityId", "=", activityId)
|
||||
.and("userId", "=", userId));
|
||||
if (Lang.isNotEmpty(raffleUser)) {
|
||||
return raffleUser.getIsRaffle() ? Result.error() : Result.success();
|
||||
} else {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 抽奖成功后,修改数据库状态
|
||||
* @param activityId
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SaCheckLogin
|
||||
public Result updateUserAward(String activityId, String userId) {
|
||||
fitnessWalkStepRaffleService.dao().update(FitnessWalkAwardUser.class,
|
||||
Chain.make("isRead", true).add("applyDate", DateUtil.date()),
|
||||
Cnd.where("activityId", "=", activityId).and("userId", "=", userId));
|
||||
|
||||
fitnessWalkStepRaffleService.dao().update(FitnessWalkRaffleUser.class,
|
||||
Chain.make("isRaffle", true),
|
||||
Cnd.where("activityId", "=", activityId).and("userId", "=", userId));
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@SaCheckPermission("fitnessWalk.stepRaffle")
|
||||
public void exportAwardExcel(String searchKeyword, String activityId,
|
||||
String lotteryTime, HttpServletResponse response) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("activityId", "=", activityId);
|
||||
cnd.andEX("awardName", "=", lotteryTime);
|
||||
if (StrUtil.isNotBlank(searchKeyword)) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.orLike("username", searchKeyword);
|
||||
seg.orLike("loginName", searchKeyword);
|
||||
cnd.and(seg);
|
||||
}
|
||||
cnd.and("isRead", "=", true);
|
||||
List<FitnessWalkAwardUser> list = fitnessWalkCommonService.dao().query(FitnessWalkAwardUser.class, cnd);
|
||||
|
||||
List<ExcelExportEntity> entityList = new ArrayList<>();
|
||||
ExcelExportEntity no = new ExcelExportEntity("序号", "no", 10);
|
||||
no.setFormat("isAddIndex");
|
||||
entityList.add(no);
|
||||
entityList.add(new ExcelExportEntity("工号", "loginName", 20));
|
||||
entityList.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
entityList.add(new ExcelExportEntity("分工会", "unionName", 20));
|
||||
entityList.add(new ExcelExportEntity("单位", "unitName", 40));
|
||||
entityList.add(new ExcelExportEntity("奖项名称", "awardName", 20));
|
||||
entityList.add(new ExcelExportEntity("中奖时间", "applyDate", 20));
|
||||
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, list);
|
||||
CommonDownloadUtil.download("健步走中奖人员名单.xlsx", workbook, response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@SaCheckPermission("fitnessWalk.stepRaffle")
|
||||
public void exportExcel(String searchKeyword, String activityId, String unionId,
|
||||
String unitId, HttpServletResponse response) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
ru.*,
|
||||
u.sex,
|
||||
u.unionname AS unionName,
|
||||
u.unitname AS unitName
|
||||
FROM
|
||||
fitness_walk_raffle_user ru left join `view_user` u on ru.userId = u.id
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("ru.activityId", "=", activityId);
|
||||
cnd.andEX("u.unionid", "=", unionId);
|
||||
cnd.andEX("u.unitid", "=", unitId);
|
||||
if (StrUtil.isNotBlank(searchKeyword)) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.orLike("ru.username", searchKeyword);
|
||||
seg.orLike("ru.loginName", searchKeyword);
|
||||
cnd.and(seg);
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> list = fitnessWalkStepRaffleService.listMap(sql);
|
||||
|
||||
List<ExcelExportEntity> entityList = new ArrayList<>();
|
||||
ExcelExportEntity no = new ExcelExportEntity("序号", "no", 10);
|
||||
no.setFormat("isAddIndex");
|
||||
entityList.add(no);
|
||||
entityList.add(new ExcelExportEntity("工号", "loginName", 20));
|
||||
entityList.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
entityList.add(new ExcelExportEntity("分工会", "unionName", 20));
|
||||
entityList.add(new ExcelExportEntity("单位", "unitName", 40));
|
||||
entityList.add(new ExcelExportEntity("达标天数", "standardsDays", 20));
|
||||
entityList.add(new ExcelExportEntity("步数", "awardSteps", 20));
|
||||
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, list);
|
||||
CommonDownloadUtil.download("健步走达标人员名单.xlsx", workbook, response);
|
||||
}
|
||||
}
|
||||
+232
@@ -0,0 +1,232 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.controller;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
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.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
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.result.Result;
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.base.utils.CommonDownloadUtil;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.contants.Cascader;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.contants.FitnessWalkMode;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.FitnessWalkActivity;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.service.FitnessWalkCommonService;
|
||||
import com.budwk.app.base.param.PageForm;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
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 javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 步数排行榜
|
||||
*/
|
||||
|
||||
@IocBean
|
||||
@Slf4j
|
||||
@Ok("json")
|
||||
@At("/platform/fitnessWalk/stepRanking")
|
||||
public class FitnessWalkStepRankingController {
|
||||
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
|
||||
@Inject
|
||||
private FitnessWalkCommonService fitnessWalkCommonService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zhgh/activity/fitnessWalk/stepRanking.html")
|
||||
@SaCheckPermission("fitnessWalk.stepRanking")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@SaCheckPermission("fitnessWalk.stepRanking")
|
||||
@SLog(type = "健身走", tag = "步数排行榜", msg = "获取排行榜", param = true, result = true)
|
||||
public Result pageData(PageForm pageForm,
|
||||
@Param(value = "activityId") String activityId,
|
||||
@Param(value = "unionId") String unionId,
|
||||
@Param(value = "unitId") String unitId,
|
||||
@Param(value = "mode") String mode) {
|
||||
Pagination pagination = fitnessWalkCommonService.getStepRankingPagination(pageForm, activityId, unionId, unitId, mode);
|
||||
return Result.success(pagination);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有教工 今天的步数及活动时间范围内的步数
|
||||
*
|
||||
* @param activityId
|
||||
* @param mode day:今天 all:所有
|
||||
* @return {@link Object}
|
||||
*/
|
||||
@At
|
||||
@Ok("json:full")
|
||||
@SaCheckLogin
|
||||
@SLog(type = "校工会特色活动",tag = "健身走-计步步数排行榜",msg = "小程序接口(获取今日步数及活动范围内步数)",param = true,result = true)
|
||||
public Result getUserStepRanking(String activityId, String mode, Integer pageNumber, Integer pageSize) {
|
||||
if ("day".equals(mode)) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
t.step,
|
||||
t.applyDate,
|
||||
u.username
|
||||
FROM
|
||||
`fitness_walk_step` t
|
||||
LEFT JOIN sys_user u ON u.id = t.userId\s
|
||||
WHERE
|
||||
t.activityId = @activityId
|
||||
AND t.applyDate = @today
|
||||
ORDER BY t.step DESC
|
||||
""");
|
||||
sql.setParam("activityId", activityId);
|
||||
sql.setParam("today", DateUtil.today());
|
||||
Pagination pagination = baseService.listPageMap(pageNumber, pageSize, sql);
|
||||
return Result.success(pagination);
|
||||
} else if("week".equals(mode)){
|
||||
Date startOfWeek = DateUtil.beginOfWeek(new Date());
|
||||
Date endOfWeek = DateUtil.endOfWeek(new Date());
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
t.userId,
|
||||
sum( t.step ) AS step,
|
||||
u.username
|
||||
FROM
|
||||
`fitness_walk_step` t
|
||||
LEFT JOIN sys_user u ON u.id = t.userId
|
||||
WHERE
|
||||
t.activityId = @activityId
|
||||
AND t.applyDate >= @startTime
|
||||
AND t.applyDate <= @endTime
|
||||
GROUP BY
|
||||
t.userId
|
||||
ORDER BY
|
||||
step DESC
|
||||
""");
|
||||
sql.setParam("activityId", activityId);
|
||||
sql.setParam("startTime", startOfWeek);
|
||||
sql.setParam("endTime", endOfWeek);
|
||||
Pagination pagination = baseService.listPageMap(pageNumber, pageSize, sql);
|
||||
return Result.success(pagination);
|
||||
}else if("month".equals(mode)){
|
||||
Date firstDayOfMonth = DateUtil.beginOfMonth(new Date());
|
||||
Date lastDayOfMonth = DateUtil.endOfMonth(new Date());
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
t.userId,
|
||||
sum( t.step ) AS step,
|
||||
u.username
|
||||
FROM
|
||||
`fitness_walk_step` t
|
||||
LEFT JOIN sys_user u ON u.id = t.userId
|
||||
WHERE
|
||||
t.activityId = @activityId
|
||||
AND t.applyDate >= @startTime
|
||||
AND t.applyDate <= @endTime
|
||||
GROUP BY
|
||||
t.userId
|
||||
ORDER BY
|
||||
step DESC
|
||||
""");
|
||||
sql.setParam("activityId", activityId);
|
||||
sql.setParam("startTime", firstDayOfMonth);
|
||||
sql.setParam("endTime", lastDayOfMonth);
|
||||
Pagination pagination = baseService.listPageMap(pageNumber, pageSize, sql);
|
||||
return Result.success(pagination);
|
||||
} else if ("all".equals(mode)) {
|
||||
FitnessWalkActivity activity = fitnessWalkCommonService.getActivity(activityId);
|
||||
DateTime startTime = DateUtil.date(activity.getStartTime());
|
||||
DateTime endTime = DateUtil.date(activity.getEndTime());
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
SUM(sub.max_step) AS step,
|
||||
u.username
|
||||
FROM (
|
||||
SELECT
|
||||
userId,
|
||||
activityId,
|
||||
applyDate,
|
||||
MAX(step) AS max_step
|
||||
FROM
|
||||
fitness_walk_step
|
||||
WHERE
|
||||
activityId = @activityId
|
||||
AND applyDate >= @startTime AND applyDate <= @endTime
|
||||
GROUP BY
|
||||
userId,
|
||||
activityId,
|
||||
applyDate
|
||||
) sub
|
||||
left join `view_user` u ON u.id = sub.userId
|
||||
GROUP BY
|
||||
userId
|
||||
ORDER BY
|
||||
step desc
|
||||
""");
|
||||
sql.setParam("activityId", activityId);
|
||||
sql.setParam("startTime", startTime);
|
||||
sql.setParam("endTime", endTime);
|
||||
Pagination pagination = baseService.listPageMap(pageNumber, pageSize, sql);
|
||||
return Result.success(pagination);
|
||||
} else {
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@SLog(type = "校工会特色活动",tag = "健身走-计步步数排行榜",msg = "步数排行榜导出",param = true,result = true)
|
||||
@SaCheckPermission("fitnessWalk.stepRanking")
|
||||
public void exportExcel(@Param(value = "searchName") String searchName,
|
||||
@Param(value = "searchKeyword") String searchKeyword,
|
||||
@Param(value = "activityId") String activityId,
|
||||
@Param(value = "unionId") String unionId,
|
||||
@Param(value = "unitId") String unitId,
|
||||
@Param(value = "mode") String mode,
|
||||
HttpServletResponse response) {
|
||||
List<NutMap> stepRankingList = fitnessWalkCommonService.getStepRankingList(searchName, searchKeyword, activityId, unionId, unitId, mode);
|
||||
|
||||
List<ExcelExportEntity> entityList = new ArrayList<>();
|
||||
ExcelExportEntity no = new ExcelExportEntity("序号", "no", 10);
|
||||
no.setFormat("isAddIndex");
|
||||
entityList.add(no);
|
||||
entityList.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
entityList.add(new ExcelExportEntity("工号", "loginname", 20));
|
||||
entityList.add(new ExcelExportEntity("分工会", "unionname", 20));
|
||||
entityList.add(new ExcelExportEntity("单位", "unitname", 20));
|
||||
entityList.add(new ExcelExportEntity("today".equals(mode) ? "今日步数" :"活动期间总步数", "total_steps", 20));
|
||||
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, stepRankingList);
|
||||
String fileName = ( "today".equals(mode) ? DateUtil.format(new Date(),"yyyy年MM月dd日") : "活动期间总") + "步数榜.xlsx";
|
||||
CommonDownloadUtil.download(fileName, workbook, response);
|
||||
}
|
||||
|
||||
@At
|
||||
@SaCheckPermission("fitnessWalk.stepRanking")
|
||||
public Result getCascadersActivity(@Param(value = "year") int year) {
|
||||
List<Cascader> cascaders = fitnessWalkCommonService.cascaderActivity(year, FitnessWalkMode.STEP_COUNT);
|
||||
return Result.success(cascaders);
|
||||
}
|
||||
}
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.controller;
|
||||
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
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.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.base.utils.CommonDownloadUtil;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.contants.Cascader;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.contants.FitnessWalkMode;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.service.FitnessWalkCommonService;
|
||||
import com.budwk.app.base.param.PageForm;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.utils.WeAppCloudUtil;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.cri.SqlExpressionGroup;
|
||||
import org.nutz.integration.jedis.RedisService;
|
||||
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 org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@IocBean
|
||||
@Ok("json")
|
||||
@At("/platform/fitnessWalk/stepStatistics")
|
||||
public class FitnessWalkStepStatisticsController {
|
||||
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
|
||||
@Inject
|
||||
private WeAppCloudUtil weAppCloudUtil;
|
||||
|
||||
@Inject
|
||||
private RedisService redisService;
|
||||
|
||||
@Inject
|
||||
private FitnessWalkCommonService fitnessWalkCommonService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zhgh/activity/fitnessWalk/stepStatistics.html")
|
||||
@SaCheckPermission("fitnessWalk.stepStatistics")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
|
||||
private String getSql() {
|
||||
return """
|
||||
SELECT
|
||||
u.loginname,
|
||||
u.username,
|
||||
u.unionname,
|
||||
u.unitname,
|
||||
al.applyDate,
|
||||
al.step,
|
||||
date_format(al.applyDate,'%Y-%m-%d') as prizeData
|
||||
FROM
|
||||
`fitness_walk_step` al
|
||||
LEFT JOIN `vw_user` u ON u.id = al.userId
|
||||
$condition
|
||||
""";
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json:full")
|
||||
@SaCheckPermission("fitnessWalk.stepStatistics")
|
||||
public Result pageData(PageForm pageForm,
|
||||
@Param(value = "year") Integer year,
|
||||
@Param(value = "activityId") String activityId,
|
||||
@Param(value = "activityDate") String[] activityDate,
|
||||
@Param(value = "unionId") String unionId,
|
||||
@Param(value = "unitId") String unitId) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
Sql sql = Sqls.create(getSql());
|
||||
if (Lang.isNotEmpty(activityDate)) {
|
||||
cnd.and("date_format(al.applyDate,'%Y-%m-%d')", ">=", activityDate[0]);
|
||||
cnd.and("date_format(al.applyDate,'%Y-%m-%d')", "<=", activityDate[1]);
|
||||
}
|
||||
if(StrUtil.isNotBlank(pageForm.getSearchKeyword())){
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.orLike("u.username",pageForm.getSearchKeyword());
|
||||
seg.orLike("u.loginname",pageForm.getSearchKeyword());
|
||||
cnd.and(seg);
|
||||
}
|
||||
cnd.andEX("YEAR(al.applyDate)", "=", year);
|
||||
cnd.andEX("al.activityId", "=", activityId);
|
||||
cnd.andEX("u.unionid", "=", unionId);
|
||||
cnd.andEX("u.unitId", "=", unitId);
|
||||
cnd.desc("al.applyDate");
|
||||
cnd.desc("u.unioncode");
|
||||
cnd.groupBy("al.applyDate", "al.userId");
|
||||
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = baseService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
return Result.success(pagination);
|
||||
}
|
||||
|
||||
@At
|
||||
@SaCheckPermission("fitnessWalk.stepStatistics")
|
||||
public Result getCascadersActivity(@Param(value = "year") int year) {
|
||||
List<Cascader> cascaders = fitnessWalkCommonService.cascaderActivity(year, FitnessWalkMode.STEP_COUNT);
|
||||
return Result.success(cascaders);
|
||||
}
|
||||
|
||||
@At("/exportExcel")
|
||||
@Ok("void")
|
||||
@SaCheckPermission("fitnessWalk.stepStatistics")
|
||||
public void exportExcel(@Param(value = "activityId") String activityId,
|
||||
@Param(value = "activityDate") String[] activityDate,
|
||||
@Param(value = "unionId") String unionId,
|
||||
@Param(value = "unitId") String unitId, HttpServletResponse response) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
Sql sql = Sqls.create(getSql());
|
||||
if (activityDate.length > 0) {
|
||||
cnd.and("date_format(al.applyDate,'%Y-%m-%d')", ">=", activityDate[0]);
|
||||
cnd.and("date_format(al.applyDate,'%Y-%m-%d')", "<=", activityDate[1]);
|
||||
}
|
||||
cnd.andEX("al.activityId", "=", activityId);
|
||||
cnd.andEX("u.unionid", "=", unionId);
|
||||
cnd.andEX("u.unitId", "=", unitId);
|
||||
cnd.desc("al.applyDate");
|
||||
cnd.desc("u.unioncode");
|
||||
sql.setCondition(cnd);
|
||||
|
||||
List<NutMap> exportList = baseService.listMap(sql);
|
||||
|
||||
List<ExcelExportEntity> entityList = new ArrayList<>() {{
|
||||
add(new ExcelExportEntity("姓名", "username", 20));
|
||||
add(new ExcelExportEntity("工号", "loginname", 20));
|
||||
add(new ExcelExportEntity("单位", "unitname", 20));
|
||||
add(new ExcelExportEntity("分工会", "unionname", 20));
|
||||
add(new ExcelExportEntity("当前步数", "step", 20));
|
||||
add(new ExcelExportEntity("日期", "prizeData", 20));
|
||||
}};
|
||||
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, exportList);
|
||||
CommonDownloadUtil.download("计步步数统计表.xlsx", workbook, response);
|
||||
}
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.controller;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
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.service.BaseService;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.contants.Cascader;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.contants.FitnessWalkMode;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.FitnessWalkAwardUser;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.service.FitnessWalkCommonService;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.nutz.dao.Cnd;
|
||||
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 javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* 用户中奖榜
|
||||
*/
|
||||
@Ok("json")
|
||||
@IocBean
|
||||
@At("/platform/fitnessWalk/stepWining")
|
||||
public class FitnessWalkStepWiningController {
|
||||
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
|
||||
@Inject
|
||||
private FitnessWalkCommonService fitnessWalkCommonService;
|
||||
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zhgh/activity/fitnessWalk/stepWining.html")
|
||||
@SaCheckPermission("fitnessWalk.stepWining")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取中奖榜
|
||||
*
|
||||
* @param activityId
|
||||
* @return {@link Object}
|
||||
*/
|
||||
@At
|
||||
@Ok("json:full")
|
||||
@SaCheckLogin
|
||||
@SLog(type = "校工会特色活动",tag = "健身走-计步步数中奖榜",msg = "获取中奖榜",param = true,result = true)
|
||||
public Result getUserStepWining(String activityId) {
|
||||
List<NutMap> winingRankingUserList = fitnessWalkCommonService.getWiningRankingUserList(activityId);
|
||||
return Result.success(winingRankingUserList);
|
||||
}
|
||||
|
||||
@At
|
||||
@SaCheckPermission("fitnessWalk.stepWining")
|
||||
public Result getCascadersActivity(@Param(value = "year") int year) {
|
||||
List<Cascader> cascaders = fitnessWalkCommonService.cascaderActivity(year, FitnessWalkMode.STEP_COUNT);
|
||||
return Result.success(cascaders);
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@SLog(type = "校工会特色活动",tag = "健身走-计步步数中奖榜",msg = "导出中奖榜",param = true,result = true)
|
||||
@SaCheckPermission("fitnessWalk.stepWining")
|
||||
public void exportUserStepWining(String activityId, HttpServletResponse response){
|
||||
List<NutMap> winingRankingUserList = fitnessWalkCommonService.getWiningRankingUserList(activityId);
|
||||
List<ExcelExportEntity> entityList = new ArrayList<>();
|
||||
ExcelExportEntity no = new ExcelExportEntity("序号", "no", 10);
|
||||
no.setFormat("isAddIndex");
|
||||
entityList.add(no);
|
||||
entityList.add(new ExcelExportEntity("工号", "loginName", 20));
|
||||
entityList.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
entityList.add(new ExcelExportEntity("分工会", "unionName", 20));
|
||||
entityList.add(new ExcelExportEntity("单位", "unitName", 40));
|
||||
entityList.add(new ExcelExportEntity("奖项名称", "awardName", 20));
|
||||
entityList.add(new ExcelExportEntity("步数", "awardSteps", 20));
|
||||
entityList.add(new ExcelExportEntity("中奖时间", "applyDate", 20));
|
||||
try {
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("content-disposition", "attachment;filename="
|
||||
+ URLEncoder.encode("中奖明细.zip", "UTF-8"));
|
||||
ZipOutputStream zipOutputStream = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()));
|
||||
for (NutMap map : winingRankingUserList) {
|
||||
List<NutMap> awardList = map.getAsList("awardList", NutMap.class);
|
||||
awardList.forEach(v->v.setv("applyDate",DateUtil.format(v.getTime("applyDate"),"yyyy-MM-dd")));
|
||||
zipOutputStream.putNextEntry(new ZipEntry(map.getString("title") + ".xlsx"));
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), entityList, awardList);
|
||||
workbook.write(zipOutputStream);
|
||||
zipOutputStream.closeEntry();
|
||||
}
|
||||
zipOutputStream.flush();
|
||||
zipOutputStream.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 中奖奖项列表
|
||||
*
|
||||
* @param activityId
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@SaCheckLogin
|
||||
public Result prizeOption(String activityId) {
|
||||
List<NutMap> list = fitnessWalkCommonService.prizeOption(activityId);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 中奖用户
|
||||
* @param lotteryTime
|
||||
* @param activityId
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@SaCheckLogin
|
||||
public Result prizeUsers(String lotteryTime, String activityId) {
|
||||
String lotteryDate = lotteryTime.substring(0, 10);
|
||||
List<FitnessWalkAwardUser> awardUserList = fitnessWalkCommonService.dao().query(FitnessWalkAwardUser.class,
|
||||
Cnd.where("activityId", "=", activityId).and("date(applyDate)", "=", lotteryDate));
|
||||
return Result.success(awardUserList);
|
||||
}
|
||||
|
||||
}
|
||||
+371
@@ -0,0 +1,371 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.controller.weapp;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.interceptor.sLog.SLogService;
|
||||
import com.budwk.app.base.result.Result;
|
||||
|
||||
import com.budwk.app.sys.models.Sys_file;
|
||||
import com.budwk.app.sys.models.Sys_log;
|
||||
import com.budwk.app.sys.models.Sys_user;
|
||||
import com.budwk.app.sys.services.SysFileService;
|
||||
import com.budwk.app.sys.views.View_user;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.FitnessWalkActivity;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.FitnessWalkAwardUser;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.FitnessWalkStep;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.weapp.FitnessWalkGiftVoucher;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.weapp.FitnessWalkRegister;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.weapp.FitnessWalkSign;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.weapp.FitnessWalkSignature;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.service.FitnessWalkCommonService;
|
||||
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.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.json.Json;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.AdaptBy;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
import org.nutz.mvc.upload.TempFile;
|
||||
import org.nutz.mvc.upload.UploadAdaptor;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:FitnessWalkWeAppController
|
||||
* @Date 2025/2/26 15:23
|
||||
* @注释
|
||||
*/
|
||||
@Slf4j
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@At("/platform/fitnessWalk/weApp")
|
||||
public class FitnessWalkWeAppController {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
@Inject
|
||||
private SLogService sLogService;
|
||||
@Inject
|
||||
private SysFileService sysFileService;
|
||||
@Inject
|
||||
private FitnessWalkCommonService fitnessWalkCommonService;
|
||||
|
||||
|
||||
/**
|
||||
* 保存报名信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@SaCheckLogin
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public Result saveRegister(@Param("activityId") String activityId, @Param("userId") String userId) {
|
||||
View_user user = dao.fetch(View_user.class, Cnd.where("id", "=", userId));
|
||||
dao.clear(FitnessWalkRegister.class, Cnd.where("activityId", "=", activityId).and("userId", "=", userId));
|
||||
FitnessWalkRegister register = new FitnessWalkRegister();
|
||||
register.setId(R.UU32());
|
||||
register.setActivityId(activityId);
|
||||
register.setUserId(user.getId());
|
||||
register.setLoginname(user.getLoginname());
|
||||
register.setUsername(user.getUsername());
|
||||
register.setSex(user.getSex());
|
||||
register.setMember(user.getMember());
|
||||
register.setUnionId(user.getUnionId());
|
||||
register.setUnionName(user.getUnionName());
|
||||
register.setUnitId(user.getUnitId());
|
||||
register.setUnitName(user.getUnitName());
|
||||
register.setMobile(user.getMobile());
|
||||
register.setIsLeader(false);
|
||||
dao.fastInsert(register);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 取消报名
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@SaCheckLogin
|
||||
public Result cancelRegister(@Param("activityId") String activityId, @Param("userId") String userId) {
|
||||
dao.clear(FitnessWalkRegister.class, Cnd.where("activityId", "=", activityId).and("userId", "=", userId));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 保存打卡点位信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public Result saveLunchSign(@Param("activityId") String activityId, @Param("userId") String userId,
|
||||
@Param("userLongitude") String userLongitude, @Param("userLatitude") String userLatitude,
|
||||
@Param("ptsCode") Integer ptsCode) {
|
||||
dao.clear(FitnessWalkSign.class, Cnd.where("activityId", "=", activityId).and("userId", "=", userId).and("ptsCode", "=", ptsCode));
|
||||
|
||||
View_user user = dao.fetch(View_user.class, Cnd.where("id", "=", userId));
|
||||
|
||||
FitnessWalkSign sign = new FitnessWalkSign();
|
||||
sign.setId(R.UU32());
|
||||
sign.setActivityId(activityId);
|
||||
sign.setAddress(List.of(userLongitude, userLatitude));
|
||||
sign.setPtsCode(ptsCode);
|
||||
sign.setUserId(userId);
|
||||
sign.setLoginname(user.getLoginname());
|
||||
sign.setUsername(user.getUsername());
|
||||
sign.setUnionName(user.getUnionName());
|
||||
sign.setUnitName(user.getUnitName());
|
||||
sign.setSignData(DateUtil.date());
|
||||
dao.fastInsert(sign);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 保存礼品券信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SaCheckLogin
|
||||
public Result saveGiftVoucher(@Param("activityId") String activityId, @Param("userId") String userId) {
|
||||
dao.clear(FitnessWalkGiftVoucher.class, Cnd.where("activityId", "=", activityId).and("userId", "=", userId));
|
||||
|
||||
View_user user = dao.fetch(View_user.class, Cnd.where("id", "=", userId));
|
||||
FitnessWalkGiftVoucher voucher = new FitnessWalkGiftVoucher();
|
||||
voucher.setId(R.UU32());
|
||||
voucher.setActivityId(activityId);
|
||||
voucher.setGrantTime(DateUtil.date());
|
||||
voucher.setIssuedBy(null);
|
||||
voucher.setUserId(userId);
|
||||
voucher.setLoginname(user.getLoginname());
|
||||
voucher.setUsername(user.getUsername());
|
||||
voucher.setUnionName(user.getUnionName());
|
||||
voucher.setUnitName(user.getUnitName());
|
||||
voucher.setUseTime(null);
|
||||
voucher.setUsed(false);
|
||||
dao.fastInsert(voucher);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改礼品卷为领取状态
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@SaCheckLogin
|
||||
public Result receiveGiftVoucher(@Param("activityId") String activityId, @Param("userId") String userId) {
|
||||
dao.update(FitnessWalkGiftVoucher.class, Chain.make("used", true).add("useTime", DateUtil.date()),
|
||||
Cnd.where("activityId", "=", activityId).and("userId", "=", userId));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断当前时间,用户是否达标了
|
||||
*
|
||||
* @param userId
|
||||
* @param activityId
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@SaCheckLogin
|
||||
public Result validateStepCanChooseWelfare(@Param("activityId") String activityId, @Param("userId") String userId) {
|
||||
try {
|
||||
FitnessWalkActivity activity = fitnessWalkCommonService.getActivity(activityId);
|
||||
// 判断领取福利的条件
|
||||
if (activity.getStepReceive()) {
|
||||
// 达标可以选福利
|
||||
if (activity.getIsAutoLottery()) {
|
||||
// 系统自动抽奖
|
||||
if ("custom".equals(activity.getLotteryMode())) {
|
||||
// 自定义模式的达标,判断当前时间在定义时间段的范围内的总步数,是否达标
|
||||
List<FitnessWalkActivity.CustomLotteryRule> ruleList = activity.getCustomLotteryRules();
|
||||
|
||||
// 找出当前时间在定义时间段的范围内的规则
|
||||
FitnessWalkActivity.CustomLotteryRule customLotteryRule = ruleList.stream()
|
||||
.filter(v -> DateUtil.isIn(DateUtil.date(), v.getStartDate(), v.getEndDate()))
|
||||
.collect(Collectors.toList()).stream().findFirst().orElse(new FitnessWalkActivity.CustomLotteryRule());
|
||||
|
||||
if (Lang.isEmpty(customLotteryRule)) {
|
||||
return Result.error("当前时间不在活动时间范围内");
|
||||
} else {
|
||||
Sql sql = fitnessWalkCommonService.commonSql();
|
||||
if (customLotteryRule.getLotteryQualificationDay() != null) {
|
||||
sql.setVar("lotteryQualificationDaySql", new Static(" AND step >= '%d' ".formatted(customLotteryRule.getLotteryQualificationStep())));
|
||||
sql.setVar("stepHavingSql", new Static(" over3k.standardsDays >= '%d' ".formatted(customLotteryRule.getLotteryQualificationDay())));
|
||||
} else {
|
||||
sql.setVar("stepHavingSql", new Static(" COALESCE(SUM(sub.step), 0) >= '%d' ".formatted(customLotteryRule.getLotteryQualificationStep())));
|
||||
}
|
||||
sql.setVar("whereSql", new Static(" where u.id = '%s'".formatted(userId)));
|
||||
sql.setParam("activityId", activityId);
|
||||
sql.setParam("startDate", customLotteryRule.getStartDate());
|
||||
sql.setParam("endDate", customLotteryRule.getEndDate());
|
||||
sql.setCallback(Sqls.callback.map());
|
||||
dao.execute(sql);
|
||||
NutMap nutMap = (NutMap) sql.getResult();
|
||||
if (Lang.isEmpty(nutMap)) {
|
||||
return Result.error();
|
||||
} else {
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
} else if ("everyDay".equals(activity.getLotteryMode())) {
|
||||
// 如果是每日,只需要判断今天的步数是否达标
|
||||
FitnessWalkStep step = dao.fetch(FitnessWalkStep.class, Cnd.where("activityId", "=", activityId)
|
||||
.and("userId", "=", userId).and("applyDate", "=", DateUtil.today())
|
||||
.desc("step"));
|
||||
// 找出当天的步数,判断是否达标
|
||||
|
||||
FitnessWalkActivity.DayLotteryRule rule = activity.getDayLotteryRule();
|
||||
|
||||
if (step.getStep() > rule.getLotteryQualificationStep()) {
|
||||
return Result.success();
|
||||
} else {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 手动抽奖的达标
|
||||
Sql sql = fitnessWalkCommonService.commonSql();
|
||||
|
||||
sql.setVar("lotteryQualificationDaySql", new Static(" AND step >= '%d' ".formatted(activity.getLotteryQualificationSteps())));
|
||||
sql.setVar("stepHavingSql", new Static(" over3k.standardsDays >= '%d' ".formatted(activity.getLotteryQualificationDays())));
|
||||
sql.setVar("whereSql", new Static(" where u.id = '%s'".formatted(userId)));
|
||||
sql.setParam("activityId", activityId);
|
||||
DateTime startTime = DateUtil.date(activity.getStartTime());
|
||||
DateTime endTime = DateUtil.date(activity.getEndTime());
|
||||
sql.setParam("startDate", startTime);
|
||||
sql.setParam("endDate", endTime);
|
||||
|
||||
sql.setCallback(Sqls.callback.map());
|
||||
dao.execute(sql);
|
||||
NutMap nutMap = (NutMap) sql.getResult();
|
||||
if (Lang.isEmpty(nutMap)) {
|
||||
return Result.error();
|
||||
} else {
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 不按照达标,按照中奖,这块就比较简单了,直接去中奖表里边找人,有人就返回true
|
||||
int count = dao.count(FitnessWalkAwardUser.class, Cnd.where("activityId", "=", activityId).and("userId", "=", userId));
|
||||
if (count <= 0) {
|
||||
return Result.error();
|
||||
} else {
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
return Result.error();
|
||||
} catch (Exception e) {
|
||||
log.error("validateStepCanLottery error", e);
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断当前用户是否签字
|
||||
*
|
||||
* @param activityId
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@SaCheckLogin
|
||||
public Result validateStepCanSign(@Param("activityId") String activityId, @Param("userId") String userId) {
|
||||
FitnessWalkAwardUser user = dao.fetch(FitnessWalkAwardUser.class, Cnd.where("activityId", "=", activityId).and("userId", "=", userId));
|
||||
if (Lang.isEmpty(user)) {
|
||||
return Result.error();
|
||||
} else {
|
||||
return Result.success().addData(NutMap.NEW().addv("sign", StrUtil.isNotBlank(user.getSignatureId())));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
|
||||
@SaCheckLogin
|
||||
public Result saveSignature(@Param("file") TempFile file, @Param("activityId") String activityId,
|
||||
@Param("userId") String userId, HttpServletRequest request) {
|
||||
// System.out.println(file.getFile());
|
||||
// System.out.println(file);
|
||||
//
|
||||
// if (Lang.isEmpty(file)) {
|
||||
// return Result.error("文件不能为空");
|
||||
// }
|
||||
//
|
||||
// Sys_user user = dao.fetch(Sys_user.class, Cnd.where("id", "=", userId));
|
||||
// Sys_log sysLog = new Sys_log();
|
||||
// sysLog.setType("info");
|
||||
// sysLog.setTag("上传文件");
|
||||
// sysLog.setSrc(this.getClass().getName() + "#uploadFile");
|
||||
// sysLog.setIp(Lang.getIP(request));
|
||||
// sysLog.setCreatedBy(user.getId());
|
||||
// sysLog.setUsername(user.getUsername());
|
||||
// sysLog.setLoginname(user.getLoginname());
|
||||
// sysLog.setParam(file.getSubmittedFileName());
|
||||
//
|
||||
// try {
|
||||
// Sys_file sysFile = sysFileService.saveFile(file, 2, null);
|
||||
// sysLog.setMsg("上传成功");
|
||||
// sysLog.setResult(Json.toJson(sysFile));
|
||||
//
|
||||
// // 如果该活动下,这个userId有签字,删掉再插入
|
||||
// dao.clear(FitnessWalkSignature.class, Cnd.where("activityId", "=", activityId).and("userId", "=", userId));
|
||||
// // 保存签字
|
||||
// FitnessWalkSignature signature = new FitnessWalkSignature();
|
||||
// signature.setId(R.UU32());
|
||||
// signature.setActivityId(activityId);
|
||||
// signature.setUserId(userId);
|
||||
// signature.setLoginname(user.getLoginname());
|
||||
// signature.setUsername(user.getUsername());
|
||||
// signature.setSignatureData(DateUtil.date());
|
||||
// signature.setUserSign(sysFile.getFilepath());
|
||||
// dao.insert(signature);
|
||||
//
|
||||
// // 看这个健步走活动是不是计步模式,如果是,要关联用户中奖的中奖记录
|
||||
// int count = dao.count(FitnessWalkAwardUser.class, Cnd.where("id", "=", activityId).and("userId", "=", userId));
|
||||
// if (count > 0) {
|
||||
// dao.update(FitnessWalkAwardUser.class, Chain.make("signatureId", signature.getId()),
|
||||
// Cnd.where("activityId", "=", activityId).and("userId", "=", userId));
|
||||
// }
|
||||
// return Result.success("签字保存成功");
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// sysLog.setMsg("上传失败");
|
||||
// sysLog.setResult(e.getMessage());
|
||||
// return Result.error("签字保存失败");
|
||||
// } finally {
|
||||
// sLogService.async(sysLog);
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,339 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.model;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Table
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class FitnessWalkActivity extends BaseModel{
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String _id;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("主活动名称")
|
||||
private String masterActivityName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("分活动名称")
|
||||
private String branchActivityName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("活动地址")
|
||||
private String address;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("礼品名称")
|
||||
private String giftName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("活动组别id")
|
||||
private String groupId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("所属工会id")
|
||||
private String unionId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("活动类别")
|
||||
private String activityModel;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
@Comment("活动报名时间数组")
|
||||
private Long[] applyTime;
|
||||
|
||||
@Column
|
||||
@ColDefine(customType = "bigint")
|
||||
@Comment("活动报名开始时间")
|
||||
private Long applyStartTime;
|
||||
|
||||
@Column
|
||||
@ColDefine(customType = "bigint")
|
||||
@Comment("活动报名结束时间")
|
||||
private Long applyEndTime;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
@Comment("活动举行时间范围")
|
||||
private Long[] time;
|
||||
|
||||
@Column
|
||||
@ColDefine(customType = "bigint")
|
||||
@Comment("活动开始时间")
|
||||
private Long startTime;
|
||||
|
||||
@Column
|
||||
@ColDefine(customType = "bigint")
|
||||
@Comment("活动结束时间")
|
||||
private Long endTime;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.TEXT)
|
||||
@Comment("备注")
|
||||
private String note;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("封面")
|
||||
private String cover;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("封面")
|
||||
private String tempCover;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
@Comment("是否答题")
|
||||
private Boolean isQuestion;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("答题id")
|
||||
private String questionId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("速度控制")
|
||||
private String speedControlMode;
|
||||
|
||||
//打卡完成之后 gift_voucher:礼品券 cert:完赛证书 null啥也不干
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("打卡完成后发放什么")
|
||||
private String punchFinishAfter;
|
||||
|
||||
//完赛证书
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("完赛证书")
|
||||
private String completionCertificateCover;
|
||||
|
||||
//完赛证书临时url
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("完赛证书临时url")
|
||||
private String tempCompletionCertificateCover;
|
||||
|
||||
//是否抽奖
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("是否抽奖")
|
||||
private Boolean isLottery;
|
||||
|
||||
//打卡模式奖品列表
|
||||
@Column
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
@Comment("打卡模式奖品")
|
||||
private List<PunchLotteryPrize> punchLotteryPrizes;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
@Comment("活动")
|
||||
private Boolean showGiftTicket;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
@Comment("点位坐标")
|
||||
private List<Pts> pts;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
@Comment("线路点位")
|
||||
private List<Point> linePoints;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
@Comment("第二条线路的点位")
|
||||
private List<Point> linePoints2;
|
||||
|
||||
//是否按顺序签到
|
||||
@Column
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
@Comment("是否按顺序签到")
|
||||
private Boolean isOrderSignIn;
|
||||
|
||||
//是否多条线路
|
||||
@Column
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
@Comment("是否有多条线路")
|
||||
private Boolean isMultipleLines;
|
||||
|
||||
//抽奖模式 none无 everyday每天 monthly每月 custom自定义
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("计步抽奖模式")
|
||||
private String lotteryMode;
|
||||
|
||||
//每月抽奖模式抽奖时间
|
||||
@Column
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
@Comment("计步模式抽奖时间")
|
||||
private List<Date> everyMonthLotteryTime;
|
||||
|
||||
//自定义模式抽奖抽奖时间规则
|
||||
@Column
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
@Comment("计步模式自定义抽奖时间及规则")
|
||||
private List<CustomLotteryRule> customLotteryRules;
|
||||
|
||||
//每日模式抽奖抽奖时间规则
|
||||
@Column
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
@Comment("计步模式每日抽奖规则")
|
||||
private DayLotteryRule dayLotteryRule;
|
||||
|
||||
//随机图片数组
|
||||
@Column
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
@Comment("打卡点位随机数组图片")
|
||||
private List<String> randomPics;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
@Comment("打卡模式点位随机图片上传临时URL")
|
||||
private List<String> templateRandomPics;
|
||||
|
||||
//外链地址
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("外链地址")
|
||||
private String externalLinkAddress;
|
||||
|
||||
//是否开启距离限制
|
||||
@Column
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
@Comment("是否开启距离限制")
|
||||
private Boolean enableDistance;
|
||||
|
||||
//签到几个点位算完成
|
||||
@Column
|
||||
@ColDefine(type = ColType.INT)
|
||||
@Comment("签到几个点位算完成")
|
||||
private Integer finishPointNum;
|
||||
|
||||
// 是否自动抽奖
|
||||
@Column
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
@Comment("是否自动抽奖")
|
||||
private Boolean isAutoLottery;
|
||||
|
||||
// 手动抽奖,抽奖资格天数
|
||||
@Column
|
||||
@ColDefine(type = ColType.INT)
|
||||
@Comment("手动抽奖,抽奖资格天数")
|
||||
private Integer lotteryQualificationDays;
|
||||
|
||||
// 手动抽奖,抽奖资格步数
|
||||
@Column
|
||||
@ColDefine(type = ColType.INT)
|
||||
@Comment("手动抽奖,抽奖资格步数")
|
||||
private Integer lotteryQualificationSteps;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
@Comment("是否绑定福利")
|
||||
private Boolean hasWelfare;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("绑定福利的id")
|
||||
private String welfareId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
@Comment("完成后是否签字")
|
||||
private Boolean completeIsSign;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
@Comment("计步模式的选福利或签字条件,true:达标 false:中奖")
|
||||
private Boolean stepReceive;
|
||||
|
||||
@Data
|
||||
public static class Point implements Serializable {
|
||||
private String type;
|
||||
private Double[] coordinates;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Pts implements Serializable {
|
||||
private int code;
|
||||
private String name;
|
||||
private int interval;
|
||||
private List<String> issueIds;
|
||||
private Point location;
|
||||
private int radius;
|
||||
private String tip;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义抽奖规则
|
||||
*/
|
||||
@Data
|
||||
public static class CustomLotteryRule implements Serializable {
|
||||
//抽奖时间
|
||||
private Date lotteryTime;
|
||||
//抽奖从那天开始计算
|
||||
private Date startDate;
|
||||
//抽奖截至到哪天
|
||||
private Date endDate;
|
||||
//奖项名称
|
||||
private String awardName;
|
||||
//抽奖人数
|
||||
private Integer lotteryUserNum;
|
||||
//抽奖资格步数
|
||||
private Integer lotteryQualificationStep;
|
||||
//抽奖资格天数
|
||||
private Integer lotteryQualificationDay;
|
||||
}
|
||||
|
||||
/**
|
||||
* 每日抽奖规则
|
||||
*/
|
||||
@Data
|
||||
public static class DayLotteryRule implements Serializable {
|
||||
//抽奖资格步数
|
||||
private Integer lotteryQualificationStep;
|
||||
//抽奖资格天数
|
||||
private Integer lotteryQualificationDay;
|
||||
//抽奖人数
|
||||
private Integer lotteryUserNum;
|
||||
//是否可以重复抽奖
|
||||
private Boolean repeatLottery;
|
||||
//是否可以增加抽奖机会
|
||||
private Boolean addLotteryChance;
|
||||
//每日抽奖模式抽奖时间
|
||||
private String everyDayLotteryTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打卡抽奖奖品列表
|
||||
*/
|
||||
@Data
|
||||
public static class PunchLotteryPrize implements Serializable{
|
||||
private String name;
|
||||
private String value;
|
||||
private String url;
|
||||
//份数
|
||||
private String num;
|
||||
}
|
||||
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.model;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Table
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class FitnessWalkAwardUser extends BaseModel {
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("活动")
|
||||
private String activityId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("用户Id")
|
||||
private String userId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("工号")
|
||||
private String loginName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("姓名")
|
||||
private String username;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("奖项名称")
|
||||
private String awardName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("工会id")
|
||||
private String unionId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
@Comment("工会名称")
|
||||
private String unionName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("单位id")
|
||||
private String unitId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.INT)
|
||||
@Comment("达标天数")
|
||||
private Integer standardsDays;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 20)
|
||||
@Comment("中奖步数")
|
||||
private String awardSteps;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
@Comment("单位名称")
|
||||
private String unitName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
@Comment("中奖时间")
|
||||
private Date applyDate;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
@Comment("是否已读")
|
||||
private Boolean isRead;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.DATE)
|
||||
@Comment("开始时间")
|
||||
private Date startDate;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.DATE)
|
||||
@Comment("结束时间")
|
||||
private Date endDate;
|
||||
|
||||
@Column
|
||||
@Comment("健步走签字表的id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String signatureId;
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.model;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table
|
||||
@Data
|
||||
@Comment("打卡模式抽奖记录")
|
||||
public class FitnessWalkPunchLottery extends BaseModel {
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
@Comment("活动")
|
||||
private String activityId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
@Comment("中奖用户")
|
||||
private String userName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 20)
|
||||
@Comment("奖品名称")
|
||||
private String prizeName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 20)
|
||||
@Comment("奖品")
|
||||
private String prizeId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
@Comment("是否中奖")
|
||||
private Boolean isWin;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
@Comment("是否中奖")
|
||||
private Date winDate;
|
||||
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.model;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:FitenssWalkRaffleRules
|
||||
* @Date 2024/12/28 10:05
|
||||
* @注释
|
||||
*/
|
||||
@Data
|
||||
@Table
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class FitnessWalkRaffleRules extends BaseModel {
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("活动id")
|
||||
private String activityId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
@Comment("手动抽奖规则")
|
||||
private List<ManualLotteryRules> manualLotteryRules;
|
||||
|
||||
@Data
|
||||
public static class ManualLotteryRules implements Serializable {
|
||||
// 奖项名称
|
||||
private String awardName;
|
||||
// 抽奖人数
|
||||
private Integer lotteryUserNum;
|
||||
// 抽奖类型
|
||||
private String raffleType;
|
||||
// 排名位次
|
||||
private Integer rankingPosition;
|
||||
// 是否兼得
|
||||
private Boolean isSimultaneously;
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.model;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:FitnessWalkRaffleUser
|
||||
* @Date 2024/12/28 17:10
|
||||
* @注释
|
||||
*/
|
||||
@Data
|
||||
@Table
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class FitnessWalkRaffleUser extends BaseModel {
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@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 userId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
@Comment("用户工号")
|
||||
private String loginName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
@Comment("用户姓名")
|
||||
private String username;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.INT)
|
||||
@Comment("达标天数")
|
||||
private Integer standardsDays;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 20)
|
||||
@Comment("中奖步数")
|
||||
private String awardSteps;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
@Comment("是否已抽奖")
|
||||
private Boolean isRaffle;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.model;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
//@Table("fitness_walk_step_${month}")
|
||||
@Table
|
||||
public class FitnessWalkStep extends BaseModel implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("活动id")
|
||||
private String activityId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("姓名Id")
|
||||
private String userId;
|
||||
|
||||
@Column
|
||||
@ColDefine(customType = "int")
|
||||
@Comment("步数")
|
||||
private Integer step;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.DATE)
|
||||
@Comment("时间")
|
||||
private Date applyDate;
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.model.weapp;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:FitnessWalkGiftVoucher
|
||||
* @Date 2025/2/26 14:45
|
||||
* @注释 小程序礼物发放表
|
||||
*/
|
||||
@Data
|
||||
@Table
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class FitnessWalkGiftVoucher extends BaseModel {
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("活动id")
|
||||
private String activityId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
@Comment("授予时间")
|
||||
private Date grantTime;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("授予人")
|
||||
private String issuedBy;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("userid")
|
||||
private String userId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("工号")
|
||||
private String loginname;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("姓名")
|
||||
private String username;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("工会")
|
||||
private String unionName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("单位")
|
||||
private String unitName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
@Comment("使用时间")
|
||||
private Date useTime;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
@Comment("是否使用")
|
||||
private Boolean used;
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.model.weapp;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:FitnessWalkRegister
|
||||
* @Date 2025/2/26 14:53
|
||||
* @注释 小程序报名表
|
||||
*/
|
||||
@Data
|
||||
@Table
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class FitnessWalkRegister extends BaseModel {
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("活动id")
|
||||
private String activityId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
@Comment("是否领队")
|
||||
private Boolean isLeader;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("userId")
|
||||
private String userId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("工号")
|
||||
private String loginname;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("姓名")
|
||||
private String username;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("性别")
|
||||
private String sex;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("工会id")
|
||||
private String unionId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("工会名称")
|
||||
private String unionName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("单位id")
|
||||
private String unitId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("单位名称")
|
||||
private String unitName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("联系方式")
|
||||
private String mobile;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.INT)
|
||||
@Comment("会员")
|
||||
private Integer member;
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.model.weapp;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:FitnessWalkSign
|
||||
* @Date 2025/2/26 15:05
|
||||
* @注释 小程序点位签到表
|
||||
*/
|
||||
@Data
|
||||
@Table
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class FitnessWalkSign extends BaseModel {
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("活动id")
|
||||
private String activityId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
@Comment("打卡经纬度")
|
||||
private List<String> address;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.INT)
|
||||
@Comment("打卡的点位记录,打的第几个卡")
|
||||
private Integer ptsCode;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("userId")
|
||||
private String userId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("工号")
|
||||
private String loginname;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("姓名")
|
||||
private String username;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("工会")
|
||||
private String unionName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("单位")
|
||||
private String unitName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
@Comment("打卡时间")
|
||||
private Date signData;
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.model.weapp;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:FitnessWalkSignature
|
||||
* @Date 2025/3/7 11:16
|
||||
* @注释 健步走签字表
|
||||
*/
|
||||
@Data
|
||||
@Table
|
||||
@Comment("健步走签字表")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class FitnessWalkSignature extends BaseModel {
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("活动id")
|
||||
private String activityId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("签字人")
|
||||
private String userId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("工号")
|
||||
private String loginname;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
@Comment("姓名")
|
||||
private String username;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
@Comment("签字时间")
|
||||
private Date signatureData;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 150)
|
||||
@Comment("签字数据")
|
||||
private String userSign;
|
||||
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.service;
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.sys.models.Sys_user;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:FitnessWalkAuthService
|
||||
* @Date 2025/7/24 10:35
|
||||
* @注释
|
||||
*/
|
||||
public interface FitnessWalkAuthService extends BaseService {
|
||||
|
||||
/**
|
||||
* 检查工号是否存在
|
||||
* @param loginname
|
||||
* @return
|
||||
*/
|
||||
boolean checkLoginName(String loginname);
|
||||
|
||||
/**
|
||||
* 获取短信验证码
|
||||
* @param loginname
|
||||
*/
|
||||
void getSmsCode(String loginname);
|
||||
|
||||
/**
|
||||
* 验证短信验证码
|
||||
* @param loginname
|
||||
* @param code
|
||||
*/
|
||||
void checkSmsCode(String loginname, String code);
|
||||
|
||||
/**
|
||||
* 验证密码
|
||||
* @param user
|
||||
* @param password
|
||||
*/
|
||||
void checkPassword(Sys_user user, String password);
|
||||
}
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.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.fitnessWalk.contants.Cascader;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.contants.FitnessWalkMode;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.FitnessWalkActivity;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface FitnessWalkCommonService extends BaseService {
|
||||
|
||||
//活动缓存时间
|
||||
int CACHE_TIME = 7200;
|
||||
|
||||
/**
|
||||
* 活动,从Redis中取
|
||||
*
|
||||
* @param activityId 活动id
|
||||
* @return
|
||||
*/
|
||||
FitnessWalkActivity getActivity(String activityId);
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有活动
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<FitnessWalkActivity> getAllActivity();
|
||||
|
||||
/**
|
||||
* 级联活动
|
||||
*/
|
||||
List<Cascader> cascaderActivity(int year, FitnessWalkMode mode);
|
||||
|
||||
|
||||
/**
|
||||
* 添加活动或修改活动,存放至redis
|
||||
*
|
||||
* @param activity 活动
|
||||
* @param isAddOrEdit true:新增;false修改
|
||||
*/
|
||||
void addOrEditDoSaveRedis(FitnessWalkActivity activity, Boolean isAddOrEdit);
|
||||
|
||||
|
||||
/**
|
||||
* 健身走抽奖模式添加定时抽奖任务
|
||||
*
|
||||
* @param fitnessWalkActivity 活动
|
||||
*/
|
||||
void addLotteryTask(FitnessWalkActivity fitnessWalkActivity);
|
||||
|
||||
|
||||
/**
|
||||
* 获取步数排行榜
|
||||
*
|
||||
* @param activityId 活动id
|
||||
* @param unionId 工会id
|
||||
* @param unitId 单位id
|
||||
* @param mode today all
|
||||
* @return
|
||||
*/
|
||||
Pagination getStepRankingPagination(PageForm pageForm, String activityId, String unionId, String unitId, String mode);
|
||||
|
||||
List<NutMap> getStepRankingList(String searchName, String searchKeyword, String activityId, String unionId, String unitId, String mode);
|
||||
|
||||
|
||||
/**
|
||||
* 获取中奖榜
|
||||
*
|
||||
* @param activityId 活动id
|
||||
* @return
|
||||
*/
|
||||
List<NutMap> getWiningRankingUserList(String activityId);
|
||||
|
||||
/**
|
||||
* 中奖奖项列表
|
||||
*
|
||||
* @param activityId
|
||||
* @return
|
||||
*/
|
||||
List<NutMap> prizeOption(String activityId);
|
||||
|
||||
|
||||
/**
|
||||
* 查询达标的sql,很多地方都是通用的
|
||||
*/
|
||||
default Sql commonSql(){
|
||||
return Sqls.create("""
|
||||
SELECT
|
||||
u.id,
|
||||
COALESCE(SUM(sub.step), 0) AS total_steps,
|
||||
u.loginname,
|
||||
u.username,
|
||||
u.unionid,
|
||||
u.unionname,
|
||||
u.unitid,
|
||||
u.unitname,
|
||||
over3k.standardsDays
|
||||
FROM
|
||||
`view_user` u
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
userId,
|
||||
applyDate,
|
||||
step
|
||||
FROM
|
||||
`fitness_walk_step`
|
||||
WHERE
|
||||
activityId = @activityId
|
||||
AND DATE(applyDate) >= @startDate
|
||||
AND DATE(applyDate) <= @endDate
|
||||
$lotteryQualificationDaySql
|
||||
GROUP BY
|
||||
userId,
|
||||
applyDate
|
||||
) AS sub ON u.id = sub.userId
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
userId,
|
||||
COUNT(DISTINCT DATE(applyDate)) AS standardsDays
|
||||
FROM
|
||||
`fitness_walk_step`
|
||||
WHERE
|
||||
activityId = @activityId
|
||||
AND DATE(applyDate) >= @startDate
|
||||
AND DATE(applyDate) <= @endDate
|
||||
$lotteryQualificationDaySql
|
||||
GROUP BY
|
||||
userId
|
||||
) AS over3k ON u.id = over3k.userId
|
||||
$whereSql
|
||||
GROUP BY
|
||||
u.id,
|
||||
u.username,
|
||||
u.loginname,
|
||||
u.unionname,
|
||||
u.unitname
|
||||
HAVING
|
||||
$stepHavingSql
|
||||
""");
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.service;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface FitnessWalkPunchStatisticsService extends BaseService {
|
||||
|
||||
List<NutMap> unionRegCheckInNum(String activityId, String unionId);
|
||||
|
||||
List<JSONObject> unionRegistrationData(String activityId, String unionId);
|
||||
|
||||
List<JSONObject> unionCheckInData(String activityId, String unionId);
|
||||
|
||||
List<JSONObject> exportNotGetGiftVoucherUsers(String activityId);
|
||||
List<JSONObject> exportNotUseGiftVoucherUsers(String activityId);
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.service;
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.FitnessWalkRaffleRules;
|
||||
import com.budwk.app.base.param.PageForm;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:FitnessWalkStepRaffleService
|
||||
* @Date 2024/12/28 11:13
|
||||
* @注释
|
||||
*/
|
||||
public interface FitnessWalkStepRaffleService extends BaseService<FitnessWalkRaffleRules> {
|
||||
|
||||
Sql getRaffleSql(PageForm pageForm, String activityId, String unionId, String unitId);
|
||||
|
||||
/**
|
||||
* 获取活动的奖项
|
||||
* @param activityId
|
||||
* @return
|
||||
*/
|
||||
List<NutMap> getActivityAwardList(String activityId);
|
||||
|
||||
/**
|
||||
* 手动抽奖
|
||||
* @param activityId 活动id
|
||||
*/
|
||||
void manualLottery(String activityId);
|
||||
}
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.service.impl;
|
||||
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.constant.RedisConstant;
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.sys.models.Sys_user;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.service.FitnessWalkAuthService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.integration.jedis.RedisService;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:FitnessWalkAuthServiceImpl
|
||||
* @Date 2025/7/24 10:35
|
||||
* @注释
|
||||
*/
|
||||
@Slf4j
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class FitnessWalkAuthServiceImpl extends BaseServiceImpl implements FitnessWalkAuthService {
|
||||
|
||||
@Inject
|
||||
private RedisService redisService;
|
||||
|
||||
|
||||
public FitnessWalkAuthServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查工号是否存在
|
||||
* @param loginname
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean checkLoginName(String loginname) {
|
||||
int count = dao().count(Sys_user.class, Cnd.where("loginname", "=", loginname));
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取短信验证码
|
||||
* @param loginname
|
||||
*/
|
||||
@Override
|
||||
public void getSmsCode(String loginname) {
|
||||
// String text = R.captchaNumber(6);
|
||||
String text = "965098";
|
||||
String codeFromRedis = redisService.get(RedisConstant.REDIS_KEY_FITNESS_WALK_LOGIN_CAPTCHA + loginname + ":LOCK");
|
||||
if (Strings.isNotBlank(codeFromRedis)) {
|
||||
throw new RuntimeException("请1分钟之后再试");
|
||||
}
|
||||
ThreadUtil.execute(() -> {
|
||||
String content = "【智慧工会】您的验证码为%s,用于小程序安全验证,5分钟内有效,若非本人操作,请忽略此消息。".formatted(text);
|
||||
// msgApi.sendMsg(content, loginname, MsgApi.DING_DING_TEMPLATE_ID);
|
||||
log.debug("FitnessWalkLoginNameCode:::::::" + content);
|
||||
redisService.setex(RedisConstant.REDIS_KEY_FITNESS_WALK_LOGIN_CAPTCHA + loginname, 300, text);
|
||||
redisService.setex(RedisConstant.REDIS_KEY_FITNESS_WALK_LOGIN_CAPTCHA + loginname + ":LOCK", 60, text);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 验证短信验证码
|
||||
* @param loginname
|
||||
* @param code
|
||||
*/
|
||||
@Override
|
||||
public void checkSmsCode(String loginname, String code) {
|
||||
String codeFromRedis = redisService.get(RedisConstant.REDIS_KEY_FITNESS_WALK_LOGIN_CAPTCHA + loginname);
|
||||
|
||||
if (Strings.isBlank(code)) {
|
||||
throw new RuntimeException("请输入验证码");
|
||||
}
|
||||
if (Strings.isEmpty(codeFromRedis)) {
|
||||
throw new RuntimeException("验证码已过期");
|
||||
}
|
||||
if (!Strings.equalsIgnoreCase(code, codeFromRedis)) {
|
||||
throw new RuntimeException("验证码不正确");
|
||||
}
|
||||
|
||||
redisService.del(RedisConstant.REDIS_KEY_FITNESS_WALK_LOGIN_CAPTCHA + loginname);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证密码
|
||||
* @param user
|
||||
*/
|
||||
@Override
|
||||
public void checkPassword(Sys_user user, String password) {
|
||||
if (StrUtil.isBlank(password)) {
|
||||
throw new RuntimeException("请输入密码");
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(user.getIdCard()) || (user.getIdCard().length() < 6) ||
|
||||
(!password.equals(StringUtils.right(user.getIdCard(), 6)))) {
|
||||
throw new RuntimeException("账号或密码错误");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+481
@@ -0,0 +1,481 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.budwk.app.base.constant.RoleConstant;
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.sys.models.Sys_task;
|
||||
import com.budwk.app.sys.services.SysTaskService;
|
||||
import com.budwk.app.task.services.TaskPlatformService;
|
||||
import com.budwk.app.web.commons.auth.utils.AuthUtil;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.contants.Cascader;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.contants.FitnessWalkMode;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.FitnessWalkActivity;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.FitnessWalkAwardUser;
|
||||
import com.budwk.app.base.param.PageForm;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.service.FitnessWalkCommonService;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.utils.WeAppCloudUtil;
|
||||
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.integration.jedis.RedisService;
|
||||
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.Strings;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class FitnessWalkCommonServiceImpl extends BaseServiceImpl implements FitnessWalkCommonService {
|
||||
|
||||
@Inject
|
||||
private RedisService redisService;
|
||||
|
||||
@Inject
|
||||
private WeAppCloudUtil weAppCloudUtil;
|
||||
|
||||
@Inject
|
||||
private SysTaskService sysTaskService;
|
||||
|
||||
@Inject
|
||||
private TaskPlatformService taskPlatformService;
|
||||
|
||||
|
||||
public FitnessWalkCommonServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 活动,从Redis中取
|
||||
*
|
||||
* @param activityId 活动id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public FitnessWalkActivity getActivity(String activityId) {
|
||||
String redisKey = "FitnessWalk:" + activityId;
|
||||
Boolean exists = redisService.exists("FitnessWalk:" + activityId);
|
||||
FitnessWalkActivity activity = null;
|
||||
exists = false;
|
||||
if (exists) {
|
||||
String string = redisService.get(redisKey);
|
||||
activity = JSONUtil.toBean(string, FitnessWalkActivity.class);
|
||||
if (Lang.isNotEmpty(activity.getRandomPics())) {
|
||||
List<String> urlStr = new ArrayList<>();
|
||||
for (String url : activity.getRandomPics()) {
|
||||
String tempUrl = weAppCloudUtil.httpFile(url);
|
||||
urlStr.add(tempUrl);
|
||||
}
|
||||
activity.setTemplateRandomPics(urlStr);
|
||||
redisService.set(redisKey, JSONUtil.toJsonStr(activity));
|
||||
}
|
||||
|
||||
if (Strings.isNotBlank(activity.getCover())) {
|
||||
String tempUrl = weAppCloudUtil.httpFile(activity.getCover());
|
||||
activity.setTempCover(tempUrl);
|
||||
}
|
||||
|
||||
if (Strings.isNotBlank(activity.getCompletionCertificateCover())) {
|
||||
String tempUrl = weAppCloudUtil.httpFile(activity.getCompletionCertificateCover());
|
||||
activity.setTempCompletionCertificateCover(tempUrl);
|
||||
}
|
||||
|
||||
} else {
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("db.collection('activity').doc('").append(activityId).append("').get()");
|
||||
try {
|
||||
JSONObject jsonObject = weAppCloudUtil.request(WeAppCloudUtil.CRUD.QUERY, sql.toString());
|
||||
activity = jsonObject.getJSONArray("data").stream().map(v -> JSONUtil.toBean((String) v, FitnessWalkActivity.class)).findFirst().orElse(null);
|
||||
if (Lang.isEmpty(activity)) {
|
||||
return null;
|
||||
}
|
||||
if (Lang.isNotEmpty(activity.getRandomPics())) {
|
||||
List<String> urlStr = new ArrayList<>();
|
||||
for (String url : activity.getRandomPics()) {
|
||||
String tempUrl = weAppCloudUtil.httpFile(url);
|
||||
urlStr.add(tempUrl);
|
||||
}
|
||||
activity.setTemplateRandomPics(urlStr);
|
||||
}
|
||||
if (Strings.isNotBlank(activity.getCover())) {
|
||||
String tempCover = weAppCloudUtil.httpFile(activity.getCover());
|
||||
activity.setTempCover(tempCover);
|
||||
}
|
||||
|
||||
if (Strings.isNotBlank(activity.getCompletionCertificateCover())) {
|
||||
String tempUrl = weAppCloudUtil.httpFile(activity.getCompletionCertificateCover());
|
||||
activity.setTempCompletionCertificateCover(tempUrl);
|
||||
}
|
||||
|
||||
redisService.setex(redisKey, CACHE_TIME, JSONUtil.toJsonStr(activity));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("获取数据异常!");
|
||||
}
|
||||
}
|
||||
|
||||
if (AuthUtil.hasRoleOr(RoleConstant.BRANCH_UNION_CHAIRMAN.name(), RoleConstant.BRANCH_UNION_OPERATOR.name())
|
||||
&& !AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_ADMIN.name())) {
|
||||
return SecurityUtil.getUnionId().equals(activity.getUnionId()) ? activity : null;
|
||||
}
|
||||
|
||||
return activity;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<FitnessWalkActivity> getAllActivity() {
|
||||
List<FitnessWalkActivity> fitnessWalkActivities;
|
||||
if (redisService.exists("FitnessWalk:ActivityList")) {
|
||||
String dataString = redisService.get("FitnessWalk:ActivityList");
|
||||
fitnessWalkActivities = JSONUtil.toList(dataString, FitnessWalkActivity.class);
|
||||
} else {
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("db.collection('activity').field({")
|
||||
.append("masterActivityName:true,")
|
||||
.append("branchActivityName:true,")
|
||||
.append("activityModel:true,")
|
||||
.append("endTime:true,")
|
||||
.append("startTime:true,")
|
||||
.append("unionId:true")
|
||||
.append("}).orderBy('startTime', 'desc').get()");
|
||||
JSONObject jsonObject = weAppCloudUtil.request(WeAppCloudUtil.CRUD.QUERY, sql.toString());
|
||||
fitnessWalkActivities = jsonObject.getJSONArray("data").stream().map(v -> JSONUtil.toBean((String) v, FitnessWalkActivity.class)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
if (AuthUtil.hasRoleOr(RoleConstant.BRANCH_UNION_CHAIRMAN.name(), RoleConstant.BRANCH_UNION_OPERATOR.name())
|
||||
&& !AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_ADMIN.name())) {
|
||||
fitnessWalkActivities = fitnessWalkActivities.stream().filter(v -> SecurityUtil.getUnionId().equals(v.getUnionId())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
redisService.set("FitnessWalk:ActivityList", JSONUtil.toJsonStr(fitnessWalkActivities));
|
||||
return fitnessWalkActivities;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Cascader> cascaderActivity(int year, FitnessWalkMode mode) {
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.YEAR, year);
|
||||
|
||||
long startTs = DateUtil.beginOfYear(calendar.getTime()).getTime();
|
||||
long endTs = DateUtil.endOfYear(calendar.getTime()).getTime();
|
||||
|
||||
List<Cascader> cascaders = this.getAllActivity().stream()
|
||||
.filter(v -> v.getActivityModel().equals(mode.getValue()) && v.getStartTime() >= startTs && v.getStartTime() <= endTs)
|
||||
.collect(Collectors.groupingBy(FitnessWalkActivity::getMasterActivityName))
|
||||
.entrySet().stream()
|
||||
.map(entry -> {
|
||||
Cascader cascader = new Cascader();
|
||||
cascader.setValue(entry.getValue().stream().findFirst().map(FitnessWalkActivity::get_id).orElse(null));
|
||||
cascader.setLabel(entry.getKey());
|
||||
if (entry.getValue().size() > 1) {
|
||||
List<Cascader> children = entry.getValue().stream().map(z -> {
|
||||
Cascader cascader2 = new Cascader();
|
||||
cascader2.setLabel(z.getBranchActivityName());
|
||||
cascader2.setValue(z.get_id());
|
||||
return cascader2;
|
||||
}).collect(Collectors.toList());
|
||||
cascader.setChildren(children);
|
||||
}
|
||||
return cascader;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return cascaders;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOrEditDoSaveRedis(FitnessWalkActivity activity, Boolean isAddOrEdit) {
|
||||
if (!isAddOrEdit) {
|
||||
redisService.del("FitnessWalk:" + activity.get_id());
|
||||
redisService.del("FitnessWalk:ActivityList");
|
||||
}
|
||||
redisService.set("FitnessWalk:" + activity.get_id(), JSONUtil.toJsonStr(activity));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLotteryTask(FitnessWalkActivity fitnessWalkActivity) {
|
||||
//删除和该活动关联的定时任务
|
||||
List<Sys_task> oldTasks = sysTaskService.dao().query(Sys_task.class, Cnd.where("data", "like", "%" + fitnessWalkActivity.get_id() + "%"));
|
||||
for (Sys_task task : oldTasks) {
|
||||
taskPlatformService.delete(task.getId(), task.getId());
|
||||
sysTaskService.delete(task.getId());
|
||||
}
|
||||
|
||||
|
||||
if ("everyday".equals(fitnessWalkActivity.getLotteryMode())) {
|
||||
FitnessWalkActivity.DayLotteryRule dayLotteryRule = fitnessWalkActivity.getDayLotteryRule();
|
||||
if (Lang.isNotEmpty(dayLotteryRule)) {
|
||||
//每日抽奖时间
|
||||
String lotteryTime = dayLotteryRule.getEveryDayLotteryTime();
|
||||
SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
|
||||
Date timeDate = null;
|
||||
try {
|
||||
timeDate = timeFormat.parse(lotteryTime);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
String cron = timeDate.getSeconds() + " " + timeDate.getMinutes() + " " + timeDate.getHours() + " * * ?";
|
||||
try {
|
||||
List<String> cronExeTimes = taskPlatformService.getCronExeTimesPlus(cron);
|
||||
|
||||
if (CollectionUtil.isNotEmpty(cronExeTimes)) {
|
||||
//调用类
|
||||
String jobClass = "io.v.nutz.task.job.fitnessWalk.FitnessWalkLotteryJob";
|
||||
HashMap<String, Object> map = new HashMap<>(5);
|
||||
map.put("id", fitnessWalkActivity.get_id());
|
||||
// 唯一标识的删除id,用于执行定时任务完成后,将此定时任务禁用
|
||||
map.put("deleteId", R.UU32());
|
||||
//每天抽奖达标步数
|
||||
map.put("lotteryQualificationStep", dayLotteryRule.getLotteryQualificationStep().toString());
|
||||
//每天抽奖人数
|
||||
map.put("lotteryUserNum", dayLotteryRule.getLotteryUserNum().toString());
|
||||
//抽奖模式
|
||||
map.put("mode", "everyday");
|
||||
|
||||
// 设置定时任务
|
||||
Sys_task task = new Sys_task();
|
||||
task.setName(fitnessWalkActivity.getMasterActivityName() + "健步走计步模式每日抽奖任务");
|
||||
task.setJobClass(jobClass);
|
||||
task.setNote("健步走计步模式每日抽奖任务");
|
||||
task.setCron(cron);
|
||||
task.setData(Json.toJson(map));
|
||||
task.setDisabled(false);
|
||||
sysTaskService.insert(task);
|
||||
taskPlatformService.add(task.getId(), task.getId(), task.getJobClass(), task.getCron(), task.getNote(), task.getData());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else if ("custom".equals(fitnessWalkActivity.getLotteryMode())) {
|
||||
List<FitnessWalkActivity.CustomLotteryRule> customLotteryRules = fitnessWalkActivity.getCustomLotteryRules();
|
||||
customLotteryRules.removeIf(Lang::isEmpty);
|
||||
|
||||
for (FitnessWalkActivity.CustomLotteryRule rule : customLotteryRules) {
|
||||
Date lotteryTime = rule.getLotteryTime();
|
||||
SimpleDateFormat dateFormatCron = new SimpleDateFormat("ss mm HH dd MM ? yyyy");
|
||||
// 设置定时任务执行时间
|
||||
String cron = dateFormatCron.format(lotteryTime);
|
||||
try {
|
||||
//调用类
|
||||
String jobClass = "io.v.nutz.task.job.fitnessWalk.FitnessWalkLotteryJob";
|
||||
HashMap<String, Object> map = new HashMap<>(8);
|
||||
map.put("id", fitnessWalkActivity.get_id());
|
||||
// 唯一标识的删除id,用于执行定时任务完成后,将此定时任务禁用
|
||||
map.put("deleteId", R.UU32());
|
||||
//月抽奖达标步数
|
||||
map.put("lotteryQualificationStep", rule.getLotteryQualificationStep().toString());
|
||||
//月抽奖人数
|
||||
map.put("lotteryUserNum", rule.getLotteryUserNum().toString());
|
||||
//查询开始时间
|
||||
map.put("startDate", rule.getStartDate());
|
||||
//查询结束时间
|
||||
map.put("endDate", rule.getEndDate());
|
||||
//抽奖天数
|
||||
map.put("lotteryQualificationDay", rule.getLotteryQualificationDay());
|
||||
//获奖名称
|
||||
map.put("awardName", rule.getAwardName());
|
||||
//抽奖模式
|
||||
map.put("mode", "custom");
|
||||
|
||||
Sys_task task = new Sys_task();
|
||||
task.setName(fitnessWalkActivity.getMasterActivityName() + "健步走计步模式自定义抽奖任务");
|
||||
task.setJobClass(jobClass);
|
||||
task.setNote("健步走计步模式自定义抽奖任务");
|
||||
task.setCron(cron);
|
||||
task.setData(Json.toJson(map));
|
||||
task.setDisabled(false);
|
||||
sysTaskService.insert(task);
|
||||
taskPlatformService.add(task.getId(), task.getId(), task.getJobClass(), task.getCron(), task.getNote(), task.getData());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Pagination getStepRankingPagination(PageForm pageForm, String activityId, String unionId, String unitId, String mode) {
|
||||
Sql sql = rankingListSql(pageForm.getSearchName(), pageForm.getSearchKeyword(), activityId, unionId, unitId, mode);
|
||||
return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NutMap> getStepRankingList(String searchName, String searchKeyword, String activityId, String unionId, String unitId, String mode) {
|
||||
Sql sql = rankingListSql(searchName, searchKeyword, activityId, unionId, unitId, mode);
|
||||
return listMap(sql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取中奖榜
|
||||
*
|
||||
* @param activityId 活动id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<NutMap> getWiningRankingUserList(String activityId) {
|
||||
FitnessWalkActivity activity = getActivity(activityId);
|
||||
List<NutMap> resultMapList = new ArrayList<>();
|
||||
if ("everyday".equals(activity.getLotteryMode())) {
|
||||
String lastDayFormat = DateUtil.format(DateUtil.offsetDay(new Date(), -1), "yyyy-MM-dd");
|
||||
List<FitnessWalkAwardUser> awardUserList = dao().query(FitnessWalkAwardUser.class, Cnd.where("activityId", "=", activityId)
|
||||
.and("DATE( applyDate )", ">=", lastDayFormat));
|
||||
|
||||
//昨天的中奖榜
|
||||
List<FitnessWalkAwardUser> lastDayAwardUserList = awardUserList.stream().filter(v -> DateUtil.compare(v.getApplyDate(),
|
||||
DateUtil.offsetDay(new Date(), -1), "yyyy-MM-dd") == 0).collect(Collectors.toList());
|
||||
NutMap lastDayAwardMap = new NutMap();
|
||||
//昨日中奖时间
|
||||
lastDayAwardMap.put("title", "昨日中奖榜");
|
||||
lastDayAwardMap.put("lotteryTime", lastDayFormat);
|
||||
lastDayAwardMap.put("awardName", "幸运奖");
|
||||
lastDayAwardMap.put("awardList", lastDayAwardUserList);
|
||||
resultMapList.add(lastDayAwardMap);
|
||||
|
||||
//今天的中奖榜
|
||||
List<FitnessWalkAwardUser> thisDayAwardUserList = (List<FitnessWalkAwardUser>) CollectionUtil.subtract(awardUserList, lastDayAwardUserList);
|
||||
NutMap thisDayAwardMap = new NutMap();
|
||||
//今日中奖时间
|
||||
lastDayAwardMap.put("title", "今日中奖榜");
|
||||
thisDayAwardMap.put("lotteryTime", DateUtil.today());
|
||||
thisDayAwardMap.put("awardName", "幸运奖");
|
||||
thisDayAwardMap.put("awardList", thisDayAwardUserList);
|
||||
resultMapList.add(thisDayAwardMap);
|
||||
|
||||
} else if ("custom".equals(activity.getLotteryMode())) {
|
||||
List<FitnessWalkActivity.CustomLotteryRule> customLotteryRules = activity.getCustomLotteryRules();
|
||||
//当前活动中奖榜单
|
||||
List<FitnessWalkAwardUser> awardUserList = dao().query(FitnessWalkAwardUser.class, Cnd.where("activityId", "=", activityId));
|
||||
|
||||
for (FitnessWalkActivity.CustomLotteryRule rule : customLotteryRules) {
|
||||
NutMap map = new NutMap();
|
||||
List<FitnessWalkAwardUser> customAwardList = awardUserList.stream().filter(v -> DateUtil.compare(v.getApplyDate(), DateUtil.date(rule.getLotteryTime()), "yyyy-MM-dd") == 0).collect(Collectors.toList());
|
||||
//自定义抽奖时间范围
|
||||
map.put("title", DateUtil.format(DateUtil.date(rule.getStartDate()), "MM-dd") + "至" + DateUtil.format(DateUtil.date(rule.getEndDate()), "MM-dd") + rule.getAwardName() + "中奖榜");
|
||||
// map.put("customTimeRange", DateUtil.format(DateUtil.date(rule.getStartDate()), "yyyy-MM-dd") + "——" + DateUtil.format(DateUtil.date(rule.getEndDate()), "yyyy-MM-dd"));
|
||||
//抽奖时间
|
||||
map.put("lotteryTime", DateUtil.format(rule.getLotteryTime(), "yyyy-MM-dd"));
|
||||
//奖项名称
|
||||
map.put("awardName", rule.getAwardName());
|
||||
//中奖人员
|
||||
map.put("awardList", customAwardList);
|
||||
resultMapList.add(map);
|
||||
}
|
||||
}
|
||||
return resultMapList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NutMap> prizeOption(String activityId) {
|
||||
FitnessWalkActivity activity = getActivity(activityId);
|
||||
if (Lang.isEmpty(activity)) {
|
||||
return null;
|
||||
}
|
||||
if ("custom".equals(activity.getLotteryMode())) {
|
||||
List<FitnessWalkActivity.CustomLotteryRule> customLotteryRules = activity.getCustomLotteryRules();
|
||||
return customLotteryRules.stream().map(rule -> {
|
||||
NutMap map = new NutMap();
|
||||
map.put("text", DateUtil.format(DateUtil.date(rule.getStartDate()), "MM-dd") + "至" + DateUtil.format(DateUtil.date(rule.getEndDate()), "MM-dd") + rule.getAwardName() + "中奖榜");
|
||||
map.put("value", rule.getLotteryTime());
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private Sql rankingListSql(String searchName, String searchKeyword, String activityId, String unionId, String unitId, String mode) {
|
||||
FitnessWalkActivity activity = getActivity(activityId);
|
||||
Cnd cnd = Cnd.NEW();
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.id,
|
||||
COALESCE(SUM(sub.step), 0) AS total_steps,
|
||||
u.username,
|
||||
u.loginname,
|
||||
u.unionname,
|
||||
u.unitname,
|
||||
over3k.standardsDays
|
||||
FROM
|
||||
`view_user` u
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
userId,
|
||||
applyDate,
|
||||
step
|
||||
FROM
|
||||
`fitness_walk_step`
|
||||
WHERE
|
||||
step >= @step
|
||||
AND activityId=@activityId
|
||||
AND $dateSql
|
||||
GROUP BY
|
||||
userId,
|
||||
applyDate
|
||||
) AS sub ON u.id = sub.userId
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
userId,
|
||||
COUNT(DISTINCT DATE(applyDate)) AS standardsDays
|
||||
FROM
|
||||
`fitness_walk_step`
|
||||
WHERE
|
||||
step >= @step
|
||||
AND activityId=@activityId
|
||||
AND $dateSql
|
||||
GROUP BY
|
||||
userId
|
||||
) AS over3k ON u.id = over3k.userId
|
||||
$condition
|
||||
""").setParam("activityId", activityId).setParam("step", 6000);
|
||||
|
||||
if ("today".equals(mode)) {
|
||||
sql.setVar("dateSql", new Static("DATE(applyDate) = '" + DateUtil.today() + "'"));
|
||||
// cnd.and("DATE( s.applyDate )", "=", DateUtil.today());
|
||||
} else {
|
||||
sql.setVar("dateSql", new Static("DATE(applyDate) >= '"
|
||||
+ DateUtil.format(DateUtil.date(activity.getStartTime()), "yyyy-MM-dd") + "' and DATE(applyDate) <= '"
|
||||
+ DateUtil.format(DateUtil.date(activity.getEndTime()), "yyyy-MM-dd") + "'"));
|
||||
// cnd.and("DATE( s.applyDate )", ">=", DateUtil.format(DateUtil.date(activity.getStartTime()), "yyyy-MM-dd"));
|
||||
// cnd.and("DATE( s.applyDate )", "<=", DateUtil.format(DateUtil.date(activity.getEndTime()), "yyyy-MM-dd"));
|
||||
}
|
||||
|
||||
if (Strings.isNotBlank(unitId)) {
|
||||
cnd.and("u.unitId", "=", unitId);
|
||||
}
|
||||
if (Strings.isNotBlank(unionId)) {
|
||||
cnd.and("u.unionId", "=", unionId);
|
||||
}
|
||||
|
||||
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
|
||||
cnd.and(searchName, "LIKE", "%" + searchKeyword + "%");
|
||||
}
|
||||
// cnd.and("u.id","in",Sqls.create("select userId from activity_user_scope where groupId = @groupId").setParam("groupId",activity.getGroupId()));
|
||||
cnd.groupBy("u.id", "u.username", "u.loginname", "u.unionname", "u.unitname", "over3k.standardsDays");
|
||||
cnd.desc("total_steps");
|
||||
cnd.having(Cnd.NEW().and("COALESCE(SUM(sub.step), 0)", ">", 0));
|
||||
sql.setCondition(cnd);
|
||||
return sql;
|
||||
}
|
||||
}
|
||||
+269
@@ -0,0 +1,269 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.service.impl;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.sys.models.Sys_union;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.weapp.FitnessWalkRegister;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.service.FitnessWalkPunchStatisticsService;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.utils.WeAppCloudUtil;
|
||||
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 java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class FitnessWalkPunchStatisticsServiceImpl extends BaseServiceImpl implements FitnessWalkPunchStatisticsService {
|
||||
public FitnessWalkPunchStatisticsServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Inject
|
||||
private WeAppCloudUtil weAppCloudUtil;
|
||||
|
||||
@Override
|
||||
public List<NutMap> unionRegCheckInNum(String activityId, String unionId) {
|
||||
List<Sys_union> unions = dao().query(Sys_union.class, Cnd.NEW().desc("unioncode"));
|
||||
|
||||
// 查询报名数据
|
||||
List<FitnessWalkRegister> registerList = dao().query(FitnessWalkRegister.class, Cnd.where("activityId", "=", activityId).groupBy("userId"));
|
||||
// 每个分工会的报名数据
|
||||
Map<String, Long> unionRegisterMap = registerList.stream().collect(Collectors.groupingBy(FitnessWalkRegister::getUnionId, Collectors.counting()));
|
||||
|
||||
// 查询个分工会的打卡数据
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.unionid AS unionId,
|
||||
COUNT(sign.userId) AS unionCount
|
||||
FROM
|
||||
`fitness_walk_sign` sign
|
||||
LEFT JOIN `vw_user` u ON u.id = sign.userId
|
||||
WHERE sign.activityId = @activityId
|
||||
GROUP BY u.unionid
|
||||
""").setParam("activityId", activityId);
|
||||
sql.setCallback(Sqls.callback.maps());
|
||||
dao().execute(sql);
|
||||
List<NutMap> unionSignCountList = (List<NutMap>) sql.getResult();
|
||||
|
||||
Map<String, Integer> unionSignCountMap = unionSignCountList.stream().collect(Collectors.toMap(v -> v.getString("unionId"), v -> v.getInt("unionCount")));
|
||||
|
||||
|
||||
// //查询报名的数据
|
||||
// StringBuffer regCountSql = new StringBuffer();
|
||||
// regCountSql.append("db.collection('register').aggregate()");
|
||||
// regCountSql.append(".match({");
|
||||
// regCountSql.append("activity_id:'").append(activityId).append("'");
|
||||
// if (StrUtil.isNotBlank(unionId)) {
|
||||
// regCountSql.append(",unionid:'").append(unionId).append("'");
|
||||
// }
|
||||
// regCountSql.append("})");
|
||||
// regCountSql.append(".group({_id:'$unionid',count:$.sum(1)}).end()");
|
||||
//
|
||||
// JSONObject regCountJsonObject = weAppCloudUtil.request(WeAppCloudUtil.CRUD.AGGREGATE, regCountSql.toString());
|
||||
// Map<String, Integer> regCountData = regCountJsonObject.getJSONArray("data").stream().map(v -> {
|
||||
// JSONObject rowData = JSONObject.parseObject((String) v);
|
||||
// String id = rowData.getString("_id");
|
||||
// int count = rowData.getJSONObject("count").getIntValue("$numberInt");
|
||||
// return NutMap.NEW().addv("id", id).addv("count", count);
|
||||
// }).collect(Collectors.toMap(v -> v.getString("id"), v -> v.getInt("count")));
|
||||
//
|
||||
// //查询打卡的数据
|
||||
// StringBuffer checkInCountSql = new StringBuffer();
|
||||
// checkInCountSql.append("db.collection('sign').aggregate()");
|
||||
// checkInCountSql.append(".match({");
|
||||
// checkInCountSql.append("activity_id:'").append(activityId).append("'");
|
||||
// if (StrUtil.isNotBlank(unionId)) {
|
||||
// checkInCountSql.append(",unionid:'").append(unionId).append("'");
|
||||
// }
|
||||
// checkInCountSql.append("})");
|
||||
// checkInCountSql.append(".group({_id:'$unionid',count: $.addToSet('$userid')})");
|
||||
// checkInCountSql.append(".project({_id: 0,unionid:'$_id',count:$.size('$count')})");
|
||||
// checkInCountSql.append(".end()");
|
||||
//
|
||||
// JSONObject checkInCountJsonObject = weAppCloudUtil.request(WeAppCloudUtil.CRUD.AGGREGATE, checkInCountSql.toString());
|
||||
// Map<String, Integer> checkInCountData = checkInCountJsonObject.getJSONArray("data").stream().map(v -> {
|
||||
// JSONObject rowData = JSONObject.parseObject((String) v);
|
||||
// String id = rowData.getString("unionid");
|
||||
// int count = rowData.getJSONObject("count").getIntValue("$numberInt");
|
||||
// return NutMap.NEW().addv("id", id).addv("count", count);
|
||||
// }).collect(Collectors.toMap(v -> v.getString("id"), v -> v.getInt("count")));
|
||||
|
||||
List<NutMap> list = unions.stream().map(v -> {
|
||||
String id = v.getId();
|
||||
String unionname = v.getName();
|
||||
String unioncode = v.getUnionCode();
|
||||
|
||||
NutMap map = NutMap.NEW();
|
||||
map.put("id", id);
|
||||
map.put("unionname", unionname);
|
||||
map.put("unioncode", unioncode);
|
||||
map.put("regCount", unionRegisterMap.getOrDefault(id, 0L));
|
||||
map.put("checkInCount", unionSignCountMap.getOrDefault(id, 0));
|
||||
// map.put("regCount", regCountData.getOrDefault(id, 0));
|
||||
// map.put("checkInCount", checkInCountData.getOrDefault(id, 0));
|
||||
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> unionRegistrationData(String activityId, String unionId) {
|
||||
StringBuffer sql = new StringBuffer("db.collection('register').aggregate()");
|
||||
sql.append(".match({");
|
||||
sql.append("activity_id:'").append(activityId).append("',unionid:'").append(unionId).append("'");
|
||||
sql.append("})");
|
||||
sql.append(".addFields({register_time_date:$.toDate('$register_time')})");
|
||||
sql.append("""
|
||||
.project({
|
||||
_id:true,
|
||||
loginname:true,
|
||||
username:true,
|
||||
unitname:true,
|
||||
mobile:true,
|
||||
sex:true,
|
||||
register_time:true,
|
||||
register_time_str: $.dateToString({
|
||||
date: '$register_time_date',
|
||||
format: '%Y-%m-%d %H:%M:%S',
|
||||
timezone: 'Asia/Shanghai'
|
||||
})
|
||||
})
|
||||
.sort({ unitname: 1 })
|
||||
.end()
|
||||
""");
|
||||
|
||||
JSONObject jsonObject = weAppCloudUtil.request(WeAppCloudUtil.CRUD.AGGREGATE, sql.toString());
|
||||
List<JSONObject> list = jsonObject.getJSONArray("data").stream().map(v -> JSONUtil.parseObj((String) v)).collect(Collectors.toList());
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> unionCheckInData(String activityId, String unionId) {
|
||||
String sql = """
|
||||
db.collection('sign').aggregate()
|
||||
.match({
|
||||
activity_id: '%s',
|
||||
unionid: '%s'
|
||||
})
|
||||
.lookup({
|
||||
from: 'activity',
|
||||
localField: 'activity_id',
|
||||
foreignField: '_id',
|
||||
as: 'activity'
|
||||
})
|
||||
.lookup({
|
||||
from: 'gift_voucher',
|
||||
let: {
|
||||
signActivityId: '$activity_id',
|
||||
signLoginName: '$loginname'
|
||||
},
|
||||
pipeline: $.pipeline()
|
||||
.match({
|
||||
$expr: {
|
||||
$and: [
|
||||
{ $eq: ['$activity_id', '$$signActivityId'] },
|
||||
{ $eq: ['$loginname', '$$signLoginName'] }
|
||||
]
|
||||
}
|
||||
})
|
||||
.project({
|
||||
used: 1,
|
||||
_id: 0
|
||||
})
|
||||
.done(),
|
||||
as: 'gift_voucher'
|
||||
})
|
||||
.addFields({
|
||||
used: { $arrayElemAt: ['$gift_voucher.used', 0] },
|
||||
masterActivityName: { $arrayElemAt: ['$activity.masterActivityName', 0] },
|
||||
pts: { $arrayElemAt: ['$activity.pts', 0] },
|
||||
})
|
||||
.group({
|
||||
_id: {
|
||||
activity_id: '$activity_id',
|
||||
loginname: '$loginname'
|
||||
},
|
||||
loginname: { $first: '$loginname' },
|
||||
sex: { $first: '$sex' },
|
||||
username: { $first: '$username' },
|
||||
unitname: { $first: '$unitname' },
|
||||
unionname: { $first: '$unionname' },
|
||||
used: { $first: '$used' },
|
||||
sign_size: { $sum: 1 },
|
||||
masterActivityName: { $first: '$masterActivityName' },
|
||||
pts_size: { $first: { $size: '$pts' } },
|
||||
})
|
||||
.project({
|
||||
_id: 0,
|
||||
loginname: 1,
|
||||
sex: 1,
|
||||
username: 1,
|
||||
unitname: 1,
|
||||
unionname: 1,
|
||||
used: 1,
|
||||
sign_size: { $toString: '$sign_size' },
|
||||
masterActivityName: 1,
|
||||
pts_size: { $toString: '$pts_size' }
|
||||
})
|
||||
.sort({ unitname: 1 })
|
||||
.end()
|
||||
""";
|
||||
sql = sql.formatted(activityId, unionId);
|
||||
JSONObject jsonObject = weAppCloudUtil.request(WeAppCloudUtil.CRUD.AGGREGATE, sql);
|
||||
List<JSONObject> list = jsonObject.getJSONArray("data").stream().map(v -> {
|
||||
JSONObject jo = JSONUtil.parseObj((String) v);
|
||||
if (jo.getInt("sign_size") > jo.getInt("pts_size")) {
|
||||
jo.put("sign_size", jo.getInt("pts_size"));
|
||||
}
|
||||
return jo;
|
||||
}).collect(Collectors.toList());
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> exportNotGetGiftVoucherUsers(String activityId) {
|
||||
//查询报名的人员
|
||||
JSONObject regJsonObject = weAppCloudUtil.request(WeAppCloudUtil.CRUD.AGGREGATE, """
|
||||
db.collection('register').aggregate([
|
||||
{ $match: { activity_id: '%s' } }
|
||||
])
|
||||
.sort({ unitname: 1 })
|
||||
.end()
|
||||
""".formatted(activityId));
|
||||
//查询打完卡获得礼品券的人员
|
||||
JSONObject giftUserJsonObject = weAppCloudUtil.request(WeAppCloudUtil.CRUD.AGGREGATE, """
|
||||
db.collection('gift_voucher').aggregate()
|
||||
.match({ activity_id: '%s' })
|
||||
.group({ _id: '$loginname' })
|
||||
.project({ _id: 0, loginname: '$_id' })
|
||||
.end()
|
||||
""".formatted(activityId));
|
||||
|
||||
List<String> giftUserLoginNames = giftUserJsonObject.getJSONArray("data").stream().map(v -> {
|
||||
JSONObject jo = JSONUtil.parseObj((String) v);
|
||||
return jo.getStr("loginname");
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
List<JSONObject> list = regJsonObject.getJSONArray("data").stream().map(v -> JSONUtil.parseObj((String) v)).filter(v -> !giftUserLoginNames.contains(v.getStr("loginname"))).collect(Collectors.toList());
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> exportNotUseGiftVoucherUsers(String activityId) {
|
||||
JSONObject jsonObject = weAppCloudUtil.request(WeAppCloudUtil.CRUD.AGGREGATE, """
|
||||
db.collection('gift_voucher').aggregate()
|
||||
.match({ activity_id: '%s', used: false })
|
||||
.sort({ unitname: 1 })
|
||||
.end()
|
||||
""".formatted(activityId));
|
||||
return jsonObject.getJSONArray("data").stream().map(v -> JSONUtil.parseObj((String) v)).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+350
@@ -0,0 +1,350 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.FitnessWalkActivity;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.FitnessWalkAwardUser;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.FitnessWalkRaffleRules;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.model.FitnessWalkRaffleUser;
|
||||
import com.budwk.app.base.param.PageForm;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.service.FitnessWalkCommonService;
|
||||
import com.budwk.app.zhgh.activity.fitnessWalk.service.FitnessWalkStepRaffleService;
|
||||
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.dao.util.cri.SqlExpressionGroup;
|
||||
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.Strings;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:FitnessWalkStepRaffleServiceImpl
|
||||
* @Date 2024/12/28 11:17
|
||||
* @注释
|
||||
*/
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class FitnessWalkStepRaffleServiceImpl extends BaseServiceImpl<FitnessWalkRaffleRules> implements FitnessWalkStepRaffleService {
|
||||
public FitnessWalkStepRaffleServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Inject
|
||||
private FitnessWalkCommonService fitnessWalkCommonService;
|
||||
|
||||
@Override
|
||||
public Sql getRaffleSql(PageForm pageForm, String activityId, String unionId, String unitId) {
|
||||
FitnessWalkActivity activity = fitnessWalkCommonService.getActivity(activityId);
|
||||
Integer lotteryQualificationDays = activity.getLotteryQualificationDays();
|
||||
Integer lotteryQualificationSteps = activity.getLotteryQualificationSteps();
|
||||
Date startDate = DateUtil.parse(DateUtil.format(DateUtil.date(activity.getStartTime()), "yyyy-MM-dd"), "yyyy-MM-dd");
|
||||
Date endDate = DateUtil.parse(DateUtil.format(DateUtil.date(activity.getEndTime()), "yyyy-MM-dd"), "yyyy-MM-dd");
|
||||
|
||||
Cnd cnd = Cnd.NEW();
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.id,
|
||||
COALESCE(SUM(sub.step), 0) AS total_steps,
|
||||
u.loginname,
|
||||
u.username,
|
||||
u.unionid,
|
||||
u.unionname,
|
||||
u.unitid,
|
||||
u.unitname,
|
||||
over3k.standardsDays
|
||||
FROM
|
||||
`view_user` u
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
userId,
|
||||
applyDate,
|
||||
step
|
||||
FROM
|
||||
`fitness_walk_step`
|
||||
WHERE
|
||||
activityId = @activityId
|
||||
AND DATE(applyDate) >= @startDate
|
||||
AND DATE(applyDate) <= @endDate
|
||||
$lotteryQualificationDaySql
|
||||
GROUP BY
|
||||
userId,
|
||||
applyDate
|
||||
) AS sub ON u.id = sub.userId
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
userId,
|
||||
COUNT(DISTINCT DATE(applyDate)) AS standardsDays
|
||||
FROM
|
||||
`fitness_walk_step`
|
||||
WHERE
|
||||
activityId = @activityId
|
||||
AND DATE(applyDate) >= @startDate
|
||||
AND DATE(applyDate) <= @endDate
|
||||
$lotteryQualificationDaySql
|
||||
GROUP BY
|
||||
userId
|
||||
) AS over3k ON u.id = over3k.userId
|
||||
$condition
|
||||
""");
|
||||
if (lotteryQualificationDays != null) {
|
||||
if (lotteryQualificationSteps != null) {
|
||||
sql.setVar("lotteryQualificationDaySql", new Static(" AND step >= '%s' ".formatted(String.valueOf(lotteryQualificationSteps))));
|
||||
}
|
||||
cnd.having(cnd.and(new Static(" over3k.standardsDays >= '%s' ".formatted(lotteryQualificationDays))));
|
||||
|
||||
// sql.setVar("stepHavingSql", new Static(" over3k.standardsDays >= '%s' ".formatted(lotteryQualificationDays)));
|
||||
} else {
|
||||
if (lotteryQualificationSteps != null) {
|
||||
cnd.having(cnd.and(new Static(" COALESCE(SUM(sub.step), 0) >= '%s' ".formatted(String.valueOf(lotteryQualificationSteps)))));
|
||||
}
|
||||
// sql.setVar("stepHavingSql", new Static(" COALESCE(SUM(sub.step), 0) >= '%s' ".formatted(lotteryQualificationSteps)));
|
||||
}
|
||||
sql.setParam("activityId", activityId);
|
||||
sql.setParam("step", lotteryQualificationSteps);
|
||||
sql.setParam("startDate", startDate);
|
||||
sql.setParam("endDate", endDate);
|
||||
|
||||
if (Strings.isNotBlank(unitId)) {
|
||||
cnd.and("u.unitId", "=", unitId);
|
||||
}
|
||||
if (Strings.isNotBlank(unionId)) {
|
||||
cnd.and("u.unionId", "=", unionId);
|
||||
}
|
||||
|
||||
if (pageForm != null && Strings.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.orLike("u.loginname", pageForm.getSearchKeyword());
|
||||
seg.orLike("u.username", pageForm.getSearchKeyword());
|
||||
cnd.and(seg);
|
||||
}
|
||||
// cnd.and("u.id","in",Sqls.create("select userId from activity_user_scope where groupId = @groupId").setParam("groupId",activity.getGroupId()));
|
||||
cnd.groupBy("u.id", "u.username", "u.loginname", "u.unionname", "u.unitname");
|
||||
cnd.desc("total_steps");
|
||||
sql.setCondition(cnd);
|
||||
return sql;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取活动的奖项
|
||||
* @param activityId
|
||||
* @return { index: 0, name: '奖项名称', type: 0 }
|
||||
*/
|
||||
@Override
|
||||
public List<NutMap> getActivityAwardList(String activityId) {
|
||||
FitnessWalkRaffleRules rules = fetch(Cnd.where("activityId", "=", activityId));
|
||||
List<FitnessWalkRaffleRules.ManualLotteryRules> manualLotteryRules = rules.getManualLotteryRules();
|
||||
// 存放奖品列表
|
||||
List<String> ruleList = new ArrayList<>();
|
||||
// 奖品数量
|
||||
int size = manualLotteryRules.size();
|
||||
if (size == 1) {
|
||||
String prize = manualLotteryRules.get(0).getAwardName();
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ruleList.add(prize);
|
||||
if (ruleList.size() < 8) {
|
||||
ruleList.add("没有中奖");
|
||||
}
|
||||
}
|
||||
} else if (size == 2) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
String prize = manualLotteryRules.get(i % size).getAwardName();
|
||||
ruleList.add(prize);
|
||||
if (ruleList.size() < 8) {
|
||||
ruleList.add("没有中奖");
|
||||
}
|
||||
}
|
||||
} else if (size == 3) {
|
||||
for (int i = 0; i < 8; ) {
|
||||
for (int j = 0; j < size && i < 8; j++) {
|
||||
String prize = manualLotteryRules.get(j).getAwardName();
|
||||
ruleList.add(prize);
|
||||
if (ruleList.size() < 8) {
|
||||
ruleList.add("没有中奖");
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (size == 4) {
|
||||
for (int i = 0; i < 8; ) {
|
||||
for (int j = 0; j < size && i < 8; j++) {
|
||||
String prize = manualLotteryRules.get(j).getAwardName();
|
||||
ruleList.add(prize);
|
||||
if (ruleList.size() < 8) {
|
||||
ruleList.add("没有中奖");
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (size == 5) {
|
||||
ruleList = manualLotteryRules.stream().map(FitnessWalkRaffleRules.ManualLotteryRules::getAwardName).collect(Collectors.toList());
|
||||
ruleList.add(2, "没有中奖");
|
||||
ruleList.add(4, "没有中奖");
|
||||
ruleList.add(7, "没有中奖");
|
||||
} else if (size == 6) {
|
||||
ruleList = manualLotteryRules.stream().map(FitnessWalkRaffleRules.ManualLotteryRules::getAwardName).collect(Collectors.toList());
|
||||
ruleList.add(2, "没有中奖");
|
||||
ruleList.add(6, "没有中奖");
|
||||
} else {
|
||||
ruleList = manualLotteryRules.stream().map(FitnessWalkRaffleRules.ManualLotteryRules::getAwardName).collect(Collectors.toList());
|
||||
ruleList.add("没有中奖");
|
||||
}
|
||||
|
||||
List<String> finalRuleList = ruleList;
|
||||
List<NutMap> awardList = IntStream.range(0, ruleList.size())
|
||||
.mapToObj(index -> {
|
||||
String awardName = finalRuleList.get(index);
|
||||
NutMap map = NutMap.NEW();
|
||||
map.put("index", index);
|
||||
map.put("name", awardName);
|
||||
map.put("type", "没有中奖".equals(awardName) ? 1 : 0);
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
return awardList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动抽奖
|
||||
*
|
||||
* @param activityId 活动id
|
||||
*/
|
||||
@Override
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void manualLottery(String activityId) {
|
||||
// 删除此活动下的获奖记录
|
||||
dao().clear(FitnessWalkAwardUser.class, Cnd.where("activityId", "=", activityId));
|
||||
dao().clear(FitnessWalkRaffleUser.class, Cnd.where("activityId", "=", activityId));
|
||||
|
||||
FitnessWalkActivity activity = fitnessWalkCommonService.getActivity(activityId);
|
||||
Date startDate = DateUtil.parse(DateUtil.format(DateUtil.date(activity.getStartTime()), "yyyy-MM-dd"), "yyyy-MM-dd");
|
||||
Date endDate = DateUtil.parse(DateUtil.format(DateUtil.date(activity.getEndTime()), "yyyy-MM-dd"), "yyyy-MM-dd");
|
||||
|
||||
// 获取达标的所有人,按照步数倒序
|
||||
Sql sql = getRaffleSql(null, activityId, null, null);
|
||||
List<NutMap> list = listMap(sql);
|
||||
|
||||
List<FitnessWalkRaffleUser> raffleUserList = list.stream().map(v -> {
|
||||
FitnessWalkRaffleUser raffleUser = new FitnessWalkRaffleUser();
|
||||
raffleUser.setId(R.UU32());
|
||||
raffleUser.setActivityId(activityId);
|
||||
raffleUser.setUserId(v.getString("id"));
|
||||
raffleUser.setLoginName(v.getString("loginname"));
|
||||
raffleUser.setUsername(v.getString("username"));
|
||||
raffleUser.setAwardSteps(v.getString("total_steps"));
|
||||
raffleUser.setStandardsDays(v.getInt("standardsDays"));
|
||||
raffleUser.setIsRaffle(false);
|
||||
return raffleUser;
|
||||
}).collect(Collectors.toList());
|
||||
dao().fastInsert(raffleUserList);
|
||||
|
||||
Set<String> winningRankLoginNames = new HashSet<>();
|
||||
|
||||
// 获奖人员
|
||||
List<FitnessWalkAwardUser> winningUsers = new ArrayList<>();
|
||||
|
||||
// 获取抽奖规则
|
||||
FitnessWalkRaffleRules rules = fetch(Cnd.where("activityId", "=", activityId));
|
||||
List<FitnessWalkRaffleRules.ManualLotteryRules> manualLotteryRules = rules.getManualLotteryRules();
|
||||
|
||||
// 找出是按照排名来颁奖的奖项
|
||||
List<FitnessWalkRaffleRules.ManualLotteryRules> ranks = manualLotteryRules.stream().filter(v -> "排名".equals(v.getRaffleType()))
|
||||
.sorted(Comparator.comparing(FitnessWalkRaffleRules.ManualLotteryRules::getRankingPosition)).collect(Collectors.toList());
|
||||
|
||||
for (FitnessWalkRaffleRules.ManualLotteryRules rank : ranks) {
|
||||
String awardName = rank.getAwardName();
|
||||
Integer lotteryUserNum = rank.getLotteryUserNum();
|
||||
|
||||
// 排除之前获奖的人,再倒序排列
|
||||
List<NutMap> canLotteryUsers = list.stream()
|
||||
.filter(v -> !winningRankLoginNames.contains(v.getString("loginname")))
|
||||
.sorted(Comparator.comparingInt((NutMap v) -> v.getInt("total_steps")).reversed())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 截取当前奖项的中奖人员
|
||||
List<NutMap> rankNutMaps = canLotteryUsers.subList(0, lotteryUserNum);
|
||||
// 收集成中奖人员存储
|
||||
List<FitnessWalkAwardUser> collect = rankNutMaps.stream().map(v -> {
|
||||
FitnessWalkAwardUser awardUser = new FitnessWalkAwardUser();
|
||||
awardUser.setId(R.UU32());
|
||||
awardUser.setActivityId(activityId);
|
||||
awardUser.setUserId(v.getString("id"));
|
||||
awardUser.setLoginName(v.getString("loginname"));
|
||||
awardUser.setUsername(v.getString("username"));
|
||||
awardUser.setAwardName(awardName);
|
||||
awardUser.setStartDate(startDate);
|
||||
awardUser.setEndDate(endDate);
|
||||
awardUser.setUnionId(v.getString("unionid"));
|
||||
awardUser.setUnionName(v.getString("unionname"));
|
||||
awardUser.setUnitId(v.getString("unitid"));
|
||||
awardUser.setUnitName(v.getString("unitname"));
|
||||
awardUser.setStandardsDays(v.getInt("standardsDays"));
|
||||
awardUser.setAwardSteps(v.getString("total_steps"));
|
||||
return awardUser;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
winningRankLoginNames.addAll(collect.stream().map(FitnessWalkAwardUser::getLoginName).collect(Collectors.toList()));
|
||||
|
||||
winningUsers.addAll(collect);
|
||||
}
|
||||
|
||||
|
||||
List<FitnessWalkRaffleRules.ManualLotteryRules> reachList = manualLotteryRules.stream().filter(v -> "达标".equals(v.getRaffleType()))
|
||||
.sorted(Comparator.comparing(FitnessWalkRaffleRules.ManualLotteryRules::getRankingPosition)).collect(Collectors.toList());
|
||||
|
||||
for (FitnessWalkRaffleRules.ManualLotteryRules reach : reachList) {
|
||||
List<NutMap> nutMaps;
|
||||
if (reach.getIsSimultaneously() != null && reach.getIsSimultaneously()) {
|
||||
// 可以兼得
|
||||
nutMaps = list;
|
||||
} else {
|
||||
// 不可兼得
|
||||
nutMaps = list.stream().filter(v -> !winningRankLoginNames.contains(v.getString("loginname"))).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
Integer lotteryUserNum = reach.getLotteryUserNum();
|
||||
String awardName = reach.getAwardName();
|
||||
|
||||
List<NutMap> reachNutMaps = nutMaps.stream().collect(Collectors.collectingAndThen(Collectors.toList(), collected -> {
|
||||
Collections.shuffle(collected);
|
||||
return collected.subList(0, lotteryUserNum);
|
||||
}));
|
||||
|
||||
List<FitnessWalkAwardUser> collect = reachNutMaps.stream().map(v -> {
|
||||
FitnessWalkAwardUser awardUser = new FitnessWalkAwardUser();
|
||||
awardUser.setId(R.UU32());
|
||||
awardUser.setActivityId(activityId);
|
||||
awardUser.setUserId(v.getString("id"));
|
||||
awardUser.setLoginName(v.getString("loginname"));
|
||||
awardUser.setUsername(v.getString("username"));
|
||||
awardUser.setAwardName(awardName);
|
||||
awardUser.setStartDate(startDate);
|
||||
awardUser.setEndDate(endDate);
|
||||
awardUser.setUnionId(v.getString("unionid"));
|
||||
awardUser.setUnionName(v.getString("unionname"));
|
||||
awardUser.setUnitId(v.getString("unitid"));
|
||||
awardUser.setUnitName(v.getString("unitname"));
|
||||
awardUser.setStandardsDays(v.getInt("standardsDays"));
|
||||
awardUser.setAwardSteps(v.getString("total_steps"));
|
||||
return awardUser;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
winningRankLoginNames.addAll(collect.stream().map(FitnessWalkAwardUser::getLoginName).collect(Collectors.toList()));
|
||||
|
||||
winningUsers.addAll(collect);
|
||||
}
|
||||
|
||||
dao().fastInsert(winningUsers);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package com.budwk.app.zhgh.activity.fitnessWalk.utils;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.budwk.app.base.constant.RedisConstant;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import org.nutz.integration.jedis.RedisService;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 微信小程序云开发工具类
|
||||
*/
|
||||
@IocBean
|
||||
public class WeAppCloudUtil {
|
||||
public static String ENV = "cloud1-1g7dbkfjde47e591";
|
||||
|
||||
private static final String APPID = "wx381fc111ffdfd1b3";
|
||||
|
||||
private static final String APP_SECRET = "75d24a56eb6fe462fdc929eb7f4ba149";
|
||||
|
||||
@Inject
|
||||
public RedisService redisService;
|
||||
|
||||
public JSONObject request(CRUD crud, String sql) {
|
||||
String url = crud.url.replace("ACCESS_TOKEN", getAccessToken());
|
||||
String responseJson = HttpUtil.createPost(url).header("Content-Type", "application/json").body(JSONUtil.toJsonStr(Map.of("env", ENV, "query", sql))).execute().body();
|
||||
JSONObject response = JSONUtil.parseObj(responseJson);
|
||||
if (response.getInt("errcode") == 42001) {
|
||||
redisService.del(RedisConstant.REDIS_KEY_WE_APP_ACCESS_TOKEN);
|
||||
// request(crud, sql);
|
||||
} else if (response.getInt("errcode") == 40001) {
|
||||
redisService.del(RedisConstant.REDIS_KEY_WE_APP_ACCESS_TOKEN);
|
||||
} else if (response.getInt("errcode") != 0) {
|
||||
throw new RuntimeException("小程序云函数接口调用失败,errcode:" + response.getStr("errcode") + ",errmsg:" + response.getStr("errmsg"));
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取token
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getAccessToken() {
|
||||
String token = redisService.get(RedisConstant.REDIS_KEY_WE_APP_ACCESS_TOKEN);
|
||||
if (StrUtil.isNotBlank(token)) {
|
||||
return token;
|
||||
}
|
||||
String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET".replace("APPID", APPID).replace("APPSECRET", APP_SECRET);
|
||||
String responseJson = HttpUtil.createGet(url).execute().body();
|
||||
TokenResponse tokenResponse = JSONUtil.toBean(responseJson, TokenResponse.class);
|
||||
redisService.setex(RedisConstant.REDIS_KEY_WE_APP_ACCESS_TOKEN, 7000, tokenResponse.getAccess_token());
|
||||
return tokenResponse.getAccess_token();
|
||||
|
||||
/*String result = Http.get(url).getContent();
|
||||
HashMap<String, Object> tokenObject = Json.fromJson(HashMap.class, result);
|
||||
if (tokenObject.containsKey("errcode")) {
|
||||
log.error("获取token失败------" + tokenObject.get("errmsg"));
|
||||
throw new RuntimeException("获取token失败------" + tokenObject.get("errmsg"));
|
||||
}
|
||||
redisService.setex(RedisConstant.REDIS_KEY_WE_APP_ACCESS_TOKEN, 7200 - 200, (String) tokenObject.get("access_token"));
|
||||
return (String) tokenObject.get("access_token");
|
||||
return null;*/
|
||||
}
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum CRUD {
|
||||
INSERT("https://api.weixin.qq.com/tcb/databaseadd?access_token=ACCESS_TOKEN"),
|
||||
QUERY("https://api.weixin.qq.com/tcb/databasequery?access_token=ACCESS_TOKEN"),
|
||||
DELETE("https://api.weixin.qq.com/tcb/databasedelete?access_token=ACCESS_TOKEN"),
|
||||
UPDATE("https://api.weixin.qq.com/tcb/databaseupdate?access_token=ACCESS_TOKEN"),
|
||||
AGGREGATE("https://api.weixin.qq.com/tcb/databaseaggregate?access_token=ACCESS_TOKEN"),
|
||||
COUNT("https://api.weixin.qq.com/tcb/databasecount?access_token=ACCESS_TOKEN");
|
||||
private final String url;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Response {
|
||||
private int errcode;
|
||||
private String erremsg;
|
||||
}
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public static class TokenResponse extends Response {
|
||||
private int expires_in;
|
||||
private String access_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件返回cloud—url
|
||||
*
|
||||
* @param rootPath
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public String uploadFile(String rootPath, File file) {
|
||||
String path = rootPath + file.getName();
|
||||
String url = "https://api.weixin.qq.com/tcb/uploadfile?access_token=ACCESS_TOKEN".replace("ACCESS_TOKEN", getAccessToken());
|
||||
String responseJson = HttpUtil.createPost(url).header("Content-Type", "application/json").body(JSONUtil.toJsonStr(Map.of("env", ENV, "path", path))).execute().body();
|
||||
JSONObject jsonObject = JSONUtil.parseObj(responseJson);
|
||||
if (jsonObject.getInt("errcode") != 0) {
|
||||
throw new RuntimeException(jsonObject.getStr("errmsg"));
|
||||
}
|
||||
try{
|
||||
HttpUtil.createPost(jsonObject.getStr("url"))
|
||||
.form("key", path)
|
||||
.form("Signature", jsonObject.getStr("authorization"))
|
||||
.form("x-cos-security-token", jsonObject.getStr("token"))
|
||||
.form("x-cos-meta-fileid", jsonObject.getStr("cos_file_id"))
|
||||
.form("file", file)
|
||||
.execute().body();
|
||||
return jsonObject.getStr("file_id");
|
||||
}catch (Exception e){
|
||||
return jsonObject.getStr("file_id");
|
||||
}
|
||||
}
|
||||
|
||||
public String httpFile(String fileId) {
|
||||
String url = "https://api.weixin.qq.com/tcb/batchdownloadfile?access_token=ACCESS_TOKEN".replace("ACCESS_TOKEN", getAccessToken());
|
||||
|
||||
HashMap<Object, Object> body = new HashMap<>(2) {{
|
||||
put("env", ENV);
|
||||
put("file_list", new ArrayList<>() {{
|
||||
add(new HashMap<>() {{
|
||||
put("fileid", fileId);
|
||||
put("max_age", 7200);
|
||||
}});
|
||||
}});
|
||||
}};
|
||||
|
||||
Map mf = new HashMap<String, String>();
|
||||
mf.put("fileid", fileId);
|
||||
mf.put("max_age", 7200);
|
||||
ArrayList<Map> fm = new ArrayList<>();
|
||||
fm.add(mf);
|
||||
|
||||
body.put("file_list", fm);
|
||||
|
||||
|
||||
String responseJson = HttpUtil.createPost(url)
|
||||
.header("Content-Type", "application/json")
|
||||
.body(JSONUtil.toJsonStr(body))
|
||||
.execute().body();
|
||||
System.out.println(JSONUtil.toJsonStr(body));
|
||||
JSONObject jsonObject = JSONUtil.parseObj(responseJson);
|
||||
if (jsonObject.getInt("errcode") != 0) {
|
||||
throw new RuntimeException(jsonObject.getStr("errmsg"));
|
||||
}
|
||||
return jsonObject.getJSONArray("file_list").toList(JSONObject.class).get(0).getStr("download_url");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,287 @@
|
||||
<!--#
|
||||
layout("/layouts/platform.html"){
|
||||
#-->
|
||||
<style>
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<guava>
|
||||
<el-card shadow="never">
|
||||
<div class="search">
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">姓名工号:</div>
|
||||
<div class="search-item-option">
|
||||
<el-input placeholder="请输入关键字查询" v-model="pageForm.keyWord"></el-input>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">所属工会:</div>
|
||||
<div class="search-item-option">
|
||||
<el-select v-model="pageForm.unionId" clearable filterable placeholder="请选择院级工会"
|
||||
style="width: 100%">
|
||||
<el-option
|
||||
v-for="item in unionList"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-query">
|
||||
<el-button icon="el-icon-search" type="primary" @click="doSearch"></el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-card shadow="never" class="mt10">
|
||||
<table-tool :app="this" label="绑定列表">
|
||||
<template #func>
|
||||
<el-dropdown @command="dropdownCommand">
|
||||
<el-button size="medium" type="danger">
|
||||
批量删除 
|
||||
<span class="ti-angle-down"></span>
|
||||
</el-button>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item :command="{type:'delete2'}">
|
||||
删除已选
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item :command="{type:'delete3'}">
|
||||
全部删除
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
</table-tool>
|
||||
<el-table :data="tableData" style="width: 100%" row-key="_id" @sort-change="pageOrder"
|
||||
v-loading="tabLoading" @selection-change="handleSelectionChange">
|
||||
<el-table-column :reserve-selection="true"
|
||||
type="selection"
|
||||
width="55">
|
||||
</el-table-column>
|
||||
<el-table-column align="center" header-align="center" label="序号" width="60" type="index">
|
||||
<template scope="scope">
|
||||
<span>{{scope.$index+(pageForm.pageNumber - 1) * pageForm.pageSize + 1}} </span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="工号" prop="loginname" header-align="center"
|
||||
align="center"></el-table-column>
|
||||
|
||||
<el-table-column label="姓名" prop="username" header-align="center"
|
||||
align="center"></el-table-column>
|
||||
|
||||
<el-table-column label="openid" prop="openid" header-align="center"
|
||||
align="center"></el-table-column>
|
||||
|
||||
<el-table-column align="center" header-align="center" label="操作" fixed="right" width="240px">
|
||||
<template scope="{row}">
|
||||
<el-button type="danger" @click="doDelete(row._id)" size="mini"
|
||||
icon="el-icon-delete"></el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<el-row class="el-pagination-container">
|
||||
<el-pagination
|
||||
@size-change="pageSizeChange"
|
||||
@current-change="pageNumberChange"
|
||||
:current-page="pageForm.pageNumber"
|
||||
:page-sizes="[10, 20]"
|
||||
:page-size="pageForm.pageSize"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="pageForm.totalCount">
|
||||
</el-pagination>
|
||||
</el-row>
|
||||
</el-card>
|
||||
|
||||
</guava>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
const vue = new Vue({
|
||||
el: '#app',
|
||||
store,
|
||||
data() {
|
||||
return {
|
||||
v: "index",
|
||||
stepActive: 0,
|
||||
tabLoading: false,
|
||||
subDis: false,
|
||||
formData: {},
|
||||
tableData: [],
|
||||
pageForm: {
|
||||
searchName: "name",
|
||||
searchKeyword: "",
|
||||
pageNumber: 1,
|
||||
pageSize: 10,
|
||||
totalCount: 0,
|
||||
pageOrderName: "",
|
||||
pageOrderBy: ""
|
||||
},
|
||||
multipleSelection: [],
|
||||
unionList: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
dropdownCommand: function (command) {
|
||||
const {type, data} = command
|
||||
if (type == 'delete2') {
|
||||
this.doDelete2()
|
||||
} else if (type == 'delete3') {
|
||||
this.doDelete3()
|
||||
}
|
||||
},
|
||||
async doDelete(id) {
|
||||
this.$confirm('是否确定删除!', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
callback: async (a, b) => {
|
||||
if ("confirm" == a) {//确认后再执行
|
||||
const {
|
||||
code,
|
||||
data,
|
||||
msg
|
||||
} = await this.$axios.post(loc() + "/delete", {ids: JSON.stringify([id])})
|
||||
if (code == 0) {
|
||||
this.$message({
|
||||
message: msg,
|
||||
type: 'success'
|
||||
});
|
||||
this.pageData()
|
||||
} else {
|
||||
this.$message({
|
||||
message: data.msg,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
async doDelete2() {
|
||||
|
||||
if (!this.multipleSelection.length) {
|
||||
this.$notify({
|
||||
title: '提示',
|
||||
message: '请先勾选需要删除的人员!',
|
||||
type: 'warning'
|
||||
});
|
||||
return
|
||||
}
|
||||
|
||||
this.$confirm('是否确定删除!', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
callback: async (a, b) => {
|
||||
if ("confirm" === a) {//确认后再执行
|
||||
|
||||
const arr = this.multipleSelection.map(v => {
|
||||
return v._id
|
||||
})
|
||||
|
||||
const {
|
||||
code,
|
||||
data,
|
||||
msg
|
||||
} = await this.$axios.post(loc() + "/delete", {ids: JSON.stringify(arr)})
|
||||
if (code === 0) {
|
||||
this.multipleSelection = []
|
||||
this.$message({
|
||||
message: msg,
|
||||
type: 'success'
|
||||
});
|
||||
this.pageData()
|
||||
} else {
|
||||
this.$message({
|
||||
message: data.msg,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
async doDelete3() {
|
||||
this.$confirm('是否确定删除全部登录记录!', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
callback: async (a, b) => {
|
||||
if ("confirm" == a) {//确认后再执行
|
||||
const {code, data, msg} = await this.$axios.post(loc() + "/deleteAll")
|
||||
if (code === 0) {
|
||||
this.multipleSelection = []
|
||||
this.$message({
|
||||
message: msg,
|
||||
type: 'success'
|
||||
});
|
||||
this.pageData()
|
||||
} else {
|
||||
this.$message({
|
||||
message: data.msg,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
handleSelectionChange(val) {
|
||||
this.multipleSelection = val;
|
||||
},
|
||||
doSearch() {
|
||||
this.tabKey = new Date().getTime()
|
||||
this.pageForm.pageNumber = 1
|
||||
this.pageData()
|
||||
},
|
||||
pageOrder(column) {//按字段排序
|
||||
this.pageForm.pageOrderName = column.prop;
|
||||
this.pageForm.pageOrderBy = column.order;
|
||||
this.pageData();
|
||||
},
|
||||
pageNumberChange(val) {//页码更新操作
|
||||
this.pageForm.pageNumber = val;
|
||||
this.pageData();
|
||||
},
|
||||
pageSizeChange(val) {//分页大小更新操作
|
||||
this.pageForm.pageSize = val;
|
||||
this.pageData();
|
||||
},
|
||||
pageData() {//加载分页数据
|
||||
this.tabLoading = true
|
||||
this.$axios.post(loc() + '/pageData', this.pageForm)
|
||||
.then(res => {
|
||||
this.tabLoading = false
|
||||
if (res.code === 0) {
|
||||
this.tableData = data.data.list;
|
||||
this.pageForm.totalCount = data.data.totalCount;
|
||||
} else {
|
||||
this.$message({
|
||||
message: res.msg,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
},
|
||||
async created() {
|
||||
this.pageData();
|
||||
if (this.$auth.hasRoleOr("SYSADMIN, SCHOOL_UNION_ADMIN")) {
|
||||
this.unionList = await this.$businessTool.listUnion()
|
||||
} else {
|
||||
this.unionList = await this.$businessTool.listUnion(this.$store.state.union.id)
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<!--#
|
||||
}
|
||||
#-->
|
||||
@@ -0,0 +1,260 @@
|
||||
<!--#
|
||||
layout("/layouts/platform.html"){
|
||||
#-->
|
||||
<div id="app" v-cloak>
|
||||
<guava ref="guava">
|
||||
<template>
|
||||
<el-card shadow="never">
|
||||
<div class="search">
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">年份:</div>
|
||||
<div class="search-item-option">
|
||||
<el-date-picker
|
||||
:clearable="false"
|
||||
placeholder="选择年"
|
||||
style="width: 100%"
|
||||
@change="getCascadersActivity"
|
||||
type="year" v-model="pageForm.year"
|
||||
value-format="yyyy">
|
||||
</el-date-picker>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">活动:</div>
|
||||
<div class="search-item-option">
|
||||
<el-cascader
|
||||
style="width: 100%"
|
||||
@change="doSearch"
|
||||
v-model="pageForm.activityId"
|
||||
:options="activityOptions"
|
||||
:props="{ checkStrictly: true,emitPath:false}"
|
||||
clearable></el-cascader>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-query">
|
||||
<el-button @click="doSearch" icon="el-icon-search" type="primary"></el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
<el-card class="mt10" shadow="never">
|
||||
<table-tool :app="this" label="参与列表">
|
||||
<template #func>
|
||||
<el-button @click="window.open(loc()+'/exportUnionRegCheckInNum?activityId='+pageForm.activityId)"
|
||||
class="ml10"
|
||||
size="small"
|
||||
type="primary"
|
||||
icon="el-icon-download">
|
||||
导出报名及打卡人数
|
||||
</el-button>
|
||||
|
||||
<el-button @click="window.open(loc()+'/exportNotGetGiftVoucherUsers?activityId='+pageForm.activityId)"
|
||||
class="ml10"
|
||||
size="small"
|
||||
type="primary"
|
||||
icon="el-icon-download">
|
||||
导出未取得礼品券人员
|
||||
</el-button>
|
||||
|
||||
<el-button @click="window.open(loc()+'/exportNotGetGiftVoucherUsers?activityId='+pageForm.activityId)"
|
||||
class="ml10"
|
||||
size="small"
|
||||
type="primary"
|
||||
icon="el-icon-download">
|
||||
导出未使用礼品券用户
|
||||
</el-button>
|
||||
|
||||
</template>
|
||||
</table-tool>
|
||||
<el-table :data="tableData" :size="tableSize" show-summary>
|
||||
<el-table-column :index="indexMethod" align="center" header-align="center" label="序号" type="index"
|
||||
width="80px"></el-table-column>
|
||||
<el-table-column
|
||||
:label="column.label"
|
||||
:prop="column.prop"
|
||||
:key="column.prop"
|
||||
:sortable="column.sortable"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
v-for="column in tableColumns"
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="300px">
|
||||
<template scope="{row}">
|
||||
<el-button @click="viewReg(row)" size="mini" type="primary">查看报名情况</el-button>
|
||||
<el-button @click="viewCheckIn(row)" size="mini" type="primary">查看打卡情况</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<template #view>
|
||||
<el-card shadow="never" v-if="viewIndex==='regTableShow'">
|
||||
<template #header>
|
||||
<div style="display: flex;justify-content: space-between;align-items: center">
|
||||
<h4 style="color: rgb(24, 103, 176);">
|
||||
{{viewUnion.unionname}}
|
||||
</h4>
|
||||
<el-button type="primary" size="mini" icon="el-icon-download"
|
||||
@click="exportRegUsers">
|
||||
导出名单
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<el-table :data="regTableData" style="width: 100%" row-key="_id" max-height="600px">
|
||||
<el-table-column label="工号" prop="loginname"></el-table-column>
|
||||
<el-table-column label="姓名" prop="username"></el-table-column>
|
||||
<el-table-column label="性别" prop="sex"></el-table-column>
|
||||
<el-table-column label="单位" prop="unitname" show-overflow-tooltip></el-table-column>
|
||||
<el-table-column label="电话" prop="mobile"></el-table-column>
|
||||
<el-table-column label="报名时间" prop="register_time_str"></el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
<el-card shadow="never" v-else-if="viewIndex==='checkInTableShow'">
|
||||
<template #header>
|
||||
<div style="display: flex;justify-content: space-between;align-items: center">
|
||||
<h4 style="color: rgb(24, 103, 176);">
|
||||
{{viewUnion.unionname}}
|
||||
</h4>
|
||||
<el-button type="primary" size="mini" icon="el-icon-download"
|
||||
@click="exportCheckInUsers">
|
||||
导出名单
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<el-table :data="regTableData" style="width: 100%" row-key="_id" max-height="600px">
|
||||
<el-table-column label="工号" prop="loginname"></el-table-column>
|
||||
<el-table-column label="姓名" prop="username"></el-table-column>
|
||||
<el-table-column label="性别" prop="sex"></el-table-column>
|
||||
<el-table-column label="单位" prop="unitname" show-overflow-tooltip></el-table-column>
|
||||
<el-table-column label="电话" prop="mobile"></el-table-column>
|
||||
<el-table-column label="点位总数" prop="pts_size"></el-table-column>
|
||||
<el-table-column label="已打卡点位数" prop="sign_size"></el-table-column>
|
||||
<el-table-column label="礼品券" prop="used">
|
||||
<template scope="{row}">
|
||||
<span v-if="row.used==null" class="text-danger">未取得</span>
|
||||
<span v-else-if="row.used" class="text-success">已使用</span>
|
||||
<span v-else-if="!row.used" class="text-warning">未使用</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
</template>
|
||||
</guava>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let vue = new Vue({
|
||||
el: '#app',
|
||||
store,
|
||||
mixins: [initTableMixins],
|
||||
data() {
|
||||
return {
|
||||
tableColumns: [
|
||||
{label: '分工会', prop: 'unionname'},
|
||||
{label: '报名人数', prop: 'regCount'},
|
||||
{label: '打卡人数', prop: 'checkInCount'},
|
||||
],
|
||||
pageForm: {
|
||||
unionId: '',
|
||||
unitId: '',
|
||||
activityDate: [],
|
||||
year: new Date().getFullYear() + '',
|
||||
},
|
||||
|
||||
activityOptions: [],
|
||||
|
||||
regTableData: [],
|
||||
checkInTableData: [],
|
||||
viewIndex: '',
|
||||
viewUnion: {}
|
||||
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
viewReg({id, unionname}) {
|
||||
this.viewUnion.unionId = id
|
||||
this.viewUnion.unionname = unionname
|
||||
this.$refs.guava.view()
|
||||
this.viewIndex = 'regTableShow'
|
||||
this.$axios.post(loc() + '/unionRegistrationData', {
|
||||
unionId: id,
|
||||
activityId: this.pageForm.activityId
|
||||
}).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.regTableData = res.data
|
||||
} else {
|
||||
this.$message.error(res.msg)
|
||||
}
|
||||
})
|
||||
},
|
||||
viewCheckIn({id, unionname}) {
|
||||
this.viewUnion.unionId = id
|
||||
this.viewUnion.unionname = unionname
|
||||
this.$refs.guava.view()
|
||||
this.viewIndex = 'checkInTableShow'
|
||||
this.$axios.post(loc() + '/unionCheckInData', {
|
||||
unionId: id,
|
||||
activityId: this.pageForm.activityId
|
||||
}).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.regTableData = res.data
|
||||
} else {
|
||||
this.$message.error(res.msg)
|
||||
}
|
||||
})
|
||||
},
|
||||
exportExcel() {
|
||||
const {hdid, unionId, unitId, activityDate} = this.pageForm
|
||||
let activityDate1 = []
|
||||
if (activityDate && activityDate.length > 0) {
|
||||
activityDate1 = JSON.stringify(activityDate)
|
||||
}
|
||||
const pageForm = {
|
||||
hdid: hdid,
|
||||
unionId: unionId,
|
||||
unitId: unitId,
|
||||
activityDate: activityDate1
|
||||
}
|
||||
this.$downLoad(loc() + '/exportExcel', pageForm)
|
||||
},
|
||||
activityDateChange() {
|
||||
},
|
||||
pageData() {
|
||||
this.$axios.post(loc() + '/pageData', this.pageForm).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.tableData = res.data
|
||||
} else {
|
||||
this.$message.error(res.msg)
|
||||
}
|
||||
})
|
||||
},
|
||||
async getCascadersActivity() {
|
||||
const {code, data} = await this.$axios.post(loc() + '/getCascadersActivity', {year: this.pageForm.year})
|
||||
this.activityOptions = data
|
||||
if (this.activityOptions && this.activityOptions.length > 0) {
|
||||
this.pageForm.activityId = this.activityOptions[0].value
|
||||
this.pageData()
|
||||
} else {
|
||||
this.tableData = []
|
||||
}
|
||||
},
|
||||
|
||||
exportCheckInUsers() {
|
||||
window.open(loc() + '/exportCheckInUsers?unionId=' + this.viewUnion.unionId + '&activityId=' + this.pageForm.activityId)
|
||||
},
|
||||
exportRegUsers(){
|
||||
window.open(loc() + '/exportRegUsers?unionId=' + this.viewUnion.unionId + '&activityId=' + this.pageForm.activityId)
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
await this.getCascadersActivity()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
<!--#
|
||||
}
|
||||
#-->
|
||||
@@ -0,0 +1,388 @@
|
||||
<!--#
|
||||
layout("/layouts/platform.html"){
|
||||
#-->
|
||||
<style>
|
||||
|
||||
</style>
|
||||
<div id="app" v-cloak>
|
||||
<guava ref="guava">
|
||||
<el-card shadow="never">
|
||||
<div class="search">
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">年份:</div>
|
||||
<div class="search-item-option">
|
||||
<el-date-picker style="width: 100%"
|
||||
class="mr5"
|
||||
:picker-options="pickerOptions"
|
||||
v-model="pageForm.year" :clearable="false"
|
||||
type="year"
|
||||
value-format="yyyy" @change="getCascadersActivity"
|
||||
placeholder="选择年">
|
||||
</el-date-picker>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">活动:</div>
|
||||
<div class="search-item-option">
|
||||
<el-cascader
|
||||
style="width: 100%"
|
||||
@change="doSearch()"
|
||||
v-model="pageForm.activityId"
|
||||
:options="activityOptions"
|
||||
:props="{ checkStrictly: true,emitPath:false}"
|
||||
:clearable="false"></el-cascader>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">姓名工号:</div>
|
||||
<div class="search-item-option">
|
||||
<el-input placeholder="请输入姓名或工号查询" clearable v-model="pageForm.searchKeyword"
|
||||
style="width: 100%" @keyup.enter.native="doSearch">
|
||||
</el-input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<template v-if="$auth.hasRoleOr('SYSADMIN, SCHOOL_UNION_ADMIN')">
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">所属工会:</div>
|
||||
<div class="search-item-option">
|
||||
<el-select @change="unionChange" clearable filterable style="width: 100%"
|
||||
placeholder="请选择所属工会" v-model="pageForm.unionId">
|
||||
<el-option
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
v-for="item in unionOptions">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">所属单位:</div>
|
||||
<div class="search-item-option">
|
||||
<el-select @change="doSearch" clearable filterable style="width: 100%"
|
||||
placeholder="请选择所属单位" v-model="pageForm.unitId">
|
||||
<el-option
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
v-for="item in unitOptions">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="search-query">
|
||||
<el-button @click="doSearch" icon="el-icon-search" type="primary"></el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
<el-card class="mt10" shadow="never">
|
||||
<table-tool :app="this" label="达标人员列表">
|
||||
<template #func>
|
||||
<el-button @click="setRaffle" class="ml10" size="small" type="primary">设置抽奖条件</el-button>
|
||||
<el-button @click="viewLotteryUsers" class="ml10" size="small" type="primary">查看中奖人员</el-button>
|
||||
<el-button @click="exportExcel" class="ml10" size="small" type="primary">导出达标人员</el-button>
|
||||
</template>
|
||||
</table-tool>
|
||||
<el-table :data="tableData" :size="tableSize">
|
||||
<el-table-column :index="indexMethod" align="center" header-align="center" label="排名" type="index"
|
||||
width="80px"></el-table-column>
|
||||
<el-table-column
|
||||
:label="column.label"
|
||||
:prop="column.prop"
|
||||
:sortable="column.sortable"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
v-for="column in tableColumns"
|
||||
>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!--#include("/layouts/pagination.html"){}#-->
|
||||
</el-card>
|
||||
|
||||
<template #edit>
|
||||
<el-card shadow="never">
|
||||
<h2 style="color: #0a84ff">抽奖规则</h2>
|
||||
<span>排名位次指:一等奖,二等奖,三等奖;如您填写【1】,会按照达标总步数降序,取最高位次;填写【2】则排除【1】的中奖人数后再取抽奖人数的最高位次</span>
|
||||
<el-form :model="formData" ref="formRef" label-width="100px">
|
||||
<el-form-item>
|
||||
<el-table tooltip-effect="dark" style="width: 100%" :data="formData.manualLotteryRules">
|
||||
<el-table-column label="奖项名称" align="center">
|
||||
<template scope="scope">
|
||||
<el-input v-model="scope.row.awardName" placeholder="请输入奖项名称" max="50" clearable></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="抽奖人数" align="center">
|
||||
<template scope="scope">
|
||||
<el-input-number v-model="scope.row.lotteryUserNum"
|
||||
style="width: 100%"></el-input-number>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="抽奖类型" align="center">
|
||||
<template scope="scope">
|
||||
<el-select v-model="scope.row.raffleType">
|
||||
<el-option
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
v-for="item in raffleTypeOptions">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="排名位次" align="center">
|
||||
<template scope="scope">
|
||||
<el-input-number v-if="scope.row.raffleType == '排名'"
|
||||
v-model="scope.row.rankingPosition"
|
||||
style="width: 100%"></el-input-number>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="是否兼得" align="center">
|
||||
<template scope="scope">
|
||||
<el-radio-group v-if="scope.row.raffleType == '达标'"
|
||||
v-model="scope.row.isSimultaneously" size="small">
|
||||
<el-radio label="true" border>是</el-radio>
|
||||
<el-radio label="false" border>否</el-radio>
|
||||
</el-radio-group>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="操作" align="center">
|
||||
<template slot="header" slot-scope="scope">
|
||||
<el-button @click="formData.manualLotteryRules.push({})"
|
||||
icon="el-icon-plus" size="mini" type="primary"></el-button>
|
||||
</template>
|
||||
<template scope="scope">
|
||||
<el-button @click="formData.manualLotteryRules.splice(scope.$index,1)"
|
||||
icon="el-icon-delete" size="mini" type="danger"></el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div style="text-align: right">
|
||||
<el-button @click="$refs.guava.index()" class="ml10">返回</el-button>
|
||||
<el-button @click="saveRaffle" class="ml10" type="primary">提交</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<template #view>
|
||||
<el-card shadow="never">
|
||||
<div class="search">
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">姓名工号</div>
|
||||
<div class="search-item-option">
|
||||
<el-input v-model="awardPageForm.searchKeyword" placeholder="请输入姓名或工号" clearable></el-input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">奖项名称</div>
|
||||
<div class="search-item-option">
|
||||
<el-select v-model="awardPageForm.lotteryTime" style="width: 100%" clearable>
|
||||
<el-option
|
||||
:key="item.value"
|
||||
:label="item.value"
|
||||
:value="item.value"
|
||||
v-for="item in awardNameOptions">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="search-query">
|
||||
<el-button @click="awardPageData" icon="el-icon-search" type="primary"></el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
<el-card class="mt10" shadow="never">
|
||||
<table-tool :app="this" label="中奖人员列表">
|
||||
<template #func>
|
||||
<el-button @click="exportAwardExcel" icon="el-icon-download" type="primary" size="small">导出中奖人员</el-button>
|
||||
</template>
|
||||
</table-tool>
|
||||
<el-table :data="awardTableData">
|
||||
<el-table-column :index="indexMethod" align="center" header-align="center" label="排名" type="index"
|
||||
width="80px"></el-table-column>
|
||||
<el-table-column align="center" header-align="center" label="工号" prop="loginName"></el-table-column>
|
||||
<el-table-column align="center" header-align="center" label="姓名" prop="username"></el-table-column>
|
||||
<el-table-column align="center" header-align="center" label="分工会" prop="unionName"></el-table-column>
|
||||
<el-table-column align="center" header-align="center" label="单位" prop="unitName"></el-table-column>
|
||||
<el-table-column align="center" header-align="center" label="奖项名称" prop="awardName"></el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
</template>
|
||||
</guava>
|
||||
</div>
|
||||
<script>
|
||||
const vue = new Vue({
|
||||
el: '#app',
|
||||
mixins:[initTableMixins],
|
||||
data() {
|
||||
return {
|
||||
pickerOptions: {
|
||||
disabledDate(time) {
|
||||
return (
|
||||
time.getFullYear() > new Date().getFullYear()
|
||||
);
|
||||
}
|
||||
},
|
||||
pageForm: {
|
||||
year: moment().format('YYYY'),
|
||||
unionId:'',
|
||||
unitId:''
|
||||
},
|
||||
unionOptions: [],
|
||||
unitOptions: [],
|
||||
activityOptions: [],
|
||||
tableColumns: [
|
||||
{label: '姓名', prop: 'username'},
|
||||
{label: '工号', prop: 'loginname'},
|
||||
{label: '分工会', prop: 'unionname', sortable: true},
|
||||
{label: '单位', prop: 'unitname'},
|
||||
{label: '步数', prop: 'total_steps', sortable: true},
|
||||
{label: '达标天数', prop: 'standardsDays', sortable: true},
|
||||
],
|
||||
raffleTypeOptions: [
|
||||
{ value: '排名', label: '排名' },
|
||||
{ value: '达标', label: '达标' },
|
||||
],
|
||||
formData: {
|
||||
manualLotteryRules: []
|
||||
},
|
||||
|
||||
awardNameOptions: [],
|
||||
awardPageForm: {
|
||||
searchKeyword: '',
|
||||
activityId: '',
|
||||
lotteryTime: ''
|
||||
},
|
||||
awardTableData: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 设置抽奖条件
|
||||
*/
|
||||
async setRaffle(){
|
||||
this.$refs.guava.edit()
|
||||
// 获取该活动的抽奖条件
|
||||
const resp = await this.$axios.post('/platform/fitnessWalk/stepRaffle/getRaffle', {
|
||||
activityId: this.pageForm.activityId
|
||||
})
|
||||
if (resp.code === 0) {
|
||||
this.formData = resp.data
|
||||
} else {
|
||||
this.formData = {
|
||||
manualLotteryRules: []
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 查看中奖人员
|
||||
*/
|
||||
viewLotteryUsers(){
|
||||
this.$refs.guava.view()
|
||||
this.$nextTick(() => {
|
||||
this.awardPageData()
|
||||
})
|
||||
},
|
||||
async awardPageData() {
|
||||
this.awardPageForm.activityId = this.pageForm.activityId
|
||||
const resp = await this.$axios.post('/platform/fitnessWalk/stepWining/prizeUsers', this.awardPageForm)
|
||||
if (resp.code === 0) {
|
||||
this.awardTableData = resp.data
|
||||
}
|
||||
},
|
||||
exportAwardExcel(){
|
||||
const {searchKeyword,activityId,lotteryTime} = this.awardPageForm
|
||||
window.open( loc() + '/exportAwardExcel?searchKeyword=' + searchKeyword +
|
||||
'&activityId=' + activityId +'&lotteryTime=' + lotteryTime)
|
||||
},
|
||||
async saveRaffle() {
|
||||
console.log(this.formData)
|
||||
const formData = this.formData
|
||||
formData.activityId = this.pageForm.activityId
|
||||
formData.manualLotteryRules = JSON.stringify(this.formData.manualLotteryRules)
|
||||
const resp = await this.$axios.post('/platform/fitnessWalk/stepRaffle/saveRaffle', this.formData)
|
||||
if (resp.code === 0) {
|
||||
this.$message.success('保存成功')
|
||||
this.$refs.guava.index()
|
||||
} else {
|
||||
this.$message.warning(resp.msg)
|
||||
}
|
||||
},
|
||||
exportExcel(){
|
||||
const {searchKeyword,activityId,unionId,unitId} = this.pageForm
|
||||
window.open( loc() + '/exportExcel?searchKeyword=' + searchKeyword +
|
||||
'&activityId=' + activityId +'&unionId=' + unionId + '&unitId=' + unitId)
|
||||
},
|
||||
|
||||
async getAllActivity() {
|
||||
this.pageForm.activityId = ''
|
||||
this.activityOptions = []
|
||||
|
||||
const {data} = await this.$axios.post('/platform/fitnessWalk/activityManage/getAllActivity', this.pageForm)
|
||||
if (data == null || data.length === 0) {
|
||||
this.tableData = []
|
||||
return
|
||||
} else {
|
||||
this.activityOptions = data.filter(item => item.activityModel === 'stepCount')
|
||||
}
|
||||
|
||||
if (this.activityOptions) {
|
||||
this.pageForm.activityId = this.activityOptions[0]._id
|
||||
}
|
||||
},
|
||||
async unionChange(val) {
|
||||
this.pageForm.unitId = null
|
||||
this.unitOptions = await this.$businessTool.listUnit(val)
|
||||
this.doSearch()
|
||||
},
|
||||
async getCascadersActivity() {
|
||||
const {code, data} = await this.$axios.post(loc() + '/getCascadersActivity', {year: this.pageForm.year})
|
||||
this.activityOptions = data
|
||||
if (this.activityOptions && this.activityOptions.length > 0) {
|
||||
this.pageForm.activityId = this.activityOptions[0].value
|
||||
this.doSearch()
|
||||
} else {
|
||||
this.tableData = []
|
||||
}
|
||||
},
|
||||
async getAwardUserNum(){
|
||||
const resp = await this.$axios.post('/platform/fitnessWalk/stepRaffle/getAwardUserNum')
|
||||
if (resp.code === 0) {
|
||||
|
||||
}
|
||||
},
|
||||
async getAwardNameOptions(){
|
||||
const resp = await this.$axios.post('/platform/fitnessWalk/stepWining/prizeOption', {
|
||||
activityId: this.pageForm.activityId
|
||||
})
|
||||
if (resp.code === 0) {
|
||||
this.awardNameOptions = resp.data
|
||||
}
|
||||
},
|
||||
},
|
||||
async created() {
|
||||
this.unionOptions = await this.$businessTool.listUnion()
|
||||
this.unitOptions = await this.$businessTool.listUnit()
|
||||
await this.getCascadersActivity()
|
||||
await this.getAwardNameOptions()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<!--#
|
||||
}
|
||||
#-->
|
||||
@@ -0,0 +1,195 @@
|
||||
<!--#
|
||||
layout("/layouts/platform.html"){
|
||||
#-->
|
||||
<style>
|
||||
|
||||
</style>
|
||||
<div id="app" v-cloak>
|
||||
<guava>
|
||||
<el-card shadow="never">
|
||||
<div class="search">
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">年份:</div>
|
||||
<div class="search-item-option">
|
||||
<el-date-picker style="width: 100%"
|
||||
class="mr5"
|
||||
:picker-options="pickerOptions"
|
||||
v-model="pageForm.year" :clearable="false"
|
||||
type="year"
|
||||
value-format="yyyy" @change="getCascadersActivity"
|
||||
placeholder="选择年">
|
||||
</el-date-picker>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">活动:</div>
|
||||
<div class="search-item-option">
|
||||
<el-cascader
|
||||
style="width: 100%"
|
||||
@change="doSearch()"
|
||||
v-model="pageForm.activityId"
|
||||
:options="activityOptions"
|
||||
:props="{ checkStrictly: true,emitPath:false}"
|
||||
:clearable="false"></el-cascader>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">姓名工号:</div>
|
||||
<div class="search-item-option">
|
||||
<el-input placeholder="请输入内容" clearable v-model="pageForm.searchKeyword"
|
||||
style="width: 100%" @keyup.enter.native="doSearch">
|
||||
<el-select v-model="pageForm.searchName" slot="prepend" placeholder="查询类型"
|
||||
style="width: 110px;">
|
||||
<el-option label="姓名" value="u.username"></el-option>
|
||||
<el-option label="工号" value="u.loginname"></el-option>
|
||||
</el-select>
|
||||
</el-input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<template v-if="$auth.hasRoleOr('SYSADMIN, SCHOOL_UNION_ADMIN')">
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">所属工会:</div>
|
||||
<div class="search-item-option">
|
||||
<el-select @change="unionChange" clearable filterable style="width: 100%"
|
||||
placeholder="请选择所属工会" v-model="pageForm.unionId">
|
||||
<el-option
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
v-for="item in unionOptions">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">所属单位:</div>
|
||||
<div class="search-item-option">
|
||||
<el-select @change="doSearch" clearable filterable style="width: 100%"
|
||||
placeholder="请选择所属单位" v-model="pageForm.unitId">
|
||||
<el-option
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
v-for="item in unitOptions">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="search-query">
|
||||
<el-button @click="doSearch" icon="el-icon-search" type="primary"></el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
<el-card class="mt10" shadow="never">
|
||||
<table-tool :app="this" label="排行榜">
|
||||
<template #func>
|
||||
<el-radio-group v-model="pageForm.mode" size="small" @change="doSearch">
|
||||
<el-radio-button label="today">今日排行榜</el-radio-button>
|
||||
<el-radio-button label="all">总排行榜</el-radio-button>
|
||||
</el-radio-group>
|
||||
<el-button @click="exportExcel" class="ml10" size="small" type="primary">导出{{pageForm.mode == 'today' ? '今日排行榜' : '总排行榜'}}</el-button>
|
||||
</template>
|
||||
</table-tool>
|
||||
<el-table :data="tableData" :size="tableSize">
|
||||
<el-table-column :index="indexMethod" align="center" header-align="center" label="排名" type="index"
|
||||
width="80px"></el-table-column>
|
||||
<el-table-column
|
||||
:label="column.label"
|
||||
:prop="column.prop"
|
||||
:sortable="column.sortable"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
v-for="column in tableColumns"
|
||||
>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!--#include("/layouts/pagination.html"){}#-->
|
||||
</el-card>
|
||||
</guava>
|
||||
</div>
|
||||
<script>
|
||||
const vue = new Vue({
|
||||
el: '#app',
|
||||
mixins:[initTableMixins],
|
||||
data() {
|
||||
return {
|
||||
pickerOptions: {
|
||||
disabledDate(time) {
|
||||
return (
|
||||
time.getFullYear() > new Date().getFullYear()
|
||||
);
|
||||
}
|
||||
},
|
||||
pageForm: {
|
||||
year: new Date().getFullYear() + '',
|
||||
mode:'today',
|
||||
searchName:'u.username',
|
||||
unionId:'',
|
||||
unitId:''
|
||||
},
|
||||
unionOptions: [],
|
||||
unitOptions: [],
|
||||
activityOptions: [],
|
||||
tableColumns: [
|
||||
{label: '姓名', prop: 'username'},
|
||||
{label: '工号', prop: 'loginname'},
|
||||
{label: '分工会', prop: 'unionname', sortable: true},
|
||||
{label: '单位', prop: 'unitname'},
|
||||
{label: '步数', prop: 'total_steps', sortable: true},
|
||||
],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
exportExcel(){
|
||||
this.$downLoad(loc()+ '/exportExcel', this.pageForm)
|
||||
},
|
||||
|
||||
async getAllActivity() {
|
||||
this.pageForm.activityId = ''
|
||||
this.activityOptions = []
|
||||
|
||||
const {data} = await this.$axios.post('/platform/fitnessWalk/activityManage/getAllActivity', this.pageForm)
|
||||
if (data == null || data.length === 0) {
|
||||
this.tableData = []
|
||||
return
|
||||
} else {
|
||||
this.activityOptions = data.filter(item => item.activityModel === 'stepCount')
|
||||
}
|
||||
|
||||
if (this.activityOptions) {
|
||||
this.pageForm.activityId = this.activityOptions[0]._id
|
||||
}
|
||||
},
|
||||
async unionChange(val) {
|
||||
this.pageForm.unitId = null
|
||||
this.unitOptions = await this.$businessTool.listUnit(val)
|
||||
this.doSearch()
|
||||
},
|
||||
async getCascadersActivity() {
|
||||
const {code, data} = await this.$axios.post(loc() + '/getCascadersActivity', {year: this.pageForm.year})
|
||||
this.activityOptions = data
|
||||
if (this.activityOptions && this.activityOptions.length > 0) {
|
||||
this.pageForm.activityId = this.activityOptions[0].value
|
||||
this.doSearch()
|
||||
} else {
|
||||
this.tableData = []
|
||||
}
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
this.unionOptions = await this.$businessTool.listUnion(null)
|
||||
this.unitOptions = await this.$businessTool.listUnit(null)
|
||||
await this.getCascadersActivity()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<!--#
|
||||
}
|
||||
#-->
|
||||
@@ -0,0 +1,228 @@
|
||||
<!--#
|
||||
layout("/layouts/platform.html"){
|
||||
#-->
|
||||
<div id="app" v-cloak>
|
||||
<guava ref="guava">
|
||||
<template>
|
||||
<el-card shadow="never">
|
||||
<div class="search">
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">年份:</div>
|
||||
<div class="search-item-option">
|
||||
<el-date-picker
|
||||
:clearable="false"
|
||||
placeholder="选择年"
|
||||
style="width: 100%"
|
||||
@change="getCascadersActivity"
|
||||
type="year" v-model="pageForm.year"
|
||||
value-format="yyyy">
|
||||
</el-date-picker>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">活动:</div>
|
||||
<div class="search-item-option">
|
||||
<el-cascader
|
||||
style="width: 100%"
|
||||
@change="doSearch();getActivityById()"
|
||||
v-model="pageForm.activityId"
|
||||
:options="activityOptions"
|
||||
:props="{ checkStrictly: true,emitPath:false}"
|
||||
:clearable="false"></el-cascader>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">日期范围:</div>
|
||||
<div class="search-item-option">
|
||||
<el-date-picker
|
||||
end-placeholder="结束日期"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
type="daterange"
|
||||
style="width: 100%"
|
||||
@change="activityDateChange"
|
||||
value-format="yyyy-MM-dd"
|
||||
v-model="pageForm.activityDate">
|
||||
</el-date-picker>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">姓名工号:</div>
|
||||
<div class="search-item-option">
|
||||
<el-input v-model="pageForm.searchKeyword" max="20" placeholder="请输入工号或者姓名查询" clearable></el-input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template v-if="$auth.hasRoleOr('SYSADMIN, SCHOOL_UNION_ADMIN')">
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">所属工会:</div>
|
||||
<div class="search-item-option">
|
||||
<el-select @change="unionChange" clearable filterable style="width: 100%"
|
||||
placeholder="请选择所属工会" v-model="pageForm.unionId">
|
||||
<el-option
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
v-for="item in unionOptions">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">所属单位:</div>
|
||||
<div class="search-item-option">
|
||||
<el-select @change="doSearch" clearable filterable style="width: 100%"
|
||||
placeholder="请选择所属单位" v-model="pageForm.unitId">
|
||||
<el-option
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
v-for="item in unitOptions">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="search-query">
|
||||
<el-button @click="doSearch" icon="el-icon-search" type="primary"></el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
<el-card class="mt20" shadow="never">
|
||||
<table-tool :app="this" label="步数列表">
|
||||
<template #func>
|
||||
<el-button @click="exportExcel" class="ml10" size="small" type="primary">导出</el-button>
|
||||
</template>
|
||||
</table-tool>
|
||||
<el-table :data="tableData" :size="tableSize">
|
||||
<el-table-column :index="indexMethod" align="center" header-align="center" label="序号" type="index"
|
||||
width="80px"></el-table-column>
|
||||
<el-table-column
|
||||
:label="column.label"
|
||||
:prop="column.prop"
|
||||
:sortable="column.sortable"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
v-for="column in tableColumns"
|
||||
>
|
||||
<template scope="{row}" v-if="column.prop==='registerNum'">
|
||||
<el-link @click="openView(row.id)" type="primary">
|
||||
{{row.registerNum}}
|
||||
</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!--#include("/layouts/pagination.html"){}#-->
|
||||
</el-card>
|
||||
</template>
|
||||
</guava>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let vue = new Vue({
|
||||
el: '#app',
|
||||
mixins: [initTableMixins],
|
||||
data() {
|
||||
return {
|
||||
tableColumns: [
|
||||
{label: '姓名', prop: 'username'},
|
||||
{label: '工号', prop: 'loginname'},
|
||||
{label: '单位', prop: 'unitname'},
|
||||
{label: '分工会', prop: 'unionname', sortable: true},
|
||||
{label: '当前步数', prop: 'step', sortable: true},
|
||||
{label: '日期', prop: 'prizeData', sortable: true}
|
||||
],
|
||||
unionOptions: [],
|
||||
unitOptions: [],
|
||||
pageForm: {
|
||||
unionId: '',
|
||||
unitId: '',
|
||||
activityDate: [],
|
||||
activityId: null,
|
||||
year: new Date().getFullYear() + '',
|
||||
},
|
||||
activityOptions: [],
|
||||
activityDatePickerOptions: {
|
||||
disabledDate: time => {
|
||||
return (
|
||||
time <= moment(this.activityInfo.endTime) || time >= moment(this.activityInfo.startTime)
|
||||
);
|
||||
}
|
||||
},
|
||||
activityInfo:{},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
exportExcel() {
|
||||
const {activityId, unionId, unitId, activityDate} = this.pageForm
|
||||
let activityDate1 = []
|
||||
if (activityDate && activityDate.length > 0) {
|
||||
activityDate1 = JSON.stringify(activityDate)
|
||||
}
|
||||
const pageForm = {
|
||||
activityId,
|
||||
unionId,
|
||||
unitId,
|
||||
activityDate: activityDate1
|
||||
}
|
||||
this.$downLoad(loc() + '/exportExcel', pageForm)
|
||||
},
|
||||
activityDateChange() {
|
||||
// this.$set(this.pageForm, "activityDate", [])
|
||||
},
|
||||
async unionChange(val) {
|
||||
this.pageForm.unitId = null
|
||||
this.unitOptions = await this.$businessTool.listUnit(val)
|
||||
this.doSearch()
|
||||
},
|
||||
async getCascadersActivity() {
|
||||
const {code, data} = await this.$axios.post(loc() + '/getCascadersActivity', {year: this.pageForm.year})
|
||||
this.activityOptions = data
|
||||
if (this.activityOptions && this.activityOptions.length > 0) {
|
||||
this.pageForm.activityId = this.activityOptions[0].value
|
||||
this.doSearch()
|
||||
} else {
|
||||
this.tableData = []
|
||||
}
|
||||
},
|
||||
pageData() {
|
||||
this.tableLoading = true
|
||||
let pageForm = clone(this.pageForm)
|
||||
if (pageForm.activityDate && pageForm.activityDate.length > 0) {
|
||||
pageForm.activityDate = JSON.stringify(pageForm.activityDate)
|
||||
}
|
||||
this.$axios.post(loc() + "/pageData", pageForm, (data) => {
|
||||
this.tableLoading = false
|
||||
if (data.code === 0) {
|
||||
this.tableData = data.data.list;
|
||||
this.pageForm.totalCount = data.data.totalCount;
|
||||
} else {
|
||||
this.$message.error(data.msg);
|
||||
}
|
||||
}, "json");
|
||||
},
|
||||
|
||||
async getActivityById(){
|
||||
const resp = await this.$axios.post('/platform/fitnessWalk/activityManage/findOne',{id:this.pageForm.activityId})
|
||||
if (resp.code === 0){
|
||||
this.activityInfo = resp.data
|
||||
}
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
this.unionOptions = await this.$businessTool.listUnion(null)
|
||||
this.unitOptions = await this.$businessTool.listUnit(null)
|
||||
await this.getCascadersActivity()
|
||||
await this.getActivityById();
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
<!--#
|
||||
}
|
||||
#-->
|
||||
@@ -0,0 +1,238 @@
|
||||
<!--#
|
||||
layout("/layouts/platform.html"){
|
||||
#-->
|
||||
<style>
|
||||
.query-row {
|
||||
height: 50px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.query-row:not(:last-child) {
|
||||
border-bottom: 1px dashed rgb(230, 230, 230);
|
||||
}
|
||||
|
||||
.query-row-title {
|
||||
width: 120px;
|
||||
}
|
||||
</style>
|
||||
<div id="app" v-cloak>
|
||||
<guava>
|
||||
<el-card shadow="never">
|
||||
<div class="search">
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">年份:</div>
|
||||
<div class="search-item-option">
|
||||
<el-date-picker style="width: 100%"
|
||||
class="mr5"
|
||||
:picker-options="pickerOptions"
|
||||
v-model="pageForm.year" :clearable="false"
|
||||
type="year"
|
||||
value-format="yyyy" @change="getCascadersActivity"
|
||||
placeholder="选择年">
|
||||
</el-date-picker>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">活动:</div>
|
||||
<div class="search-item-option">
|
||||
<el-cascader
|
||||
style="width: 100%"
|
||||
@change="doSearch()"
|
||||
v-model="pageForm.activityId"
|
||||
:options="activityOptions"
|
||||
:props="{ checkStrictly: true,emitPath:false}"
|
||||
:clearable="false"></el-cascader>
|
||||
</div>
|
||||
</div>
|
||||
<!--<div class="search-item">
|
||||
<div class="search-item-label">姓名工号:</div>
|
||||
<div class="search-item-option">
|
||||
<el-input placeholder="请输入内容" clearable v-model="pageForm.searchKeyword"
|
||||
style="width: 100%" @keyup.enter.native="doSearch">
|
||||
<el-select v-model="pageForm.searchName" slot="prepend" placeholder="查询类型"
|
||||
style="width: 110px;">
|
||||
<el-option label="姓名" value="u.username"></el-option>
|
||||
<el-option label="工号" value="u.loginname"></el-option>
|
||||
</el-select>
|
||||
</el-input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template v-if="$auth.hasRoleOr('SYSADMIN, SCHOOL_UNION_ADMIN')">
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">所属工会:</div>
|
||||
<div class="search-item-option">
|
||||
<el-select @change="unionChange" clearable filterable style="width: 100%"
|
||||
placeholder="请选择所属工会" v-model="pageForm.unionId">
|
||||
<el-option
|
||||
:key="item.id"
|
||||
:label="item.unionname"
|
||||
:value="item.id"
|
||||
v-for="item in unionOptions">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">所属单位:</div>
|
||||
<div class="search-item-option">
|
||||
<el-select @change="doSearch" clearable filterable style="width: 100%"
|
||||
placeholder="请选择所属单位" v-model="pageForm.unitId">
|
||||
<el-option
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
v-for="item in unitOptions">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
</template>-->
|
||||
<div class="search-query">
|
||||
<el-button @click="doSearch" icon="el-icon-search" type="primary"></el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-card class="mt10" shadow="never" style="height: 100px">
|
||||
<el-row type="flex" align="middle" class="query-row">
|
||||
<el-col class="query-row-title">奖项名称:</el-col>
|
||||
<el-col class="query-row-content">
|
||||
<el-radio-group v-model="changKeyItem" @change="subsectionChange(changKeyItem)" size="small">
|
||||
<el-radio
|
||||
style="margin-right: 10px;margin-top:5px;cursor: pointer"
|
||||
border
|
||||
v-for="item in subsectionList"
|
||||
:key="item.value"
|
||||
:label="item.name">
|
||||
{{ item.name }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-card>
|
||||
|
||||
<el-card class="mt10" shadow="never">
|
||||
<table-tool :app="this" label="中奖榜">
|
||||
<template #func>
|
||||
<el-button @click="exportUserStepWining" class="ml10" size="small" type="primary">导出中奖名单</el-button>
|
||||
</template>
|
||||
</table-tool>
|
||||
<el-table :data="tableData" :size="tableSize">
|
||||
<el-table-column :index="indexMethod" align="center" header-align="center" label="序号" type="index"
|
||||
width="80px"></el-table-column>
|
||||
<el-table-column
|
||||
:label="column.label"
|
||||
:prop="column.prop"
|
||||
:sortable="column.sortable"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
v-for="column in tableColumns">
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
</guava>
|
||||
</div>
|
||||
<script>
|
||||
const vue = new Vue({
|
||||
el: '#app',
|
||||
mixins:[initTableMixins],
|
||||
data() {
|
||||
return {
|
||||
pickerOptions: {
|
||||
disabledDate(time) {
|
||||
return (
|
||||
time.getFullYear() > new Date().getFullYear()
|
||||
);
|
||||
}
|
||||
},
|
||||
pageForm: {
|
||||
year: new Date().getFullYear() + '',
|
||||
mode:'today',
|
||||
searchName:'u.username',
|
||||
activityId:null
|
||||
},
|
||||
unionOptions: [],
|
||||
unitOptions: [],
|
||||
activityOptions: [],
|
||||
tableColumns: [
|
||||
{label: '姓名', prop: 'username'},
|
||||
// {label: '工号', prop: 'loginname'},
|
||||
{label: '分工会', prop: 'unionName', sortable: true},
|
||||
{label: '单位', prop: 'unitName'},
|
||||
{label: '奖项名称', prop: 'awardName'},
|
||||
],
|
||||
|
||||
allDataList:[],
|
||||
subsectionList:[],
|
||||
subsectionIndex: 0,
|
||||
changKeyItem:'',
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
exportUserStepWining(){
|
||||
this.$downLoad(loc() + '/exportUserStepWining?activityId=' + this.pageForm.activityId)
|
||||
},
|
||||
async getAllActivity() {
|
||||
this.pageForm.activityId = ''
|
||||
this.activityOptions = []
|
||||
const {data} = await this.$axios.post('/platform/fitnessWalk/activityManage/getAllActivity', this.pageForm)
|
||||
if (data == null || data.length === 0) {
|
||||
this.tableData = []
|
||||
return
|
||||
} else {
|
||||
this.activityOptions = data.filter(item => item.activityModel === 'stepCount')
|
||||
}
|
||||
if (this.activityOptions) {
|
||||
this.pageForm.activityId = this.activityOptions[0]._id
|
||||
}
|
||||
},
|
||||
async unionChange(val) {
|
||||
this.pageForm.unitId = null
|
||||
this.unitOptions = await this.$businessTool.listUnit(val)
|
||||
this.doSearch()
|
||||
},
|
||||
subsectionChange(key) {
|
||||
const data = this.allDataList.find(item => item.title === key)
|
||||
this.tableData = data.awardList
|
||||
},
|
||||
async pageData(){
|
||||
const resp = await this.$axios.post(loc() + '/getUserStepWining',this.pageForm)
|
||||
if (resp.code === 0){
|
||||
this.allDataList = resp.data
|
||||
this.subsectionList = resp.data.map(v => {
|
||||
return {
|
||||
name: v.title,
|
||||
key: v.title
|
||||
}
|
||||
})
|
||||
this.tableData = this.allDataList[0].awardList
|
||||
this.changKeyItem = this.allDataList[0].title
|
||||
}
|
||||
},
|
||||
async getCascadersActivity() {
|
||||
const {code, data} = await this.$axios.post(loc() + '/getCascadersActivity', {year: this.pageForm.year})
|
||||
this.activityOptions = data
|
||||
if (this.activityOptions && this.activityOptions.length > 0) {
|
||||
this.pageForm.activityId = this.activityOptions[0].value
|
||||
this.doSearch()
|
||||
} else {
|
||||
this.tableData = []
|
||||
}
|
||||
},
|
||||
},
|
||||
async created() {
|
||||
// this.unionOptions = await getUnions(null)
|
||||
// this.unitOptions = await getUnits(null)
|
||||
await this.getCascadersActivity()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<!--#
|
||||
}
|
||||
#-->
|
||||
@@ -320,6 +320,8 @@ layout("/layouts/platform.html"){
|
||||
changeWelfareMobileVisible: false,
|
||||
welfareFormData: {},
|
||||
|
||||
changeTypeData: [],
|
||||
|
||||
checkedFields: []
|
||||
},
|
||||
components: {
|
||||
|
||||
Reference in New Issue
Block a user