| | |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.panzhihua.common.model.dtos.community.integral.admin.AddComActIntegralUserDTO; |
| | | import com.panzhihua.service_community.dao.*; |
| | | import com.panzhihua.service_community.model.dos.*; |
| | | import com.panzhihua.service_community.service.ComActIntegralUserTradeService; |
| | | import org.apache.commons.lang3.time.DateUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | |
| | | import com.panzhihua.common.service.user.UserService; |
| | | import com.panzhihua.common.utlis.WxUtil; |
| | | import com.panzhihua.common.utlis.WxXCXTempSend; |
| | | 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.service.ComActActivityService; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | private ComActActPictureDAO comActActPictureDAO; |
| | | @Resource |
| | | private ComActActivityCodeDao comActActivityCodeDao; |
| | | @Resource |
| | | private ComBpActivityDAO comBpActivityDAO; |
| | | @Resource |
| | | private ComActIntegralUserTradeService comActIntegralUserTradeService; |
| | | |
| | | /** |
| | | * 新增社区活动 |
| | |
| | | if (isNull(activityId)) { |
| | | return R.fail("签到所属活动id不能为空!"); |
| | | } |
| | | ComActActivityDO comActActivityDO = comActActivityDAO.selectById(activityId); |
| | | if (isNull(comActActivityDO)) { |
| | | return R.fail("活动不存在!"); |
| | | } |
| | | if(comActActRegistVO.getActivityType()==1){ |
| | | ComActActivityDO comActActivityDO = comActActivityDAO.selectById(activityId); |
| | | if (isNull(comActActivityDO)) { |
| | | 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("不在活动时间范围内"); |
| | | } |
| | | |
| | | 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(signAllCount>=comActActivityDO.getLimit()){ |
| | | return R.fail("签到次数上限"); |
| | | } |
| | | int signDayCount = comActActRegistDAO.selectCount(new QueryWrapper<ComActActRegistDO>() |
| | | .lambda().eq(ComActActRegistDO::getActivityId, activityId).eq(ComActActRegistDO::getUserId, userId).eq(ComActActRegistDO::getCodeId,comActActRegistVO.getCodeId()).eq(ComActActRegistDO::getType,1)); |
| | | int signAllCount = comActActRegistDAO.selectCount(new QueryWrapper<ComActActRegistDO>() |
| | | .lambda().eq(ComActActRegistDO::getActivityId, activityId).eq(ComActActRegistDO::getUserId, userId).eq(ComActActRegistDO::getType,1)); |
| | | if (signDayCount >= 0) { |
| | | return R.fail("请扫描新的签到码"); |
| | | } |
| | | if(signAllCount>=comActActivityDO.getLimit()){ |
| | | return R.fail("签到次数上限"); |
| | | } |
| | | |
| | | // String activitySignInKey = String.join(DELIMITER, ACTIVITY_SIGN_IN, userId.toString(), activityId.toString()); |
| | | // if (stringRedisTemplate.hasKey(activitySignInKey)) { |
| | | // return R.fail("你已签到,如要再次签到请三十分钟后尝试!"); |
| | | // } |
| | | ComActActRegistDO comActActRegistDO = new ComActActRegistDO(); |
| | | comActActRegistDO.setActivityId(activityId); |
| | | comActActRegistDO.setUserId(userId); |
| | | comActActRegistDO.setIsVolunteer(comActActRegistVO.getIsVolunteer()); |
| | | comActActRegistDO.setCreateAt(nowDate); |
| | | comActActRegistDO.setCodeId(comActActRegistVO.getCodeId()); |
| | | comActActRegistDO.setAward(comActActivityDO.getRewardIntegral()); |
| | | comActActRegistDO.setPosition(comActActRegistVO.getPosition()); |
| | | comActActRegistDO.setTimes(signAllCount+1); |
| | | int result = comActActRegistDAO.insert(comActActRegistDO); |
| | | if (result > 0) { |
| | | ComActActRegistDO comActActRegistDO = new ComActActRegistDO(); |
| | | comActActRegistDO.setActivityId(activityId); |
| | | comActActRegistDO.setType(1); |
| | | comActActRegistDO.setUserId(userId); |
| | | comActActRegistDO.setIsVolunteer(comActActRegistVO.getIsVolunteer()); |
| | | comActActRegistDO.setCreateAt(nowDate); |
| | | comActActRegistDO.setCodeId(comActActRegistVO.getCodeId()); |
| | | comActActRegistDO.setAward(comActActivityDO.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(1); |
| | | addComActIntegralUserDTO.setCommunityId(comActActivityDO.getCommunityId()); |
| | | addComActIntegralUserDTO.setServiceId(activityId); |
| | | comActIntegralUserTradeService.addIntegralTradeAdmin(addComActIntegralUserDTO); |
| | | // ValueOperations<String, String> opsForValue = stringRedisTemplate.opsForValue(); |
| | | // opsForValue.set(activitySignInKey, "", 1800L, TimeUnit.SECONDS); |
| | | return R.ok(); |
| | | return R.ok(); |
| | | } |
| | | return R.fail("网络错误,请重试"); |
| | | } |
| | | 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()).eq(ComActActRegistDO::getType,2)); |
| | | int signAllCount = comActActRegistDAO.selectCount(new QueryWrapper<ComActActRegistDO>() |
| | | .lambda().eq(ComActActRegistDO::getActivityId, activityId).eq(ComActActRegistDO::getUserId, userId).eq(ComActActRegistDO::getType,2)); |
| | | if (signDayCount >= 0) { |
| | | return R.fail("请扫描新的签到码"); |
| | | } |
| | | if(signAllCount>=comPbActivityDO.getLimit()){ |
| | | 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("网络错误,请重试"); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /** |