From de91c84954157bb9f8b6d938cbe0b1b51fb6e65d Mon Sep 17 00:00:00 2001
From: CeDo <cedoogle@gmail.com>
Date: 星期五, 07 五月 2021 15:23:57 +0800
Subject: [PATCH] bugfixed:新增便民服务商家 报错

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActNeighborCircleServiceImpl.java |  123 +++++++++++++++++++++++++++++++++++-----
 1 files changed, 107 insertions(+), 16 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActNeighborCircleServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActNeighborCircleServiceImpl.java
index c82e518..6ab3ae2 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActNeighborCircleServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActNeighborCircleServiceImpl.java
@@ -1,5 +1,6 @@
 package com.panzhihua.service_community.service.impl;
 
+import java.util.ArrayList;
 import java.util.Date;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -84,8 +85,9 @@
                 ComActNeighborCircleFabulousDO circleFabulousDO = comActNeighborCircleFabulousDAO.selectOne(
                         new QueryWrapper<ComActNeighborCircleFabulousDO>().lambda().eq(ComActNeighborCircleFabulousDO::getParentId,circleAppVO.getId())
                 .eq(ComActNeighborCircleFabulousDO::getUserId,neighborCircleAppDTO.getUserId())
-                                .eq(ComActNeighborCircleFabulousDO::getType,ComActNeighborCircleFabulousDO.type.llq));
-                if(circleFabulousDO != null && circleFabulousDO.getIsEffective().equals(ComActNeighborCircleFabulousDO.isEffective.yes)){
+                                .eq(ComActNeighborCircleFabulousDO::getType,ComActNeighborCircleFabulousDO.type.llq)
+                                .eq(ComActNeighborCircleFabulousDO::getIsEffective,ComActNeighborCircleFabulousDO.isEffective.yes));
+                if(circleFabulousDO != null){
                     circleAppVO.setHaveSign(1);
                 }else{
                     circleAppVO.setHaveSign(2);
@@ -139,8 +141,9 @@
         ComActNeighborCircleFabulousDO circleFabulousDO = comActNeighborCircleFabulousDAO.selectOne(
                 new QueryWrapper<ComActNeighborCircleFabulousDO>().lambda().eq(ComActNeighborCircleFabulousDO::getParentId,circleDetailAppVO.getId())
                         .eq(ComActNeighborCircleFabulousDO::getUserId,neighborCircleAppDTO.getUserId())
-                        .eq(ComActNeighborCircleFabulousDO::getType,ComActNeighborCircleFabulousDO.type.llq));
-        if(circleFabulousDO != null && circleFabulousDO.getIsEffective().equals(ComActNeighborCircleFabulousDO.isEffective.yes)){
+                        .eq(ComActNeighborCircleFabulousDO::getType,ComActNeighborCircleFabulousDO.type.llq)
+                        .eq(ComActNeighborCircleFabulousDO::getIsEffective,ComActNeighborCircleFabulousDO.isEffective.yes));
+        if(circleFabulousDO != null){
             circleDetailAppVO.setHaveSign(1);
         }else{
             circleDetailAppVO.setHaveSign(2);
@@ -155,8 +158,9 @@
                 ComActNeighborCircleFabulousDO circleCommentFabulousDO = comActNeighborCircleFabulousDAO.selectOne(
                         new QueryWrapper<ComActNeighborCircleFabulousDO>().lambda().eq(ComActNeighborCircleFabulousDO::getParentId,circleCommentVo.getId())
                                 .eq(ComActNeighborCircleFabulousDO::getUserId,neighborCircleAppDTO.getUserId())
-                                .eq(ComActNeighborCircleFabulousDO::getType,ComActNeighborCircleFabulousDO.type.pl));
-                if(circleCommentFabulousDO != null && circleCommentFabulousDO.getIsEffective().equals(ComActNeighborCircleFabulousDO.isEffective.yes)){
+                                .eq(ComActNeighborCircleFabulousDO::getType,ComActNeighborCircleFabulousDO.type.pl)
+                                .eq(ComActNeighborCircleFabulousDO::getIsEffective,ComActNeighborCircleFabulousDO.isEffective.yes));
+                if(circleCommentFabulousDO != null){
                     circleCommentVo.setHaveSign(1);
                 }else{
                     circleCommentVo.setHaveSign(2);
@@ -164,19 +168,28 @@
                 //查询评论下评论回复
                 List<ComActNeighborCircleCommentReplyAppVO> commentReplyAppVOS = comActNeighborCircleCommentReplyDAO.getCircleCommentReplyList(circleCommentVo.getId());
                 if(!commentReplyAppVOS.isEmpty()){
+                    List<ComActNeighborCircleCommentReplyAppVO> newCommentReplyAppVOS = new ArrayList<>();
+                    int i = 0;
                     for (ComActNeighborCircleCommentReplyAppVO commentReplyVO:commentReplyAppVOS) {
+                        if(i >= 2){
+                            break;
+                        }
                         //查询点赞信息
                         ComActNeighborCircleFabulousDO circleReplyFabulousDO = comActNeighborCircleFabulousDAO.selectOne(
                                 new QueryWrapper<ComActNeighborCircleFabulousDO>().lambda().eq(ComActNeighborCircleFabulousDO::getParentId,commentReplyVO.getId())
                                         .eq(ComActNeighborCircleFabulousDO::getUserId,neighborCircleAppDTO.getUserId())
-                                        .eq(ComActNeighborCircleFabulousDO::getType,ComActNeighborCircleFabulousDO.type.hf));
-                        if(circleReplyFabulousDO != null && circleReplyFabulousDO.getIsEffective().equals(ComActNeighborCircleFabulousDO.isEffective.yes)){
+                                        .eq(ComActNeighborCircleFabulousDO::getType,ComActNeighborCircleFabulousDO.type.hf)
+                                        .eq(ComActNeighborCircleFabulousDO::getIsEffective,ComActNeighborCircleFabulousDO.isEffective.yes));
+                        if(circleReplyFabulousDO != null){
                             commentReplyVO.setHaveSign(1);
                         }else{
                             commentReplyVO.setHaveSign(2);
                         }
+                        newCommentReplyAppVOS.add(commentReplyVO);
+                        i++;
                     }
-                    circleCommentVo.setCircleCommentReplyAppList(commentReplyAppVOS);
+                    circleCommentVo.setCircleCommentReplyAppList(newCommentReplyAppVOS);
+                    circleCommentVo.setCommentReplyNum(commentReplyAppVOS.size());
                 }
             }
         }
@@ -188,6 +201,11 @@
     public R pageNeighborByAdmin(ComActNeighborCircleAdminDTO neighborCircleAdminDTO) {
         Page page = new Page(neighborCircleAdminDTO.getPageNum(), neighborCircleAdminDTO.getPageSize());
         IPage<ComActNeighborCircleAdminVO> doPager = this.baseMapper.pageNeighborByAdmin(page, neighborCircleAdminDTO);
+        doPager.getRecords().forEach(data->{
+            if(data.getUserType()!=1){
+                data.setReleaseName(data.getCommunityName());
+            }
+        });
         return R.ok(doPager);
     }
 
@@ -228,7 +246,7 @@
             neighborCircleDO.setRefuseReason(editVO.getRefuseReason());
         }
         this.baseMapper.updateById(neighborCircleDO);
