| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import org.springframework.beans.BeanUtils; |
| | | 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.service_community.dao.ComActIntegralRuleMapper; |
| | | import com.panzhihua.service_community.model.dos.ComActIntegralRuleDO; |
| | | import com.panzhihua.service_community.service.ComActIntegralRuleService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | /** |
| | | * @auther lyq |
| | |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ComActIntegralRuleServiceImpl extends ServiceImpl<ComActIntegralRuleMapper, ComActIntegralRuleDO> implements ComActIntegralRuleService { |
| | | public class ComActIntegralRuleServiceImpl extends ServiceImpl<ComActIntegralRuleMapper, ComActIntegralRuleDO> |
| | | implements ComActIntegralRuleService { |
| | | |
| | | /** |
| | | * 查询社区下积分任务列表 |
| | | * @param communityId 社区id |
| | | * @return 查询社区下积分任务列表 |
| | | * |
| | | * @param communityId |
| | | * 社区id |
| | | * @return 查询社区下积分任务列表 |
| | | */ |
| | | @Override |
| | | public List<ComActIntegralUserRuleVO> getIntegralReceiveApplets(Long communityId){ |
| | | public List<ComActIntegralUserRuleVO> getIntegralReceiveApplets(Long communityId) { |
| | | return this.baseMapper.getIntegralReceiveApplets(communityId); |
| | | } |
| | | |
| | | /** |
| | | * 社区后台-根据社区id查询社区下积分规则列表 |
| | | * @param integralRuleDTO 请求参数 |
| | | * @return 社区下积分规则列表 |
| | | * |
| | | * @param integralRuleDTO |
| | | * 请求参数 |
| | | * @return 社区下积分规则列表 |
| | | */ |
| | | @Override |
| | | public R getIntegralRuleAdminList(PageComActIntegralRuleDTO integralRuleDTO){ |
| | | Integer count = this.baseMapper.selectCount(new QueryWrapper<ComActIntegralRuleDO>().lambda().eq(ComActIntegralRuleDO::getCommunityId,integralRuleDTO.getCommunityId())); |
| | | if(count == null || count <= 0){ |
| | | public R getIntegralRuleAdminList(PageComActIntegralRuleDTO integralRuleDTO) { |
| | | Integer count = this.baseMapper.selectCount(new QueryWrapper<ComActIntegralRuleDO>().lambda() |
| | | .eq(ComActIntegralRuleDO::getCommunityId, integralRuleDTO.getCommunityId())); |
| | | if (count == null || count <= 0) { |
| | | List<ComActIntegralRuleDO> integralRuleList = getIntegralRuleList(integralRuleDTO.getCommunityId()); |
| | | this.saveBatch(integralRuleList); |
| | | } |
| | | return R.ok(this.baseMapper.getIntegralRuleAdminList(new Page(integralRuleDTO.getPageNum(),integralRuleDTO.getPageSize()),integralRuleDTO)); |
| | | return R.ok(this.baseMapper.getIntegralRuleAdminList( |
| | | new Page(integralRuleDTO.getPageNum(), integralRuleDTO.getPageSize()), integralRuleDTO)); |
| | | } |
| | | |
| | | /** |
| | | * 加载默认社区积分规则列表 |
| | | * @param communityId 社区id |
| | | * @return 默认积分规则列表 |
| | | * |
| | | * @param communityId |
| | | * 社区id |
| | | * @return 默认积分规则列表 |
| | | */ |
| | | @Override |
| | | public List<ComActIntegralRuleDO> getIntegralRuleList(Long communityId){ |
| | | public List<ComActIntegralRuleDO> getIntegralRuleList(Long communityId) { |
| | | List<ComActIntegralRuleDO> integralRuleList = new ArrayList<>(); |
| | | |
| | | List<ComActIntegralRuleDO> defaultRuleList = this.baseMapper.getIntegralDefaultList(); |
| | | if(!defaultRuleList.isEmpty()){ |
| | | if (!defaultRuleList.isEmpty()) { |
| | | defaultRuleList.forEach(defaultRule -> { |
| | | ComActIntegralRuleDO integralRuleDO = new ComActIntegralRuleDO(); |
| | | integralRuleDO.setCommunityId(communityId); |
| | |
| | | return integralRuleList; |
| | | } |
| | | |
| | | //随手拍默认积分规则 |
| | | // 随手拍默认积分规则 |
| | | ComActIntegralRuleDO integralRuleSSPDO = new ComActIntegralRuleDO(); |
| | | integralRuleSSPDO.setCommunityId(communityId); |
| | | integralRuleSSPDO.setName("发布随手拍"); |
| | |
| | | integralRuleSSPDO.setIntegralType(ComActIntegralRuleDO.integralType.fbssp); |
| | | integralRuleList.add(integralRuleSSPDO); |
| | | |
| | | //微心愿默认积分规则 |
| | | // ComActIntegralRuleDO integralRuleWXYDO = new ComActIntegralRuleDO(); |
| | | // integralRuleWXYDO.setCommunityId(communityId); |
| | | // integralRuleWXYDO.setName("发布微心愿"); |
| | | // integralRuleWXYDO.setAmount(7); |
| | | // integralRuleWXYDO.setIntegralDescribe("发布微心愿并完成后"); |
| | | // integralRuleWXYDO.setIsRestrict(1); |
| | | // integralRuleWXYDO.setType(ComActIntegralRuleDO.type.month); |
| | | // integralRuleWXYDO.setCount(0); |
| | | // integralRuleWXYDO.setIntegralType(ComActIntegralRuleDO.integralType.fbwxy); |
| | | // integralRuleList.add(integralRuleWXYDO); |
| | | // 微心愿默认积分规则 |
| | | // ComActIntegralRuleDO integralRuleWXYDO = new ComActIntegralRuleDO(); |
| | | // integralRuleWXYDO.setCommunityId(communityId); |
| | | // integralRuleWXYDO.setName("发布微心愿"); |
| | | // integralRuleWXYDO.setAmount(7); |
| | | // integralRuleWXYDO.setIntegralDescribe("发布微心愿并完成后"); |
| | | // integralRuleWXYDO.setIsRestrict(1); |
| | | // integralRuleWXYDO.setType(ComActIntegralRuleDO.type.month); |
| | | // integralRuleWXYDO.setCount(0); |
| | | // integralRuleWXYDO.setIntegralType(ComActIntegralRuleDO.integralType.fbwxy); |
| | | // integralRuleList.add(integralRuleWXYDO); |
| | | |
| | | //议事投票默认积分规则 |
| | | // 议事投票默认积分规则 |
| | | ComActIntegralRuleDO integralRuleYSTPDO = new ComActIntegralRuleDO(); |
| | | integralRuleYSTPDO.setCommunityId(communityId); |
| | | integralRuleYSTPDO.setName("参与议事投票"); |
| | |
| | | integralRuleYSTPDO.setIntegralType(ComActIntegralRuleDO.integralType.cyystp); |
| | | integralRuleList.add(integralRuleYSTPDO); |
| | | |
| | | //志愿者活动默认积分规则 |
| | | // ComActIntegralRuleDO integralRuleZYZDO = new ComActIntegralRuleDO(); |
| | | // integralRuleZYZDO.setCommunityId(communityId); |
| | | // integralRuleZYZDO.setName("参与志愿者活动"); |
| | | // integralRuleZYZDO.setAmount(2); |
| | | // integralRuleZYZDO.setIntegralDescribe("报名参加志愿者活动,仅限志愿者"); |
| | | // integralRuleZYZDO.setIsRestrict(1); |
| | | // integralRuleZYZDO.setType(ComActIntegralRuleDO.type.month); |
| | | // integralRuleZYZDO.setCount(0); |
| | | // integralRuleZYZDO.setIntegralType(ComActIntegralRuleDO.integralType.cyzyzhd); |
| | | // integralRuleList.add(integralRuleZYZDO); |
| | | // 志愿者活动默认积分规则 |
| | | // ComActIntegralRuleDO integralRuleZYZDO = new ComActIntegralRuleDO(); |
| | | // integralRuleZYZDO.setCommunityId(communityId); |
| | | // integralRuleZYZDO.setName("参与志愿者活动"); |
| | | // integralRuleZYZDO.setAmount(2); |
| | | // integralRuleZYZDO.setIntegralDescribe("报名参加志愿者活动,仅限志愿者"); |
| | | // integralRuleZYZDO.setIsRestrict(1); |
| | | // integralRuleZYZDO.setType(ComActIntegralRuleDO.type.month); |
| | | // integralRuleZYZDO.setCount(0); |
| | | // integralRuleZYZDO.setIntegralType(ComActIntegralRuleDO.integralType.cyzyzhd); |
| | | // integralRuleList.add(integralRuleZYZDO); |
| | | |
| | | //社区活动默认积分规则 |
| | | // ComActIntegralRuleDO integralRuleSQHDDO = new ComActIntegralRuleDO(); |
| | | // integralRuleSQHDDO.setCommunityId(communityId); |
| | | // integralRuleSQHDDO.setName("参与社区活动"); |
| | | // integralRuleSQHDDO.setAmount(2); |
| | | // integralRuleSQHDDO.setIntegralDescribe("报名参加社区活动,所有人可参与"); |
| | | // integralRuleSQHDDO.setIsRestrict(1); |
| | | // integralRuleSQHDDO.setType(ComActIntegralRuleDO.type.month); |
| | | // integralRuleSQHDDO.setCount(0); |
| | | // integralRuleSQHDDO.setIntegralType(ComActIntegralRuleDO.integralType.cysqhd); |
| | | // integralRuleList.add(integralRuleSQHDDO); |
| | | // 社区活动默认积分规则 |
| | | // ComActIntegralRuleDO integralRuleSQHDDO = new ComActIntegralRuleDO(); |
| | | // integralRuleSQHDDO.setCommunityId(communityId); |
| | | // integralRuleSQHDDO.setName("参与社区活动"); |
| | | // integralRuleSQHDDO.setAmount(2); |
| | | // integralRuleSQHDDO.setIntegralDescribe("报名参加社区活动,所有人可参与"); |
| | | // integralRuleSQHDDO.setIsRestrict(1); |
| | | // integralRuleSQHDDO.setType(ComActIntegralRuleDO.type.month); |
| | | // integralRuleSQHDDO.setCount(0); |
| | | // integralRuleSQHDDO.setIntegralType(ComActIntegralRuleDO.integralType.cysqhd); |
| | | // integralRuleList.add(integralRuleSQHDDO); |
| | | |
| | | //党员活动默认积分规则 |
| | | // ComActIntegralRuleDO integralRuleDYHDDO = new ComActIntegralRuleDO(); |
| | | // integralRuleDYHDDO.setCommunityId(communityId); |
| | | // integralRuleDYHDDO.setName("参与党员活动"); |
| | | // integralRuleDYHDDO.setAmount(1); |
| | | // integralRuleDYHDDO.setIntegralDescribe("报名参加社区党员活动,党员可参与"); |
| | | // integralRuleDYHDDO.setIsRestrict(1); |
| | | // integralRuleDYHDDO.setType(ComActIntegralRuleDO.type.day); |
| | | // integralRuleDYHDDO.setCount(0); |
| | | // integralRuleDYHDDO.setIntegralType(ComActIntegralRuleDO.integralType.cydyhd); |
| | | // integralRuleList.add(integralRuleDYHDDO); |
| | | // 党员活动默认积分规则 |
| | | // ComActIntegralRuleDO integralRuleDYHDDO = new ComActIntegralRuleDO(); |
| | | // integralRuleDYHDDO.setCommunityId(communityId); |
| | | // integralRuleDYHDDO.setName("参与党员活动"); |
| | | // integralRuleDYHDDO.setAmount(1); |
| | | // integralRuleDYHDDO.setIntegralDescribe("报名参加社区党员活动,党员可参与"); |
| | | // integralRuleDYHDDO.setIsRestrict(1); |
| | | // integralRuleDYHDDO.setType(ComActIntegralRuleDO.type.day); |
| | | // integralRuleDYHDDO.setCount(0); |
| | | // integralRuleDYHDDO.setIntegralType(ComActIntegralRuleDO.integralType.cydyhd); |
| | | // integralRuleList.add(integralRuleDYHDDO); |
| | | |
| | | //问卷调查默认积分规则 |
| | | // 问卷调查默认积分规则 |
| | | ComActIntegralRuleDO integralRuleWJDCDO = new ComActIntegralRuleDO(); |
| | | integralRuleWJDCDO.setCommunityId(communityId); |
| | | integralRuleWJDCDO.setName("参与问卷调查"); |
| | |
| | | |
| | | /** |
| | | * 社区后台-编辑社区积分规则 |
| | | * @param integralRuleDTO 请求参数 |
| | | * @return 编辑结果 |
| | | * |
| | | * @param integralRuleDTO |
| | | * 请求参数 |
| | | * @return 编辑结果 |
| | | */ |
| | | @Override |
| | | public R editIntegralRuleAdmin(EditComActIntegralRuleDTO integralRuleDTO){ |
| | | //查询社区积分规则记录 |
| | | public R editIntegralRuleAdmin(EditComActIntegralRuleDTO integralRuleDTO) { |
| | | // 查询社区积分规则记录 |
| | | ComActIntegralRuleDO integralRuleDO = this.baseMapper.selectById(integralRuleDTO.getId()); |
| | | if(integralRuleDO == null){ |
| | | if (integralRuleDO == null) { |
| | | return R.fail("未找到积分规则记录"); |
| | | } |
| | | BeanUtils.copyProperties(integralRuleDTO,integralRuleDO); |
| | | if(integralRuleDTO.getIsRestrict().equals(ComActIntegralRuleDO.isRestrict.no)){ |
| | | BeanUtils.copyProperties(integralRuleDTO, integralRuleDO); |
| | | if (integralRuleDTO.getIsRestrict().equals(ComActIntegralRuleDO.isRestrict.no)) { |
| | | integralRuleDO.setCount(null); |
| | | integralRuleDO.setType(null); |
| | | } |
| | | integralRuleDO.setUpdateAt(new Date()); |
| | | if(this.baseMapper.updateById(integralRuleDO) > 0){ |
| | | if (this.baseMapper.updateById(integralRuleDO) > 0) { |
| | | return R.ok(); |
| | | }else { |
| | | } else { |
| | | return R.fail("修改失败"); |
| | | } |
| | | } |