commit
This commit is contained in:
+2
-4
@@ -8,8 +8,8 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import io.v.nutz.base.annontation.ViReturn;
|
import io.v.nutz.base.annontation.ViReturn;
|
||||||
import io.v.nutz.base.utils.Vi;
|
import io.v.nutz.base.utils.Vi;
|
||||||
import io.v.nutz.base.utils.WxHttpUtil;
|
import io.v.nutz.base.utils.WxHttpUtil;
|
||||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
|
||||||
import io.v.nutz.zhgh.fitnessWalk.utils.WeAppCloudUtil;
|
import io.v.nutz.zhgh.fitnessWalk.utils.WeAppCloudUtil;
|
||||||
|
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.nutz.ioc.loader.annotation.Inject;
|
import org.nutz.ioc.loader.annotation.Inject;
|
||||||
import org.nutz.ioc.loader.annotation.IocBean;
|
import org.nutz.ioc.loader.annotation.IocBean;
|
||||||
@@ -22,7 +22,6 @@ import org.nutz.mvc.annotation.Param;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@IocBean
|
@IocBean
|
||||||
@@ -81,14 +80,13 @@ public class FitnessWalkActivityBindingRecordController {
|
|||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
return Result.error(e.getMessage());
|
return Result.error(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@ViReturn
|
@ViReturn
|
||||||
@RequiresPermissions("fitnessWalk.bindingRecord")
|
@RequiresPermissions("fitnessWalk.bindingRecord")
|
||||||
public Object delete(String[] ids){
|
public Object delete(String[] ids) {
|
||||||
try {
|
try {
|
||||||
String sql = "db.collection('login_record').where({_id:_.in(" + Json.toJson(ids) + ")}).remove()";
|
String sql = "db.collection('login_record').where({_id:_.in(" + Json.toJson(ids) + ")}).remove()";
|
||||||
weAppCloudUtil.request(WeAppCloudUtil.CRUD.DELETE,sql);
|
weAppCloudUtil.request(WeAppCloudUtil.CRUD.DELETE,sql);
|
||||||
|
|||||||
+5
-30
@@ -1,26 +1,23 @@
|
|||||||
package io.v.nutz.zhgh.fitnessWalk.controller;
|
package io.v.nutz.zhgh.fitnessWalk.controller;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
|
||||||
import cn.hutool.core.date.DateTime;
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.wizzer.framework.base.Result;
|
import cn.wizzer.framework.base.Result;
|
||||||
import cn.wizzer.framework.page.Pagination;
|
import cn.wizzer.framework.page.Pagination;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import io.v.nutz.base.annontation.ViReturn;
|
import io.v.nutz.base.annontation.ViReturn;
|
||||||
import io.v.nutz.base.utils.Vi;
|
import io.v.nutz.base.utils.Vi;
|
||||||
import io.v.nutz.base.utils.WxHttpUtil;
|
import io.v.nutz.base.utils.WxHttpUtil;
|
||||||
|
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkActivity;
|
||||||
|
import io.v.nutz.zhgh.fitnessWalk.service.FitnessWalkCommonService;
|
||||||
|
import io.v.nutz.zhgh.fitnessWalk.utils.WeAppCloudUtil;
|
||||||
import io.v.nutz.sys.models.Sys_task;
|
import io.v.nutz.sys.models.Sys_task;
|
||||||
import io.v.nutz.sys.services.SysTaskService;
|
import io.v.nutz.sys.services.SysTaskService;
|
||||||
import io.v.nutz.sys.services.SysUserService;
|
import io.v.nutz.sys.services.SysUserService;
|
||||||
import io.v.nutz.task.services.TaskPlatformService;
|
import io.v.nutz.task.services.TaskPlatformService;
|
||||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||||
import io.v.nutz.web.commons.base.Globals;
|
|
||||||
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkActivity;
|
|
||||||
import io.v.nutz.zhgh.fitnessWalk.service.FitnessWalkCommonService;
|
|
||||||
import io.v.nutz.zhgh.fitnessWalk.utils.WeAppCloudUtil;
|
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.nutz.dao.Cnd;
|
import org.nutz.dao.Cnd;
|
||||||
import org.nutz.ioc.loader.annotation.Inject;
|
import org.nutz.ioc.loader.annotation.Inject;
|
||||||
@@ -28,8 +25,6 @@ import org.nutz.ioc.loader.annotation.IocBean;
|
|||||||
import org.nutz.json.Json;
|
import org.nutz.json.Json;
|
||||||
import org.nutz.lang.Lang;
|
import org.nutz.lang.Lang;
|
||||||
import org.nutz.lang.Strings;
|
import org.nutz.lang.Strings;
|
||||||
import org.nutz.lang.random.R;
|
|
||||||
import org.nutz.lang.tmpl.Tmpl;
|
|
||||||
import org.nutz.lang.util.NutMap;
|
import org.nutz.lang.util.NutMap;
|
||||||
import org.nutz.log.Log;
|
import org.nutz.log.Log;
|
||||||
import org.nutz.log.Logs;
|
import org.nutz.log.Logs;
|
||||||
@@ -39,17 +34,11 @@ import org.nutz.mvc.annotation.Ok;
|
|||||||
import org.nutz.mvc.annotation.Param;
|
import org.nutz.mvc.annotation.Param;
|
||||||
import org.nutz.mvc.upload.TempFile;
|
import org.nutz.mvc.upload.TempFile;
|
||||||
import org.nutz.mvc.upload.UploadAdaptor;
|
import org.nutz.mvc.upload.UploadAdaptor;
|
||||||
import org.nutz.plugins.wkcache.annotation.CacheRemove;
|
|
||||||
import org.nutz.plugins.wkcache.annotation.CacheRemoveAll;
|
|
||||||
import org.nutz.trans.Trans;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
@At("/platform/fitnessWalk/activityManage")
|
@At("/platform/fitnessWalk/activityManage")
|
||||||
@Ok("json")
|
@Ok("json")
|
||||||
@IocBean
|
@IocBean
|
||||||
@@ -152,14 +141,6 @@ public class FitnessWalkActivityManageController {
|
|||||||
fitnessWalkActivity.setUnionId("");
|
fitnessWalkActivity.setUnionId("");
|
||||||
}
|
}
|
||||||
|
|
||||||
//判断打卡抽奖的奖品列表是否有value
|
|
||||||
if (Lang.isNotEmpty(fitnessWalkActivity.getPunchLotteryPrizes())){
|
|
||||||
fitnessWalkActivity.getPunchLotteryPrizes().forEach(v->{
|
|
||||||
if (StrUtil.isNotBlank(v.getValue())) return;
|
|
||||||
v.setValue(R.UU32());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fitnessWalkActivity.setNote(fitnessWalkActivity.getNote().replace("\"", "'"));
|
fitnessWalkActivity.setNote(fitnessWalkActivity.getNote().replace("\"", "'"));
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
sql.append("db.collection('activity').add({data:").append(Json.toJson(fitnessWalkActivity)).append("})");
|
sql.append("db.collection('activity').add({data:").append(Json.toJson(fitnessWalkActivity)).append("})");
|
||||||
@@ -246,13 +227,7 @@ public class FitnessWalkActivityManageController {
|
|||||||
} else {
|
} else {
|
||||||
fitnessWalkActivity.setUnionId("");
|
fitnessWalkActivity.setUnionId("");
|
||||||
}
|
}
|
||||||
//判断打卡抽奖的奖品列表是否有value
|
|
||||||
if (Lang.isNotEmpty(fitnessWalkActivity.getPunchLotteryPrizes())){
|
|
||||||
fitnessWalkActivity.getPunchLotteryPrizes().forEach(v->{
|
|
||||||
if (StrUtil.isNotBlank(v.getValue())) return;
|
|
||||||
v.setValue(R.UU32());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
fitnessWalkActivity.setNote(fitnessWalkActivity.getNote().replace("\"", "'"));
|
fitnessWalkActivity.setNote(fitnessWalkActivity.getNote().replace("\"", "'"));
|
||||||
|
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
@@ -287,6 +262,7 @@ public class FitnessWalkActivityManageController {
|
|||||||
taskPlatformService.delete(v.getId(), v.getId());
|
taskPlatformService.delete(v.getId(), v.getId());
|
||||||
sysTaskService.delete(v.getId());
|
sysTaskService.delete(v.getId());
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
return Result.success();
|
return Result.success();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -294,7 +270,6 @@ public class FitnessWalkActivityManageController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 健身走健步模式通知提醒
|
* 健身走健步模式通知提醒
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package io.v.nutz.zhgh.fitnessWalk.controller;
|
||||||
|
|
||||||
|
import io.v.nutz.base.annontation.ViReturn;
|
||||||
|
import io.v.nutz.base.utils.DateUtil;
|
||||||
|
import io.v.nutz.zhgh.question.model.Question_issue;
|
||||||
|
import io.v.nutz.zhgh.question.model.Question_reply;
|
||||||
|
import io.v.nutz.zhgh.question.service.QuestionIssueService;
|
||||||
|
import io.v.nutz.zhgh.question.service.QuestionReplyService;
|
||||||
|
import io.v.nutz.zhgh.question.service.QuestionService;
|
||||||
|
import io.v.nutz.zhgh.question.service.QuestionWorService;
|
||||||
|
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
|
||||||
|
public Object getQuestion() {
|
||||||
|
return questionService.query(Cnd.where("qflag", "=", 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
@At
|
||||||
|
@ViReturn
|
||||||
|
public Object 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
|
||||||
|
public Object 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
-256
@@ -1,256 +0,0 @@
|
|||||||
package io.v.nutz.zhgh.fitnessWalk.controller;
|
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.wizzer.framework.base.Result;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import io.v.nutz.base.annontation.ViReturn;
|
|
||||||
import io.v.nutz.sys.models.Sys_user;
|
|
||||||
import io.v.nutz.web.commons.slog.annotation.SLog;
|
|
||||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
|
||||||
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkActivity;
|
|
||||||
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkPunchLottery;
|
|
||||||
import io.v.nutz.zhgh.fitnessWalk.service.FitnessWalkCommonService;
|
|
||||||
import io.v.nutz.zhgh.fitnessWalk.utils.WeAppCloudUtil;
|
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
||||||
import org.nutz.dao.Chain;
|
|
||||||
import org.nutz.dao.Cnd;
|
|
||||||
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.random.R;
|
|
||||||
import org.nutz.lang.util.NutMap;
|
|
||||||
import org.nutz.mvc.annotation.At;
|
|
||||||
import org.nutz.mvc.annotation.Ok;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 打卡抽奖
|
|
||||||
*/
|
|
||||||
@IocBean
|
|
||||||
@Ok("json")
|
|
||||||
@At("/platform/fitnessWalk/punchLottery")
|
|
||||||
public class FitnessWalkPunchLotteryController {
|
|
||||||
|
|
||||||
private final ReentrantLock lock = new ReentrantLock(true);
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private FitnessWalkCommonService fitnessWalkCommonService;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private WeAppCloudUtil weAppCloudUtil;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private RedisService redisService;
|
|
||||||
|
|
||||||
@At("")
|
|
||||||
@Ok("beetl:/platform/fitnessWalk/punchLottery.html")
|
|
||||||
public void index() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 打卡完成之后抽奖
|
|
||||||
*
|
|
||||||
* @param activityId 活动Id
|
|
||||||
* @param userId 用户Id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@At
|
|
||||||
public Result judgeWinningToPunch(String activityId, String userId) {
|
|
||||||
try {
|
|
||||||
if (StrUtil.isBlank(activityId) && StrUtil.isBlank(userId)) {
|
|
||||||
return Result.error("参数错误");
|
|
||||||
}
|
|
||||||
|
|
||||||
lock.lock();
|
|
||||||
int winingCount = fitnessWalkCommonService.dao().count(FitnessWalkPunchLottery.class, Cnd.where("activityId", "=", activityId).and("userId", "=", userId));
|
|
||||||
if (winingCount > 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String redisKey = this.getClass().getName() + "#judgeWinningToPunch#activityid:" + activityId + "#PRIZELIST:";
|
|
||||||
String getPrizeIndexesKey = this.getClass().getName() + "#judgeWinningToPunch#activityid:" + activityId + "#GETPRIZEINDEXES:";
|
|
||||||
|
|
||||||
// redisService.del(getPrizeIndexesKey);
|
|
||||||
List<FitnessWalkActivity.PunchLotteryPrize> punchLotteryPrizes = new ArrayList<>();
|
|
||||||
String punchLotteryPrizesJson = redisService.get(redisKey);
|
|
||||||
if (StrUtil.isNotBlank(punchLotteryPrizesJson)) {
|
|
||||||
punchLotteryPrizes = JSON.parseArray(punchLotteryPrizesJson, FitnessWalkActivity.PunchLotteryPrize.class);
|
|
||||||
} else {
|
|
||||||
JSONObject prizeJsonObject = weAppCloudUtil.request(WeAppCloudUtil.CRUD.QUERY, "db.collection('activity').doc('%s').field({punchLotteryPrizes: true}).get()".formatted(activityId));
|
|
||||||
List<FitnessWalkActivity.PunchLotteryPrize> prizeList = JSON.parseObject((String) prizeJsonObject.getJSONArray("data").get(0)).getJSONArray("punchLotteryPrizes").toJavaList(FitnessWalkActivity.PunchLotteryPrize.class);
|
|
||||||
redisService.set(redisKey, JSON.toJSONString(prizeList));
|
|
||||||
punchLotteryPrizes = prizeList;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Integer> winningUserIndexList = null;
|
|
||||||
//奖项,抽取多少个
|
|
||||||
int sum = punchLotteryPrizes.stream().mapToInt(v -> Integer.parseInt(v.getNum())).sum();
|
|
||||||
//判断是否有key,可以获得奖项的下标数组
|
|
||||||
if (!redisService.exists(getPrizeIndexesKey)) {
|
|
||||||
JSONObject jsonObject = weAppCloudUtil.request(WeAppCloudUtil.CRUD.QUERY, "db.collection('register').where({activity_id:'%s'}).count()".formatted(activityId));
|
|
||||||
JSONObject pager = jsonObject.getJSONObject("pager");
|
|
||||||
String total = pager.getString("Total");
|
|
||||||
//报名人数的一半,从这里的人中取数(最多抽取人数)
|
|
||||||
Integer lotteryNum = (int) Math.ceil(Double.parseDouble(total) / 2);
|
|
||||||
winningUserIndexList = generateRandomNumber(1, lotteryNum, sum);
|
|
||||||
redisService.set(getPrizeIndexesKey, JSON.toJSONString(winningUserIndexList));
|
|
||||||
} else {
|
|
||||||
String data = redisService.get(getPrizeIndexesKey);
|
|
||||||
winningUserIndexList = JSONObject.parseArray(data, Integer.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<FitnessWalkPunchLottery> punchLotteryList = fitnessWalkCommonService.dao().query(FitnessWalkPunchLottery.class, Cnd.where("activityId", "=", activityId));
|
|
||||||
|
|
||||||
Sys_user user = fitnessWalkCommonService.dao().fetch(Sys_user.class, Cnd.where("id", "=", userId));
|
|
||||||
|
|
||||||
FitnessWalkPunchLottery punchLottery = new FitnessWalkPunchLottery();
|
|
||||||
punchLottery.setId(R.UU32());
|
|
||||||
punchLottery.setActivityId(activityId);
|
|
||||||
punchLottery.setUserId(userId);
|
|
||||||
punchLottery.setLoginName(user.getLoginname());
|
|
||||||
punchLottery.setUserName(user.getUsername());
|
|
||||||
punchLottery.setWinDate(new Date());
|
|
||||||
punchLottery.setIsRead(false);
|
|
||||||
punchLottery.setIsWin(false);
|
|
||||||
punchLottery.setIsExchange(false);
|
|
||||||
|
|
||||||
if (winningUserIndexList.contains((punchLotteryList.size()))) {
|
|
||||||
|
|
||||||
//奖项map
|
|
||||||
Map<String, String> prizeMap = punchLotteryPrizes.stream().collect(Collectors.toMap(v -> v.getValue(), v -> v.getName()));
|
|
||||||
|
|
||||||
//奖项池
|
|
||||||
List<String> prizeIdList = new ArrayList<>();
|
|
||||||
|
|
||||||
punchLotteryPrizes.forEach(v -> {
|
|
||||||
for (int i = 0; i < Integer.parseInt(v.getNum()); i++) {
|
|
||||||
prizeIdList.add(v.getValue());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//已经中奖的奖项ID集合
|
|
||||||
List<String> winPrizeIdList = punchLotteryList.stream().filter(v -> v.getIsWin()).map(v -> v.getPrizeId()).collect(Collectors.toList());
|
|
||||||
winPrizeIdList.forEach(prizeId -> {
|
|
||||||
int i = prizeIdList.indexOf(prizeId);
|
|
||||||
prizeIdList.remove(i);
|
|
||||||
});
|
|
||||||
|
|
||||||
Random random = new Random();
|
|
||||||
if (prizeIdList.size() != 0) {
|
|
||||||
int index = random.nextInt(prizeIdList.size());
|
|
||||||
|
|
||||||
// 获取随机元素
|
|
||||||
String winingPrizeId = prizeIdList.get(index);
|
|
||||||
String winingPrizeName = prizeMap.get(winingPrizeId);
|
|
||||||
punchLottery.setPrizeName(winingPrizeName);
|
|
||||||
punchLottery.setPrizeId(winingPrizeId);
|
|
||||||
punchLottery.setIsWin(true);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fitnessWalkCommonService.dao().insert(punchLottery);
|
|
||||||
if (punchLottery.getIsWin()) {
|
|
||||||
return Result.success().addData(punchLottery.getPrizeId());
|
|
||||||
} else {
|
|
||||||
return Result.success().addData(null);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
|
||||||
} finally {
|
|
||||||
if (lock.isLocked()) {
|
|
||||||
lock.unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@At
|
|
||||||
public Result getLotteryRecord(String activityId, String userId) {
|
|
||||||
List<FitnessWalkPunchLottery> list = fitnessWalkCommonService.dao().query(FitnessWalkPunchLottery.class, Cnd.where("activityId", "=", activityId)
|
|
||||||
.and("userId", "=", userId));
|
|
||||||
return Result.success(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 兑奖
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@At
|
|
||||||
public Result doExchange(String id) {
|
|
||||||
|
|
||||||
int count = fitnessWalkCommonService.dao().count(FitnessWalkPunchLottery.class, Cnd.where("id", "=", id).and("isExchange", "=", 1));
|
|
||||||
//返回2 "该二维码已兑奖!"
|
|
||||||
if (count > 0) return Result.success(2);
|
|
||||||
|
|
||||||
int update = fitnessWalkCommonService.dao().update(FitnessWalkPunchLottery.class,
|
|
||||||
Chain.make("isExchange", 1).add("exchangeDate", new Date()),
|
|
||||||
Cnd.where("id", "=", id));
|
|
||||||
return update > 0 ? Result.success() : Result.error();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 改为已读
|
|
||||||
*
|
|
||||||
* @param activityId
|
|
||||||
* @param userId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@At
|
|
||||||
public Result doReadLottery(String activityId, String userId) {
|
|
||||||
fitnessWalkCommonService.dao().update(FitnessWalkPunchLottery.class, Chain.make("isRead", 1),
|
|
||||||
Cnd.where("userId", "=", userId).and("activityId", "=", activityId));
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看获奖人员
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@At
|
|
||||||
public Result getPunchWining(String activityId) {
|
|
||||||
List<FitnessWalkPunchLottery> punchLotteryList = fitnessWalkCommonService.dao().query(FitnessWalkPunchLottery.class,
|
|
||||||
Cnd.where("isWin", "=", 1).and("activityId", "=", activityId));
|
|
||||||
return Result.success(punchLotteryList);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成随机数,该随机数为中奖人
|
|
||||||
*
|
|
||||||
* @param minNum 最小值
|
|
||||||
* @param maxNum 最多抽取多少人
|
|
||||||
* @param count 抽几个
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public List<Integer> generateRandomNumber(Integer minNum, Integer maxNum, Integer count) {
|
|
||||||
Set<Integer> randomNumbers = new HashSet<>();
|
|
||||||
Random rand = new Random();
|
|
||||||
//如果是 抽奖人数小于了 奖品数量,会陷入死循环
|
|
||||||
if (maxNum <= count) {
|
|
||||||
for (int i = 0; i <= maxNum; i++) {
|
|
||||||
randomNumbers.add(i + 1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
while (randomNumbers.size() < count) {
|
|
||||||
int randomNum = rand.nextInt(maxNum - minNum + 1) + minNum;
|
|
||||||
randomNumbers.add(randomNum);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new ArrayList<>(randomNumbers);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-16
@@ -3,33 +3,21 @@ package io.v.nutz.zhgh.fitnessWalk.controller;
|
|||||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||||
import cn.hutool.core.date.DateTime;
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.hutool.core.util.URLUtil;
|
|
||||||
import cn.wizzer.framework.base.Result;
|
import cn.wizzer.framework.base.Result;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import io.v.nutz.base.annontation.ViReturn;
|
import io.v.nutz.base.annontation.ViReturn;
|
||||||
import io.v.nutz.base.service.BaseService;
|
import io.v.nutz.base.service.BaseService;
|
||||||
import io.v.nutz.base.utils.Vi;
|
|
||||||
import io.v.nutz.base.utils.ViTool;
|
import io.v.nutz.base.utils.ViTool;
|
||||||
import io.v.nutz.sys.models.Sys_union;
|
|
||||||
import io.v.nutz.zhgh.fitnessWalk.contants.Cascader;
|
|
||||||
import io.v.nutz.zhgh.fitnessWalk.contants.FitnessWalkMode;
|
import io.v.nutz.zhgh.fitnessWalk.contants.FitnessWalkMode;
|
||||||
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkActivity;
|
|
||||||
import io.v.nutz.zhgh.fitnessWalk.service.FitnessWalkCommonService;
|
import io.v.nutz.zhgh.fitnessWalk.service.FitnessWalkCommonService;
|
||||||
import io.v.nutz.zhgh.fitnessWalk.service.FitnessWalkPunchStatisticsService;
|
import io.v.nutz.zhgh.fitnessWalk.service.FitnessWalkPunchStatisticsService;
|
||||||
import io.v.nutz.zhgh.fitnessWalk.utils.WeAppCloudUtil;
|
import io.v.nutz.zhgh.fitnessWalk.utils.WeAppCloudUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import io.v.nutz.sys.models.Sys_union;
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.nutz.dao.Cnd;
|
|
||||||
import org.nutz.dao.Dao;
|
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.Inject;
|
||||||
import org.nutz.ioc.loader.annotation.IocBean;
|
import org.nutz.ioc.loader.annotation.IocBean;
|
||||||
import org.nutz.lang.Strings;
|
|
||||||
import org.nutz.lang.util.NutMap;
|
import org.nutz.lang.util.NutMap;
|
||||||
import org.nutz.mvc.annotation.At;
|
import org.nutz.mvc.annotation.At;
|
||||||
import org.nutz.mvc.annotation.Ok;
|
import org.nutz.mvc.annotation.Ok;
|
||||||
@@ -37,12 +25,9 @@ import org.nutz.mvc.annotation.Param;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打卡统计
|
* 打卡统计
|
||||||
|
|||||||
+29
-23
@@ -1,16 +1,11 @@
|
|||||||
package io.v.nutz.zhgh.fitnessWalk.controller;
|
package io.v.nutz.zhgh.fitnessWalk.controller;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
|
||||||
import cn.hutool.core.date.DateBetween;
|
|
||||||
import cn.hutool.core.date.DateTime;
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.core.date.DateUnit;
|
import cn.hutool.core.date.DateUnit;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.wizzer.framework.base.Result;
|
import cn.wizzer.framework.base.Result;
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import io.v.nutz.base.annontation.ViReturn;
|
import io.v.nutz.base.annontation.ViReturn;
|
||||||
import io.v.nutz.base.page.Pagination;
|
|
||||||
import io.v.nutz.base.service.BaseService;
|
import io.v.nutz.base.service.BaseService;
|
||||||
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkActivity;
|
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkActivity;
|
||||||
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkAwardUser;
|
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkAwardUser;
|
||||||
@@ -35,7 +30,10 @@ import org.nutz.mvc.annotation.Ok;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@IocBean
|
@IocBean
|
||||||
@@ -75,8 +73,19 @@ public class FitnessWalkStepManageController {
|
|||||||
return Result.error("上传步数失败,请重新登录后再次上传!");
|
return Result.error("上传步数失败,请重新登录后再次上传!");
|
||||||
}
|
}
|
||||||
|
|
||||||
DateTime activityStartDate = DateUtil.date(start_time);
|
/*DateTime activityStartDate = DateUtil.date(start_time);
|
||||||
DateTime activityEndDate = DateUtil.date(end_time);
|
DateTime activityEndDate = DateUtil.date(end_time);*/
|
||||||
|
|
||||||
|
// 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");
|
||||||
|
Date startDate = DateUtil.parse("2025-04-01 00:00:00", "yyyy-MM-dd HH:mm:ss");
|
||||||
|
Date endDate = DateUtil.parse("2025-05-06 23:59:59", "yyyy-MM-dd HH:mm:ss");
|
||||||
|
if (!DateUtil.isIn(DateUtil.date(), startDate, endDate)) {
|
||||||
|
return Result.error("已过活动时间,无法上传步数");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
List<NutMap> steps = Json.fromJsonAsList(NutMap.class, monthSteps);
|
List<NutMap> steps = Json.fromJsonAsList(NutMap.class, monthSteps);
|
||||||
|
|
||||||
@@ -195,7 +204,6 @@ public class FitnessWalkStepManageController {
|
|||||||
// cnd.and("DATE(applyDate)",">=",DateUtil.format(startDate, "yyyy-MM-dd"));
|
// cnd.and("DATE(applyDate)",">=",DateUtil.format(startDate, "yyyy-MM-dd"));
|
||||||
// cnd.and("DATE(applyDate)","<=",DateUtil.format(endDate, "yyyy-MM-dd"));
|
// cnd.and("DATE(applyDate)","<=",DateUtil.format(endDate, "yyyy-MM-dd"));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
FitnessWalkActivity activity = fitnessWalkCommonService.getActivity(activityId);
|
FitnessWalkActivity activity = fitnessWalkCommonService.getActivity(activityId);
|
||||||
DateTime startTime = DateUtil.date(activity.getStartTime());
|
DateTime startTime = DateUtil.date(activity.getStartTime());
|
||||||
DateTime endTime = DateUtil.date(activity.getEndTime());
|
DateTime endTime = DateUtil.date(activity.getEndTime());
|
||||||
@@ -209,7 +217,7 @@ public class FitnessWalkStepManageController {
|
|||||||
List<FitnessWalkStep> stepList = baseService.dao().query(FitnessWalkStep.class, cnd);
|
List<FitnessWalkStep> stepList = baseService.dao().query(FitnessWalkStep.class, cnd);
|
||||||
|
|
||||||
return stepList.stream().map(v -> {
|
return stepList.stream().map(v -> {
|
||||||
return Map.of("step", v.getStep(), "timestamp", v.getApplyDate().getTime()/1000);
|
return Map.of("step", v.getStep(), "timestamp", v.getApplyDate().getTime());
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
// userStepList.addAll(stepList.stream().map(FitnessWalkStep::getStep).collect(Collectors.toList()));
|
// userStepList.addAll(stepList.stream().map(FitnessWalkStep::getStep).collect(Collectors.toList()));
|
||||||
@@ -280,7 +288,6 @@ public class FitnessWalkStepManageController {
|
|||||||
.and("activityId", "=", activityId)
|
.and("activityId", "=", activityId)
|
||||||
.and("DATE(applyDate)", ">=", DateUtil.format(DateUtil.date(activity.getStartTime()), "yyyy-MM-dd"))
|
.and("DATE(applyDate)", ">=", DateUtil.format(DateUtil.date(activity.getStartTime()), "yyyy-MM-dd"))
|
||||||
.and("DATE(applyDate)", "<=", DateUtil.format(DateUtil.date(activity.getEndTime()), "yyyy-MM-dd"))
|
.and("DATE(applyDate)", "<=", DateUtil.format(DateUtil.date(activity.getEndTime()), "yyyy-MM-dd"))
|
||||||
.groupBy("applyDate")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
List<NutMap> result = new ArrayList<>();
|
List<NutMap> result = new ArrayList<>();
|
||||||
@@ -308,10 +315,6 @@ public class FitnessWalkStepManageController {
|
|||||||
nutMap.put("userComplianceSumDay", partSteps.stream().filter(s -> s.getStep() > lotteryQualificationStep).count());
|
nutMap.put("userComplianceSumDay", partSteps.stream().filter(s -> s.getStep() > lotteryQualificationStep).count());
|
||||||
//总达标天数
|
//总达标天数
|
||||||
nutMap.put("complianceSumDay", lotteryQualificationDay);
|
nutMap.put("complianceSumDay", lotteryQualificationDay);
|
||||||
//开始时间
|
|
||||||
nutMap.put("startDate",rule.getStartDate());
|
|
||||||
//结束时间
|
|
||||||
nutMap.put("endDate",rule.getEndDate());
|
|
||||||
} else if (lotteryQualificationDay == null && lotteryQualificationStep != null) {
|
} else if (lotteryQualificationDay == null && lotteryQualificationStep != null) {
|
||||||
//总步数
|
//总步数
|
||||||
nutMap.put("mode", "customLotterySumStepMode");
|
nutMap.put("mode", "customLotterySumStepMode");
|
||||||
@@ -319,6 +322,9 @@ public class FitnessWalkStepManageController {
|
|||||||
nutMap.put("userSumStep", partSteps.stream().mapToInt(s -> s.getStep()).sum());
|
nutMap.put("userSumStep", partSteps.stream().mapToInt(s -> s.getStep()).sum());
|
||||||
//总达标步数
|
//总达标步数
|
||||||
nutMap.put("complianceSumStep", lotteryQualificationStep);
|
nutMap.put("complianceSumStep", lotteryQualificationStep);
|
||||||
|
|
||||||
|
nutMap.put("title", DateUtil.format(rule.getStartDate(), "MM月dd日") + "至" + DateUtil.format(rule.getEndDate(), "MM月dd日"));
|
||||||
|
|
||||||
}
|
}
|
||||||
result.add(nutMap);
|
result.add(nutMap);
|
||||||
}
|
}
|
||||||
@@ -337,19 +343,19 @@ public class FitnessWalkStepManageController {
|
|||||||
@At
|
@At
|
||||||
@Ok("json:full")
|
@Ok("json:full")
|
||||||
public Result winningRecord(String activityId, String userId) {
|
public Result winningRecord(String activityId, String userId) {
|
||||||
/*List<FitnessWalkAwardUser> awardUsers = baseService.dao().query(FitnessWalkAwardUser.class,
|
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);
|
||||||
|
|
||||||
|
/* List<FitnessWalkAwardUser> awardUsers = baseService.dao().query(FitnessWalkAwardUser.class,
|
||||||
Cnd.where("activityId", "=", activityId)
|
Cnd.where("activityId", "=", activityId)
|
||||||
.and("userId", "=", userId));
|
.and("userId", "=", userId).and("isRead", "=", true));*/
|
||||||
baseService.dao().update(FitnessWalkAwardUser.class, Chain.make("isRead", 1),
|
return Result.success(baseService.listMap(sql));
|
||||||
Cnd.where("activityId", "=", activityId)
|
|
||||||
.and("userId", "=", userId));*/
|
|
||||||
return Result.success(new ArrayList<>());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("json:full")
|
@Ok("json:full")
|
||||||
public Result hasReadAward(String id) {
|
public Result hasReadAward(String activityId) {
|
||||||
baseService.dao().update(FitnessWalkAwardUser.class, Chain.make("isRead", 1), Cnd.where("id", "=", id));
|
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+293
@@ -0,0 +1,293 @@
|
|||||||
|
package io.v.nutz.zhgh.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.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.wizzer.framework.base.Result;
|
||||||
|
import io.v.nutz.base.annontation.ViReturn;
|
||||||
|
import io.v.nutz.base.service.BaseService;
|
||||||
|
import io.v.nutz.base.utils.ViTool;
|
||||||
|
import io.v.nutz.zhgh.fitnessWalk.contants.FitnessWalkMode;
|
||||||
|
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkAwardUser;
|
||||||
|
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkRaffleRules;
|
||||||
|
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkRaffleUser;
|
||||||
|
import io.v.nutz.zhgh.fitnessWalk.service.FitnessWalkCommonService;
|
||||||
|
import io.v.nutz.zhgh.fitnessWalk.service.FitnessWalkStepRaffleService;
|
||||||
|
import io.v.nutz.base.query.PageForm;
|
||||||
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
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/fitnessWalk/stepRaffle.html")
|
||||||
|
@RequiresPermissions("fitnessWalk.stepRaffle")
|
||||||
|
public void index() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@At
|
||||||
|
@ViReturn
|
||||||
|
@RequiresPermissions("fitnessWalk.stepRaffle")
|
||||||
|
public Object pageData(PageForm pageForm,
|
||||||
|
@Param(value = "activityId", required = false) String activityId,
|
||||||
|
@Param(value = "unionId", required = false) String unionId,
|
||||||
|
@Param(value = "unitId", required = false) String unitId){
|
||||||
|
Sql sql = fitnessWalkStepRaffleService.getRaffleSql(pageForm, activityId, unionId, unitId);
|
||||||
|
return baseService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@At
|
||||||
|
@ViReturn
|
||||||
|
@RequiresPermissions("fitnessWalk.stepRaffle")
|
||||||
|
public Object getCascadersActivity(@Param(value = "year") int year) {
|
||||||
|
return fitnessWalkCommonService.cascaderActivity(year, FitnessWalkMode.STEP_COUNT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手动抽奖规则
|
||||||
|
* @param fitnessWalkRaffleRules
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@At
|
||||||
|
@ViReturn
|
||||||
|
@Aop(TransAop.READ_COMMITTED)
|
||||||
|
@RequiresPermissions("fitnessWalk.stepRaffle")
|
||||||
|
public Object saveRaffle(FitnessWalkRaffleRules fitnessWalkRaffleRules){
|
||||||
|
baseService.dao().insertOrUpdate(fitnessWalkRaffleRules);
|
||||||
|
fitnessWalkStepRaffleService.manualLottery(fitnessWalkRaffleRules.getActivityId());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@At
|
||||||
|
@ViReturn
|
||||||
|
@RequiresPermissions("fitnessWalk.stepRaffle")
|
||||||
|
public Object getRaffle(String activityId){
|
||||||
|
return baseService.dao().fetch(FitnessWalkRaffleRules.class, Cnd.where("activityId", "=", activityId));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序获取奖项信息
|
||||||
|
* @param activityId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@At
|
||||||
|
@ViReturn
|
||||||
|
public Object getAwardList(String activityId){
|
||||||
|
return fitnessWalkStepRaffleService.getActivityAwardList(activityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序获取自己的中奖信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@At
|
||||||
|
@ViReturn
|
||||||
|
public Object getAwardInfo(String activityId, String userId){
|
||||||
|
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 map;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序获取查询是否可以抽奖
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@At
|
||||||
|
public Object 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
|
||||||
|
@ViReturn
|
||||||
|
@Aop(TransAop.READ_COMMITTED)
|
||||||
|
public Object 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 null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@At
|
||||||
|
@ViReturn
|
||||||
|
@Ok("void")
|
||||||
|
@RequiresPermissions("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);
|
||||||
|
|
||||||
|
for (FitnessWalkAwardUser awardUser : list) {
|
||||||
|
awardUser.setApplyDate2(DateUtil.formatDateTime(awardUser.getApplyDate()));
|
||||||
|
}
|
||||||
|
|
||||||
|
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("中奖时间", "applyDate2", 20));
|
||||||
|
|
||||||
|
try {
|
||||||
|
ViTool.excelResponse(response, "健步走中奖人员名单.xlsx");
|
||||||
|
ExportParams exportParams = new ExportParams();
|
||||||
|
exportParams.setType(ExcelType.XSSF);
|
||||||
|
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, list);
|
||||||
|
workbook.write(response.getOutputStream());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@At
|
||||||
|
@ViReturn
|
||||||
|
@Ok("void")
|
||||||
|
@RequiresPermissions("fitnessWalk.stepRaffle")
|
||||||
|
public void exportExcel(String searchKeyword, String activityId, String unionId,
|
||||||
|
String unitId, HttpServletResponse response) {
|
||||||
|
PageForm pageForm = new PageForm();
|
||||||
|
pageForm.setSearchKeyword(searchKeyword);
|
||||||
|
Sql sql = fitnessWalkStepRaffleService.getRaffleSql(pageForm, activityId, unionId, unitId);
|
||||||
|
|
||||||
|
|
||||||
|
// Sql sql = Sqls.create("""
|
||||||
|
// SELECT
|
||||||
|
// ru.*,
|
||||||
|
// u.sex,
|
||||||
|
// u.unionname AS unionName,
|
||||||
|
// u.unitname AS unitName
|
||||||
|
// FROM
|
||||||
|
// fitness_walk_raffle_user ru left join `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("步数", "total_steps", 20));
|
||||||
|
|
||||||
|
try {
|
||||||
|
ViTool.excelResponse(response, "健步走达标人员名单.xlsx");
|
||||||
|
ExportParams exportParams = new ExportParams();
|
||||||
|
exportParams.setType(ExcelType.XSSF);
|
||||||
|
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, list);
|
||||||
|
workbook.write(response.getOutputStream());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+44
-47
@@ -7,16 +7,13 @@ import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
|||||||
import cn.hutool.core.date.DateTime;
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import io.v.nutz.base.annontation.ViReturn;
|
import io.v.nutz.base.annontation.ViReturn;
|
||||||
import io.v.nutz.base.dao.CndPlus;
|
|
||||||
import io.v.nutz.base.query.PageForm;
|
|
||||||
import io.v.nutz.base.service.BaseService;
|
import io.v.nutz.base.service.BaseService;
|
||||||
import io.v.nutz.base.utils.ViTool;
|
import io.v.nutz.base.utils.ViTool;
|
||||||
import io.v.nutz.sys.models.Sys_user;
|
|
||||||
import io.v.nutz.web.commons.slog.annotation.SLog;
|
|
||||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
|
||||||
import io.v.nutz.zhgh.fitnessWalk.contants.FitnessWalkMode;
|
import io.v.nutz.zhgh.fitnessWalk.contants.FitnessWalkMode;
|
||||||
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkActivity;
|
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkActivity;
|
||||||
import io.v.nutz.zhgh.fitnessWalk.service.FitnessWalkCommonService;
|
import io.v.nutz.zhgh.fitnessWalk.service.FitnessWalkCommonService;
|
||||||
|
import io.v.nutz.base.query.PageForm;
|
||||||
|
import io.v.nutz.web.commons.slog.annotation.SLog;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
@@ -24,8 +21,6 @@ import org.nutz.dao.Sqls;
|
|||||||
import org.nutz.dao.sql.Sql;
|
import org.nutz.dao.sql.Sql;
|
||||||
import org.nutz.ioc.loader.annotation.Inject;
|
import org.nutz.ioc.loader.annotation.Inject;
|
||||||
import org.nutz.ioc.loader.annotation.IocBean;
|
import org.nutz.ioc.loader.annotation.IocBean;
|
||||||
import org.nutz.lang.Lang;
|
|
||||||
import org.nutz.lang.Strings;
|
|
||||||
import org.nutz.lang.util.NutMap;
|
import org.nutz.lang.util.NutMap;
|
||||||
import org.nutz.mvc.annotation.At;
|
import org.nutz.mvc.annotation.At;
|
||||||
import org.nutz.mvc.annotation.Ok;
|
import org.nutz.mvc.annotation.Ok;
|
||||||
@@ -35,7 +30,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 步数排行榜
|
* 步数排行榜
|
||||||
@@ -63,7 +57,6 @@ public class FitnessWalkStepRankingController {
|
|||||||
@At
|
@At
|
||||||
@ViReturn
|
@ViReturn
|
||||||
@RequiresPermissions("fitnessWalk.stepRanking")
|
@RequiresPermissions("fitnessWalk.stepRanking")
|
||||||
@SLog(type = "健身走", tag = "步数排行榜", msg = "获取排行榜", param = true, result = false)
|
|
||||||
public Object pageData(PageForm pageForm,
|
public Object pageData(PageForm pageForm,
|
||||||
@Param(value = "activityId", required = false) String activityId,
|
@Param(value = "activityId", required = false) String activityId,
|
||||||
@Param(value = "unionId", required = false) String unionId,
|
@Param(value = "unionId", required = false) String unionId,
|
||||||
@@ -77,13 +70,13 @@ public class FitnessWalkStepRankingController {
|
|||||||
* 获取所有教工 今天的步数及活动时间范围内的步数
|
* 获取所有教工 今天的步数及活动时间范围内的步数
|
||||||
*
|
*
|
||||||
* @param activityId
|
* @param activityId
|
||||||
* @param mode day:今天 week:周 month:月 all:所有
|
* @param mode day:今天 all:所有
|
||||||
* @return {@link Object}
|
* @return {@link Object}
|
||||||
*/
|
*/
|
||||||
@At
|
@At
|
||||||
@Ok("json:full")
|
@Ok("json:full")
|
||||||
@ViReturn
|
@ViReturn
|
||||||
// @SLog(type = "校工会特色活动",tag = "健身走-计步步数排行榜",msg = "小程序接口(获取今日步数及活动范围内步数)",param = true,result = true)
|
@SLog(type = "校工会特色活动", tag = "健身走-计步步数排行榜", msg = "小程序接口(获取今日步数及活动范围内步数)", param = true, result = true)
|
||||||
public Object getUserStepRanking(String activityId, String mode, Integer pageNumber, Integer pageSize) {
|
public Object getUserStepRanking(String activityId, String mode, Integer pageNumber, Integer pageSize) {
|
||||||
if (mode.equals("day")) {
|
if (mode.equals("day")) {
|
||||||
Sql sql = Sqls.create("""
|
Sql sql = Sqls.create("""
|
||||||
@@ -97,83 +90,88 @@ public class FitnessWalkStepRankingController {
|
|||||||
WHERE
|
WHERE
|
||||||
t.activityId = @activityId
|
t.activityId = @activityId
|
||||||
AND t.applyDate = @today
|
AND t.applyDate = @today
|
||||||
GROUP BY
|
ORDER BY t.step DESC
|
||||||
t.userId
|
|
||||||
ORDER BY t.step DESC,u.loginname DESC
|
|
||||||
""");
|
""");
|
||||||
sql.setParam("activityId", activityId);
|
sql.setParam("activityId", activityId);
|
||||||
sql.setParam("today", DateUtil.today());
|
sql.setParam("today", DateUtil.today());
|
||||||
return baseService.listPageMap(pageNumber, pageSize, sql);
|
return baseService.listPageMap(pageNumber, pageSize, sql);
|
||||||
}else if(mode.equals("week")){
|
} else if (mode.equals("week")) {
|
||||||
Date startOfWeek = DateUtil.beginOfWeek(new Date());
|
Date startOfWeek = DateUtil.beginOfWeek(new Date());
|
||||||
Date endOfWeek = DateUtil.endOfWeek(new Date());
|
Date endOfWeek = DateUtil.endOfWeek(new Date());
|
||||||
|
|
||||||
Sql sql = Sqls.create("""
|
Sql sql = Sqls.create("""
|
||||||
SELECT
|
SELECT
|
||||||
t.userId,
|
sum( t.step ) AS step,
|
||||||
sum( t.step ) AS step,
|
u.username
|
||||||
u.username
|
|
||||||
FROM
|
FROM
|
||||||
`fitness_walk_step` t
|
`fitness_walk_step` t
|
||||||
LEFT JOIN sys_user u ON u.id = t.userId
|
LEFT JOIN sys_user u ON u.id = t.userId
|
||||||
WHERE
|
WHERE
|
||||||
t.activityId = @activityId
|
t.activityId = @activityId
|
||||||
AND t.applyDate >= @startTime
|
AND t.applyDate >= @startTime
|
||||||
AND t.applyDate <= @endTime
|
AND t.applyDate <= @endTime
|
||||||
GROUP BY
|
GROUP BY
|
||||||
t.userId
|
t.userId
|
||||||
ORDER BY
|
ORDER BY
|
||||||
step DESC
|
step DESC
|
||||||
""");
|
""");
|
||||||
sql.setParam("activityId", activityId);
|
sql.setParam("activityId", activityId);
|
||||||
sql.setParam("startTime", startOfWeek);
|
sql.setParam("startTime", startOfWeek);
|
||||||
sql.setParam("endTime", endOfWeek);
|
sql.setParam("endTime", endOfWeek);
|
||||||
return baseService.listPageMap(pageNumber, pageSize, sql);
|
return baseService.listPageMap(pageNumber, pageSize, sql);
|
||||||
} else if(mode.equals("month")){
|
} else if (mode.equals("month")) {
|
||||||
Date firstDayOfMonth = DateUtil.beginOfMonth(new Date());
|
Date firstDayOfMonth = DateUtil.beginOfMonth(new Date());
|
||||||
Date lastDayOfMonth = DateUtil.endOfMonth(new Date());
|
Date lastDayOfMonth = DateUtil.endOfMonth(new Date());
|
||||||
Sql sql = Sqls.create("""
|
Sql sql = Sqls.create("""
|
||||||
SELECT
|
SELECT
|
||||||
t.userId,
|
sum( t.step ) AS step,
|
||||||
sum( t.step ) AS step,
|
u.username
|
||||||
u.username
|
|
||||||
FROM
|
FROM
|
||||||
`fitness_walk_step` t
|
`fitness_walk_step` t
|
||||||
LEFT JOIN sys_user u ON u.id = t.userId
|
LEFT JOIN sys_user u ON u.id = t.userId
|
||||||
WHERE
|
WHERE
|
||||||
t.activityId = @activityId
|
t.activityId = @activityId
|
||||||
AND t.applyDate >= @startTime
|
AND t.applyDate >= @startTime
|
||||||
AND t.applyDate <= @endTime
|
AND t.applyDate <= @endTime
|
||||||
GROUP BY
|
GROUP BY
|
||||||
t.userId
|
t.userId
|
||||||
ORDER BY
|
ORDER BY
|
||||||
step DESC
|
step DESC
|
||||||
""");
|
""");
|
||||||
sql.setParam("activityId", activityId);
|
sql.setParam("activityId", activityId);
|
||||||
sql.setParam("startTime", firstDayOfMonth);
|
sql.setParam("startTime", firstDayOfMonth);
|
||||||
sql.setParam("endTime", lastDayOfMonth);
|
sql.setParam("endTime", lastDayOfMonth);
|
||||||
return baseService.listPageMap(pageNumber, pageSize, sql);
|
return baseService.listPageMap(pageNumber, pageSize, sql);
|
||||||
}else if (mode.equals("all")) {
|
} else if (mode.equals("all")) {
|
||||||
FitnessWalkActivity activity = fitnessWalkCommonService.getActivity(activityId);
|
FitnessWalkActivity activity = fitnessWalkCommonService.getActivity(activityId);
|
||||||
DateTime startTime = DateUtil.date(activity.getStartTime());
|
DateTime startTime = DateUtil.date(activity.getStartTime());
|
||||||
DateTime endTime = DateUtil.date(activity.getEndTime());
|
DateTime endTime = DateUtil.date(activity.getEndTime());
|
||||||
|
|
||||||
Sql sql = Sqls.create("""
|
Sql sql = Sqls.create("""
|
||||||
SELECT
|
SELECT
|
||||||
t.userId,
|
SUM(sub.max_step) AS step,
|
||||||
sum( t.step ) AS step,
|
u.username
|
||||||
u.username
|
FROM (
|
||||||
FROM
|
SELECT
|
||||||
`fitness_walk_step` t
|
userId,
|
||||||
LEFT JOIN sys_user u ON u.id = t.userId
|
activityId,
|
||||||
WHERE
|
applyDate,
|
||||||
t.activityId = @activityId
|
MAX(step) AS max_step
|
||||||
AND t.applyDate >= @startTime
|
FROM
|
||||||
AND t.applyDate <= @endTime
|
fitness_walk_step
|
||||||
|
WHERE
|
||||||
|
activityId = @activityId
|
||||||
|
AND applyDate >= @startTime AND applyDate <= @endTime
|
||||||
|
GROUP BY
|
||||||
|
userId,
|
||||||
|
activityId,
|
||||||
|
applyDate
|
||||||
|
) sub
|
||||||
|
left join `user` u ON u.id = sub.userId
|
||||||
GROUP BY
|
GROUP BY
|
||||||
t.userId
|
userId
|
||||||
ORDER BY
|
ORDER BY
|
||||||
step DESC
|
step desc
|
||||||
""");
|
""");
|
||||||
sql.setParam("activityId", activityId);
|
sql.setParam("activityId", activityId);
|
||||||
sql.setParam("startTime", startTime);
|
sql.setParam("startTime", startTime);
|
||||||
@@ -187,7 +185,7 @@ public class FitnessWalkStepRankingController {
|
|||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("void")
|
@Ok("void")
|
||||||
@SLog(type = "校工会特色活动",tag = "健身走-计步步数排行榜",msg = "步数排行榜导出",param = true,result = true)
|
@SLog(type = "校工会特色活动", tag = "健身走-计步步数排行榜", msg = "步数排行榜导出", param = true, result = true)
|
||||||
@RequiresPermissions("fitnessWalk.stepRanking")
|
@RequiresPermissions("fitnessWalk.stepRanking")
|
||||||
public void exportExcel(@Param(value = "searchName", required = false) String searchName,
|
public void exportExcel(@Param(value = "searchName", required = false) String searchName,
|
||||||
@Param(value = "searchKeyword", required = false) String searchKeyword,
|
@Param(value = "searchKeyword", required = false) String searchKeyword,
|
||||||
@@ -206,10 +204,9 @@ public class FitnessWalkStepRankingController {
|
|||||||
entityList.add(new ExcelExportEntity("工号", "loginname", 20));
|
entityList.add(new ExcelExportEntity("工号", "loginname", 20));
|
||||||
entityList.add(new ExcelExportEntity("分工会", "unionname", 20));
|
entityList.add(new ExcelExportEntity("分工会", "unionname", 20));
|
||||||
entityList.add(new ExcelExportEntity("单位", "unitname", 20));
|
entityList.add(new ExcelExportEntity("单位", "unitname", 20));
|
||||||
entityList.add(new ExcelExportEntity("today".equals(mode) ? "今日步数" :"活动期间总步数", "total_steps", 20));
|
entityList.add(new ExcelExportEntity("today".equals(mode) ? "今日步数" : "活动期间总步数", "total_steps", 20));
|
||||||
entityList.add(new ExcelExportEntity("达标天数(天)","standardsDays",20));
|
|
||||||
try {
|
try {
|
||||||
ViTool.excelResponse(response, ( "today".equals(mode) ? DateUtil.format(new Date(),"yyyy年MM月dd日") : "活动期间总") + "步数榜.xlsx");
|
ViTool.excelResponse(response, ("today".equals(mode) ? DateUtil.format(new Date(), "yyyy年MM月dd日") : "活动期间总") + "步数榜.xlsx");
|
||||||
ExportParams exportParams = new ExportParams();
|
ExportParams exportParams = new ExportParams();
|
||||||
exportParams.setType(ExcelType.XSSF);
|
exportParams.setType(ExcelType.XSSF);
|
||||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, stepRankingList);
|
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, stepRankingList);
|
||||||
|
|||||||
+4
-14
@@ -5,23 +5,15 @@ import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
|||||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||||
import cn.hutool.core.date.DateTime;
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.wizzer.framework.base.Result;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import io.v.nutz.base.annontation.ViReturn;
|
import io.v.nutz.base.annontation.ViReturn;
|
||||||
import io.v.nutz.base.query.PageForm;
|
|
||||||
import io.v.nutz.base.service.BaseService;
|
import io.v.nutz.base.service.BaseService;
|
||||||
import io.v.nutz.base.utils.ViTool;
|
import io.v.nutz.base.utils.ViTool;
|
||||||
import io.v.nutz.zhgh.fitnessWalk.contants.FitnessWalkMode;
|
import io.v.nutz.zhgh.fitnessWalk.contants.FitnessWalkMode;
|
||||||
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkActivity;
|
|
||||||
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkStep;
|
|
||||||
import io.v.nutz.zhgh.fitnessWalk.service.FitnessWalkCommonService;
|
import io.v.nutz.zhgh.fitnessWalk.service.FitnessWalkCommonService;
|
||||||
import io.v.nutz.zhgh.fitnessWalk.utils.WeAppCloudUtil;
|
import io.v.nutz.zhgh.fitnessWalk.utils.WeAppCloudUtil;
|
||||||
|
import io.v.nutz.base.query.PageForm;
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.shiro.authz.annotation.RequiresAuthentication;
|
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.nutz.dao.Cnd;
|
import org.nutz.dao.Cnd;
|
||||||
import org.nutz.dao.Sqls;
|
import org.nutz.dao.Sqls;
|
||||||
@@ -31,15 +23,14 @@ import org.nutz.integration.jedis.RedisService;
|
|||||||
import org.nutz.ioc.loader.annotation.Inject;
|
import org.nutz.ioc.loader.annotation.Inject;
|
||||||
import org.nutz.ioc.loader.annotation.IocBean;
|
import org.nutz.ioc.loader.annotation.IocBean;
|
||||||
import org.nutz.lang.Lang;
|
import org.nutz.lang.Lang;
|
||||||
import org.nutz.lang.Strings;
|
|
||||||
import org.nutz.lang.util.NutMap;
|
import org.nutz.lang.util.NutMap;
|
||||||
import org.nutz.mvc.annotation.At;
|
import org.nutz.mvc.annotation.At;
|
||||||
import org.nutz.mvc.annotation.Ok;
|
import org.nutz.mvc.annotation.Ok;
|
||||||
import org.nutz.mvc.annotation.Param;
|
import org.nutz.mvc.annotation.Param;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
import java.util.stream.Collectors;
|
import java.util.List;
|
||||||
|
|
||||||
@IocBean
|
@IocBean
|
||||||
@Ok("json")
|
@Ok("json")
|
||||||
@@ -110,7 +101,7 @@ public class FitnessWalkStepStatisticsController {
|
|||||||
cnd.andEX("u.unitId", "=", unitId);
|
cnd.andEX("u.unitId", "=", unitId);
|
||||||
cnd.desc("al.applyDate");
|
cnd.desc("al.applyDate");
|
||||||
cnd.desc("u.unioncode");
|
cnd.desc("u.unioncode");
|
||||||
cnd.groupBy("al.applyDate","al.userId");
|
cnd.groupBy("al.applyDate", "al.userId");
|
||||||
|
|
||||||
sql.setCondition(cnd);
|
sql.setCondition(cnd);
|
||||||
return baseService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
return baseService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||||
@@ -141,7 +132,6 @@ public class FitnessWalkStepStatisticsController {
|
|||||||
cnd.andEX("u.unitId", "=", unitId);
|
cnd.andEX("u.unitId", "=", unitId);
|
||||||
cnd.desc("al.applyDate");
|
cnd.desc("al.applyDate");
|
||||||
cnd.desc("u.unioncode");
|
cnd.desc("u.unioncode");
|
||||||
cnd.groupBy("al.applyDate","al.userId");
|
|
||||||
sql.setCondition(cnd);
|
sql.setCondition(cnd);
|
||||||
|
|
||||||
List<NutMap> exportList = baseService.listMap(sql);
|
List<NutMap> exportList = baseService.listMap(sql);
|
||||||
|
|||||||
+28
-21
@@ -3,26 +3,21 @@ package io.v.nutz.zhgh.fitnessWalk.controller;
|
|||||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.wizzer.framework.base.Result;
|
import cn.wizzer.framework.base.Result;
|
||||||
import io.v.nutz.base.annontation.ViReturn;
|
import io.v.nutz.base.annontation.ViReturn;
|
||||||
import io.v.nutz.base.expression.Exp;
|
|
||||||
import io.v.nutz.base.query.PageForm;
|
|
||||||
import io.v.nutz.base.service.BaseService;
|
import io.v.nutz.base.service.BaseService;
|
||||||
import io.v.nutz.web.commons.slog.annotation.SLog;
|
|
||||||
import io.v.nutz.zhgh.fitnessWalk.contants.FitnessWalkMode;
|
import io.v.nutz.zhgh.fitnessWalk.contants.FitnessWalkMode;
|
||||||
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkActivity;
|
|
||||||
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkAwardUser;
|
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkAwardUser;
|
||||||
import io.v.nutz.zhgh.fitnessWalk.service.FitnessWalkCommonService;
|
import io.v.nutz.zhgh.fitnessWalk.service.FitnessWalkCommonService;
|
||||||
|
import io.v.nutz.web.commons.slog.annotation.SLog;
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.nutz.dao.Cnd;
|
import org.nutz.dao.Cnd;
|
||||||
import org.nutz.dao.Sqls;
|
import org.nutz.dao.util.cri.SqlExpressionGroup;
|
||||||
import org.nutz.dao.sql.Sql;
|
|
||||||
import org.nutz.ioc.loader.annotation.Inject;
|
import org.nutz.ioc.loader.annotation.Inject;
|
||||||
import org.nutz.ioc.loader.annotation.IocBean;
|
import org.nutz.ioc.loader.annotation.IocBean;
|
||||||
import org.nutz.lang.Lang;
|
|
||||||
import org.nutz.lang.util.NutMap;
|
import org.nutz.lang.util.NutMap;
|
||||||
import org.nutz.mvc.annotation.At;
|
import org.nutz.mvc.annotation.At;
|
||||||
import org.nutz.mvc.annotation.Ok;
|
import org.nutz.mvc.annotation.Ok;
|
||||||
@@ -32,9 +27,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
@@ -69,7 +62,7 @@ public class FitnessWalkStepWiningController {
|
|||||||
@At
|
@At
|
||||||
@Ok("json:full")
|
@Ok("json:full")
|
||||||
@ViReturn
|
@ViReturn
|
||||||
@SLog(type = "校工会特色活动", tag = "健身走-计步步数中奖榜", msg = "获取中奖榜", param = true, result = true)
|
@SLog(type = "校工会特色活动",tag = "健身走-计步步数中奖榜",msg = "获取中奖榜",param = true,result = true)
|
||||||
public Object getUserStepWining(String activityId) {
|
public Object getUserStepWining(String activityId) {
|
||||||
return fitnessWalkCommonService.getWiningRankingUserList(activityId);
|
return fitnessWalkCommonService.getWiningRankingUserList(activityId);
|
||||||
}
|
}
|
||||||
@@ -84,9 +77,9 @@ public class FitnessWalkStepWiningController {
|
|||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("void")
|
@Ok("void")
|
||||||
@SLog(type = "校工会特色活动", tag = "健身走-计步步数中奖榜", msg = "导出中奖榜", param = true, result = true)
|
@SLog(type = "校工会特色活动",tag = "健身走-计步步数中奖榜",msg = "导出中奖榜",param = true,result = true)
|
||||||
@RequiresPermissions("fitnessWalk.stepWining")
|
@RequiresPermissions("fitnessWalk.stepWining")
|
||||||
public void exportUserStepWining(String activityId, HttpServletResponse response) {
|
public void exportUserStepWining(String activityId, HttpServletResponse response){
|
||||||
List<NutMap> winingRankingUserList = fitnessWalkCommonService.getWiningRankingUserList(activityId);
|
List<NutMap> winingRankingUserList = fitnessWalkCommonService.getWiningRankingUserList(activityId);
|
||||||
List<ExcelExportEntity> entityList = new ArrayList<>();
|
List<ExcelExportEntity> entityList = new ArrayList<>();
|
||||||
ExcelExportEntity no = new ExcelExportEntity("序号", "no", 10);
|
ExcelExportEntity no = new ExcelExportEntity("序号", "no", 10);
|
||||||
@@ -95,8 +88,9 @@ public class FitnessWalkStepWiningController {
|
|||||||
entityList.add(new ExcelExportEntity("工号", "loginName", 20));
|
entityList.add(new ExcelExportEntity("工号", "loginName", 20));
|
||||||
entityList.add(new ExcelExportEntity("姓名", "username", 20));
|
entityList.add(new ExcelExportEntity("姓名", "username", 20));
|
||||||
entityList.add(new ExcelExportEntity("分工会", "unionName", 20));
|
entityList.add(new ExcelExportEntity("分工会", "unionName", 20));
|
||||||
entityList.add(new ExcelExportEntity("单位", "unitName", 20));
|
entityList.add(new ExcelExportEntity("单位", "unitName", 40));
|
||||||
entityList.add(new ExcelExportEntity("奖项名称", "awardName", 20));
|
entityList.add(new ExcelExportEntity("奖项名称", "awardName", 20));
|
||||||
|
entityList.add(new ExcelExportEntity("步数", "awardSteps", 20));
|
||||||
entityList.add(new ExcelExportEntity("中奖时间", "applyDate", 20));
|
entityList.add(new ExcelExportEntity("中奖时间", "applyDate", 20));
|
||||||
try {
|
try {
|
||||||
response.setContentType("application/octet-stream");
|
response.setContentType("application/octet-stream");
|
||||||
@@ -105,8 +99,8 @@ public class FitnessWalkStepWiningController {
|
|||||||
ZipOutputStream zipOutputStream = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()));
|
ZipOutputStream zipOutputStream = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()));
|
||||||
for (NutMap map : winingRankingUserList) {
|
for (NutMap map : winingRankingUserList) {
|
||||||
List<NutMap> awardList = map.getAsList("awardList", NutMap.class);
|
List<NutMap> awardList = map.getAsList("awardList", NutMap.class);
|
||||||
awardList.forEach(v -> v.setv("applyDate", DateUtil.format(v.getTime("applyDate"), "yyyy-MM-dd")));
|
awardList.forEach(v->v.setv("applyDate",DateUtil.format(v.getTime("applyDate"),"yyyy-MM-dd")));
|
||||||
zipOutputStream.putNextEntry(new ZipEntry(map.getString("title") + ".xls"));
|
zipOutputStream.putNextEntry(new ZipEntry(map.getString("title") + ".xlsx"));
|
||||||
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), entityList, awardList);
|
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), entityList, awardList);
|
||||||
workbook.write(zipOutputStream);
|
workbook.write(zipOutputStream);
|
||||||
zipOutputStream.closeEntry();
|
zipOutputStream.closeEntry();
|
||||||
@@ -126,6 +120,7 @@ public class FitnessWalkStepWiningController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@At
|
@At
|
||||||
|
@ViReturn
|
||||||
public Result prizeOption(String activityId) {
|
public Result prizeOption(String activityId) {
|
||||||
List<NutMap> list = fitnessWalkCommonService.prizeOption(activityId);
|
List<NutMap> list = fitnessWalkCommonService.prizeOption(activityId);
|
||||||
return Result.success(list);
|
return Result.success(list);
|
||||||
@@ -133,16 +128,28 @@ public class FitnessWalkStepWiningController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 中奖用户
|
* 中奖用户
|
||||||
*
|
|
||||||
* @param lotteryTime
|
* @param lotteryTime
|
||||||
* @param activityId
|
* @param activityId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@At
|
@At
|
||||||
public Result prizeUsers(String lotteryTime, String activityId) {
|
public Result prizeUsers(String lotteryTime, String activityId, String searchKeyword) {
|
||||||
// List<NutMap> list = fitnessWalkCommonService.prizeOption(activityId);
|
|
||||||
List<FitnessWalkAwardUser> awardUserList = fitnessWalkCommonService.dao().query(FitnessWalkAwardUser.class,
|
Cnd cnd = Cnd.NEW();
|
||||||
Cnd.where("activityId", "=", activityId).and("applyDate", "like", lotteryTime.substring(0, lotteryTime.length() - 3) + "%"));
|
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> awardUserList = fitnessWalkCommonService.dao().query(FitnessWalkAwardUser.class, cnd);
|
||||||
|
// 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);
|
return Result.success(awardUserList);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package io.v.nutz.zhgh.fitnessWalk.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.wizzer.framework.base.Result;
|
||||||
|
import io.v.nutz.sys.services.SysUserService;
|
||||||
|
import org.nutz.dao.Cnd;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: Aaron
|
||||||
|
* @create: 2020-09-11 13:50
|
||||||
|
* @description: 小程序登录
|
||||||
|
**/
|
||||||
|
@At("/platform/jsz/login")
|
||||||
|
@Ok("json:full")
|
||||||
|
@IocBean
|
||||||
|
public class loginController {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private SysUserService sysUserService;
|
||||||
|
|
||||||
|
@At("/")
|
||||||
|
public Object 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -45,9 +45,11 @@ public class FitnessWalkActivity {
|
|||||||
|
|
||||||
private Boolean isQuestion;
|
private Boolean isQuestion;
|
||||||
|
|
||||||
|
private String questionId;
|
||||||
|
|
||||||
private String speedControlMode;
|
private String speedControlMode;
|
||||||
|
|
||||||
//打卡完成之后 gift_voucher:礼品券 cert:完赛证书
|
//打卡完成之后 gift_voucher:礼品券 cert:完赛证书 null啥也不干
|
||||||
private String punchFinishAfter;
|
private String punchFinishAfter;
|
||||||
|
|
||||||
//完赛证书
|
//完赛证书
|
||||||
@@ -62,6 +64,8 @@ public class FitnessWalkActivity {
|
|||||||
//打卡模式奖品列表
|
//打卡模式奖品列表
|
||||||
private List<PunchLotteryPrize> punchLotteryPrizes;
|
private List<PunchLotteryPrize> punchLotteryPrizes;
|
||||||
|
|
||||||
|
private Boolean showGiftTicket;
|
||||||
|
|
||||||
private List<Pts> pts;
|
private List<Pts> pts;
|
||||||
|
|
||||||
private List<Point> linePoints;
|
private List<Point> linePoints;
|
||||||
@@ -97,6 +101,17 @@ public class FitnessWalkActivity {
|
|||||||
//是否开启距离限制
|
//是否开启距离限制
|
||||||
private Boolean enableDistance;
|
private Boolean enableDistance;
|
||||||
|
|
||||||
|
//签到几个点位算完成
|
||||||
|
private Integer finishPointNum;
|
||||||
|
|
||||||
|
// 是否自动抽奖
|
||||||
|
private Boolean isAutoLottery;
|
||||||
|
|
||||||
|
// 手动抽奖,抽奖资格天数
|
||||||
|
private Integer lotteryQualificationDays;
|
||||||
|
// 手动抽奖,抽奖资格步数
|
||||||
|
private Integer lotteryQualificationSteps;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class Point implements Serializable {
|
public static class Point implements Serializable {
|
||||||
private String type;
|
private String type;
|
||||||
|
|||||||
@@ -59,6 +59,16 @@ public class FitnessWalkAwardUser extends BaseModel {
|
|||||||
@Comment("单位id")
|
@Comment("单位id")
|
||||||
private String unitId;
|
private String unitId;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
@ColDefine(type = ColType.INT)
|
||||||
|
@Comment("达标天数")
|
||||||
|
private Integer standardsDays;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
@ColDefine(type = ColType.VARCHAR, width = 20)
|
||||||
|
@Comment("中奖步数")
|
||||||
|
private String awardSteps;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||||
@Comment("单位名称")
|
@Comment("单位名称")
|
||||||
@@ -68,9 +78,20 @@ public class FitnessWalkAwardUser extends BaseModel {
|
|||||||
@ColDefine(type = ColType.DATETIME)
|
@ColDefine(type = ColType.DATETIME)
|
||||||
@Comment("中奖时间")
|
@Comment("中奖时间")
|
||||||
private Date applyDate;
|
private Date applyDate;
|
||||||
|
private String applyDate2;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
@ColDefine(type = ColType.BOOLEAN)
|
@ColDefine(type = ColType.BOOLEAN)
|
||||||
@Comment("是否已读")
|
@Comment("是否已读")
|
||||||
private Boolean isRead;
|
private Boolean isRead;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
@ColDefine(type = ColType.DATE)
|
||||||
|
@Comment("开始时间")
|
||||||
|
private Date startDate;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
@ColDefine(type = ColType.DATE)
|
||||||
|
@Comment("结束时间")
|
||||||
|
private Date endDate;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,20 +20,10 @@ public class FitnessWalkPunchLottery extends BaseModel {
|
|||||||
@PrevInsert(uu32 = true)
|
@PrevInsert(uu32 = true)
|
||||||
private String id;
|
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
|
@Column
|
||||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||||
@Comment("用户工号")
|
@Comment("活动")
|
||||||
private String loginName;
|
private String activityId;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||||
@@ -46,7 +36,7 @@ public class FitnessWalkPunchLottery extends BaseModel {
|
|||||||
private String prizeName;
|
private String prizeName;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
@ColDefine(type = ColType.VARCHAR, width = 20)
|
||||||
@Comment("奖品")
|
@Comment("奖品")
|
||||||
private String prizeId;
|
private String prizeId;
|
||||||
|
|
||||||
@@ -57,22 +47,7 @@ public class FitnessWalkPunchLottery extends BaseModel {
|
|||||||
|
|
||||||
@Column
|
@Column
|
||||||
@ColDefine(type = ColType.DATETIME)
|
@ColDefine(type = ColType.DATETIME)
|
||||||
@Comment("中奖时间")
|
@Comment("是否中奖")
|
||||||
private Date winDate;
|
private Date winDate;
|
||||||
|
|
||||||
@Column
|
|
||||||
@ColDefine(type = ColType.BOOLEAN)
|
|
||||||
@Comment("是否已读")
|
|
||||||
private Boolean isRead;
|
|
||||||
|
|
||||||
@Column
|
|
||||||
@ColDefine(type = ColType.DATETIME)
|
|
||||||
@Comment("兑奖时间")
|
|
||||||
private Date exchangeDate;
|
|
||||||
|
|
||||||
|
|
||||||
@Column
|
|
||||||
@ColDefine(type = ColType.BOOLEAN)
|
|
||||||
@Comment("是否兑换")
|
|
||||||
private Boolean isExchange;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package io.v.nutz.zhgh.fitnessWalk.model;
|
||||||
|
|
||||||
|
import io.v.nutz.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package io.v.nutz.zhgh.fitnessWalk.model;
|
||||||
|
|
||||||
|
import io.v.nutz.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;
|
||||||
|
}
|
||||||
@@ -82,4 +82,5 @@ public interface FitnessWalkCommonService extends ViService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<NutMap> prizeOption(String activityId);
|
List<NutMap> prizeOption(String activityId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package io.v.nutz.zhgh.fitnessWalk.service;
|
||||||
|
|
||||||
|
import io.v.nutz.base.service.BaseService;
|
||||||
|
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkRaffleRules;
|
||||||
|
import io.v.nutz.base.query.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);
|
||||||
|
}
|
||||||
+44
-30
@@ -2,25 +2,23 @@ package io.v.nutz.zhgh.fitnessWalk.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.db.Page;
|
|
||||||
import cn.wizzer.framework.page.Pagination;
|
import cn.wizzer.framework.page.Pagination;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import io.v.nutz.base.dao.CndPlus;
|
import io.v.nutz.base.dao.CndPlus;
|
||||||
import io.v.nutz.base.query.PageForm;
|
|
||||||
import io.v.nutz.base.service.impl.ViServiceImpl;
|
|
||||||
import io.v.nutz.base.utils.Vi;
|
import io.v.nutz.base.utils.Vi;
|
||||||
import io.v.nutz.sys.models.Sys_task;
|
|
||||||
import io.v.nutz.sys.models.Sys_user;
|
|
||||||
import io.v.nutz.sys.services.SysTaskService;
|
|
||||||
import io.v.nutz.task.services.TaskPlatformService;
|
|
||||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
|
||||||
import io.v.nutz.zhgh.fitnessWalk.contants.Cascader;
|
import io.v.nutz.zhgh.fitnessWalk.contants.Cascader;
|
||||||
import io.v.nutz.zhgh.fitnessWalk.contants.FitnessWalkMode;
|
import io.v.nutz.zhgh.fitnessWalk.contants.FitnessWalkMode;
|
||||||
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkActivity;
|
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkActivity;
|
||||||
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkAwardUser;
|
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkAwardUser;
|
||||||
import io.v.nutz.zhgh.fitnessWalk.service.FitnessWalkCommonService;
|
import io.v.nutz.zhgh.fitnessWalk.service.FitnessWalkCommonService;
|
||||||
import io.v.nutz.zhgh.fitnessWalk.utils.WeAppCloudUtil;
|
import io.v.nutz.zhgh.fitnessWalk.utils.WeAppCloudUtil;
|
||||||
|
import io.v.nutz.base.query.PageForm;
|
||||||
|
import io.v.nutz.base.service.impl.ViServiceImpl;
|
||||||
|
import io.v.nutz.sys.models.Sys_task;
|
||||||
|
import io.v.nutz.sys.services.SysTaskService;
|
||||||
|
import io.v.nutz.task.services.TaskPlatformService;
|
||||||
|
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||||
import org.nutz.dao.Cnd;
|
import org.nutz.dao.Cnd;
|
||||||
import org.nutz.dao.Dao;
|
import org.nutz.dao.Dao;
|
||||||
import org.nutz.dao.Sqls;
|
import org.nutz.dao.Sqls;
|
||||||
@@ -37,7 +35,6 @@ import org.nutz.lang.util.NutMap;
|
|||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@IocBean(args = {"refer:dao"})
|
@IocBean(args = {"refer:dao"})
|
||||||
@@ -72,6 +69,7 @@ public class FitnessWalkCommonServiceImpl extends ViServiceImpl implements Fitne
|
|||||||
String redisKey = "FitnessWalk:" + activityId;
|
String redisKey = "FitnessWalk:" + activityId;
|
||||||
Boolean exists = redisService.exists("FitnessWalk:" + activityId);
|
Boolean exists = redisService.exists("FitnessWalk:" + activityId);
|
||||||
FitnessWalkActivity activity = null;
|
FitnessWalkActivity activity = null;
|
||||||
|
exists = false;
|
||||||
if (exists) {
|
if (exists) {
|
||||||
String string = redisService.get(redisKey);
|
String string = redisService.get(redisKey);
|
||||||
activity = JSONObject.parseObject(string, FitnessWalkActivity.class);
|
activity = JSONObject.parseObject(string, FitnessWalkActivity.class);
|
||||||
@@ -90,7 +88,7 @@ public class FitnessWalkCommonServiceImpl extends ViServiceImpl implements Fitne
|
|||||||
activity.setTempCover(tempUrl);
|
activity.setTempCover(tempUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Strings.isNotBlank(activity.getCompletionCertificateCover())) {
|
if(Strings.isNotBlank(activity.getCompletionCertificateCover())){
|
||||||
String tempUrl = weAppCloudUtil.httpFile(activity.getCompletionCertificateCover());
|
String tempUrl = weAppCloudUtil.httpFile(activity.getCompletionCertificateCover());
|
||||||
activity.setTempCompletionCertificateCover(tempUrl);
|
activity.setTempCompletionCertificateCover(tempUrl);
|
||||||
}
|
}
|
||||||
@@ -114,20 +112,21 @@ public class FitnessWalkCommonServiceImpl extends ViServiceImpl implements Fitne
|
|||||||
activity.setTempCover(tempCover);
|
activity.setTempCover(tempCover);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Strings.isNotBlank(activity.getCompletionCertificateCover())) {
|
if(Strings.isNotBlank(activity.getCompletionCertificateCover())){
|
||||||
String tempUrl = weAppCloudUtil.httpFile(activity.getCompletionCertificateCover());
|
String tempUrl = weAppCloudUtil.httpFile(activity.getCompletionCertificateCover());
|
||||||
activity.setTempCompletionCertificateCover(tempUrl);
|
activity.setTempCompletionCertificateCover(tempUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
redisService.setex(redisKey, CACHE_TIME, JSONObject.toJSONString(activity));
|
redisService.setex(redisKey, CACHE_TIME, JSONObject.toJSONString(activity));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
throw new RuntimeException("获取数据异常!");
|
throw new RuntimeException("获取数据异常!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (ShiroUtil.hasRole("H04") && !ShiroUtil.hasAnyRoles("sysadmin,A06")) {
|
if (ShiroUtil.hasRole("H04") && !ShiroUtil.hasAnyRoles("sysadmin,A06")) {
|
||||||
// return Vi.getUnionId().equals(activity.getUnionId()) ? activity : null;
|
return Vi.getUnionId().equals(activity.getUnionId()) ? activity : null;
|
||||||
// }
|
}
|
||||||
return activity;
|
return activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,6 +145,7 @@ public class FitnessWalkCommonServiceImpl extends ViServiceImpl implements Fitne
|
|||||||
.append("activityModel:true,")
|
.append("activityModel:true,")
|
||||||
.append("endTime:true,")
|
.append("endTime:true,")
|
||||||
.append("startTime:true,")
|
.append("startTime:true,")
|
||||||
|
.append("unionId:true")
|
||||||
.append("}).orderBy('startTime', 'desc').get()");
|
.append("}).orderBy('startTime', 'desc').get()");
|
||||||
JSONObject jsonObject = weAppCloudUtil.request(WeAppCloudUtil.CRUD.QUERY, sql.toString());
|
JSONObject jsonObject = weAppCloudUtil.request(WeAppCloudUtil.CRUD.QUERY, sql.toString());
|
||||||
fitnessWalkActivities = jsonObject.getJSONArray("data").stream().map(v -> JSON.parseObject((String) v, FitnessWalkActivity.class)).collect(Collectors.toList());
|
fitnessWalkActivities = jsonObject.getJSONArray("data").stream().map(v -> JSON.parseObject((String) v, FitnessWalkActivity.class)).collect(Collectors.toList());
|
||||||
@@ -203,13 +203,16 @@ public class FitnessWalkCommonServiceImpl extends ViServiceImpl implements Fitne
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addLotteryTask(FitnessWalkActivity fitnessWalkActivity) {
|
public void addLotteryTask(FitnessWalkActivity fitnessWalkActivity) {
|
||||||
|
//删除和该活动关联的定时任务
|
||||||
List<Sys_task> sys_tasks = sysTaskService.query(Cnd.where("note", "=", fitnessWalkActivity.get_id()));
|
List<Sys_task> sys_tasks = sysTaskService.query(Cnd.where("note", "=", fitnessWalkActivity.get_id()));
|
||||||
if (sys_tasks != null) {
|
if (CollectionUtil.isNotEmpty(sys_tasks)) {
|
||||||
sys_tasks.forEach(v -> {
|
sys_tasks.forEach(v -> {
|
||||||
taskPlatformService.delete(v.getId(), v.getId());
|
taskPlatformService.delete(v.getId(), v.getId());
|
||||||
sysTaskService.delete(v.getId());
|
sysTaskService.delete(v.getId());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ("everyday".equals(fitnessWalkActivity.getLotteryMode())) {
|
if ("everyday".equals(fitnessWalkActivity.getLotteryMode())) {
|
||||||
FitnessWalkActivity.DayLotteryRule dayLotteryRule = fitnessWalkActivity.getDayLotteryRule();
|
FitnessWalkActivity.DayLotteryRule dayLotteryRule = fitnessWalkActivity.getDayLotteryRule();
|
||||||
if (Lang.isNotEmpty(dayLotteryRule)) {
|
if (Lang.isNotEmpty(dayLotteryRule)) {
|
||||||
@@ -284,7 +287,7 @@ public class FitnessWalkCommonServiceImpl extends ViServiceImpl implements Fitne
|
|||||||
//查询结束时间
|
//查询结束时间
|
||||||
map.put("endDate", rule.getEndDate());
|
map.put("endDate", rule.getEndDate());
|
||||||
//抽奖天数
|
//抽奖天数
|
||||||
map.put("lotteryQualificationDay", rule.getLotteryQualificationDay().toString());
|
map.put("lotteryQualificationDay", rule.getLotteryQualificationDay());
|
||||||
//获奖名称
|
//获奖名称
|
||||||
map.put("awardName", rule.getAwardName());
|
map.put("awardName", rule.getAwardName());
|
||||||
//抽奖模式
|
//抽奖模式
|
||||||
@@ -376,19 +379,31 @@ public class FitnessWalkCommonServiceImpl extends ViServiceImpl implements Fitne
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<NutMap> prizeOption(String activityId) {
|
public List<NutMap> prizeOption(String activityId) {
|
||||||
FitnessWalkActivity activity = getActivity(activityId);
|
List<FitnessWalkAwardUser> list = dao().query(FitnessWalkAwardUser.class,
|
||||||
if ("custom".equals(activity.getLotteryMode())) {
|
Cnd.where("activityId", "=", activityId).groupBy("awardName").asc("awardName"));
|
||||||
List<FitnessWalkActivity.CustomLotteryRule> customLotteryRules = activity.getCustomLotteryRules();
|
|
||||||
return customLotteryRules.stream().map(rule -> {
|
List<NutMap> collect = list.stream().map(v -> {
|
||||||
NutMap map = new NutMap();
|
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("text", v.getAwardName());
|
||||||
map.put("value", rule.getLotteryTime());
|
map.put("value", v.getAwardName());
|
||||||
return map;
|
return map;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
}
|
|
||||||
return null;
|
|
||||||
|
// FitnessWalkActivity activity = getActivity(activityId);
|
||||||
|
// 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 collect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Sql rankingListSql(String searchName, String searchKeyword, String activityId, String unionId, String unitId, String mode) {
|
private Sql rankingListSql(String searchName, String searchKeyword, String activityId, String unionId, String unitId, String mode) {
|
||||||
FitnessWalkActivity activity = getActivity(activityId);
|
FitnessWalkActivity activity = getActivity(activityId);
|
||||||
CndPlus cnd = CndPlus.create();
|
CndPlus cnd = CndPlus.create();
|
||||||
@@ -446,7 +461,6 @@ public class FitnessWalkCommonServiceImpl extends ViServiceImpl implements Fitne
|
|||||||
// cnd.and("DATE( s.applyDate )", "<=", DateUtil.format(DateUtil.date(activity.getEndTime()), "yyyy-MM-dd"));
|
// cnd.and("DATE( s.applyDate )", "<=", DateUtil.format(DateUtil.date(activity.getEndTime()), "yyyy-MM-dd"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (Strings.isNotBlank(unitId)) {
|
if (Strings.isNotBlank(unitId)) {
|
||||||
cnd.and("u.unitId", "=", unitId);
|
cnd.and("u.unitId", "=", unitId);
|
||||||
}
|
}
|
||||||
@@ -457,10 +471,10 @@ public class FitnessWalkCommonServiceImpl extends ViServiceImpl implements Fitne
|
|||||||
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
|
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
|
||||||
cnd.and(searchName, "LIKE", "%" + 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.and("u.id","in",Sqls.create("select userId from activity_user_scope where groupId = @groupId").setParam("groupId",activity.getGroupId()));
|
||||||
cnd.and("over3k.standardsDays","is not",null);
|
|
||||||
cnd.groupBy("u.id","u.username","u.loginname","u.unionname","u.unitname","over3k.standardsDays");
|
cnd.groupBy("u.id","u.username","u.loginname","u.unionname","u.unitname","over3k.standardsDays");
|
||||||
cnd.desc("total_steps");
|
cnd.desc("total_steps");
|
||||||
|
cnd.having(Cnd.NEW().and("COALESCE(SUM(sub.step), 0)",">",0));
|
||||||
sql.setCondition(cnd);
|
sql.setCondition(cnd);
|
||||||
return sql;
|
return sql;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -3,10 +3,10 @@ package io.v.nutz.zhgh.fitnessWalk.service.impl;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import io.v.nutz.base.service.impl.ViServiceImpl;
|
|
||||||
import io.v.nutz.sys.models.Sys_union;
|
|
||||||
import io.v.nutz.zhgh.fitnessWalk.service.FitnessWalkPunchStatisticsService;
|
import io.v.nutz.zhgh.fitnessWalk.service.FitnessWalkPunchStatisticsService;
|
||||||
import io.v.nutz.zhgh.fitnessWalk.utils.WeAppCloudUtil;
|
import io.v.nutz.zhgh.fitnessWalk.utils.WeAppCloudUtil;
|
||||||
|
import io.v.nutz.base.service.impl.ViServiceImpl;
|
||||||
|
import io.v.nutz.sys.models.Sys_union;
|
||||||
import org.nutz.dao.Cnd;
|
import org.nutz.dao.Cnd;
|
||||||
import org.nutz.dao.Dao;
|
import org.nutz.dao.Dao;
|
||||||
import org.nutz.ioc.loader.annotation.Inject;
|
import org.nutz.ioc.loader.annotation.Inject;
|
||||||
|
|||||||
+346
@@ -0,0 +1,346 @@
|
|||||||
|
package io.v.nutz.zhgh.fitnessWalk.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import io.v.nutz.base.service.impl.BaseServiceImpl;
|
||||||
|
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkActivity;
|
||||||
|
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkAwardUser;
|
||||||
|
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkRaffleRules;
|
||||||
|
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkRaffleUser;
|
||||||
|
import io.v.nutz.zhgh.fitnessWalk.service.FitnessWalkCommonService;
|
||||||
|
import io.v.nutz.zhgh.fitnessWalk.service.FitnessWalkStepRaffleService;
|
||||||
|
import io.v.nutz.base.query.PageForm;
|
||||||
|
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.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
|
||||||
|
`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) {
|
||||||
|
sql.setVar("lotteryQualificationDaySql", new Static(" AND step >= '%s' ".formatted(lotteryQualificationSteps)));
|
||||||
|
cnd.having(cnd.and(new Static(" over3k.standardsDays >= '%s' ".formatted(lotteryQualificationDays))));
|
||||||
|
|
||||||
|
// sql.setVar("stepHavingSql", new Static(" over3k.standardsDays >= '%s' ".formatted(lotteryQualificationDays)));
|
||||||
|
} else {
|
||||||
|
cnd.having(cnd.and(new Static(" COALESCE(SUM(sub.step), 0) >= '%s' ".formatted(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 - 1);
|
||||||
|
}));
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -234,7 +234,7 @@ layout("/layouts/platform.html"){
|
|||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="主活动名称" prop="masterActivityName"
|
<el-form-item label="主活动名称" prop="masterActivityName"
|
||||||
:rules="[{ required:true, message: '请填写主活动名称' }]">
|
:rules="[{ required:true, message: '请填写主活动名称' }]">
|
||||||
<el-input type="text" v-model="formData.masterActivityName" maxlength="50"
|
<el-input type="text" v-model="formData.masterActivityName" maxlength="20"
|
||||||
placeholder="请填写主活动名称"></el-input>
|
placeholder="请填写主活动名称"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@@ -308,6 +308,7 @@ layout("/layouts/platform.html"){
|
|||||||
<el-col :span="12" v-if="formData.isQuestion">
|
<el-col :span="12" v-if="formData.isQuestion">
|
||||||
<el-form-item label="答题试卷" prop="questionId">
|
<el-form-item label="答题试卷" prop="questionId">
|
||||||
<el-select v-model="formData.questionId" filterable style="width: 100%"
|
<el-select v-model="formData.questionId" filterable style="width: 100%"
|
||||||
|
clearable
|
||||||
placeholder="选择答题试卷">
|
placeholder="选择答题试卷">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in questionOptions"
|
v-for="item in questionOptions"
|
||||||
@@ -350,6 +351,7 @@ layout("/layouts/platform.html"){
|
|||||||
<el-radio-group v-model="formData.punchFinishAfter">
|
<el-radio-group v-model="formData.punchFinishAfter">
|
||||||
<el-radio border label="gift_voucher">礼品券</el-radio>
|
<el-radio border label="gift_voucher">礼品券</el-radio>
|
||||||
<el-radio border label="cert">完赛证书</el-radio>
|
<el-radio border label="cert">完赛证书</el-radio>
|
||||||
|
<el-radio border label="none">无</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@@ -372,52 +374,6 @@ layout("/layouts/platform.html"){
|
|||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-row type="flex" :gutter="20">
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="是否抽奖"
|
|
||||||
:rules="[{ required:true, message: '必填' }]">
|
|
||||||
<el-radio-group v-model="formData.isLottery">
|
|
||||||
<el-radio border :label="true">是</el-radio>
|
|
||||||
<el-radio border :label="false">否</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<el-row type="flex" :gutter="20" v-if="formData.isLottery && formData.activityModel=='punch'">
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item label="奖品列表" prop="punchLotteryPrizes">
|
|
||||||
<el-table :data="formData.punchLotteryPrizes">
|
|
||||||
<el-table-column label="奖品名称">
|
|
||||||
<template scope="scope">
|
|
||||||
<el-input v-model="scope.row.name" max="20" clearable></el-input>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="奖品图片">
|
|
||||||
<template scope="scope">
|
|
||||||
<el-input v-model="scope.row.url" max="20" clearable></el-input>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="奖品份数">
|
|
||||||
<template scope="scope">
|
|
||||||
<el-input-number v-model="scope.row.num" clearable></el-input-number>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="操作">
|
|
||||||
<template slot="header" slot-scope="scope">
|
|
||||||
<el-button @click="formData.punchLotteryPrizes.push({})"
|
|
||||||
icon="el-icon-plus" size="mini" type="primary"></el-button>
|
|
||||||
</template>
|
|
||||||
<template scope="scope">
|
|
||||||
<el-button @click="formData.punchLotteryPrizes.splice(scope.$index,1)"
|
|
||||||
icon="el-icon-delete" size="mini" type="danger"></el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<el-row type="flex" gutter="20">
|
<el-row type="flex" gutter="20">
|
||||||
<el-col :span="12" v-if="formData.activityModel === 'punch'">
|
<el-col :span="12" v-if="formData.activityModel === 'punch'">
|
||||||
<el-form-item label="报名时间" prop="applyTime"
|
<el-form-item label="报名时间" prop="applyTime"
|
||||||
@@ -449,7 +405,82 @@ layout("/layouts/platform.html"){
|
|||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<template v-if="formData.isLottery && formData.activityModel=='stepCount'">
|
<el-row type="flex" :gutter="20">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="是否抽奖"
|
||||||
|
:rules="[{ required:true, message: '必填' }]">
|
||||||
|
<el-radio-group v-model="formData.isLottery" size="small">
|
||||||
|
<el-radio border :label="true">是</el-radio>
|
||||||
|
<el-radio border :label="false">否</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<template v-if="formData.isLottery && formData.activityModel=='stepCount'">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="抽奖模式" :rules="[{ required:true, message: '必填' }]">
|
||||||
|
<el-radio-group v-model="formData.isAutoLottery" size="small">
|
||||||
|
<el-radio border :label="true">系统自动抽奖</el-radio>
|
||||||
|
<el-radio border :label="false">手动抽奖</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</template>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
|
||||||
|
<template v-if="formData.isLottery && formData.activityModel=='stepCount' && formData.isAutoLottery!=null && !formData.isAutoLottery">
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="抽奖资格天数">
|
||||||
|
<el-input-number style="width: 100%" v-model="formData.lotteryQualificationDays" placeholder="请填写抽奖资格天数"></el-input-number>
|
||||||
|
<span style="color: #ac3111">如果没有天数,此项请勿填写;例如:达标80000步抽奖,请在抽奖资格步数中填写80000即可</span>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="抽奖资格步数" :rules="[{ required:true, message: '必填' }]">
|
||||||
|
<el-input-number style="width: 100%" v-model="formData.lotteryQualificationSteps" placeholder="请填写抽奖资格步数"></el-input-number>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<el-row type="flex" :gutter="20" v-if="formData.isLottery && formData.activityModel=='punch'">
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="奖品列表" prop="punchLotteryPrizes">
|
||||||
|
<el-table :data="formData.punchLotteryPrizes">
|
||||||
|
<el-table-column label="奖品名称">
|
||||||
|
<template scope="scope">
|
||||||
|
<el-input v-model="scope.row.name" max="20" clearable></el-input>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="奖品图片">
|
||||||
|
<template scope="scope">
|
||||||
|
<el-input v-model="scope.row.url" max="20" clearable></el-input>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="奖品份数">
|
||||||
|
<template scope="scope">
|
||||||
|
<el-input-number v-model="scope.row.num" clearable></el-input-number>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作">
|
||||||
|
<template slot="header" slot-scope="scope">
|
||||||
|
<el-button @click="formData.punchLotteryPrizes.push({})"
|
||||||
|
icon="el-icon-plus" size="mini" type="primary"></el-button>
|
||||||
|
</template>
|
||||||
|
<template scope="scope">
|
||||||
|
<el-button @click="formData.punchLotteryPrizes.splice(scope.$index,1)"
|
||||||
|
icon="el-icon-delete" size="mini" type="danger"></el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<template v-if="formData.isLottery && formData.isAutoLottery && formData.activityModel=='stepCount'">
|
||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="抽奖模式"
|
<el-form-item label="抽奖模式"
|
||||||
@@ -598,6 +629,13 @@ layout("/layouts/platform.html"){
|
|||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="完成点位数" prop="finishPointNum"
|
||||||
|
v-if="formData.activityModel=='punch'"
|
||||||
|
:rules="[{ required:true, message: '必填' }]">
|
||||||
|
<el-input-number v-model="formData.finishPointNum" :min="2"></el-input-number>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
|
||||||
<el-form-item label="外链地址" prop="externalLinkAddress">
|
<el-form-item label="外链地址" prop="externalLinkAddress">
|
||||||
<el-input v-model="formData.externalLinkAddress"></el-input>
|
<el-input v-model="formData.externalLinkAddress"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -682,7 +720,7 @@ layout("/layouts/platform.html"){
|
|||||||
</el-input>
|
</el-input>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column v-if="formData.hasAnswer" label="答题题目" prop="issueIds">
|
<el-table-column v-if="formData.isQuestion" label="答题题目" prop="issueIds">
|
||||||
<template scope="scope">
|
<template scope="scope">
|
||||||
<el-select v-model="scope.row.issueIds" filterable multiple
|
<el-select v-model="scope.row.issueIds" filterable multiple
|
||||||
style="width: 100%" placeholder="选择答题题目" @change="issueChange">
|
style="width: 100%" placeholder="选择答题题目" @change="issueChange">
|
||||||
@@ -806,27 +844,27 @@ layout("/layouts/platform.html"){
|
|||||||
|
|
||||||
|
|
||||||
<el-row gutter="20">
|
<el-row gutter="20">
|
||||||
<el-col :span="12" v-if="viewData.applyStartTime">
|
<el-col :span="12">
|
||||||
<el-form-item label="开始报名时间:">
|
<el-form-item label="开始报名时间:">
|
||||||
{{moment(viewData.applyStartTime).format('YYYY-MM-DD HH:mm:ss')}}
|
{{moment(viewData.apply_start_time).format('YYYY-MM-DD HH:mm:ss')}}
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12" v-if="viewData.applyEndTime">
|
<el-col :span="12">
|
||||||
<el-form-item label="结束报名时间:">
|
<el-form-item label="结束报名时间:">
|
||||||
{{moment(viewData.applyEndTime).format('YYYY-MM-DD HH:mm:ss')}}
|
{{moment(viewData.apply_end_time).format('YYYY-MM-DD HH:mm:ss')}}
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-row gutter="20">
|
<el-row gutter="20">
|
||||||
<el-col :span="12" v-if="viewData.startTime">
|
<el-col :span="12">
|
||||||
<el-form-item label="活动开始时间:">
|
<el-form-item label="活动开始时间:">
|
||||||
{{moment(viewData.startTime).format('YYYY-MM-DD HH:mm:ss')}}
|
{{moment(viewData.start_time).format('YYYY-MM-DD HH:mm:ss')}}
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12" v-if="viewData.endTime">
|
<el-col :span="12">
|
||||||
<el-form-item label="活动结束时间:">
|
<el-form-item label="活动结束时间:">
|
||||||
{{moment(viewData.endTime).format('YYYY-MM-DD HH:mm:ss')}}
|
{{moment(viewData.end_time).format('YYYY-MM-DD HH:mm:ss')}}
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@@ -1553,7 +1591,7 @@ layout("/layouts/platform.html"){
|
|||||||
type: 'warning',
|
type: 'warning',
|
||||||
callback: (a, b) => {
|
callback: (a, b) => {
|
||||||
if ("confirm" == a) {//确认后再执行
|
if ("confirm" == a) {//确认后再执行
|
||||||
$.post(base + "/platform/jsz/hdMange/delete", {id: row._id}, (data) => {
|
$.post("/platform/fitnessWalk/activityManage/delete", {id: row._id}, (data) => {
|
||||||
if (data.code == 0) {
|
if (data.code == 0) {
|
||||||
this.$message({
|
this.$message({
|
||||||
message: data.msg,
|
message: data.msg,
|
||||||
@@ -1669,6 +1707,7 @@ layout("/layouts/platform.html"){
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
this.pictureList = [{url: data.tempCover}]
|
this.pictureList = [{url: data.tempCover}]
|
||||||
this.stepPictureList = []
|
this.stepPictureList = []
|
||||||
if (data.templateRandomPics) {
|
if (data.templateRandomPics) {
|
||||||
@@ -1840,16 +1879,32 @@ layout("/layouts/platform.html"){
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
getQuestion(){
|
||||||
|
$.get('/platform/fitnessWalk/common/getQuestion').then(res=>{
|
||||||
|
this.questionOptions = res.data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getIssueByQuestionId(id){
|
||||||
|
$.get('/platform/fitnessWalk/common/getIssueById',{id}).then(res=>{
|
||||||
|
this.issueOptions = res.data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
'formData.questionId': {
|
'formData.questionId': {
|
||||||
async handler(newVal, oldVal) {
|
async handler(newVal, oldVal) {
|
||||||
if (oldVal !== undefined) {
|
if(newVal){
|
||||||
// this.issueOptions = await Jsz.getIssueById(this.formData.questionId)
|
this.getIssueByQuestionId(newVal)
|
||||||
// this.formData.pts.map(v => v.issueIds = [])
|
// this.formData.pts.map(v => v.issueIds = [])
|
||||||
|
}else{
|
||||||
|
this.formData.pts.map(v => v.issueIds = [])
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
deep: true
|
deep: true,
|
||||||
|
immediate:true
|
||||||
},
|
},
|
||||||
'formData.groupId': {
|
'formData.groupId': {
|
||||||
async handler(newVal, oldVal) {
|
async handler(newVal, oldVal) {
|
||||||
@@ -1866,6 +1921,7 @@ layout("/layouts/platform.html"){
|
|||||||
},
|
},
|
||||||
async created() {
|
async created() {
|
||||||
this.getActivityGroup()
|
this.getActivityGroup()
|
||||||
|
this.getQuestion()
|
||||||
// this.questionOptions = await Jsz.getQuestion()
|
// this.questionOptions = await Jsz.getQuestion()
|
||||||
this.pageForm.year = (new Date().getFullYear()).toString()
|
this.pageForm.year = (new Date().getFullYear()).toString()
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,390 @@
|
|||||||
|
<!--#
|
||||||
|
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="${@shiro.hasRole('sysadmin')||@shiro.hasRole('A06')}">
|
||||||
|
<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">
|
||||||
|
<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 $.post('/platform/fitnessWalk/stepRaffle/getRaffle', {
|
||||||
|
activityId: this.pageForm.activityId
|
||||||
|
})
|
||||||
|
if (resp.code === 0) {
|
||||||
|
if (resp.data) {
|
||||||
|
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 $.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 $.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 $.get('/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 getUnits(val)
|
||||||
|
this.doSearch()
|
||||||
|
},
|
||||||
|
async getCascadersActivity() {
|
||||||
|
const {code, data} = await $.get(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 $.post('/platform/fitnessWalk/stepRaffle/getAwardUserNum')
|
||||||
|
if (resp.code === 0) {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async getAwardNameOptions(){
|
||||||
|
const resp = await $.post('/platform/fitnessWalk/stepWining/prizeOption', {
|
||||||
|
activityId: this.pageForm.activityId
|
||||||
|
})
|
||||||
|
if (resp.code === 0) {
|
||||||
|
this.awardNameOptions = resp.data
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
async created() {
|
||||||
|
this.unionOptions = await getUnions(null)
|
||||||
|
this.unitOptions = await getUnits(null)
|
||||||
|
await this.getCascadersActivity()
|
||||||
|
await this.getAwardNameOptions()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!--#
|
||||||
|
}
|
||||||
|
#-->
|
||||||
@@ -142,7 +142,6 @@ layout("/layouts/platform.html"){
|
|||||||
{label: '分工会', prop: 'unionname', sortable: true},
|
{label: '分工会', prop: 'unionname', sortable: true},
|
||||||
{label: '单位', prop: 'unitname'},
|
{label: '单位', prop: 'unitname'},
|
||||||
{label: '步数', prop: 'total_steps', sortable: true},
|
{label: '步数', prop: 'total_steps', sortable: true},
|
||||||
{label: '达标天数', prop: 'standardsDays', sortable: true},
|
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -148,9 +148,9 @@ layout("/layouts/platform.html"){
|
|||||||
activityOptions: [],
|
activityOptions: [],
|
||||||
activityDatePickerOptions: {
|
activityDatePickerOptions: {
|
||||||
disabledDate: time => {
|
disabledDate: time => {
|
||||||
return (
|
return (
|
||||||
time <= moment(this.activityInfo.endTime) || time >= moment(this.activityInfo.startTime)
|
time <= moment(this.activityInfo.endTime) || time >= moment(this.activityInfo.startTime)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
activityInfo:{},
|
activityInfo:{},
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ layout("/layouts/platform.html"){
|
|||||||
#-->
|
#-->
|
||||||
<style>
|
<style>
|
||||||
.query-row {
|
.query-row {
|
||||||
height: 40px;
|
height: 50px;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -97,13 +97,13 @@ layout("/layouts/platform.html"){
|
|||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<el-card class="mt10" shadow="never" style="height: 80px">
|
<el-card class="mt10" shadow="never" style="height: 100px">
|
||||||
<el-row type="flex" align="middle" class="query-row">
|
<el-row type="flex" align="middle" class="query-row">
|
||||||
<el-col class="query-row-title">奖项名称:</el-col>
|
<el-col class="query-row-title">奖项名称:</el-col>
|
||||||
<el-col class="query-row-content">
|
<el-col class="query-row-content">
|
||||||
<el-radio-group v-model="changKeyItem" @change="subsectionChange(changKeyItem)" size="small">
|
<el-radio-group v-model="changKeyItem" @change="subsectionChange(changKeyItem)" size="small">
|
||||||
<el-radio
|
<el-radio
|
||||||
style="margin-right: 10px;cursor: pointer"
|
style="margin-right: 10px;margin-top:5px;cursor: pointer"
|
||||||
border
|
border
|
||||||
v-for="item in subsectionList"
|
v-for="item in subsectionList"
|
||||||
:key="item.value"
|
:key="item.value"
|
||||||
|
|||||||
Reference in New Issue
Block a user