-        return R.ok();
+        return R.ok(neighborCircleDO.getReleaseId());
     }
 
     /**
@@ -258,6 +276,15 @@
         circleFabulousDO.setParentId(fabulousAppDTO.getServiceId());
         //判断点赞类型
         if(fabulousAppDTO.getType().equals(ComActNeighborFabulousAppDTO.type.llq)){
+
+            ComActNeighborCircleFabulousDO oldCircleFabulousDO = comActNeighborCircleFabulousDAO.selectOne(
+                    new QueryWrapper<ComActNeighborCircleFabulousDO>().lambda().eq(ComActNeighborCircleFabulousDO::getType,ComActNeighborFabulousAppDTO.type.llq)
+                            .eq(ComActNeighborCircleFabulousDO::getParentId,fabulousAppDTO.getServiceId())
+                            .eq(ComActNeighborCircleFabulousDO::getIsEffective,ComActNeighborCircleFabulousDO.isEffective.yes));
+            if(oldCircleFabulousDO != null){
+                return R.fail("您已点赞");
+            }
+
             //增加邻里圈点赞数量
             ComActNeighborCircleDO neighborCircleDO = this.baseMapper.selectById(fabulousAppDTO.getServiceId());
             if(neighborCircleDO != null){
@@ -269,6 +296,13 @@
             //添加邻里圈浏览记录
             comActNeighborCircleBrowseService.addBrowseRecord(fabulousAppDTO.getServiceId(),fabulousAppDTO.getUserId());
         }else if(fabulousAppDTO.getType().equals(ComActNeighborFabulousAppDTO.type.pl)){
+            ComActNeighborCircleFabulousDO oldCircleFabulousDO = comActNeighborCircleFabulousDAO.selectOne(
+                    new QueryWrapper<ComActNeighborCircleFabulousDO>().lambda().eq(ComActNeighborCircleFabulousDO::getType,ComActNeighborFabulousAppDTO.type.pl)
+                            .eq(ComActNeighborCircleFabulousDO::getParentId,fabulousAppDTO.getServiceId())
+                            .eq(ComActNeighborCircleFabulousDO::getIsEffective,ComActNeighborCircleFabulousDO.isEffective.yes));
+            if(oldCircleFabulousDO != null){
+                return R.fail("您已点赞");
+            }
             //增加邻里圈评论点赞数量
             ComActNeighborCircleCommentDO circleCommentDO = comActNeighborCircleCommentDAO.selectById(fabulousAppDTO.getServiceId());
             if(circleCommentDO != null){
@@ -277,6 +311,13 @@
                 circleFabulousDO.setCircleId(circleCommentDO.getCircleId());
             }
         }else if(fabulousAppDTO.getType().equals(ComActNeighborFabulousAppDTO.type.hf)){
+            ComActNeighborCircleFabulousDO oldCircleFabulousDO = comActNeighborCircleFabulousDAO.selectOne(
+                    new QueryWrapper<ComActNeighborCircleFabulousDO>().lambda().eq(ComActNeighborCircleFabulousDO::getType,ComActNeighborFabulousAppDTO.type.hf)
+                            .eq(ComActNeighborCircleFabulousDO::getParentId,fabulousAppDTO.getServiceId())
+                            .eq(ComActNeighborCircleFabulousDO::getIsEffective,ComActNeighborCircleFabulousDO.isEffective.yes));
+            if(oldCircleFabulousDO != null){
+                return R.fail("您已点赞");
+            }
             //增加邻里圈评论回复点赞数量
             ComActNeighborCircleCommentReplyDO circleCommentReplyDO = comActNeighborCircleCommentReplyDAO.selectById(fabulousAppDTO.getServiceId());
             if(circleCommentReplyDO != null){
@@ -454,9 +495,9 @@
         //邻里圈浏览器记录
         neighborCircleBrowseDAO.delete(new LambdaQueryWrapper<ComActNeighborCircleBrowseDO>()
                 .eq(ComActNeighborCircleBrowseDO::getNeighborId, id));
-        //邻里圈点赞删除 需要一层一层删
-/*        neighborCircleFabulousDAO.delete(new LambdaQueryWrapper<ComActNeighborCircleFabulousDO>()
-                .eq(ComActNeighborCircleFabulousDO::get))*/
+        //邻里圈点赞删除
+        neighborCircleFabulousDAO.delete(new LambdaQueryWrapper<ComActNeighborCircleFabulousDO>()
+                .eq(ComActNeighborCircleFabulousDO::getCircleId,id));
         return R.ok();
 
     }
