| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.panzhihua.service_community.dao.ComActActEvaluateDAO; |
| | | import com.panzhihua.service_community.model.dos.ComActActEvaluateDO; |
| | | import org.apache.commons.lang3.time.DateUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.data.redis.core.ValueOperations; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | |
| | | 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.ComActActRegistVO; |
| | | import com.panzhihua.common.model.vos.community.ActivitySignVO; |
| | | import com.panzhihua.common.model.vos.community.ComActActEvaluateVO; |
| | | 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.SignactivityVO; |
| | | import com.panzhihua.common.model.vos.community.screen.work.ActActivityListVO; |
| | | import com.panzhihua.common.service.user.UserService; |
| | | import com.panzhihua.common.utlis.WxUtil; |
| | | import com.panzhihua.common.utlis.WxXCXTempSend; |
| | | import com.panzhihua.service_community.dao.ComActActEvaluateDAO; |
| | | import com.panzhihua.service_community.dao.ComActActRegistDAO; |
| | | import com.panzhihua.service_community.dao.ComActActSignDAO; |
| | | import com.panzhihua.service_community.dao.ComActActivityDAO; |
| | | import com.panzhihua.service_community.model.dos.ComActActEvaluateDO; |
| | | 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; |
| | |
| | | @Service |
| | | public class ComActActivityServiceImpl extends ServiceImpl<ComActActivityDAO, ComActActivityDO> |
| | | implements ComActActivityService { |
| | | private static final String DELIMITER = ":"; |
| | | private static final String ACTIVITY_SIGN_IN = "ACTIVITY:SIGN:IN"; |
| | | @Resource |
| | | private ComActActivityDAO comActActivityDAO; |
| | | @Resource |
| | |
| | | private UserService userService; |
| | | @Resource |
| | | private ComActActEvaluateDAO comActActEvaluateDAO; |
| | | @Resource |
| | | private StringRedisTemplate stringRedisTemplate; |
| | | @Resource |
| | | private ComActActRegistDAO comActActRegistDAO; |
| | | |
| | | /** |
| | | * 新增社区活动 |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 用户签到 |
| | | * |
| | | * @param comActActRegistVO 签到参数 |
| | | * @return 签到结果 |
| | | */ |
| | | @Override |
| | | public R activitySignIn(ComActActRegistVO comActActRegistVO) { |
| | | Long activityId = comActActRegistVO.getActivityId(); |
| | | Long userId = comActActRegistVO.getUserId(); |
| | | 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(new Date()); |
| | | int result = comActActRegistDAO.insert(comActActRegistDO); |
| | | if (result > 0) { |
| | | ValueOperations<String, String> opsForValue = stringRedisTemplate.opsForValue(); |
| | | opsForValue.set(activitySignInKey, "", 1800L, TimeUnit.SECONDS); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | *用户签到记录列表 |
| | | * |
| | | * @param userId 用id |
| | | * @return 用户签到列表 |
| | | */ |
| | | @Override |
| | | public R listSignInActivity(Long userId) { |
| | | List<ComActActRegistDO> comActActRegistDOS = comActActRegistDAO.selectList(new QueryWrapper<ComActActRegistDO>() |
| | | .lambda().eq(ComActActRegistDO::getUserId, userId)); |
| | | ArrayList<ComActActRegistVO> comActActRegistVOS = new ArrayList<>(); |
| | | comActActRegistDOS.forEach(comActActRegistDO -> { |
| | | ComActActRegistVO comActActRegistVO = new ComActActRegistVO(); |
| | | BeanUtils.copyProperties(comActActRegistDO, comActActRegistVO); |
| | | comActActRegistVOS.add(comActActRegistVO); |
| | | }); |
| | | return R.ok(comActActRegistVOS); |
| | | } |
| | | } |