| | |
| | | |
| | | 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.utlis.Snowflake; |
| | | import com.panzhihua.service_community.entity.ComPbCheckUnit; |
| | | import com.panzhihua.common.constants.HttpStatus; |
| | | import com.panzhihua.common.model.dtos.community.ActivityInviteDTO; |
| | | import com.panzhihua.common.model.dtos.community.PageActivityInviteDTO; |
| | | import com.panzhihua.service_community.dao.ComActActivityInviteDAO; |
| | | 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 com.panzhihua.service_community.service.ComActNeighborCircleTopicWestService; |
| | | 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 ComActSocialProjectDao comActSocialProjectDao; |
| | | @Resource |
| | | private ComStreetDAO comStreetDAO; |
| | | @Resource |
| | | private ComPbMemberDAO pbMemberDAO; |
| | | @Resource |
| | | private ComActNeighborCircleTopicWestMapper comActNeighborCircleTopicWestMapper; |
| | | @Resource |
| | | private ComActActivityInviteService comActActivityInviteService; |
| | | |
| | | /** |
| | | * 新增社区活动 |
| | |
| | | */ |
| | | @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(); |
| | |
| | | .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.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(); |
| | | activityUpdate.setId(activityId); |
| | | activityUpdate.setTopicId(topicWestDO.getId()); |
| | | this.baseMapper.updateById(activityUpdate); |
| | | |
| | | //保存上传照片 |
| | | ComActActPictureDO comActActPictureDO = new ComActActPictureDO(); |
| | |
| | | log.error("消息推送失败,失败原因:" + e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | if (comActActivityVO.getHaveIntegralReward().intValue() == 2) { |
| | | comActActivityVO.setRewardWay(null); |
| | | } |
| | | BeanUtils.copyProperties(comActActivityVO, comActActivityDO); |
| | | |
| | |
| | | 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)); |
| | |
| | | comActActivityVO.setSignType(1); |
| | | } |
| | | } |
| | | comActActivityVO.setCodeType(1); |
| | | } |
| | | comActActivityVO.setCodeType(1); |
| | | return comActActivityVO; |
| | | } |
| | | |
| | |
| | | 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); |
| | | 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); |
| | | 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); |
| | | } |
| | | } |
| | |
| | | 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 = "社区活动-党员身份成功参与"; |
| | | 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(comActActRegistDO.getStartTime(), nowDate); |
| | | comActActRegistDO.setId(comActActActRegistDO.getId()); |
| | | comActActRegistDO.setEndTime(nowDate); |
| | | comActActRegistDO.setAward(rewardIntegral * hours); |
| | | 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(rewardIntegral * hours); |
| | | addComActIntegralUserDTO.setSignIdentity(comActActSignDO.getSignIdentity()); |
| | | addComActIntegralUserDTO.setCommunityId(comActActivityDO.getCommunityId()); |
| | | addComActIntegralUserDTO.setServiceId(activityId); |
| | | addComActIntegralUserDTO.setRemark(remark); |
| | | comActIntegralUserTradeService.addIntegralTradeAdmin(addComActIntegralUserDTO); |
| | | return R.ok(rewardIntegral * hours); |
| | | } 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(rewardWay == 1 ? rewardIntegral : 0); |
| | | comActActRegistDO.setPosition(comActActRegistVO.getPosition()); |
| | | comActActRegistDO.setTimes(signAllCount + 1); |
| | | int result = comActActRegistDAO.insert(comActActRegistDO); |
| | | if (result > 0 && isHave && rewardWay == 1) { |
| | | AddComActIntegralUserDTO addComActIntegralUserDTO = new AddComActIntegralUserDTO(); |
| | | addComActIntegralUserDTO.setUserId(userId); |
| | | addComActIntegralUserDTO.setIntegralType(integralType); |
| | | addComActIntegralUserDTO.setIntegral(rewardIntegral); |
| | | addComActIntegralUserDTO.setSignIdentity(comActActSignDO.getSignIdentity()); |
| | | addComActIntegralUserDTO.setCommunityId(comActActivityDO.getCommunityId()); |
| | | addComActIntegralUserDTO.setServiceId(activityId); |
| | | addComActIntegralUserDTO.setRemark(remark); |
| | | comActIntegralUserTradeService.addIntegralTradeAdmin(addComActIntegralUserDTO); |
| | | return R.ok(rewardIntegral); |
| | | } else { |
| | | return R.ok(); |
| | | } |
| | | } |
| | | return R.fail("网络错误,请重试"); |
| | | } |
| | | |
| | | /** |