@@ -559,25 +600,48 @@
             circleFabulousDO = comActNeighborCircleFabulousDAO.selectOne(
                     new QueryWrapper<ComActNeighborCircleFabulousDO>().lambda().eq(ComActNeighborCircleFabulousDO::getParentId,fabulousAppDTO.getServiceId())
                             .eq(ComActNeighborCircleFabulousDO::getUserId,fabulousAppDTO.getUserId())
-                            .eq(ComActNeighborCircleFabulousDO::getType,ComActNeighborCircleFabulousDO.type.llq));
+                            .eq(ComActNeighborCircleFabulousDO::getType,ComActNeighborCircleFabulousDO.type.llq)
+                            .eq(ComActNeighborCircleFabulousDO::getIsEffective,ComActNeighborCircleFabulousDO.isEffective.yes));
             if(circleFabulousDO == null){
                 return R.fail("未查询到点赞信息");
+            }
+
+            //减少邻里圈点赞数量
+            ComActNeighborCircleDO neighborCircleDO = this.baseMapper.selectById(fabulousAppDTO.getServiceId());
+            if(neighborCircleDO != null){
+                neighborCircleDO.setFabulousNum(neighborCircleDO.getFabulousNum() - 1);
+                this.baseMapper.updateById(neighborCircleDO);
             }
         }else if(fabulousAppDTO.getType().equals(ComActNeighborFabulousAppDTO.type.pl)){
             circleFabulousDO = comActNeighborCircleFabulousDAO.selectOne(
                     new QueryWrapper<ComActNeighborCircleFabulousDO>().lambda().eq(ComActNeighborCircleFabulousDO::getParentId,fabulousAppDTO.getServiceId())
                             .eq(ComActNeighborCircleFabulousDO::getUserId,fabulousAppDTO.getUserId())
-                            .eq(ComActNeighborCircleFabulousDO::getType,ComActNeighborCircleFabulousDO.type.pl));
+                            .eq(ComActNeighborCircleFabulousDO::getType,ComActNeighborCircleFabulousDO.type.pl)
+                            .eq(ComActNeighborCircleFabulousDO::getIsEffective,ComActNeighborCircleFabulousDO.isEffective.yes));
             if(circleFabulousDO == null){
                 return R.fail("未查询到点赞信息");
+            }
+
+            //减少邻里圈评论点赞数量
+            ComActNeighborCircleCommentDO circleCommentDO = comActNeighborCircleCommentDAO.selectById(fabulousAppDTO.getServiceId());
+            if(circleCommentDO != null){
+                circleCommentDO.setFabulousNum(circleCommentDO.getFabulousNum() - 1);
+                comActNeighborCircleCommentDAO.updateById(circleCommentDO);
             }
         }else if(fabulousAppDTO.getType().equals(ComActNeighborFabulousAppDTO.type.hf)){
             circleFabulousDO = comActNeighborCircleFabulousDAO.selectOne(
                     new QueryWrapper<ComActNeighborCircleFabulousDO>().lambda().eq(ComActNeighborCircleFabulousDO::getParentId,fabulousAppDTO.getServiceId())
                             .eq(ComActNeighborCircleFabulousDO::getUserId,fabulousAppDTO.getUserId())
-                            .eq(ComActNeighborCircleFabulousDO::getType,ComActNeighborCircleFabulousDO.type.hf));
+                            .eq(ComActNeighborCircleFabulousDO::getType,ComActNeighborCircleFabulousDO.type.hf)
+                            .eq(ComActNeighborCircleFabulousDO::getIsEffective,ComActNeighborCircleFabulousDO.isEffective.yes));
             if(circleFabulousDO == null){
                 return R.fail("未查询到点赞信息");
+            }
+            //减少邻里圈评论回复点赞数量
+            ComActNeighborCircleCommentReplyDO circleCommentReplyDO = comActNeighborCircleCommentReplyDAO.selectById(fabulousAppDTO.getServiceId());
+            if(circleCommentReplyDO != null){
+                circleCommentReplyDO.setFabulousNum(circleCommentReplyDO.getFabulousNum() - 1);
+                comActNeighborCircleCommentReplyDAO.updateById(circleCommentReplyDO);
             }
         }
         if(circleFabulousDO != null){
@@ -605,4 +669,31 @@
         }
         return R.ok();
     }
