| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import com.panzhihua.common.utlis.DateUtils; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | import com.panzhihua.service_community.dao.ComActDAO; |
| | | import com.panzhihua.service_community.dao.ComActIntegralRuleMapper; |
| | | import com.panzhihua.service_community.dao.ComActIntegralUserMapper; |
| | | import com.panzhihua.service_community.dao.ComActUserWalletMapper; |
| | | import com.panzhihua.service_community.model.dos.ComActDO; |
| | |
| | | import com.panzhihua.service_community.service.ComActIntegralRuleService; |
| | | import com.panzhihua.service_community.service.ComActIntegralUserService; |
| | | import com.panzhihua.service_community.service.ComActIntegralUserTradeService; |
| | | import com.panzhihua.service_community.service.ComActService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | /** |
| | | * @auther lyq |
| | |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ComActIntegralUserServiceImpl extends ServiceImpl<ComActIntegralUserMapper, ComActIntegralUserDO> implements ComActIntegralUserService { |
| | | public class ComActIntegralUserServiceImpl extends ServiceImpl<ComActIntegralUserMapper, ComActIntegralUserDO> |
| | | implements ComActIntegralUserService { |
| | | |
| | | @Resource |
| | | private ComActUserWalletMapper comActUserWalletMapper; |
| | |
| | | |
| | | /** |
| | | * 小程序-查询积分说明 |
| | | * @return 积分说明 |
| | | * |
| | | * @return 积分说明 |
| | | */ |
| | | @Override |
| | | public R getIntegralExplainApplets(){ |
| | | public R getIntegralExplainApplets() { |
| | | String result = ""; |
| | | Map<String,String> resultMap = comActUserWalletMapper.getAgreementContent(0L,6); |
| | | if(resultMap != null){ |
| | | if(StringUtils.isEmpty(resultMap.get("content"))){ |
| | | comActUserWalletMapper.insertSysAgreement(Constants.INTEGRAL_EXPLAIN,"积分规则说明",0L,6); |
| | | Map<String, String> resultMap = comActUserWalletMapper.getAgreementContent(0L, 6); |
| | | if (resultMap != null) { |
| | | if (StringUtils.isEmpty(resultMap.get("content"))) { |
| | | comActUserWalletMapper.insertSysAgreement(Constants.INTEGRAL_EXPLAIN, "积分规则说明", 0L, 6); |
| | | result = Constants.INTEGRAL_EXPLAIN; |
| | | }else{ |
| | | } else { |
| | | result = resultMap.get("content"); |
| | | } |
| | | }else{ |
| | | comActUserWalletMapper.insertSysAgreement(Constants.INTEGRAL_EXPLAIN,"积分规则说明",0L,6); |
| | | } else { |
| | | comActUserWalletMapper.insertSysAgreement(Constants.INTEGRAL_EXPLAIN, "积分规则说明", 0L, 6); |
| | | result = Constants.INTEGRAL_EXPLAIN; |
| | | } |
| | | return R.ok(result); |
| | |
| | | |
| | | /** |
| | | * 用户查询当前社区可领取积分规则列表 |
| | | * @param userId 用户id |
| | | * @param communityId 社区id |
| | | * @return 可领取积分规则列表 |
| | | * |
| | | * @param userId |
| | | * 用户id |
| | | * @param communityId |
| | | * 社区id |
| | | * @return 可领取积分规则列表 |
| | | */ |
| | | @Override |
| | | public R getIntegralReceiveApplets(Long userId,Long communityId){ |
| | | public R getIntegralReceiveApplets(Long userId, Long communityId) { |
| | | |
| | | List<ComActIntegralUserRuleVO> integralUserRuleList = comActIntegralRuleService.getIntegralReceiveApplets(communityId); |
| | | if(integralUserRuleList.isEmpty()){ |
| | | //如果没有查询到列表数据,增给社区增加默认规则列表再查询 |
| | | List<ComActIntegralUserRuleVO> integralUserRuleList = |
| | | comActIntegralRuleService.getIntegralReceiveApplets(communityId); |
| | | if (integralUserRuleList.isEmpty()) { |
| | | // 如果没有查询到列表数据,增给社区增加默认规则列表再查询 |
| | | List<ComActIntegralRuleDO> integralRuleList = comActIntegralRuleService.getIntegralRuleList(communityId); |
| | | comActIntegralRuleService.saveBatch(integralRuleList); |
| | | integralUserRuleList = comActIntegralRuleService.getIntegralReceiveApplets(communityId); |
| | | } |
| | | if(!integralUserRuleList.isEmpty()){ |
| | | if (!integralUserRuleList.isEmpty()) { |
| | | integralUserRuleList.forEach(integralUserRule -> { |
| | | if(integralUserRule.getIsRestrict().equals(ComActIntegralRuleDO.isRestrict.no)){ |
| | | if (integralUserRule.getIsRestrict().equals(ComActIntegralRuleDO.isRestrict.no)) { |
| | | integralUserRule.setIsComplete(ComActIntegralUserRuleVO.isComplete.no); |
| | | }else{ |
| | | } else { |
| | | ComActIntegralCountDTO integralCountDTO = new ComActIntegralCountDTO(); |
| | | integralCountDTO.setUserId(userId); |
| | | integralCountDTO.setCommunityId(communityId); |
| | | integralCountDTO.setType(ComActIntegralUserTradeDO.changeType.add); |
| | | integralCountDTO.setServiceType(integralUserRule.getIntegralType()); |
| | | if(integralUserRule.getType().equals(ComActIntegralRuleDO.type.month)){ |
| | | if (integralUserRule.getType().equals(ComActIntegralRuleDO.type.month)) { |
| | | integralCountDTO.setStartTime(DateUtils.getFirstDayOfMonthString()); |
| | | integralCountDTO.setEndTime(DateUtils.getLastDayOfMonthString()); |
| | | }else if(integralUserRule.getType().equals(ComActIntegralRuleDO.type.day)){ |
| | | } else if (integralUserRule.getType().equals(ComActIntegralRuleDO.type.day)) { |
| | | integralCountDTO.setStartTime(DateUtils.getDayOfMonthString() + " 00:00:00"); |
| | | integralCountDTO.setEndTime(DateUtils.getDayOfMonthString() + " 23:59:59"); |
| | | } |
| | | Integer count = comActIntegralUserTradeService.getIntegralCount(integralCountDTO); |
| | | if(count >= integralUserRule.getCount()){ |
| | | if (count >= integralUserRule.getCount()) { |
| | | integralUserRule.setIsComplete(ComActIntegralUserRuleVO.isComplete.yes); |
| | | }else{ |
| | | } else { |
| | | integralUserRule.setIsComplete(ComActIntegralUserRuleVO.isComplete.no); |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 小程序-查询用户积分列表 |
| | | * @param userId 用户id |
| | | * @return 用户积分列表 |
| | | * |
| | | * @param userId |
| | | * 用户id |
| | | * @return 用户积分列表 |
| | | */ |
| | | @Override |
| | | public R getIntegralUserListApplets(Long userId,Long communityId){ |
| | | public R getIntegralUserListApplets(Long userId, Long communityId) { |
| | | ComActIntegralUserVO integralUserVO = new ComActIntegralUserVO(); |
| | | Integer amount = 0; |
| | | //查询该用户在本社区下的积分账户是否存在,不存在则需要给用户创建 |
| | | ComActIntegralUserDO integralUserDO = this.baseMapper.selectOne(new QueryWrapper<ComActIntegralUserDO>().lambda() |
| | | .eq(ComActIntegralUserDO::getCommunityId,communityId).eq(ComActIntegralUserDO::getUserId,userId)); |
| | | if(integralUserDO == null){ |
| | | // 查询该用户在本社区下的积分账户是否存在,不存在则需要给用户创建 |
| | | ComActIntegralUserDO integralUserDO = |
| | | this.baseMapper.selectOne(new QueryWrapper<ComActIntegralUserDO>().lambda() |
| | | .eq(ComActIntegralUserDO::getCommunityId, communityId).eq(ComActIntegralUserDO::getUserId, userId)); |
| | | if (integralUserDO == null) { |
| | | integralUserDO = new ComActIntegralUserDO(); |
| | | integralUserDO.setCommunityId(communityId); |
| | | integralUserDO.setUserId(userId); |
| | |
| | | this.baseMapper.insert(integralUserDO); |
| | | } |
| | | |
| | | //查询用户积分账户列表 |
| | | // 查询用户积分账户列表 |
| | | List<ComActIntegralUserListVO> integralUserList = this.baseMapper.getIntegralUserListApplets(userId); |
| | | if(!integralUserList.isEmpty()){ |
| | | for (ComActIntegralUserListVO integralUser:integralUserList) { |
| | | //查询用户在本社区积分排行 |
| | | IntegralUserRankVO userRank = this.baseMapper.getIntegralUserRank(integralUser.getCommunityId(),userId); |
| | | if(userRank != null){ |
| | | if (!integralUserList.isEmpty()) { |
| | | for (ComActIntegralUserListVO integralUser : integralUserList) { |
| | | // 查询用户在本社区积分排行 |
| | | IntegralUserRankVO userRank = |
| | | this.baseMapper.getIntegralUserRank(integralUser.getCommunityId(), userId); |
| | | if (userRank != null) { |
| | | integralUser.setRank(userRank.getRank()); |
| | | amount += integralUser.getAmount(); |
| | | } |
| | | } |
| | | } |
| | | //查询用户绑定社区名字 |
| | | // 查询用户绑定社区名字 |
| | | ComActDO actDO = comActDAO.selectById(communityId); |
| | | if(actDO != null){ |
| | | if (actDO != null) { |
| | | integralUserVO.setCommunityName(actDO.getName()); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 查询社区积分账户排行榜 |
| | | * @param communityRankDTO 请求参数 |
| | | * @return 社区积分账户排行榜 |
| | | * |
| | | * @param communityRankDTO |
| | | * 请求参数 |
| | | * @return 社区积分账户排行榜 |
| | | */ |
| | | @Override |
| | | public R getIntegralCommunityRankApplets(ComActIntegralCommunityRankDTO communityRankDTO){ |
| | | return R.ok(this.baseMapper.getIntegralCommunityRankApplets(new Page(communityRankDTO.getPageNum(),communityRankDTO.getPageSize()),communityRankDTO)); |
| | | public R getIntegralCommunityRankApplets(ComActIntegralCommunityRankDTO communityRankDTO) { |
| | | return R.ok(this.baseMapper.getIntegralCommunityRankApplets( |
| | | new Page(communityRankDTO.getPageNum(), communityRankDTO.getPageSize()), communityRankDTO)); |
| | | } |
| | | |
| | | /** |
| | | * 根据社区活动id查询社区活动报名人员列表 |
| | | * @param activityId 活动id |
| | | * @return 社区活动报名人员列表 |
| | | * |
| | | * @param activityId |
| | | * 活动id |
| | | * @return 社区活动报名人员列表 |
| | | */ |
| | | @Override |
| | | public R getTaskActivityPeopleList(Long activityId){ |
| | | public R getTaskActivityPeopleList(Long activityId) { |
| | | return R.ok(this.baseMapper.getTaskActivityPeopleList(activityId)); |
| | | } |
| | | } |