|
|
@@ -2194,7 +2194,10 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
|
|
|
// 查询 comment_appeals 表,comment_id=lawyer_order_review.id
|
|
|
Map<Integer, CommentAppeal> reviewIdToAppealMap = queryCommentAppealsByReviewIds(reviewIds);
|
|
|
|
|
|
- // 为每个订单设置 commonStatus
|
|
|
+ // 直接根据订单ID查询申诉记录(包括已删除评论对应的申诉)
|
|
|
+ Map<Integer, CommentAppeal> orderIdToAppealMap = queryCommentAppealsByOrderIds(orderIds);
|
|
|
+
|
|
|
+ // 为每个订单设置 commonStatus 和 canCommentAgain
|
|
|
for (LawyerConsultationOrderVO orderVO : voPage.getRecords()) {
|
|
|
if (orderVO == null || orderVO.getId() == null) {
|
|
|
continue;
|
|
|
@@ -2203,6 +2206,29 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
|
|
|
String commonStatus = calculateCommonStatus(
|
|
|
orderVO.getId(), orderIdToReviewMap, reviewIdToAppealMap);
|
|
|
orderVO.setCommonStatus(commonStatus);
|
|
|
+
|
|
|
+ // 判断是否允许再次评论
|
|
|
+ // 规则:
|
|
|
+ // 1. 如果订单已经有评价(评价存在且未删除),不允许再次评论
|
|
|
+ // 2. 如果订单没有评价,但有申诉记录且申诉状态为1(已通过),说明评论被举报且举报通过(评论被删除),不允许再次评论
|
|
|
+ // 3. 其他情况,允许评论
|
|
|
+ OrderReview existingReview = orderIdToReviewMap.get(orderVO.getId());
|
|
|
+ CommentAppeal appeal = orderIdToAppealMap.get(orderVO.getId());
|
|
|
+
|
|
|
+ if (existingReview != null) {
|
|
|
+ // 订单已经有评价(评价存在且未删除),不允许再次评论
|
|
|
+ orderVO.setCanCommentAgain(false);
|
|
|
+ log.debug("订单已有评价,不允许再次评论,orderId={}, reviewId={}",
|
|
|
+ orderVO.getId(), existingReview.getId());
|
|
|
+ } else if (appeal != null && appeal.getStatus() != null && appeal.getStatus() == 1) {
|
|
|
+ // 订单没有评价,但有申诉记录且申诉状态为1(已通过),说明评论被举报且举报通过(评论被删除),不允许再次评论
|
|
|
+ orderVO.setCanCommentAgain(false);
|
|
|
+ log.debug("订单评论被举报且举报通过,不允许再次评论,orderId={}, appealStatus={}",
|
|
|
+ orderVO.getId(), appeal.getStatus());
|
|
|
+ } else {
|
|
|
+ // 其他情况(没有评价且没有申诉记录,或申诉未通过),允许评论
|
|
|
+ orderVO.setCanCommentAgain(true);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
log.debug("设置订单评价状态完成,订单数量={}", voPage.getRecords().size());
|
|
|
@@ -2315,6 +2341,55 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 根据订单ID列表查询 comment_appeals 记录
|
|
|
+ * <p>
|
|
|
+ * 查询条件:order_id=订单ID
|
|
|
+ * 用于判断订单是否曾经有评论被申诉且申诉通过(评论被删除)
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @param orderIds 订单ID列表
|
|
|
+ * @return 订单ID到申诉记录的映射,key为订单ID,value为申诉记录
|
|
|
+ */
|
|
|
+ private Map<Integer, CommentAppeal> queryCommentAppealsByOrderIds(List<Integer> orderIds) {
|
|
|
+ if (CollectionUtils.isEmpty(orderIds)) {
|
|
|
+ return Collections.emptyMap();
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 构建查询条件
|
|
|
+ LambdaQueryWrapper<CommentAppeal> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(CommentAppeal::getOrderId, orderIds)
|
|
|
+ .eq(CommentAppeal::getDeleteFlag, DELETE_FLAG_NOT_DELETED);
|
|
|
+
|
|
|
+ List<CommentAppeal> appealList = commentAppealMapper.selectList(queryWrapper);
|
|
|
+
|
|
|
+ // 构建映射:key为订单ID,value为申诉记录
|
|
|
+ // 如果一个订单有多个申诉记录,只取第一个(通常一个订单应该只有一个申诉记录)
|
|
|
+ Map<Integer, CommentAppeal> resultMap = new HashMap<>();
|
|
|
+
|
|
|
+ for (CommentAppeal appeal : appealList) {
|
|
|
+ if (appeal == null || appeal.getOrderId() == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果已经存在该订单的申诉记录,保留第一个(先查询到的)
|
|
|
+ if (!resultMap.containsKey(appeal.getOrderId())) {
|
|
|
+ resultMap.put(appeal.getOrderId(), appeal);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ log.debug("根据订单ID查询 comment_appeals 记录成功,orderIds={},查询到记录数={}",
|
|
|
+ orderIds, resultMap.size());
|
|
|
+
|
|
|
+ return resultMap;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("根据订单ID查询 comment_appeals 记录异常,orderIds={},异常信息:{}",
|
|
|
+ orderIds, e.getMessage(), e);
|
|
|
+ return Collections.emptyMap();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 计算订单的评价状态
|
|
|
* <p>
|
|
|
* 根据查询结果计算订单的 commonStatus 值:
|