|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import static java.util.Objects.isNull; | 
|---|
|  |  |  | import static java.util.Objects.nonNull; | 
|---|
|  |  |  | import static org.apache.commons.lang3.StringUtils.isBlank; | 
|---|
|  |  |  | import static org.apache.commons.lang3.StringUtils.isNotBlank; | 
|---|
|  |  |  | import static org.apache.commons.lang3.ObjectUtils.isEmpty; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.math.BigDecimal; | 
|---|
|  |  |  | import java.math.RoundingMode; | 
|---|
|  |  |  | import java.text.DecimalFormat; | 
|---|
|  |  |  | import java.text.ParseException; | 
|---|
|  |  |  | import java.text.SimpleDateFormat; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Arrays; | 
|---|
|  |  |  | import java.util.Comparator; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.annotation.Resource; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.panzhihua.common.model.dtos.property.CommonPage; | 
|---|
|  |  |  | import com.panzhihua.common.model.vos.community.*; | 
|---|
|  |  |  | import com.panzhihua.common.constants.HttpStatus; | 
|---|
|  |  |  | import com.panzhihua.common.model.dtos.community.ActivityInviteDTO; | 
|---|
|  |  |  | import com.panzhihua.service_community.dao.ComActNeighborCircleDAO; | 
|---|
|  |  |  | import com.panzhihua.service_community.dao.ComActNeighborCircleTopicWestMapper; | 
|---|
|  |  |  | import com.panzhihua.service_community.dao.ComPbMemberDAO; | 
|---|
|  |  |  | import com.panzhihua.service_community.entity.ComActActivityInvite; | 
|---|
|  |  |  | import com.panzhihua.service_community.model.dos.ComActNeighborCircleTopicWestDO; | 
|---|
|  |  |  | import com.panzhihua.service_community.service.ComActActivityInviteService; | 
|---|
|  |  |  | import org.apache.commons.lang3.time.DateUtils; | 
|---|
|  |  |  | import org.springframework.beans.BeanUtils; | 
|---|
|  |  |  | import org.springframework.data.redis.core.StringRedisTemplate; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.util.CollectionUtils; | 
|---|
|  |  |  | import org.springframework.util.ObjectUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
|---|
|  |  |  | import com.panzhihua.common.constants.HttpStatus; | 
|---|
|  |  |  | import com.panzhihua.common.model.dtos.community.bigscreen.work.ScreenActActivityListDTO; | 
|---|
|  |  |  | import com.panzhihua.common.model.dtos.community.bigscreen.work.ScreenActActivityPeopleListDTO; | 
|---|
|  |  |  | import com.panzhihua.common.model.dtos.community.integral.admin.AddComActIntegralUserDTO; | 
|---|
|  |  |  | import com.panzhihua.common.model.dtos.property.CommonPage; | 
|---|
|  |  |  | import com.panzhihua.common.model.vos.IndexDataVO; | 
|---|
|  |  |  | import com.panzhihua.common.model.vos.LoginUserInfoVO; | 
|---|
|  |  |  | import com.panzhihua.common.model.vos.R; | 
|---|
|  |  |  | import com.panzhihua.common.model.vos.community.*; | 
|---|
|  |  |  | import com.panzhihua.common.model.vos.community.ActivitySignVO; | 
|---|
|  |  |  | import com.panzhihua.common.model.vos.community.ComActActEvaluateVO; | 
|---|
|  |  |  | import com.panzhihua.common.model.vos.community.ComActActPictureVO; | 
|---|
|  |  |  | import com.panzhihua.common.model.vos.community.ComActActRegistVO; | 
|---|
|  |  |  | import com.panzhihua.common.model.vos.community.ComActActivityStatisticsVO; | 
|---|
|  |  |  | import com.panzhihua.common.model.vos.community.ComActActivityTypeVO; | 
|---|
|  |  |  | import com.panzhihua.common.model.vos.community.ComActActivityVO; | 
|---|
|  |  |  | import com.panzhihua.common.model.vos.community.CommunityActivitiesVO; | 
|---|
|  |  |  | import com.panzhihua.common.model.vos.community.CommunityGovernanceTrendsVO; | 
|---|
|  |  |  | import com.panzhihua.common.model.vos.community.PartyActivityLine; | 
|---|
|  |  |  | import com.panzhihua.common.model.vos.community.PartyActivityStatics; | 
|---|
|  |  |  | import com.panzhihua.common.model.vos.community.PartyActivityTypeChart; | 
|---|
|  |  |  | import com.panzhihua.common.model.vos.community.SignactivityVO; | 
|---|
|  |  |  | import com.panzhihua.common.model.vos.community.screen.work.ActActivityListVO; | 
|---|
|  |  |  | import com.panzhihua.common.model.vos.user.SysTemplateConfigVO; | 
|---|
|  |  |  | import com.panzhihua.common.service.user.UserService; | 
|---|
|  |  |  | import com.panzhihua.common.utlis.Snowflake; | 
|---|
|  |  |  | import com.panzhihua.common.utlis.WxUtil; | 
|---|
|  |  |  | import com.panzhihua.common.utlis.WxXCXTempSend; | 
|---|
|  |  |  | import com.panzhihua.service_community.dao.*; | 
|---|
|  |  |  | import com.panzhihua.service_community.dao.ComActActEvaluateDAO; | 
|---|
|  |  |  | import com.panzhihua.service_community.dao.ComActActPictureDAO; | 
|---|
|  |  |  | import com.panzhihua.service_community.dao.ComActActRegistDAO; | 
|---|
|  |  |  | import com.panzhihua.service_community.dao.ComActActSignDAO; | 
|---|
|  |  |  | import com.panzhihua.service_community.dao.ComActActivityCodeDao; | 
|---|
|  |  |  | import com.panzhihua.service_community.dao.ComActActivityDAO; | 
|---|
|  |  |  | import com.panzhihua.service_community.dao.ComActDAO; | 
|---|
|  |  |  | import com.panzhihua.service_community.dao.ComActSocialProjectDao; | 
|---|
|  |  |  | import com.panzhihua.service_community.dao.ComBpActivityDAO; | 
|---|
|  |  |  | import com.panzhihua.service_community.dao.ComPbCheckUnitDao; | 
|---|
|  |  |  | import com.panzhihua.service_community.dao.ComStreetDAO; | 
|---|
|  |  |  | import com.panzhihua.service_community.entity.ComActActivityCode; | 
|---|
|  |  |  | import com.panzhihua.service_community.model.dos.*; | 
|---|
|  |  |  | import com.panzhihua.service_community.entity.ComPbCheckUnit; | 
|---|
|  |  |  | import com.panzhihua.service_community.model.dos.ComActActEvaluateDO; | 
|---|
|  |  |  | import com.panzhihua.service_community.model.dos.ComActActPictureDO; | 
|---|
|  |  |  | import com.panzhihua.service_community.model.dos.ComActActRegistDO; | 
|---|
|  |  |  | import com.panzhihua.service_community.model.dos.ComActActSignDO; | 
|---|
|  |  |  | import com.panzhihua.service_community.model.dos.ComActActivityDO; | 
|---|
|  |  |  | import com.panzhihua.service_community.model.dos.ComActDO; | 
|---|
|  |  |  | import com.panzhihua.service_community.service.ComActActivityCodeService; | 
|---|
|  |  |  | import com.panzhihua.service_community.service.ComActActivityService; | 
|---|
|  |  |  | import com.panzhihua.service_community.service.ComActIntegralUserTradeService; | 
|---|
|  |  |  | 
|---|
|  |  |  | private ComActActivityCodeService comActActivityCodeService; | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private ComActDAO comActDAO; | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private ComPbCheckUnitDao comPbCheckUnitDao; | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private ComActSocialProjectDao comActSocialProjectDao; | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private ComStreetDAO comStreetDAO; | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private ComPbMemberDAO pbMemberDAO; | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private ComActNeighborCircleTopicWestMapper comActNeighborCircleTopicWestMapper; | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private ComActActivityInviteService comActActivityInviteService; | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private ComActNeighborCircleDAO comActNeighborCircleDAO; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 新增社区活动 | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @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(); | 
|---|
|  |  |  | 
|---|
|  |  |  | if(comActActivityVO.getType()==4){ | 
|---|
|  |  |  | comActActivityDO.setIsProject(1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(comActActivityVO.getType()==5){ | 
|---|
|  |  |  | comPbCheckUnitDao.selectOne(new QueryWrapper<ComPbCheckUnit>().lambda().eq(ComPbCheckUnit::getAdminPhone,comActActivityVO.getPhone()).last("limit 1")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | boolean save = this.save(comActActivityDO); | 
|---|
|  |  |  | if (!save) { | 
|---|
|  |  |  | return R.fail(); | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq(ComActActivityDO::getActivityName, comActActivityDO.getActivityName()) | 
|---|
|  |  |  | .orderByDesc(ComActActivityDO::getCreateAt).last(" limit 1 ")); | 
|---|
|  |  |  | Long activityId = one.getId(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<ActivityInviteDTO> inviteList = comActActivityVO.getActivityInviteList(); | 
|---|
|  |  |  | if (!isEmpty(inviteList)) { | 
|---|
|  |  |  | List<ComActActivityInvite> inviteEntityList = new ArrayList<>(); | 
|---|
|  |  |  | inviteList.forEach(e -> { | 
|---|
|  |  |  | ComActActivityInvite inviteEntity = new ComActActivityInvite(); | 
|---|
|  |  |  | BeanUtils.copyProperties(e, inviteEntity); | 
|---|
|  |  |  | inviteEntity.setActivityId(activityId); | 
|---|
|  |  |  | inviteEntity.setCreatedBy(comActActivityVO.getUserId()); | 
|---|
|  |  |  | inviteEntityList.add(inviteEntity); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | comActActivityInviteService.saveBatch(inviteEntityList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ComActNeighborCircleTopicWestDO topicWestDO = new ComActNeighborCircleTopicWestDO(); | 
|---|
|  |  |  | topicWestDO.setCommunityId(comActActivityDO.getCommunityId()); | 
|---|
|  |  |  | topicWestDO.setBelongType(2); | 
|---|
|  |  |  | topicWestDO.setRefId(activityId); | 
|---|
|  |  |  | topicWestDO.setName(comActActivityDO.getActivityName()); | 
|---|
|  |  |  | topicWestDO.setCreateAt(new Date()); | 
|---|
|  |  |  | topicWestDO.setCount(0); | 
|---|
|  |  |  | topicWestDO.setHotNum(0L); | 
|---|
|  |  |  | topicWestDO.setStatus(ComActNeighborCircleTopicWestDO.status.yes); | 
|---|
|  |  |  | comActNeighborCircleTopicWestMapper.insert(topicWestDO); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ComActActivityDO activityUpdate = new ComActActivityDO(); | 
|---|
|  |  |  | BeanUtils.copyProperties(comActActivityDO, activityUpdate); | 
|---|
|  |  |  | activityUpdate.setTopicId(topicWestDO.getId()); | 
|---|
|  |  |  | this.baseMapper.updateById(activityUpdate); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //保存上传照片 | 
|---|
|  |  |  | ComActActPictureDO comActActPictureDO = new ComActActPictureDO(); | 
|---|
|  |  |  | 
|---|
|  |  |  | if (!activitySignVOS.isEmpty()) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | WxXCXTempSend util = new WxXCXTempSend(); | 
|---|
|  |  |  | String accessToken = util.getAppAccessToken(); | 
|---|
|  |  |  | String accessToken = util.getAccessToken(); | 
|---|
|  |  |  | ComActDO comActDO=comActDAO.selectById(comActActivityDO.getCommunityId()); | 
|---|
|  |  |  | R<SysTemplateConfigVO> r=userService.selectTemplate(comActDO.getAreaCode(),1); | 
|---|
|  |  |  | activitySignVOS.forEach(activitySignVO1 -> { | 
|---|
|  |  |  | 
|---|
|  |  |  | log.error("消息推送失败,失败原因:" + e.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (comActActivityVO.getHaveIntegralReward().intValue() == 2) { | 
|---|
|  |  |  | comActActivityVO.setRewardWay(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | BeanUtils.copyProperties(comActActivityVO, comActActivityDO); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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 -> { | 
|---|
|  |  |  | 
|---|
|  |  |  | ComActActSignDO comActActSignDO = comActActSignDAO.selectOne(actSignQuery); | 
|---|
|  |  |  | if (!ObjectUtils.isEmpty(comActActSignDO)) { | 
|---|
|  |  |  | comActActivityVO.setIsSign(1); | 
|---|
|  |  |  | comActActivityVO.setIsVolunteer(comActActSignDO.getIsVolunteer()); | 
|---|
|  |  |  | comActActivityVO.setSignIdentity(comActActSignDO.getSignIdentity()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<ComActActRegistDO> regList = comActActRegistDAO.selectList(new QueryWrapper<ComActActRegistDO>().lambda() | 
|---|
|  |  |  | .eq(ComActActRegistDO::getUserId, userId).eq(ComActActRegistDO::getActivityId, id)); | 
|---|
|  |  |  | 
|---|
|  |  |  | 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()==3){ | 
|---|
|  |  |  | if(comActActRegistDO.getEndTime()==null){ | 
|---|
|  |  |  | comActActivityVO.setSignType(2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else { | 
|---|
|  |  |  | comActActivityVO.setSignType(1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(comActActRegistDO.getEndTime()==null){ | 
|---|
|  |  |  | comActActivityVO.setSignType(2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else { | 
|---|
|  |  |  | comActActivityVO.setSignType(1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else { | 
|---|
|  |  |  | comActActivityVO.setSignType(1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | comActActivityVO.setCodeType(1); | 
|---|
|  |  |  | if (comActActivityVO.getRelationId() != null) { | 
|---|
|  |  |  | comActActivityVO.setListDetail(comActNeighborCircleDAO.neighborDetailByApp(comActActivityVO.getRelationId())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | comActActivityVO.setCodeType(1); | 
|---|
|  |  |  | return comActActivityVO; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public R listActivitySign(ActivitySignVO activitySignVO) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //        ComActActivityDO comActActivityDO=comActActivityDAO.selectById(activitySignVO.getActivityId()); | 
|---|
|  |  |  | //        if(comActActivityDO!=null){ | 
|---|
|  |  |  | //            if(comActActivityDO.getType()==3||comActActivityDO.getType()==5){ | 
|---|
|  |  |  | //                IPage<ActivitySignVO> activitySignVOS = comActActSignDAO | 
|---|
|  |  |  | //                        .listActivitySignParty(new Page(activitySignVO.getPageNum(), activitySignVO.getPageSize()), activitySignVO); | 
|---|
|  |  |  | //                return R.ok(activitySignVOS); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | IPage<ActivitySignVO> activitySignVOS = comActActSignDAO | 
|---|
|  |  |  | .listActivitySign(new Page(activitySignVO.getPageNum(), activitySignVO.getPageSize()), activitySignVO); | 
|---|
|  |  |  | // List<ActivitySignVO> activitySignVOS = comActActSignDAO.listActivitySign(activitySignVO); | 
|---|
|  |  |  | return R.ok(activitySignVOS); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | int num = 0; | 
|---|
|  |  |  | ComActActSignDO comActActSignDO = comActActSignDAO.selectOne(new QueryWrapper<ComActActSignDO>() | 
|---|
|  |  |  | .lambda().eq(ComActActSignDO::getActivityId, activityId).eq(ComActActSignDO::getUserId, userId)); | 
|---|
|  |  |  | Integer signIdentity = signactivityVO.getSignIdentity(); | 
|---|
|  |  |  | if (1 == type) { | 
|---|
|  |  |  | if (nonNull(comActActSignDO) && comActActSignDO.getStatus().equals(1)) { | 
|---|
|  |  |  | return R.fail("已经报名过了,请勿重复提交"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Integer volunteerMax = actActivityDO.getVolunteerMax(); | 
|---|
|  |  |  | Integer activityType = actActivityDO.getType(); | 
|---|
|  |  |  | Integer residentMax = actActivityDO.getParticipantMax(); | 
|---|
|  |  |  | R<LoginUserInfoVO> userInfoR = userService.getUserInfoByUserId(String.valueOf(userId)); | 
|---|
|  |  |  | LoginUserInfoVO loginUserInfoVO = | 
|---|
|  |  |  | 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::getStatus, 1)); | 
|---|
|  |  |  | if (activityType.equals(1)) { | 
|---|
|  |  |  | //志愿者活动 | 
|---|
|  |  |  | boolean userIsVolunteer = loginUserInfoVO.getIsVolunteer() == 1; | 
|---|
|  |  |  | // 查询当前活动下参与志愿者 | 
|---|
|  |  |  | Integer volunteerCount = comActActSignDAO.selectCount(new QueryWrapper<ComActActSignDO>().lambda() | 
|---|
|  |  |  | .eq(ComActActSignDO::getActivityId, activityId).eq(ComActActSignDO::getIsVolunteer, 1).eq(ComActActSignDO::getStatus, 1)); | 
|---|
|  |  |  | if (userIsVolunteer) { | 
|---|
|  |  |  | //用户是志愿者以志愿者身份参加 | 
|---|
|  |  |  | if (volunteerMax > volunteerCount || volunteerMax.equals(-1)) { | 
|---|
|  |  |  | //以志愿者身份报名 | 
|---|
|  |  |  | isVolunteer = 1; | 
|---|
|  |  |  | } else if (nonNull(residentMax) && (residentMax > residentCount || residentMax.equals(-1))) { | 
|---|
|  |  |  | //志愿者报名人数已满,再以居民身份报名参加 | 
|---|
|  |  |  | isVolunteer = 0; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | Boolean isInvite = false; | 
|---|
|  |  |  | if (activityType == 1) { | 
|---|
|  |  |  | if (signIdentity == 1) { | 
|---|
|  |  |  | //以居民身份参与活动 | 
|---|
|  |  |  | Integer residentMax = actActivityDO.getParticipantMax(); | 
|---|
|  |  |  | if (residentMax == null) { | 
|---|
|  |  |  | return R.fail("活动暂未对居民开放"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 查询当前活动下参与居民 | 
|---|
|  |  |  | Integer residentCount = comActActSignDAO.selectCount(new QueryWrapper<ComActActSignDO>().lambda() | 
|---|
|  |  |  | .eq(ComActActSignDO::getActivityId, activityId).eq(ComActActSignDO::getSignIdentity, 1).eq(ComActActSignDO::getStatus, 1)); | 
|---|
|  |  |  | if (residentMax != -1 && residentMax <= residentCount) { | 
|---|
|  |  |  | return R.fail("报名人数已满"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | //用户是普通居民已居民身份参加 | 
|---|
|  |  |  | if (nonNull(residentMax) && (residentMax > residentCount || residentMax.equals(-1))) { | 
|---|
|  |  |  | //以居民身份报名参加 | 
|---|
|  |  |  | isVolunteer = 0; | 
|---|
|  |  |  | } else if (volunteerMax > volunteerCount || volunteerMax.equals(-1)) { | 
|---|
|  |  |  | return R.fail(HttpStatus.NOT_ACCEPTABLE, "您还不是志愿者哦~"); | 
|---|
|  |  |  | } else if (signIdentity == 2) { | 
|---|
|  |  |  | //以党员身份参与活动 | 
|---|
|  |  |  | Integer partyMemberMax = actActivityDO.getPartyMemberMax(); | 
|---|
|  |  |  | if (partyMemberMax == null) { | 
|---|
|  |  |  | return R.fail("活动暂未对党员开放"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ComActActivityInvite activityInvite = comActActivityInviteService.getBaseMapper().selectOne(new LambdaQueryWrapper<ComActActivityInvite>() | 
|---|
|  |  |  | .eq(ComActActivityInvite::getActivityId, activityId).eq(ComActActivityInvite::getUserId, userId)); | 
|---|
|  |  |  | if (isNull(activityInvite)) { | 
|---|
|  |  |  | int count = pbMemberDAO.checkIsPbMember(userId); | 
|---|
|  |  |  | if (count < 1) { | 
|---|
|  |  |  | return R.fail(HttpStatus.NOT_ACCEPTABLE, "您还不是党员"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 查询当前活动下参与志愿者 | 
|---|
|  |  |  | Integer partyMemberCount = comActActSignDAO.selectCount(new QueryWrapper<ComActActSignDO>().lambda() | 
|---|
|  |  |  | .eq(ComActActSignDO::getActivityId, activityId).eq(ComActActSignDO::getSignIdentity, 2) | 
|---|
|  |  |  | .eq(ComActActSignDO::getStatus, 1).eq(ComActActSignDO::getIsInvite, false)); | 
|---|
|  |  |  | if (partyMemberMax != -1 && partyMemberMax <= partyMemberCount) { | 
|---|
|  |  |  | return R.fail("报名人数已满"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | isInvite = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | //以志愿者身份参与活动 | 
|---|
|  |  |  | Integer volunteerMax = actActivityDO.getVolunteerMax(); | 
|---|
|  |  |  | if (volunteerMax == null) { | 
|---|
|  |  |  | return R.fail("活动暂未对志愿者开放"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | int count = pbMemberDAO.checkIsVolunteer(userId); | 
|---|
|  |  |  | if (count < 1) { | 
|---|
|  |  |  | return R.fail(HttpStatus.NOT_ACCEPTABLE, "您还不是志愿者"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 查询当前活动下参与志愿者 | 
|---|
|  |  |  | Integer volunteerCount = comActActSignDAO.selectCount(new QueryWrapper<ComActActSignDO>().lambda() | 
|---|
|  |  |  | .eq(ComActActSignDO::getActivityId, activityId).eq(ComActActSignDO::getSignIdentity, 3).eq(ComActActSignDO::getStatus, 1)); | 
|---|
|  |  |  | if (volunteerMax != -1 && volunteerMax <= volunteerCount) { | 
|---|
|  |  |  | return R.fail("报名人数已满"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | //普通居民活动 | 
|---|
|  |  |  | //审查用户是否有该活动报名权限(是否活动指定参与人群) | 
|---|
|  |  |  | String currentUserTags = loginUserInfoVO.getTags(); | 
|---|
|  |  |  | String attendPeople = actActivityDO.getAattendPeople(); | 
|---|
|  |  |  | if (isNotBlank(attendPeople)) { | 
|---|
|  |  |  | if (isBlank(currentUserTags)) { | 
|---|
|  |  |  | currentUserTags = "全部居民"; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | currentUserTags = currentUserTags.concat(",全部居民"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<String> currentUserTagList = Arrays.asList(currentUserTags.split(",")); | 
|---|
|  |  |  | boolean checkResult = currentUserTagList.stream().anyMatch(currentUserTag -> attendPeople.contains(currentUserTag)); | 
|---|
|  |  |  | if (!checkResult) { | 
|---|
|  |  |  | return R.fail("您不是指定参与人群!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (residentMax > residentCount || residentMax.equals(-1)) { | 
|---|
|  |  |  | //用户参加居民活动 | 
|---|
|  |  |  | isVolunteer = 0; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | return R.fail("报名人数已满"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (nonNull(comActActSignDO)) { | 
|---|
|  |  |  | comActActSignDO.setStatus(1); | 
|---|
|  |  |  | comActActSignDO.setCreateAt(new Date()); | 
|---|
|  |  |  | comActActSignDO.setReason(null); | 
|---|
|  |  |  | comActActSignDO.setIsVolunteer(isVolunteer); | 
|---|
|  |  |  | comActActSignDO.setSignIdentity(signIdentity); | 
|---|
|  |  |  | comActActSignDO.setTimes(comActActSignDO.getTimes()+1); | 
|---|
|  |  |  | comActActSignDO.setIsInvite(isInvite); | 
|---|
|  |  |  | comActActSignDO.setCheckUnitId(signactivityVO.getCheckUnitId()); | 
|---|
|  |  |  | num = comActActSignDAO.updateById(comActActSignDO); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | comActActSignDO = new ComActActSignDO(); | 
|---|
|  |  |  | comActActSignDO.setActivityId(activityId); | 
|---|
|  |  |  | comActActSignDO.setUserId(userId); | 
|---|
|  |  |  | comActActSignDO.setIsVolunteer(isVolunteer); | 
|---|
|  |  |  | comActActSignDO.setSignIdentity(signIdentity); | 
|---|
|  |  |  | comActActSignDO.setTimes(1); | 
|---|
|  |  |  | comActActSignDO.setIsInvite(isInvite); | 
|---|
|  |  |  | comActActSignDO.setCheckUnitId(signactivityVO.getCheckUnitId()); | 
|---|
|  |  |  | num = comActActSignDAO.insert(comActActSignDO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | 
|---|
|  |  |  | AddComActIntegralUserDTO addComActIntegralUserDTO = new AddComActIntegralUserDTO(); | 
|---|
|  |  |  | addComActIntegralUserDTO.setUserId(userId); | 
|---|
|  |  |  | addComActIntegralUserDTO.setIntegralType(8); | 
|---|
|  |  |  | addComActIntegralUserDTO.setActivityType(actActivityDO.getType()); | 
|---|
|  |  |  | addComActIntegralUserDTO.setIsVolunteer(comActActSignDO.getIsVolunteer()); | 
|---|
|  |  |  | addComActIntegralUserDTO.setIntegral(actActivityDO.getCancelDeduct()); | 
|---|
|  |  |  | addComActIntegralUserDTO.setSignIdentity(comActActSignDO.getSignIdentity()); | 
|---|
|  |  |  | addComActIntegralUserDTO.setCommunityId(actActivityDO.getCommunityId()); | 
|---|
|  |  |  | addComActIntegralUserDTO.setServiceId(activityId); | 
|---|
|  |  |  | addComActIntegralUserDTO.setRemark(actActivityDO.getType().intValue() == 5 ? "单位党员活动-取消报名" : "社区活动-取消报名"); | 
|---|
|  |  |  | comActIntegralUserTradeService.addIntegralTradeAdmin(addComActIntegralUserDTO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | // 修改报名状态 变为报名中 | 
|---|
|  |  |  | //        int num1 = comActActivityDAO.updateStatusToBeginSign(); | 
|---|
|  |  |  | //        log.info("定时任务--修改社区活动报名状态活动数量【{}】", num1); | 
|---|
|  |  |  | // 查询已经结束的活动,需要计算积分 | 
|---|
|  |  |  | List<Long> activityEndIds = comActActivityDAO.selectBeginIds(); | 
|---|
|  |  |  | if(!CollectionUtils.isEmpty(activityEndIds)){ | 
|---|
|  |  |  | activityEndIds.forEach(activityId->{ | 
|---|
|  |  |  | List<String> openIds=comActActivityDAO.selectOpenIdByActivityId(activityId); | 
|---|
|  |  |  | if(!CollectionUtils.isEmpty(openIds)){ | 
|---|
|  |  |  | openIds.forEach(op->{ | 
|---|
|  |  |  | WxXCXTempSend wxXCXTempSend=new WxXCXTempSend(); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | WxUtil.sendLongTimeTemplate(op,wxXCXTempSend.getAccessToken("wx118de8a734d269f0"),"活动开始提醒","您参加的活动已开始","packageC/pages/activity/communityActivityDetails/communityActivityDetails?id="+activityId); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | int num3 = comActActivityDAO.updateStatusToBeginAfterSingEnd(); | 
|---|
|  |  |  | log.info("定时任务--报名结束修改社区活动进行状态活动数量【{}】", num3); | 
|---|
|  |  |  | // 查询已经结束的活动,需要计算积分 | 
|---|
|  |  |  | List<Long> activityEndIds = comActActivityDAO.getActivityEndIds(); | 
|---|
|  |  |  | // 修改进行状态 变为进行中或者已结束 | 
|---|
|  |  |  | int num2 = comActActivityDAO.updateStatusToBeginActiveOrEnd(); | 
|---|
|  |  |  | log.info("定时任务--修改社区活动进行状态活动数量【{}】", num2); | 
|---|
|  |  |  | List<Long> ids = comActActivityDAO.getActivityEndIds(); | 
|---|
|  |  |  | if(!CollectionUtils.isEmpty(ids)){ | 
|---|
|  |  |  | int num2 = comActActivityDAO.updateStatusToBeginActiveOrEnd(); | 
|---|
|  |  |  | log.info("定时任务--修改社区活动进行状态活动数量【{}】", num2); | 
|---|
|  |  |  | ids.forEach(id ->{ | 
|---|
|  |  |  | List<String> openIds=comActActivityDAO.selectOpenIdByActivityId(id); | 
|---|
|  |  |  | if(!CollectionUtils.isEmpty(openIds)){ | 
|---|
|  |  |  | openIds.forEach(op->{ | 
|---|
|  |  |  | WxXCXTempSend wxXCXTempSend=new WxXCXTempSend(); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | WxUtil.sendLongTimeTemplate(op,wxXCXTempSend.getAccessToken("wx118de8a734d269f0"),"活动结束提醒","您参加的活动已结束","packageC/pages/activity/communityActivityDetails/communityActivityDetails?id="+id); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok(activityEndIds); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | if (!actActivityList.isEmpty()) { | 
|---|
|  |  |  | WxXCXTempSend util = new WxXCXTempSend(); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | String accessToken = util.getAppAccessToken(); | 
|---|
|  |  |  | String accessToken = util.getAccessToken(); | 
|---|
|  |  |  | actActivityList.forEach(actActivity -> { | 
|---|
|  |  |  | ComActDO comActDO=comActDAO.selectById(actActivity.getCommunityId()); | 
|---|
|  |  |  | R<SysTemplateConfigVO> r=userService.selectTemplate(comActDO.getAreaCode(),9); | 
|---|
|  |  |  | 
|---|
|  |  |  | if (isNull(activityId)) { | 
|---|
|  |  |  | return R.fail("签到所属活动id不能为空!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ComActActivityDO comActActivityDO = comActActivityDAO.selectById(activityId); | 
|---|
|  |  |  | if (isNull(comActActivityDO)) { | 
|---|
|  |  |  | return R.fail("活动不存在!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ComActActivityDO comActActivityDO = comActActivityDAO.selectById(activityId); | 
|---|
|  |  |  | if (isNull(comActActivityDO)) { | 
|---|
|  |  |  | 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("活动未报名"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | if (nowDate.before(beginAt) || nowDate.after(endAt)) { | 
|---|
|  |  |  | return R.fail("不在活动时间范围内"); | 
|---|
|  |  |  | Date beginAt = comActActivityDO.getBeginAt(); | 
|---|
|  |  |  | Date endAt = comActActivityDO.getEndAt(); | 
|---|
|  |  |  | Date nowDate = new Date(); | 
|---|
|  |  |  | if (nowDate.before(beginAt) || nowDate.after(endAt)) { | 
|---|
|  |  |  | return R.fail("不在活动时间范围内"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Integer rewardWay = null; | 
|---|
|  |  |  | Integer rewardIntegral = 0; | 
|---|
|  |  |  | Integer integralType = null; | 
|---|
|  |  |  | String remark = ""; | 
|---|
|  |  |  | switch (comActActSignDO.getSignIdentity()) { | 
|---|
|  |  |  | case 1: | 
|---|
|  |  |  | rewardWay = comActActivityDO.getParticipantRewardWay(); | 
|---|
|  |  |  | rewardIntegral = comActActivityDO.getParticipantRewardIntegral(); | 
|---|
|  |  |  | integralType = 4; | 
|---|
|  |  |  | remark = "社区活动-居民身份成功参与"; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 2: | 
|---|
|  |  |  | rewardWay = comActActivityDO.getPbRewardWay(); | 
|---|
|  |  |  | rewardIntegral = comActActivityDO.getPbRewardIntegral(); | 
|---|
|  |  |  | integralType = 5; | 
|---|
|  |  |  | remark = "社区活动-党员身份成功参与"; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 3: | 
|---|
|  |  |  | rewardWay = comActActivityDO.getVolunteerRewardWay(); | 
|---|
|  |  |  | rewardIntegral = comActActivityDO.getVolunteerRewardIntegral(); | 
|---|
|  |  |  | integralType = 6; | 
|---|
|  |  |  | remark = "社区活动-志愿者身份成功参与"; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | default: | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (comActActivityDO.getType().intValue() == 5) { | 
|---|
|  |  |  | integralType = 9; | 
|---|
|  |  |  | remark = "单位党员活动-成功参与"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | boolean isHave = rewardIntegral > 0; | 
|---|
|  |  |  | ComActActRegistDO comActActRegistDO = new ComActActRegistDO(); | 
|---|
|  |  |  | if (comActActRegistVO.getSignType() != null && comActActRegistVO.getSignType() == 2) { | 
|---|
|  |  |  | ComActActRegistDO comActActActRegistDO = comActActRegistDAO.selectOne(new QueryWrapper<ComActActRegistDO>() | 
|---|
|  |  |  | .lambda().eq(ComActActRegistDO::getActivityId, activityId).eq(ComActActRegistDO::getUserId, userId) | 
|---|
|  |  |  | .eq(ComActActRegistDO::getCodeId, comActActRegistVO.getCodeId())); | 
|---|
|  |  |  | if (comActActActRegistDO == null) { | 
|---|
|  |  |  | return R.fail("未签到无法签退"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Integer haveIntegralReward = comActActivityDO.getHaveIntegralReward(); | 
|---|
|  |  |  | boolean isHave = nonNull(haveIntegralReward) && haveIntegralReward.equals(1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //        String activitySignInKey = String.join(DELIMITER, ACTIVITY_SIGN_IN, userId.toString(), activityId.toString()); | 
|---|
|  |  |  | //        if (stringRedisTemplate.hasKey(activitySignInKey)) { | 
|---|
|  |  |  | //            return R.fail("你已签到,如要再次签到请三十分钟后尝试!"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | ComActActRegistDO comActActRegistDO = new ComActActRegistDO(); | 
|---|
|  |  |  | if(comActActRegistVO.getSignType()!=null&&comActActRegistVO.getSignType()==2){ | 
|---|
|  |  |  | ComActActRegistDO comActActActRegistDO=comActActRegistDAO.selectOne(new QueryWrapper<ComActActRegistDO>() | 
|---|
|  |  |  | .lambda().eq(ComActActRegistDO::getActivityId, activityId).eq(ComActActRegistDO::getUserId, userId).eq(ComActActRegistDO::getCodeId,comActActRegistVO.getCodeId())); | 
|---|
|  |  |  | if(comActActActRegistDO==null){ | 
|---|
|  |  |  | return R.fail("未签到无法签退"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(comActActActRegistDO.getEndTime()!=null){ | 
|---|
|  |  |  | return R.fail("无法重复签退"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | comActActRegistDO.setId(comActActActRegistDO.getId()); | 
|---|
|  |  |  | comActActRegistDO.setEndTime(new Date()); | 
|---|
|  |  |  | int result=comActActRegistDAO.updateById(comActActRegistDO); | 
|---|
|  |  |  | if (result > 0) { | 
|---|
|  |  |  | if (isHave) { | 
|---|
|  |  |  | AddComActIntegralUserDTO addComActIntegralUserDTO=new AddComActIntegralUserDTO(); | 
|---|
|  |  |  | addComActIntegralUserDTO.setUserId(userId); | 
|---|
|  |  |  | addComActIntegralUserDTO.setIntegralType(6); | 
|---|
|  |  |  | addComActIntegralUserDTO.setActivityType(2); | 
|---|
|  |  |  | addComActIntegralUserDTO.setCommunityId(comActActivityDO.getCommunityId()); | 
|---|
|  |  |  | addComActIntegralUserDTO.setServiceId(activityId); | 
|---|
|  |  |  | comActIntegralUserTradeService.addIntegralTradeAdmin(addComActIntegralUserDTO); | 
|---|
|  |  |  | return R.ok(comActActivityDO.getRewardIntegral()); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (comActActActRegistDO.getEndTime() != null) { | 
|---|
|  |  |  | return R.fail("无法重复签退"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else { | 
|---|
|  |  |  | int signDayCount = comActActRegistDAO.selectCount(new QueryWrapper<ComActActRegistDO>() | 
|---|
|  |  |  | .lambda().eq(ComActActRegistDO::getActivityId, activityId).eq(ComActActRegistDO::getUserId, userId).eq(ComActActRegistDO::getCodeId,comActActRegistVO.getCodeId())); | 
|---|
|  |  |  | int signAllCount = comActActRegistDAO.selectCount(new QueryWrapper<ComActActRegistDO>() | 
|---|
|  |  |  | .lambda().eq(ComActActRegistDO::getActivityId, activityId).eq(ComActActRegistDO::getUserId, userId)); | 
|---|
|  |  |  | if (signDayCount > 0) { | 
|---|
|  |  |  | return R.fail("请扫描新的签到码"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | int hours = com.panzhihua.common.utlis.DateUtils.getHour(comActActActRegistDO.getStartTime(), nowDate); | 
|---|
|  |  |  | int retrieveIntegral = rewardWay == 1 ? rewardIntegral : rewardIntegral * hours; | 
|---|
|  |  |  | comActActRegistDO.setId(comActActActRegistDO.getId()); | 
|---|
|  |  |  | comActActRegistDO.setEndTime(nowDate); | 
|---|
|  |  |  | comActActRegistDO.setAward(retrieveIntegral); | 
|---|
|  |  |  | int result = comActActRegistDAO.updateById(comActActRegistDO); | 
|---|
|  |  |  | if (result > 0) { | 
|---|
|  |  |  | if (isHave) { | 
|---|
|  |  |  | int limit = comActActivityDO.getLimit().intValue(); | 
|---|
|  |  |  | if(limit != -1 && signAllCount >= limit){ | 
|---|
|  |  |  | return R.fail("签到次数上限"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | comActActRegistDO.setActivityId(activityId); | 
|---|
|  |  |  | comActActRegistDO.setStartTime(new Date()); | 
|---|
|  |  |  | comActActRegistDO.setType(comActActivityDO.getType()); | 
|---|
|  |  |  | comActActRegistDO.setUserId(userId); | 
|---|
|  |  |  | comActActRegistDO.setIsVolunteer(comActActSignDO.getIsVolunteer()); | 
|---|
|  |  |  | comActActRegistDO.setCreateAt(nowDate); | 
|---|
|  |  |  | comActActRegistDO.setCodeId(comActActRegistVO.getCodeId()); | 
|---|
|  |  |  | comActActRegistDO.setAward(isHave ? comActActivityDO.getRewardIntegral() : 0); | 
|---|
|  |  |  | comActActRegistDO.setPosition(comActActRegistVO.getPosition()); | 
|---|
|  |  |  | comActActRegistDO.setTimes(signAllCount+1); | 
|---|
|  |  |  | int result = comActActRegistDAO.insert(comActActRegistDO); | 
|---|
|  |  |  | if (result > 0&&comActActivityDO.getType()!=3) { | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else { | 
|---|
|  |  |  | AddComActIntegralUserDTO addComActIntegralUserDTO = new AddComActIntegralUserDTO(); | 
|---|
|  |  |  | addComActIntegralUserDTO.setUserId(userId); | 
|---|
|  |  |  | addComActIntegralUserDTO.setIntegralType(integralType); | 
|---|
|  |  |  | addComActIntegralUserDTO.setIntegral(retrieveIntegral); | 
|---|
|  |  |  | addComActIntegralUserDTO.setSignIdentity(comActActSignDO.getSignIdentity()); | 
|---|
|  |  |  | addComActIntegralUserDTO.setCommunityId(comActActivityDO.getCommunityId()); | 
|---|
|  |  |  | addComActIntegralUserDTO.setServiceId(activityId); | 
|---|
|  |  |  | addComActIntegralUserDTO.setRemark(remark); | 
|---|
|  |  |  | comActIntegralUserTradeService.addIntegralTradeAdmin(addComActIntegralUserDTO); | 
|---|
|  |  |  | return R.ok(retrieveIntegral); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.fail("网络错误,请重试"); | 
|---|
|  |  |  | //        else { | 
|---|
|  |  |  | //            ComPbActivityDO comPbActivityDO=comBpActivityDAO.selectById(activityId); | 
|---|
|  |  |  | //            if (isNull(comPbActivityDO)) { | 
|---|
|  |  |  | //                return R.fail("活动不存在!"); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //            Date beginAt = comPbActivityDO.getActivityTimeBegin(); | 
|---|
|  |  |  | //            Date endAt = comPbActivityDO.getActivityTimeEnd(); | 
|---|
|  |  |  | //            Date nowDate = new Date(); | 
|---|
|  |  |  | //            if (nowDate.before(beginAt) || nowDate.after(endAt)) { | 
|---|
|  |  |  | //                return R.fail("不在活动时间范围内"); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //            int signDayCount = comActActRegistDAO.selectCount(new QueryWrapper<ComActActRegistDO>() | 
|---|
|  |  |  | //                    .lambda().eq(ComActActRegistDO::getActivityId, activityId).eq(ComActActRegistDO::getUserId, userId).eq(ComActActRegistDO::getCodeId,comActActRegistVO.getCodeId())); | 
|---|
|  |  |  | //            int signAllCount = comActActRegistDAO.selectCount(new QueryWrapper<ComActActRegistDO>() | 
|---|
|  |  |  | //                    .lambda().eq(ComActActRegistDO::getActivityId, activityId).eq(ComActActRegistDO::getUserId, userId)); | 
|---|
|  |  |  | //            if (signDayCount >= 0) { | 
|---|
|  |  |  | //                return R.fail("请扫描新的签到码"); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //            int limit = comPbActivityDO.getLimit().intValue(); | 
|---|
|  |  |  | //            if(limit != -1 && signAllCount >= limit){ | 
|---|
|  |  |  | //                return R.fail("签到次数上限"); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //            ComActActRegistDO comActActRegistDO = new ComActActRegistDO(); | 
|---|
|  |  |  | //            comActActRegistDO.setActivityId(activityId); | 
|---|
|  |  |  | //            comActActRegistDO.setType(2); | 
|---|
|  |  |  | //            comActActRegistDO.setUserId(userId); | 
|---|
|  |  |  | //            comActActRegistDO.setIsVolunteer(comActActRegistVO.getIsVolunteer()); | 
|---|
|  |  |  | //            comActActRegistDO.setCreateAt(nowDate); | 
|---|
|  |  |  | //            comActActRegistDO.setCodeId(comActActRegistVO.getCodeId()); | 
|---|
|  |  |  | //            comActActRegistDO.setAward(comPbActivityDO.getRewardIntegral()); | 
|---|
|  |  |  | //            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(2); | 
|---|
|  |  |  | //                addComActIntegralUserDTO.setCommunityId(comPbActivityDO.getCommunityId()); | 
|---|
|  |  |  | //                addComActIntegralUserDTO.setServiceId(activityId); | 
|---|
|  |  |  | //                comActIntegralUserTradeService.addIntegralTradeAdmin(addComActIntegralUserDTO); | 
|---|
|  |  |  | ////            ValueOperations<String, String> opsForValue = stringRedisTemplate.opsForValue(); | 
|---|
|  |  |  | ////            opsForValue.set(activitySignInKey, "", 1800L, TimeUnit.SECONDS); | 
|---|
|  |  |  | //                return R.ok(); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //            return R.fail("网络错误,请重试"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | int signDayCount = comActActRegistDAO.selectCount(new QueryWrapper<ComActActRegistDO>().lambda() | 
|---|
|  |  |  | .eq(ComActActRegistDO::getActivityId, activityId).eq(ComActActRegistDO::getUserId, userId) | 
|---|
|  |  |  | .eq(ComActActRegistDO::getCodeId, comActActRegistVO.getCodeId())); | 
|---|
|  |  |  | int signAllCount = comActActRegistDAO.selectCount(new QueryWrapper<ComActActRegistDO>().lambda() | 
|---|
|  |  |  | .eq(ComActActRegistDO::getActivityId, activityId).eq(ComActActRegistDO::getUserId, userId)); | 
|---|
|  |  |  | if (signDayCount > 0) { | 
|---|
|  |  |  | return R.fail("请扫描新的签到码"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (isHave) { | 
|---|
|  |  |  | int limit = comActActivityDO.getLimit().intValue(); | 
|---|
|  |  |  | if (limit != -1 && signAllCount >= limit) { | 
|---|
|  |  |  | return R.fail("签到次数上限"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | comActActRegistDO.setActivityId(activityId); | 
|---|
|  |  |  | comActActRegistDO.setStartTime(new Date()); | 
|---|
|  |  |  | comActActRegistDO.setType(comActActivityDO.getType()); | 
|---|
|  |  |  | comActActRegistDO.setUserId(userId); | 
|---|
|  |  |  | comActActRegistDO.setSignIdentity(comActActSignDO.getSignIdentity()); | 
|---|
|  |  |  | comActActRegistDO.setCreateAt(nowDate); | 
|---|
|  |  |  | comActActRegistDO.setCodeId(comActActRegistVO.getCodeId()); | 
|---|
|  |  |  | comActActRegistDO.setAward(0); | 
|---|
|  |  |  | comActActRegistDO.setPosition(comActActRegistVO.getPosition()); | 
|---|
|  |  |  | comActActRegistDO.setCheckUnitId(comActActSignDO.getCheckUnitId()); | 
|---|
|  |  |  | comActActRegistDO.setTimes(signAllCount + 1); | 
|---|
|  |  |  | int result = comActActRegistDAO.insert(comActActRegistDO); | 
|---|
|  |  |  | if (result > 0) { | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.fail("网络错误,请重试"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public R addActivityType(ComActActivityTypeVO comActActivityTypeVO) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | comActActivityTypeVO.setId(Snowflake.getId()); | 
|---|
|  |  |  | this.baseMapper.addActivityType(comActActivityTypeVO); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("添加活动类型错误【{}】", e.getMessage()); | 
|---|