|
|
@@ -815,4 +815,55 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
|
|
|
}
|
|
|
return commentOrderPage;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取店铺评价计数统计
|
|
|
+ *
|
|
|
+ * @param storeId 门店id
|
|
|
+ * @return StoreCommentCountVo
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public StoreCommentCountVo getAppraiseCount(Integer storeId) {
|
|
|
+ StoreCommentCountVo countVo = new StoreCommentCountVo();
|
|
|
+
|
|
|
+ // 查询条件:只统计当前门店、根评论(reply_id为null)、未删除的评论
|
|
|
+ LambdaQueryWrapper<StoreComment> totalWrapper = buildBaseStoreCommentWrapper(storeId);
|
|
|
+ countVo.setTotalCount(storeCommentMapper.selectCount(totalWrapper));
|
|
|
+
|
|
|
+ // 2. 有图评论数(img_id不为空且不为空字符串)
|
|
|
+ LambdaQueryWrapper<StoreComment> imageWrapper = buildBaseStoreCommentWrapper(storeId);
|
|
|
+ imageWrapper.isNotNull(StoreComment::getImgId)
|
|
|
+ .apply("img_id != ''");
|
|
|
+ countVo.setImageCount(storeCommentMapper.selectCount(imageWrapper));
|
|
|
+
|
|
|
+ // 3. 好评数(score >= 4.5)
|
|
|
+ LambdaQueryWrapper<StoreComment> goodWrapper = buildBaseStoreCommentWrapper(storeId);
|
|
|
+ goodWrapper.ge(StoreComment::getScore, 4.5);
|
|
|
+ countVo.setGoodCount(storeCommentMapper.selectCount(goodWrapper));
|
|
|
+
|
|
|
+ // 4. 中评数(score >= 3 && score <= 4)
|
|
|
+ LambdaQueryWrapper<StoreComment> midWrapper = buildBaseStoreCommentWrapper(storeId);
|
|
|
+ midWrapper.ge(StoreComment::getScore, 3.0)
|
|
|
+ .le(StoreComment::getScore, 4.0);
|
|
|
+ countVo.setMidCount(storeCommentMapper.selectCount(midWrapper));
|
|
|
+
|
|
|
+ // 5. 差评数(score >= 0.5 && score <= 2.5)
|
|
|
+ LambdaQueryWrapper<StoreComment> badWrapper = buildBaseStoreCommentWrapper(storeId);
|
|
|
+ badWrapper.ge(StoreComment::getScore, 0.5)
|
|
|
+ .le(StoreComment::getScore, 2.5);
|
|
|
+ countVo.setBadCount(storeCommentMapper.selectCount(badWrapper));
|
|
|
+
|
|
|
+ return countVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构建当前门店根评论的查询条件
|
|
|
+ */
|
|
|
+ private LambdaQueryWrapper<StoreComment> buildBaseStoreCommentWrapper(Integer storeId) {
|
|
|
+ return new LambdaQueryWrapper<StoreComment>()
|
|
|
+ .eq(StoreComment::getStoreId, storeId)
|
|
|
+ .gt(StoreComment::getScore,0 )
|
|
|
+ .eq(StoreComment::getBusinessType, 5)
|
|
|
+ .eq(StoreComment::getDeleteFlag, 0);
|
|
|
+ }
|
|
|
}
|