101captain
2022-02-22 c83cf9d2d82a0a29a15e38f4566eb470b9a3517b
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;
@@ -135,7 +136,9 @@
                comActActivityDO.setStatus(3);
            }
        }
        if(comActActivityVO.getType()==4){
            comActActivityDO.setIsProject(1);
        }
        boolean save = this.save(comActActivityDO);
        if (!save) {
            return R.fail();
@@ -285,8 +288,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 +319,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 +492,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 +559,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 +580,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 +910,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();
@@ -927,7 +947,7 @@
            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);
@@ -936,10 +956,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);