Parcourir la source

bugfix:商户pc端未回复数量

刘云鑫 il y a 2 mois
Parent
commit
03ad6a3c6e

+ 14 - 0
alien-entity/src/main/java/shop/alien/mapper/CommonRatingMapper.java

@@ -1,5 +1,6 @@
 package shop.alien.mapper;
 
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -72,5 +73,18 @@ public interface CommonRatingMapper extends BaseMapper<CommonRating> {
     int logicDeleteById(@Param("id") Integer id);
 
     IPage<CommonRating> getMyRatingList(Page<CommonRating> page, @Param(Constants.WRAPPER) QueryWrapper<CommonRating> wrapper);
+
+    /**
+     * 分页查询评价列表(支持 wrapper 条件,如 business_id、business_type、audit_status、is_show 等)
+     *
+     * @param page    分页参数
+     * @param wrapper 查询条件,例如:
+     *                wrapper.eq(CommonRating::getBusinessId, businessId);
+     *                wrapper.eq(CommonRating::getBusinessType, businessType);
+     *                wrapper.eq(CommonRating::getAuditStatus, 1);
+     *                wrapper.eq(CommonRating::getIsShow, 1);
+     * @return 分页结果
+     */
+    Integer getRatingWithNoReply( @Param(Constants.WRAPPER) Wrapper<CommonRating> wrapper);
 }
 

+ 17 - 0
alien-entity/src/main/resources/mapper/CommonRatingMapper.xml

@@ -38,5 +38,22 @@
         ${ew.customSqlSegment}
     </select>
 
+    <!-- 分页查询评价列表,条件由 wrapper 传入(如 business_id、business_type、audit_status=1、is_show=1 及 score、NOT EXISTS 等) -->
+    <select id="getRatingWithNoReply" resultType="Integer">
+        SELECT COUNT(*)
+        FROM common_rating
+        ${ew.customSqlSegment}
+        AND NOT EXISTS (
+        SELECT 1
+        FROM common_comment cc
+        WHERE cc.source_type = 1
+        AND cc.source_id = common_rating.id
+        AND cc.comment_type = 2
+        AND cc.is_show = 1
+        AND cc.audit_status = 1
+        AND cc.delete_flag = 0
+        );
+    </select>
+
 </mapper>
 

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

@@ -363,6 +363,9 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
         wrapper.eq(CommonRating::getIsShow, 1);
         List<CommonRating> commonRatings = commonRatingMapper.selectList(wrapper);
         List<Long> collect = commonRatings.stream().map(x -> x.getId()).collect(Collectors.toList());
+        // 查询没有回复的评价数量
+        Integer noReplyCount = commonRatingMapper.getRatingWithNoReply(wrapper);
+
         // 如果为空直接返回
         Map<String, Object> ratingCount = new HashMap<>();
         if(commonRatings.isEmpty()){
@@ -370,7 +373,7 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
         }
         // 获取评价统计信息(总评论数、有图评论数、好评数、中评数、差评数)
         ratingCount = commonRatingMapper.getRatingCount(new QueryWrapper<CommonRating>().in("id", collect));
-
+        ratingCount.put("noReplyCount", noReplyCount);
         // 计算好评、中评、差评占比
         // 注意:数据库返回的 count 可能是 BigDecimal、Long 或 Integer 类型,需要安全转换
         int goodCount = getIntValue(ratingCount.get("goodCount"));