+
+    /**
+     * 分页查询评论下所有回复
+     * @param commentReplyAppDTO    请求参数
+     * @return  回复列表
+     */
+    @Override
+    public R neighborCommentReplyByApp(ComActNeighborCommentReplyAppDTO commentReplyAppDTO){
+        IPage<ComActNeighborCommentReplyAppVO> neighborCircleIPage = this.baseMapper.neighborCommentReplyByApp(
+                new Page<>(commentReplyAppDTO.getPageNum(),commentReplyAppDTO.getPageSize()),commentReplyAppDTO.getCommentId());
+        if(!neighborCircleIPage.getRecords().isEmpty()){
+            for (ComActNeighborCommentReplyAppVO commentReplyAppVO:neighborCircleIPage.getRecords()) {
+                //查询点赞信息
+                ComActNeighborCircleFabulousDO circleFabulousDO = comActNeighborCircleFabulousDAO.selectOne(
+                        new QueryWrapper<ComActNeighborCircleFabulousDO>().lambda().eq(ComActNeighborCircleFabulousDO::getParentId,commentReplyAppVO.getId())
+                                .eq(ComActNeighborCircleFabulousDO::getUserId,commentReplyAppDTO.getUserId())
+                                .eq(ComActNeighborCircleFabulousDO::getType,ComActNeighborCircleFabulousDO.type.hf)
+                                .eq(ComActNeighborCircleFabulousDO::getIsEffective,ComActNeighborCircleFabulousDO.isEffective.yes));
+                if(circleFabulousDO != null){
+                    commentReplyAppVO.setHaveSign(1);
+                }else{
+                    commentReplyAppVO.setHaveSign(2);
+                }
+            }
+        }
+        return R.ok(neighborCircleIPage);
+    }
 }

--
Gitblit v1.7.1