From 40ff51856a11151ab3f0154a1ae3530e00dafff7 Mon Sep 17 00:00:00 2001
From: puhanshu <a9236326>
Date: 星期四, 23 十二月 2021 13:52:31 +0800
Subject: [PATCH] 修改活动bug
---
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java | 91 ++++++++++++++++++++++++++++++++++-----------
1 files changed, 68 insertions(+), 23 deletions(-)
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java
index 3456592..dd45bcc 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java
@@ -115,6 +115,9 @@
*/
@Override
public R addActivity(ComActActivityVO comActActivityVO) {
+ if (comActActivityVO.getHaveIntegralReward().intValue() == 2) {
+ comActActivityVO.setRewardWay(null);
+ }
ComActActivityDO comActActivityDO = new ComActActivityDO();
BeanUtils.copyProperties(comActActivityVO, comActActivityDO);
Integer status = comActActivityVO.getStatus();
@@ -200,11 +203,15 @@
}
}
}
+ if (comActActivityVO.getHaveIntegralReward().intValue() == 2) {
+ comActActivityVO.setRewardWay(null);
+ }
BeanUtils.copyProperties(comActActivityVO, comActActivityDO);
// 结束时间大于当前时间则设置为“进行中”
Date now = new Date();
- if (comActActivityVO.getSignUpEnd() != null && now.getTime() < comActActivityVO.getSignUpEnd().getTime()) {
+ if (comActActivityVO.getSignUpEnd() != null && now.getTime() < comActActivityVO.getSignUpEnd().getTime()
+ && now.getTime() > comActActivityVO.getSignUpBegin().getTime()) {
comActActivityDO.setStatus(3);
}
boolean b = this.updateById(comActActivityDO);
@@ -278,8 +285,7 @@
*/
@Override
public R cancelActivity(ComActActivityVO comActActivityVO) {
- ComActActivityDO comActActivityDO = new ComActActivityDO();
- comActActivityDO.setId(comActActivityVO.getId());
+ ComActActivityDO comActActivityDO = comActActivityDAO.selectById(comActActivityVO.getId());
comActActivityDO.setStatus(comActActivityVO.getStatus());
comActActivityDO.setCancelReason(comActActivityVO.getCancelReason());
int update = comActActivityDAO.updateById(comActActivityDO);
@@ -477,13 +483,13 @@
JSONObject.parseObject(JSONObject.toJSONString(userInfoR.getData()), LoginUserInfoVO.class);
// 查询当前活动下参与居民
Integer residentCount = comActActSignDAO.selectCount(new QueryWrapper<ComActActSignDO>().lambda()
- .eq(ComActActSignDO::getActivityId, activityId).eq(ComActActSignDO::getIsVolunteer, 0));
+ .eq(ComActActSignDO::getActivityId, activityId).eq(ComActActSignDO::getIsVolunteer, 0).eq(ComActActSignDO::getStatus, 1));
if (volunteerMax != 0) {
//志愿者活动
boolean userIsVolunteer = loginUserInfoVO.getIsVolunteer() == 1;
// 查询当前活动下参与志愿者
Integer volunteerCount = comActActSignDAO.selectCount(new QueryWrapper<ComActActSignDO>().lambda()
- .eq(ComActActSignDO::getActivityId, activityId).eq(ComActActSignDO::getIsVolunteer, 1));
+ .eq(ComActActSignDO::getActivityId, activityId).eq(ComActActSignDO::getIsVolunteer, 1).eq(ComActActSignDO::getStatus, 1));
if (userIsVolunteer) {
//用户是志愿者以志愿者身份参加
if (volunteerMax > volunteerCount || volunteerMax.equals(-1)) {
@@ -544,6 +550,15 @@
num = comActActSignDAO.insert(comActActSignDO);
}
} else {
+ Integer regTimes = comActActRegistDAO.selectCount(new QueryWrapper<ComActActRegistDO>().lambda()
+ .eq(ComActActRegistDO::getActivityId, activityId).eq(ComActActRegistDO::getUserId, userId).eq(ComActActRegistDO::getType, 1));
+ Integer canCancel = actActivityDO.getCanCancel();
+ if (nonNull(canCancel) && canCancel.equals(2)) {
+ return R.fail("该活动暂不支持取消");
+ }
+ if (regTimes > 0) {
+ return R.fail("您已参与活动,不可取消");
+ }
if (isNull(signactivityVO.getReason())) {
return R.fail("缺少取消原因");
}
@@ -553,6 +568,16 @@
comActActSignDO.setStatus(0);
comActActSignDO.setReason(signactivityVO.getReason());
num = comActActSignDAO.updateById(comActActSignDO);
+ if (num > 0) {
+ AddComActIntegralUserDTO addComActIntegralUserDTO = new AddComActIntegralUserDTO();
+ addComActIntegralUserDTO.setUserId(userId);
+ addComActIntegralUserDTO.setIntegralType(8);
+ addComActIntegralUserDTO.setActivityType(1);
+ addComActIntegralUserDTO.setIsVolunteer(comActActSignDO.getIsVolunteer());
+ addComActIntegralUserDTO.setCommunityId(actActivityDO.getCommunityId());
+ addComActIntegralUserDTO.setServiceId(activityId);
+ comActIntegralUserTradeService.addIntegralTradeAdmin(addComActIntegralUserDTO);
+ }
}
if (num > 0) {
return R.ok(isVolunteer);
@@ -579,8 +604,13 @@
List<ComActActivityDO> comActActivityDOS = comActActivityDAO.selectBatchIds(longs);
List<ComActActivityVO> comActActivityVOS = new ArrayList<>();
if (nonNull(status)) {
- comActActivityDOS = comActActivityDOS.stream()
- .filter(activityDO -> activityDO.getStatus().equals(status)).collect(Collectors.toList());
+ if(status.equals(4)){
+ comActActivityDOS = comActActivityDOS.stream()
+ .filter(activityDO -> activityDO.getStatus().equals(3)||activityDO.getStatus().equals(4)).collect(Collectors.toList());
+ }else{
+ comActActivityDOS = comActActivityDOS.stream()
+ .filter(activityDO -> activityDO.getStatus().equals(status)).collect(Collectors.toList());
+ }
}
if (!comActActivityDOS.isEmpty()) {
comActActivityDOS.forEach(comActActivityDO -> {
@@ -609,7 +639,8 @@
}
comActActivityVO.setSingDate(createAt);
comActActivityVO.setTimes(activitySignVO.getTimes());
- comActActivityVO.setAward(activitySignVO.getAward());
+ Integer totalAward = comActActRegistDAO.selectTotalAwardWithRegist(activitySignVO.getActivityId(), userId);
+ comActActivityVO.setAward(totalAward);
comActActivityVOS.add(comActActivityVO);
});
}
@@ -870,6 +901,12 @@
return R.fail("活动不存在!");
}
+ ComActActSignDO comActActSignDO = comActActSignDAO.selectOne(new QueryWrapper<ComActActSignDO>().lambda()
+ .eq(ComActActSignDO::getActivityId, activityId).eq(ComActActSignDO::getUserId, userId).eq(ComActActSignDO::getStatus, 1));
+ if (isNull(comActActSignDO)) {
+ return R.fail("活动未报名");
+ }
+
Date beginAt = comActActivityDO.getBeginAt();
Date endAt = comActActivityDO.getEndAt();
Date nowDate = new Date();
@@ -884,9 +921,13 @@
if (signDayCount > 0) {
return R.fail("请扫描新的签到码");
}
- int limit = comActActivityDO.getLimit().intValue();
- if(limit != -1 && signAllCount >= limit){
- return R.fail("签到次数上限");
+ Integer haveIntegralReward = comActActivityDO.getHaveIntegralReward();
+ boolean isHave = nonNull(haveIntegralReward) && haveIntegralReward.equals(1);
+ if (isHave) {
+ int limit = comActActivityDO.getLimit().intValue();
+ if(limit != -1 && signAllCount >= limit){
+ return R.fail("签到次数上限");
+ }
}
// String activitySignInKey = String.join(DELIMITER, ACTIVITY_SIGN_IN, userId.toString(), activityId.toString());
@@ -897,24 +938,28 @@
comActActRegistDO.setActivityId(activityId);
comActActRegistDO.setType(1);
comActActRegistDO.setUserId(userId);
- comActActRegistDO.setIsVolunteer(comActActRegistVO.getIsVolunteer());
+ comActActRegistDO.setIsVolunteer(comActActSignDO.getIsVolunteer());
comActActRegistDO.setCreateAt(nowDate);
comActActRegistDO.setCodeId(comActActRegistVO.getCodeId());
- comActActRegistDO.setAward(comActActivityDO.getRewardIntegral());
+ comActActRegistDO.setAward(isHave ? comActActivityDO.getRewardIntegral() : 0);
comActActRegistDO.setPosition(comActActRegistVO.getPosition());
comActActRegistDO.setTimes(signAllCount+1);
int result = comActActRegistDAO.insert(comActActRegistDO);
if (result > 0) {
- AddComActIntegralUserDTO addComActIntegralUserDTO=new AddComActIntegralUserDTO();
- addComActIntegralUserDTO.setUserId(userId);
- addComActIntegralUserDTO.setIntegralType(8);
- addComActIntegralUserDTO.setActivityType(1);
- addComActIntegralUserDTO.setCommunityId(comActActivityDO.getCommunityId());
- addComActIntegralUserDTO.setServiceId(activityId);
- comActIntegralUserTradeService.addIntegralTradeAdmin(addComActIntegralUserDTO);
-// ValueOperations<String, String> opsForValue = stringRedisTemplate.opsForValue();
-// opsForValue.set(activitySignInKey, "", 1800L, TimeUnit.SECONDS);
- return R.ok(comActActivityDO.getRewardIntegral());
+ if (isHave) {
+ boolean isVolunteerAct = comActActivityDO.getVolunteerMax() != 0;
+ AddComActIntegralUserDTO addComActIntegralUserDTO=new AddComActIntegralUserDTO();
+ addComActIntegralUserDTO.setUserId(userId);
+ addComActIntegralUserDTO.setIntegralType(isVolunteerAct ? 5 : 4);
+ addComActIntegralUserDTO.setActivityType(1);
+ addComActIntegralUserDTO.setIsVolunteer(comActActSignDO.getIsVolunteer());
+ addComActIntegralUserDTO.setCommunityId(comActActivityDO.getCommunityId());
+ addComActIntegralUserDTO.setServiceId(activityId);
+ comActIntegralUserTradeService.addIntegralTradeAdmin(addComActIntegralUserDTO);
+ return R.ok(comActActivityDO.getRewardIntegral());
+ } else {
+ return R.ok();
+ }
}
return R.fail("网络错误,请重试");
}
--
Gitblit v1.7.1