101captain
2022-07-20 d152b0f34d06434456b69c012ba2712062efc313
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java
@@ -17,6 +17,7 @@
import com.panzhihua.common.model.dtos.property.CommonPage;
import com.panzhihua.common.model.vos.community.*;
import com.panzhihua.service_community.entity.ComActSocialProject;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.data.redis.core.StringRedisTemplate;
@@ -88,6 +89,10 @@
    private ComActActivityCodeService comActActivityCodeService;
    @Resource
    private ComActDAO comActDAO;
    @Resource
    private ComActSocialProjectDao comActSocialProjectDao;
    @Resource
    private ComStreetDAO comStreetDAO;
    /**
     * 新增社区活动
@@ -171,8 +176,24 @@
                try {
                    WxXCXTempSend util = new WxXCXTempSend();
                    String accessToken = util.getAppAccessToken();
                    ComActDO comActDO=comActDAO.selectById(comActActivityDO.getCommunityId());
                    R<SysTemplateConfigVO> r=userService.selectTemplate(comActDO.getAreaCode(),1);
                    Integer type = comActActivityDO.getType();
                    String areaCode;
                    if (nonNull(type) && type.equals(4)) {
                        ComActSocialProject comActSocialProject = comActSocialProjectDao.selectById(comActActivityDO.getProjectId());
                        Long streetId = comActSocialProject.getStreetId();
                        Long communityId = comActSocialProject.getCommunityId();
                        if (nonNull(streetId)) {
                            ComStreetDO comStreetDO = comStreetDAO.selectById(streetId);
                            areaCode = comStreetDO.getAreaCode().toString();
                        } else {
                            ComActDO comActDO = comActDAO.selectById(communityId);
                            areaCode = comActDO.getAreaCode();
                        }
                    } else {
                        ComActDO comActDO = comActDAO.selectById(comActActivityDO.getCommunityId());
                        areaCode = comActDO.getAreaCode();
                    }
                    R<SysTemplateConfigVO> r=userService.selectTemplate(areaCode,1);
                    activitySignVOS.forEach(activitySignVO1 -> {
                        // 变更社区活动推送订阅消息给用户
                        WxUtil.sendSubscribeHDBG(activitySignVO1.getOpenid(), accessToken,
@@ -199,6 +220,7 @@
        if (comActActivityVO.getSignUpEnd() != null && now.getTime() < comActActivityVO.getSignUpEnd().getTime()
        && now.getTime() > comActActivityVO.getSignUpBegin().getTime()) {
            comActActivityDO.setStatus(3);
            comActActivityDO.setPublishAt(new Date());
        }
        boolean b = this.updateById(comActActivityDO);
        if (b) {
@@ -227,7 +249,19 @@
        }
        page.setSize(pageSize);
        page.setCurrent(pageNum);
        IPage<ComActActivityVO> iPage = comActActivityDAO.pageActivity(page, comActActivityVO);
        Integer type = comActActivityVO.getType();
        IPage<ComActActivityVO> iPage = null;
        if (nonNull(type) && type.equals(4)) {
            if (nonNull(comActActivityVO.getCommunityId())) {
                ComActDO comActDO = comActDAO.selectById(comActActivityVO.getCommunityId());
                if (nonNull(comActDO)) {
                    comActActivityVO.setStreetId(comActDO.getStreetId());
                }
            }
            iPage = comActActivityDAO.pageProjectActivity(page, comActActivityVO);
        } else {
            iPage = comActActivityDAO.pageActivity(page, comActActivityVO);
        }
//        List<ComActActivityVO> records = iPage.getRecords();
//        if (!ObjectUtils.isEmpty(records)) {
//            records.forEach(comActActivityVO1 -> {
@@ -309,7 +343,7 @@
                    List<ComActActRegistDO> collect = regList.stream().sorted(Comparator.comparing(ComActActRegistDO::getId).reversed()).collect(Collectors.toList());
                    comActActivityVO.setTimes(collect.get(0).getTimes());
                    ComActActRegistDO comActActRegistDO=collect.get(0);
                    if(comActActRegistDO.getType()==2){
                    if(comActActRegistDO.getType()==3){
                        if(comActActRegistDO.getEndTime()==null){
                            comActActivityVO.setSignType(2);
                        }
@@ -473,6 +507,9 @@
        if (isNull(actActivityDO)) {
            return R.fail("活动不存在");
        }
        if(actActivityDO.getSignUpBegin().after(new Date())){
            return R.fail("未到报名时间");
        }
        int num = 0;
        ComActActSignDO comActActSignDO = comActActSignDAO.selectOne(new QueryWrapper<ComActActSignDO>()
                .lambda().eq(ComActActSignDO::getActivityId, activityId).eq(ComActActSignDO::getUserId, userId));
@@ -546,12 +583,14 @@
                comActActSignDO.setCreateAt(new Date());
                comActActSignDO.setReason(null);
                comActActSignDO.setIsVolunteer(isVolunteer);
                comActActSignDO.setTimes(comActActSignDO.getTimes()+1);
                num = comActActSignDAO.updateById(comActActSignDO);
            } else {
                comActActSignDO = new ComActActSignDO();
                comActActSignDO.setActivityId(activityId);
                comActActSignDO.setUserId(userId);
                comActActSignDO.setIsVolunteer(isVolunteer);
                comActActSignDO.setTimes(1);
                num = comActActSignDAO.insert(comActActSignDO);
            }
        } else {
@@ -628,7 +667,8 @@
                        .filter(activitySignVO -> activitySignVO.getActivityId().equals(comActActivityVO.getId()))
                        .collect(Collectors.toList());
                comActActivityVO.setSignCount(collect.size());
                comActActivityVO.setIsComment(1);
                comActActivityVO.setIsComment(0);
                comActActivityVO.setIsRegist(0);
                ActivitySignVO activitySignVO = collect.get(0);
                Integer activityStatus = comActActivityVO.getStatus();
                if (activityStatus.intValue() == 3) {
@@ -642,9 +682,9 @@
                    log.error("时间转换异常【{}】", e.getMessage());
                }
                comActActivityVO.setSingDate(createAt);
                comActActivityVO.setTimes(activitySignVO.getTimes());
                Integer totalAward = comActActRegistDAO.selectTotalAwardWithRegist(activitySignVO.getActivityId(), userId);
                comActActivityVO.setAward(totalAward);
                comActActivityVO.setActivitySignVOList(collect);
                comActActivityVOS.add(comActActivityVO);
            });
        }
@@ -936,7 +976,7 @@
                if(comActActActRegistDO.getEndTime()!=null){
                    return R.fail("无法重复签退");
                }
                comActActRegistDO.setId(comActActRegistVO.getId());
                comActActRegistDO.setId(comActActActRegistDO.getId());
                comActActRegistDO.setEndTime(new Date());
                int result=comActActRegistDAO.updateById(comActActRegistDO);
                if (result > 0) {
@@ -970,7 +1010,7 @@
                }
                comActActRegistDO.setActivityId(activityId);
                comActActRegistDO.setStartTime(new Date());
                comActActRegistDO.setType(1);
                comActActRegistDO.setType(comActActivityDO.getType());
                comActActRegistDO.setUserId(userId);
                comActActRegistDO.setIsVolunteer(comActActSignDO.getIsVolunteer());
                comActActRegistDO.setCreateAt(nowDate);
@@ -979,7 +1019,7 @@
                comActActRegistDO.setPosition(comActActRegistVO.getPosition());
                comActActRegistDO.setTimes(signAllCount+1);
                int result = comActActRegistDAO.insert(comActActRegistDO);
                if (result > 0&&comActActRegistDO.getType()==1) {
                if (result > 0&&comActActivityDO.getType()!=3) {
                    if (isHave) {
                        boolean isVolunteerAct = comActActivityDO.getVolunteerMax() != 0;
                        AddComActIntegralUserDTO addComActIntegralUserDTO=new AddComActIntegralUserDTO();
@@ -995,6 +1035,9 @@
                        return R.ok();
                    }
                }
                else {
                    return R.ok();
                }
            }
            return R.fail("网络错误,请重试");
//        else {