From adf7566f482080d9fff9dd4429f308433a0e2c2f Mon Sep 17 00:00:00 2001 From: 101captain <237651143@qq.com> Date: 星期五, 07 一月 2022 16:20:22 +0800 Subject: [PATCH] 商业街代码提交 --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java | 46 ++++++++++++++++++++++++++++++++++------------ 1 files changed, 34 insertions(+), 12 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 d05ab8b..1a640df 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 @@ -12,6 +12,7 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; +import java.util.Comparator; import java.util.Date; import java.util.List; import java.util.Map; @@ -285,8 +286,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); @@ -317,6 +317,12 @@ if (!ObjectUtils.isEmpty(comActActSignDO)) { comActActivityVO.setIsSign(1); comActActivityVO.setIsVolunteer(comActActSignDO.getIsVolunteer()); + } + List<ComActActRegistDO> regList = comActActRegistDAO.selectList(new QueryWrapper<ComActActRegistDO>().lambda() + .eq(ComActActRegistDO::getUserId, userId).eq(ComActActRegistDO::getActivityId, id).eq(ComActActRegistDO::getType, 1)); + if (!regList.isEmpty()) { + List<ComActActRegistDO> collect = regList.stream().sorted(Comparator.comparing(ComActActRegistDO::getId).reversed()).collect(Collectors.toList()); + comActActivityVO.setTimes(collect.get(0).getTimes()); } } } @@ -484,13 +490,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)) { @@ -551,9 +557,14 @@ 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("缺少取消原因"); @@ -567,8 +578,9 @@ if (num > 0) { AddComActIntegralUserDTO addComActIntegralUserDTO = new AddComActIntegralUserDTO(); addComActIntegralUserDTO.setUserId(userId); - addComActIntegralUserDTO.setIntegralType(9); + addComActIntegralUserDTO.setIntegralType(8); addComActIntegralUserDTO.setActivityType(1); + addComActIntegralUserDTO.setIsVolunteer(comActActSignDO.getIsVolunteer()); addComActIntegralUserDTO.setCommunityId(actActivityDO.getCommunityId()); addComActIntegralUserDTO.setServiceId(activityId); comActIntegralUserTradeService.addIntegralTradeAdmin(addComActIntegralUserDTO); @@ -896,6 +908,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(); @@ -910,22 +928,24 @@ 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()); // if (stringRedisTemplate.hasKey(activitySignInKey)) { // return R.fail("你已签到,如要再次签到请三十分钟后尝试!"); // } - Integer haveIntegralReward = comActActivityDO.getHaveIntegralReward(); - boolean isHave = nonNull(haveIntegralReward) && haveIntegralReward.equals(1); ComActActRegistDO comActActRegistDO = new ComActActRegistDO(); 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(isHave ? comActActivityDO.getRewardIntegral() : 0); @@ -934,10 +954,12 @@ int result = comActActRegistDAO.insert(comActActRegistDO); if (result > 0) { if (isHave) { + boolean isVolunteerAct = comActActivityDO.getVolunteerMax() != 0; AddComActIntegralUserDTO addComActIntegralUserDTO=new AddComActIntegralUserDTO(); addComActIntegralUserDTO.setUserId(userId); - addComActIntegralUserDTO.setIntegralType(8); + addComActIntegralUserDTO.setIntegralType(isVolunteerAct ? 5 : 4); addComActIntegralUserDTO.setActivityType(1); + addComActIntegralUserDTO.setIsVolunteer(comActActSignDO.getIsVolunteer()); addComActIntegralUserDTO.setCommunityId(comActActivityDO.getCommunityId()); addComActIntegralUserDTO.setServiceId(activityId); comActIntegralUserTradeService.addIntegralTradeAdmin(addComActIntegralUserDTO); -- Gitblit v1.7.1