Bladeren bron

评论数量 评价列表 举报评论

qxy 1 dag geleden
bovenliggende
commit
1f5c4f87d3

+ 3 - 3
alien-store/src/main/java/shop/alien/store/controller/StoreCommentController.java

@@ -70,9 +70,9 @@ public class StoreCommentController {
             @ApiImplicitParam(name = "storeId", value = "门店id", dataType = "String", paramType = "query")
     })
     @GetMapping("/getCommitCountAndScore")
-    public R<Map<String, String>> getCommitCountAndScore(Integer businessId, Integer businessType, Integer storeId) {
-        log.info("StoreCommentController.getCommitCountAndScore?businessId={}&businessType={}&storeId={}", businessId, businessType, storeId);
-        return R.data(storeCommentService.getCommitCountAndScore(businessId, businessType, storeId));
+    public R<Map<String, String>> getCommitCountAndScore(Integer businessId, Integer businessType, Integer storeId, String phoneId, Integer days) {
+        log.info("StoreCommentController.getCommitCountAndScore?businessId={}&businessType={}&storeId={}&phoneId={}&days={}", businessId, businessType, storeId, phoneId, days);
+        return R.data(storeCommentService.getCommitCountAndScore(businessId, businessType, storeId, phoneId, days));
     }
 
     @ApiOperation(value = "新增评论(旧)", notes = "0:成功, 1:失败, 2:文本内容异常, 3:图片内容异常")

+ 1 - 1
alien-store/src/main/java/shop/alien/store/service/StoreCommentService.java

@@ -52,7 +52,7 @@ public interface StoreCommentService extends IService<StoreComment> {
      * @param storeId      门店id
      * @return Integer
      */
-    Map<String, String> getCommitCountAndScore(Integer businessId, Integer businessType, Integer storeId);
+    Map<String, String> getCommitCountAndScore(Integer businessId, Integer businessType, Integer storeId, String phoneId, Integer days);
 
     /**
      * 评论

+ 1 - 1
alien-store/src/main/java/shop/alien/store/service/impl/StoreClockInServiceImpl.java

@@ -140,7 +140,7 @@ public class StoreClockInServiceImpl extends ServiceImpl<StoreClockInMapper, Sto
 //            vo.setClockInStoreNum(clockInStoreNumMap.get(vo.getStoreId()));
 //            // 打卡次数
 //            vo.setClockInNum(clockInNum);
-            vo.setCommentCount(Integer.parseInt(storeCommentService.getCommitCountAndScore(vo.getId(), 4, vo.getStoreId()).get("commitCount")));
+            vo.setCommentCount(Integer.parseInt(storeCommentService.getCommitCountAndScore(vo.getId(), 4, vo.getStoreId(),null,null).get("commitCount")));
         });
 
 

+ 90 - 7
alien-store/src/main/java/shop/alien/store/service/impl/StoreCommentServiceImpl.java

@@ -3,6 +3,7 @@ package shop.alien.store.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -12,14 +13,10 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartRequest;
-import shop.alien.entity.store.LifeLikeRecord;
-import shop.alien.entity.store.StoreComment;
-import shop.alien.entity.store.StoreImg;
+import shop.alien.entity.store.*;
 import shop.alien.entity.store.vo.StoreCommentVo;
 import shop.alien.entity.store.vo.StoreCommitPercentVo;
-import shop.alien.mapper.LifeLikeRecordMapper;
-import shop.alien.mapper.StoreCommentMapper;
-import shop.alien.mapper.StoreImgMapper;
+import shop.alien.mapper.*;
 import shop.alien.store.service.StoreCommentService;
 import shop.alien.store.util.FileUploadUtil;
 import shop.alien.util.common.DateUtils;
@@ -52,6 +49,12 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
 
     private final StoreImgMapper storeImgMapper;
 
+    private final LifeUserViolationMapper lifeUserViolationMapper;
+
+    private final StoreUserMapper storeUserMapper;
+
+    private final LifeUserMapper lifeUserMapper;
+
     /**
      * 评论列表
      *
@@ -84,6 +87,41 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
             Date date = DateUtils.calcDays(new Date(), -days);
             queryWrapper.ge("a.created_time", DateUtils.formatDate(date, "yyyy-MM-dd"));
         }
+        //通过当前登录人id 类型 查询举报业务id
+        List<LifeUserViolation> lifeUserViolations = new ArrayList<>();
+        if(businessType==2){
+            String userId;
+            if(phoneId.startsWith("store_")){
+                userId = phoneId.substring("store_".length());
+                StoreUser storeUser = storeUserMapper.selectOne(new LambdaQueryWrapper<StoreUser>().eq(StoreUser::getPhone,userId));
+                if(storeUser!=null){
+                    LambdaQueryWrapper<LifeUserViolation> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+                    lambdaQueryWrapper.eq(LifeUserViolation::getReportingUserId,storeUser.getId());
+                    lambdaQueryWrapper.eq(LifeUserViolation::getReportingUserType,1);
+                    lambdaQueryWrapper.ne(LifeUserViolation::getProcessingStatus,2);
+                    lifeUserViolations = lifeUserViolationMapper.selectList(lambdaQueryWrapper);
+                }
+            }else{
+                userId = phoneId.substring("user_".length());
+                LifeUser lifeUser = lifeUserMapper.selectOne(new LambdaQueryWrapper<LifeUser>().eq(LifeUser::getUserPhone,userId));
+                if(lifeUser!=null){
+                    LambdaQueryWrapper<LifeUserViolation> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+                    lambdaQueryWrapper.eq(LifeUserViolation::getReportingUserId,lifeUser.getId());
+                    lambdaQueryWrapper.eq(LifeUserViolation::getReportingUserType,2);
+                    lambdaQueryWrapper.ne(LifeUserViolation::getProcessingStatus,2);
+                    lifeUserViolations = lifeUserViolationMapper.selectList(lambdaQueryWrapper);
+                }
+            }
+        }
+        List<Integer> businessIds = lifeUserViolations.stream()
+                .filter(Objects::nonNull)
+                .map(LifeUserViolation::getBusinessId)
+                .filter(id -> id != null && !id.toString().isEmpty())
+                .collect(Collectors.toList());
+        if(businessIds!=null && businessIds.size()>0){
+            queryWrapper.notIn("a.id",businessIds);
+        }
+
         //先查询父级评论
         queryWrapper.isNull(businessType != 1, "a.reply_id").eq("a.delete_flag", 0).orderByDesc("a.created_time");
         IPage<StoreCommentVo> page = storeCommentMapper.getCommentPage(storeCommentIPage, queryWrapper);
@@ -145,6 +183,9 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
                 }
             }
             QueryWrapper<StoreCommentVo> childQueryWrapper = new QueryWrapper<>();
+            if(businessIds!=null && businessIds.size()>0){
+                childQueryWrapper.notIn("a.id",businessIds);
+            }
             childQueryWrapper.eq(null != businessId && 6 == businessId, "a.business_id", businessId).eq("a.delete_flag", 0).eq("a.reply_id", storeCommentVo.getId()).orderByDesc("a.created_time");
             List<StoreCommentVo> childCommentList = storeCommentMapper.getCommentList(childQueryWrapper);
             storeCommentVo.setCommitCount(storeCommentVo.getCommitCount() + childCommentList.size());
@@ -255,13 +296,55 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
      * @return Integer
      */
     @Override
-    public Map<String, String> getCommitCountAndScore(Integer businessId, Integer businessType, Integer storeId) {
+    public Map<String, String> getCommitCountAndScore(Integer businessId, Integer businessType, Integer storeId, String phoneId, Integer days) {
         Map<String, String> map = new HashMap<>();
         AtomicReference<Integer> count = new AtomicReference<>(0);
         QueryWrapper<StoreCommentVo> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq(null != businessId, "a.business_id", businessId);
         queryWrapper.eq(null != businessType, "a.business_type", businessType);
         queryWrapper.eq(null != storeId, "a.store_id", storeId);
+
+        if (null != days) {
+            Date date = DateUtils.calcDays(new Date(), -days);
+            queryWrapper.ge("a.created_time", DateUtils.formatDate(date, "yyyy-MM-dd"));
+        }
+
+        //通过当前登录人id 类型 查询举报业务id
+        List<LifeUserViolation> lifeUserViolations = new ArrayList<>();
+        if(businessType==2){
+            String userId;
+            if(phoneId!=null && !phoneId.equals("") && phoneId.startsWith("store_")){
+                userId = phoneId.substring("store_".length());
+                StoreUser storeUser = storeUserMapper.selectOne(new LambdaQueryWrapper<StoreUser>().eq(StoreUser::getPhone,userId));
+                if(storeUser!=null){
+                    LambdaQueryWrapper<LifeUserViolation> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+                    lambdaQueryWrapper.eq(LifeUserViolation::getReportingUserId,storeUser.getId());
+                    lambdaQueryWrapper.eq(LifeUserViolation::getReportingUserType,1);
+                    lambdaQueryWrapper.ne(LifeUserViolation::getProcessingStatus,2);
+                    lifeUserViolations = lifeUserViolationMapper.selectList(lambdaQueryWrapper);
+                }
+            }else if(phoneId!=null && !phoneId.equals("") && phoneId.startsWith("user_")){
+                userId = phoneId.substring("user_".length());
+                LifeUser lifeUser = lifeUserMapper.selectOne(new LambdaQueryWrapper<LifeUser>().eq(LifeUser::getUserPhone,userId));
+                if(lifeUser!=null){
+                    LambdaQueryWrapper<LifeUserViolation> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+                    lambdaQueryWrapper.eq(LifeUserViolation::getReportingUserId,lifeUser.getId());
+                    lambdaQueryWrapper.eq(LifeUserViolation::getReportingUserType,2);
+                    lambdaQueryWrapper.ne(LifeUserViolation::getProcessingStatus,2);
+                    lifeUserViolations = lifeUserViolationMapper.selectList(lambdaQueryWrapper);
+                }
+            }
+        }
+
+        List<Integer> businessIds = lifeUserViolations.stream()
+                .filter(Objects::nonNull)
+                .map(LifeUserViolation::getBusinessId)
+                .filter(id -> id != null && !id.toString().isEmpty())
+                .collect(Collectors.toList());
+        if(businessIds!=null && businessIds.size()>0){
+            queryWrapper.notIn("a.id",businessIds);
+        }
+
         //先查询父级评论
         queryWrapper.isNull(businessType != 1, "a.reply_id").eq("a.delete_flag", 0).orderByDesc("a.created_time");
         List<StoreCommentVo> storeCommentVoList = storeCommentMapper.getCommentList(queryWrapper);