Bladeren bron

加入收费类型

zhangchen 5 dagen geleden
bovenliggende
commit
828bba8926

+ 53 - 1
alien-lawyer/src/main/java/shop/alien/lawyer/controller/LawyerClientConsultationOrderController.java

@@ -190,7 +190,7 @@ public class LawyerClientConsultationOrderController {
     @ApiImplicitParams({
             @ApiImplicitParam(name = "id", value = "订单ID", dataType = "String", paramType = "query", required = true)
     })
-    @PutMapping("/orderStartTiming")
+    @GetMapping("/orderStartTiming")
     public R<Boolean> orderStartTiming(@RequestParam(value = "id", required = true) String id) {
         log.info("订单开始计时,订单ID={}", id);
 
@@ -202,5 +202,57 @@ public class LawyerClientConsultationOrderController {
 
         return lawyerClientConsultationOrderService.orderStartTiming(id);
     }
+
+    /**
+     * 检查订单接单后是否有消息记录(律师端)
+     * <p>
+     * 根据订单ID查询订单信息,获取律师接单时间、用户ID和律师ID,
+     * 然后查询 life_message 表,检查是否存在律师发送给用户的消息记录,
+     * 且消息创建时间大于接单时间。
+     * </p>
+     * <p>
+     * 处理流程:
+     * 1. 参数校验:订单ID不能为空
+     * 2. 查询订单信息:获取接单时间、用户ID、律师ID
+     * 3. 查询律师和用户信息:获取律师手机号和用户手机号
+     * 4. 构建消息查询条件:sender_id=律师phone,receiver_id=用户phone,created_time>接单时间
+     * 5. 查询消息记录:如果存在记录返回true,否则返回false
+     * </p>
+     *
+     * @param id 订单ID,不能为空
+     * @return 统一响应结果,true表示有消息记录,false表示无消息记录
+     * @author system
+     * @since 2025-01-XX
+     */
+    @ApiOperation("检查订单接单后是否有消息记录(律师端)")
+    @ApiOperationSupport(order = 8)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "订单ID", dataType = "String", paramType = "query", required = true)
+    })
+    @GetMapping("/checkMessageAfterAccept")
+    public R<Boolean> checkMessageAfterAccept(@RequestParam(value = "id", required = true) String id) {
+        log.info("检查订单接单后是否有消息记录请求开始,订单ID={}", id);
+
+        // 参数校验
+        if (id == null || id.trim().isEmpty()) {
+            log.warn("检查订单接单后是否有消息记录失败:订单ID为空");
+            return R.fail("订单ID不能为空");
+        }
+
+        try {
+            Boolean hasMessage = lawyerClientConsultationOrderService.checkMessageAfterAccept(id);
+            log.info("检查订单接单后是否有消息记录成功,订单ID={},是否有消息={}", id, hasMessage);
+            return R.data(hasMessage);
+        } catch (IllegalArgumentException e) {
+            log.warn("检查订单接单后是否有消息记录参数校验失败,订单ID={},错误信息:{}", id, e.getMessage());
+            return R.fail(e.getMessage());
+        } catch (RuntimeException e) {
+            log.error("检查订单接单后是否有消息记录异常,订单ID={},异常信息:{}", id, e.getMessage(), e);
+            return R.fail("检查消息记录失败:" + e.getMessage());
+        } catch (Exception e) {
+            log.error("检查订单接单后是否有消息记录未知异常,订单ID={},异常信息:{}", id, e.getMessage(), e);
+            return R.fail("检查消息记录失败,请稍后重试");
+        }
+    }
 }
 

+ 17 - 0
alien-lawyer/src/main/java/shop/alien/lawyer/service/LawyerClientConsultationOrderService.java

@@ -88,5 +88,22 @@ public interface LawyerClientConsultationOrderService extends IService<LawyerCon
      * @return R<Boolean> 是否成功
      */
     R<Boolean> refundApplyProcess(LawyerConsultationOrder lawyerConsultationOrder);
+
+    /**
+     * 检查订单接单后是否有消息记录
+     * <p>
+     * 根据订单ID查询订单信息,获取律师接单时间、用户ID和律师ID,
+     * 然后查询 life_message 表,检查是否存在律师发送给用户的消息记录,
+     * 且消息创建时间大于接单时间。
+     * </p>
+     *
+     * @param id 订单ID,不能为空
+     * @return true表示有消息记录,false表示无消息记录
+     * @throws IllegalArgumentException 当订单ID无效时抛出
+     * @throws RuntimeException        当查询异常时抛出
+     * @author system
+     * @since 2025-01-XX
+     */
+    Boolean checkMessageAfterAccept(String id);
 }
 

+ 250 - 0
alien-lawyer/src/main/java/shop/alien/lawyer/service/impl/LawyerClientConsultationOrderServiceImpl.java

@@ -93,6 +93,21 @@ public class LawyerClientConsultationOrderServiceImpl extends ServiceImpl<Lawyer
      */
     private static final long MINUTE_TO_SECOND = 60L;
 
+    /**
+     * 律师发送者ID前缀
+     */
+    private static final String LAWYER_SENDER_PREFIX = "lawyer_";
+
+    /**
+     * 用户接收者ID前缀
+     */
+    private static final String USER_RECEIVER_PREFIX = "user_";
+
+    /**
+     * 删除标记:未删除
+     */
+    private static final Integer DELETE_FLAG_NOT_DELETED = 0;
+
     @Value("${order.coefficient}")
     private String coefficient;
     @Value("${order.coefficients}")
@@ -1588,5 +1603,240 @@ public class LawyerClientConsultationOrderServiceImpl extends ServiceImpl<Lawyer
 
         return lifeNotice;
     }
+
+    /**
+     * 检查订单接单后是否有消息记录
+     * <p>
+     * 根据订单ID查询订单信息,获取律师接单时间、用户ID和律师ID,
+     * 然后查询 life_message 表,检查是否存在律师发送给用户的消息记录,
+     * 且消息创建时间大于接单时间。
+     * </p>
+     * <p>
+     * 处理流程:
+     * 1. 参数校验:订单ID不能为空
+     * 2. 查询订单信息:获取接单时间、用户ID、律师ID
+     * 3. 校验订单信息:订单必须存在,且必须有接单时间
+     * 4. 查询律师信息:获取律师手机号
+     * 5. 查询用户信息:获取用户手机号
+     * 6. 构建消息查询条件:sender_id=律师phone,receiver_id=用户phone,created_time>接单时间
+     * 7. 查询消息记录:如果存在记录返回true,否则返回false
+     * </p>
+     *
+     * @param id 订单ID,不能为空
+     * @return true表示有消息记录,false表示无消息记录
+     * @throws IllegalArgumentException 当订单ID无效或订单不存在时抛出
+     * @throws RuntimeException        当查询异常时抛出
+     * @author system
+     * @since 2025-01-XX
+     */
+    @Override
+    public Boolean checkMessageAfterAccept(String id) {
+        log.info("检查订单接单后是否有消息记录开始,订单ID={}", id);
+
+        // 参数校验
+        validateOrderId(id);
+
+        try {
+            // 查询订单信息
+            LawyerConsultationOrder order = queryOrderById(id);
+
+            // 校验订单信息
+            validateOrderInfo(order, id);
+
+            // 获取接单时间、用户ID、律师ID
+            Date acceptOrdersTime = order.getAcceptOrdersTime();
+            Integer clientUserId = order.getClientUserId();
+            Integer lawyerUserId = order.getLawyerUserId();
+
+            // 查询律师和用户信息,获取手机号
+            String lawyerPhone = queryLawyerPhone(lawyerUserId, id);
+            String userPhone = queryUserPhone(clientUserId, id);
+
+            // 构建消息查询条件并查询
+            boolean hasMessage = queryMessageAfterAccept(lawyerPhone, userPhone, acceptOrdersTime, id);
+
+            log.info("检查订单接单后是否有消息记录完成,订单ID={},是否有消息={}", id, hasMessage);
+            return hasMessage;
+
+        } catch (IllegalArgumentException e) {
+            log.warn("检查订单接单后是否有消息记录参数校验失败,订单ID={},错误信息:{}", id, e.getMessage());
+            throw e;
+        } catch (RuntimeException e) {
+            log.error("检查订单接单后是否有消息记录异常,订单ID={},异常信息:{}", id, e.getMessage(), e);
+            throw new RuntimeException("检查消息记录失败:" + e.getMessage(), e);
+        } catch (Exception e) {
+            log.error("检查订单接单后是否有消息记录未知异常,订单ID={},异常信息:{}", id, e.getMessage(), e);
+            throw new RuntimeException("检查消息记录失败,请稍后重试", e);
+        }
+    }
+
+    /**
+     * 根据订单ID查询订单信息
+     * <p>
+     * 查询订单的详细信息
+     * </p>
+     *
+     * @param id 订单ID
+     * @return 订单信息
+     * @throws RuntimeException 当查询异常时抛出
+     */
+    private LawyerConsultationOrder queryOrderById(String id) {
+        try {
+            LawyerConsultationOrder order = consultationOrderMapper.selectById(id);
+            if (order == null) {
+                log.warn("检查订单接单后是否有消息记录:订单不存在,订单ID={}", id);
+                throw new IllegalArgumentException("订单不存在,订单ID=" + id);
+            }
+            log.debug("查询订单信息成功,订单ID={}", id);
+            return order;
+        } catch (IllegalArgumentException e) {
+            throw e;
+        } catch (Exception e) {
+            log.error("查询订单信息异常,订单ID={},异常信息:{}", id, e.getMessage(), e);
+            throw new RuntimeException("查询订单信息失败:" + e.getMessage(), e);
+        }
+    }
+
+    /**
+     * 校验订单信息
+     * <p>
+     * 检查订单是否包含必要的信息(接单时间、用户ID、律师ID)
+     * </p>
+     *
+     * @param order 订单信息
+     * @param id    订单ID
+     * @throws IllegalArgumentException 当订单信息不完整时抛出
+     */
+    private void validateOrderInfo(LawyerConsultationOrder order, String id) {
+        if (order.getAcceptOrdersTime() == null) {
+            log.warn("检查订单接单后是否有消息记录:订单接单时间为空,订单ID={}", id);
+            throw new IllegalArgumentException("订单接单时间为空,订单ID=" + id);
+        }
+
+        if (order.getClientUserId() == null) {
+            log.warn("检查订单接单后是否有消息记录:订单用户ID为空,订单ID={}", id);
+            throw new IllegalArgumentException("订单用户ID为空,订单ID=" + id);
+        }
+
+        if (order.getLawyerUserId() == null) {
+            log.warn("检查订单接单后是否有消息记录:订单律师ID为空,订单ID={}", id);
+            throw new IllegalArgumentException("订单律师ID为空,订单ID=" + id);
+        }
+    }
+
+    /**
+     * 查询律师手机号
+     * <p>
+     * 根据律师ID查询律师信息,获取手机号
+     * </p>
+     *
+     * @param lawyerUserId 律师ID
+     * @param orderId      订单ID(用于日志)
+     * @return 律师手机号
+     * @throws RuntimeException 当查询异常或律师不存在时抛出
+     */
+    private String queryLawyerPhone(Integer lawyerUserId, String orderId) {
+        try {
+            LawyerUser lawyerUser = lawyerUserMapper.selectById(lawyerUserId);
+            if (lawyerUser == null) {
+                log.warn("检查订单接单后是否有消息记录:律师不存在,律师ID={},订单ID={}", lawyerUserId, orderId);
+                throw new RuntimeException("律师不存在,律师ID=" + lawyerUserId);
+            }
+
+            String phone = lawyerUser.getPhone();
+            if (phone == null || phone.trim().isEmpty()) {
+                log.warn("检查订单接单后是否有消息记录:律师手机号为空,律师ID={},订单ID={}", lawyerUserId, orderId);
+                throw new RuntimeException("律师手机号为空,律师ID=" + lawyerUserId);
+            }
+
+            log.debug("查询律师手机号成功,律师ID={},手机号={}", lawyerUserId, phone);
+            return phone;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            log.error("查询律师手机号异常,律师ID={},订单ID={},异常信息:{}", lawyerUserId, orderId, e.getMessage(), e);
+            throw new RuntimeException("查询律师手机号失败:" + e.getMessage(), e);
+        }
+    }
+
+    /**
+     * 查询用户手机号
+     * <p>
+     * 根据用户ID查询用户信息,获取手机号
+     * </p>
+     *
+     * @param clientUserId 用户ID
+     * @param orderId      订单ID(用于日志)
+     * @return 用户手机号
+     * @throws RuntimeException 当查询异常或用户不存在时抛出
+     */
+    private String queryUserPhone(Integer clientUserId, String orderId) {
+        try {
+            LifeUser lifeUser = lifeUserMapper.selectById(clientUserId);
+            if (lifeUser == null) {
+                log.warn("检查订单接单后是否有消息记录:用户不存在,用户ID={},订单ID={}", clientUserId, orderId);
+                throw new RuntimeException("用户不存在,用户ID=" + clientUserId);
+            }
+
+            String phone = lifeUser.getUserPhone();
+            if (phone == null || phone.trim().isEmpty()) {
+                log.warn("检查订单接单后是否有消息记录:用户手机号为空,用户ID={},订单ID={}", clientUserId, orderId);
+                throw new RuntimeException("用户手机号为空,用户ID=" + clientUserId);
+            }
+
+            log.debug("查询用户手机号成功,用户ID={},手机号={}", clientUserId, phone);
+            return phone;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            log.error("查询用户手机号异常,用户ID={},订单ID={},异常信息:{}", clientUserId, orderId, e.getMessage(), e);
+            throw new RuntimeException("查询用户手机号失败:" + e.getMessage(), e);
+        }
+    }
+
+    /**
+     * 查询接单后的消息记录
+     * <p>
+     * 查询 life_message 表,条件:
+     * - sender_id = 律师phone(格式:lawyer_phone)
+     * - receiver_id = 用户phone(格式:user_phone)
+     * - created_time > 接单时间
+     * </p>
+     *
+     * @param lawyerPhone      律师手机号
+     * @param userPhone        用户手机号
+     * @param acceptOrdersTime 接单时间
+     * @param orderId          订单ID(用于日志)
+     * @return true表示有消息记录,false表示无消息记录
+     */
+    private boolean queryMessageAfterAccept(String lawyerPhone, String userPhone, Date acceptOrdersTime, String orderId) {
+        try {
+            // 构建发送者ID和接收者ID
+            String senderId = LAWYER_SENDER_PREFIX + lawyerPhone;
+            String receiverId = USER_RECEIVER_PREFIX + userPhone;
+
+            // 构建查询条件
+            LambdaQueryWrapper<LifeMessage> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(LifeMessage::getSenderId, senderId)
+                    .eq(LifeMessage::getReceiverId, receiverId)
+                    .gt(LifeMessage::getCreatedTime, acceptOrdersTime)
+                    .eq(LifeMessage::getDeleteFlag, DELETE_FLAG_NOT_DELETED)
+                    .last("LIMIT 1");
+
+            // 查询消息记录(只需要判断是否存在,使用 selectOne 并判断是否为 null)
+            LifeMessage message = lifeMessageMapper.selectOne(queryWrapper);
+
+            boolean hasMessage = message != null;
+            log.debug("查询接单后消息记录完成,订单ID={},发送者ID={},接收者ID={},接单时间={},是否有消息={}",
+                    orderId, senderId, receiverId, acceptOrdersTime, hasMessage);
+
+            return hasMessage;
+        } catch (Exception e) {
+            log.error("查询接单后消息记录异常,订单ID={},律师手机号={},用户手机号={},接单时间={},异常信息:{}",
+                    orderId, lawyerPhone, userPhone, acceptOrdersTime, e.getMessage(), e);
+            // 异常时返回 false,避免影响主流程
+            return false;
+        }
+    }
 }
 

+ 130 - 89
alien-lawyer/src/main/java/shop/alien/lawyer/service/impl/LawyerConsultationOrderServiceImpl.java

@@ -64,6 +64,7 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
     private final LifeMessageMapper lifeMessageMapper;
     private final StoreCommentMapper storeCommentMapper;
     private final LawyerUserViolationMapper lawyerUserViolationMapper;
+    private final CommentAppealMapper commentAppealMapper;
 
     /**
      * 系统发送者ID
@@ -71,6 +72,11 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
     private static final String SYSTEM_SENDER_ID = "system";
 
     /**
+     * 删除标记:未删除
+     */
+    private static final Integer DELETE_FLAG_NOT_DELETED = 0;
+
+    /**
      * 金额单位转换:分转元
      */
     private static final int FEN_TO_YUAN = 100;
@@ -2083,14 +2089,16 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
         // 查询 store_comment 表,businessType=8,businessId=订单ID
         Map<Integer, StoreComment> orderIdToCommentMap = queryStoreCommentByOrderIds(orderIds);
 
-        // 提取 store_comment 的 ID 列表
-        List<Integer> commentIds = orderIdToCommentMap.values().stream()
-                .map(StoreComment::getId)
-                .filter(Objects::nonNull)
-                .collect(Collectors.toList());
+        // 构建订单ID到订单号的映射(用于查询 comment_appeals)
+        Map<Integer, String> orderIdToOrderNumberMap = buildOrderIdToOrderNumberMap(voPage.getRecords());
+
+        // 提取 store_comment 的 ID 列表和对应的订单号
+        Map<Integer, String> commentIdToOrderNumberMap = buildCommentIdToOrderNumberMap(
+                orderIdToCommentMap, orderIdToOrderNumberMap);
 
-        // 查询 lawyer_user_violation 表,report_context_type=3,businessId=store_comment.id
-        Map<Integer, LawyerUserViolation> commentIdToViolationMap = queryLawyerUserViolationByCommentIds(commentIds);
+        // 查询 comment_appeals 表,comment_id=store_comment.id,appeal_number=订单号
+        Map<String, CommentAppeal> commentAppealMap = queryCommentAppealsByCommentIdsAndOrderNumbers(
+                commentIdToOrderNumberMap);
 
         // 为每个订单设置 commonStatus
         for (LawyerConsultationOrderVO orderVO : voPage.getRecords()) {
@@ -2098,7 +2106,8 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
                 continue;
             }
 
-            String commonStatus = calculateCommonStatus(orderVO.getId(), orderIdToCommentMap, commentIdToViolationMap);
+            String commonStatus = calculateCommonStatus(
+                    orderVO.getId(), orderVO.getOrderNumber(), orderIdToCommentMap, commentAppealMap);
             orderVO.setCommonStatus(commonStatus);
         }
 
@@ -2122,7 +2131,7 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
 
         try {
             LambdaQueryWrapper<StoreComment> queryWrapper = new LambdaQueryWrapper<>();
-            queryWrapper.eq(StoreComment::getBusinessType, 8)
+            queryWrapper.eq(StoreComment::getBusinessType, 5)
                     .in(StoreComment::getBusinessId, orderIds)
                     .eq(StoreComment::getDeleteFlag, 0)
                     .orderByDesc(StoreComment::getCreatedTime);
@@ -2165,88 +2174,112 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
     }
 
     /**
-     * 根据评论ID列表查询 lawyer_user_violation 记录
+     * 构建订单ID到订单号的映射
+     * <p>
+     * 从订单VO列表中提取订单ID和订单号的对应关系
+     * </p>
+     *
+     * @param orderList 订单VO列表
+     * @return 订单ID到订单号的映射,key为订单ID,value为订单号
+     */
+    private Map<Integer, String> buildOrderIdToOrderNumberMap(List<LawyerConsultationOrderVO> orderList) {
+        if (CollectionUtils.isEmpty(orderList)) {
+            return Collections.emptyMap();
+        }
+
+        return orderList.stream()
+                .filter(Objects::nonNull)
+                .filter(order -> order.getId() != null && StringUtils.hasText(order.getOrderNumber()))
+                .collect(Collectors.toMap(
+                        LawyerConsultationOrderVO::getId,
+                        LawyerConsultationOrderVO::getOrderNumber,
+                        (existing, replacement) -> existing
+                ));
+    }
+
+    /**
+     * 构建评论ID到订单号的映射
      * <p>
-     * 查询条件:report_context_type=3,businessId=评论ID
+     * 根据订单ID到评论记录的映射和订单ID到订单号的映射,构建评论ID到订单号的映射
      * </p>
+     *
+     * @param orderIdToCommentMap     订单ID到评论记录的映射
+     * @param orderIdToOrderNumberMap  订单ID到订单号的映射
+     * @return 评论ID到订单号的映射,key为评论ID,value为订单号
+     */
+    private Map<Integer, String> buildCommentIdToOrderNumberMap(
+            Map<Integer, StoreComment> orderIdToCommentMap,
+            Map<Integer, String> orderIdToOrderNumberMap) {
+        Map<Integer, String> resultMap = new HashMap<>();
+
+        for (Map.Entry<Integer, StoreComment> entry : orderIdToCommentMap.entrySet()) {
+            Integer orderId = entry.getKey();
+            StoreComment comment = entry.getValue();
+
+            if (comment == null || comment.getId() == null) {
+                continue;
+            }
+
+            String orderNumber = orderIdToOrderNumberMap.get(orderId);
+            if (StringUtils.hasText(orderNumber)) {
+                resultMap.put(comment.getId(), orderNumber);
+            }
+        }
+
+        return resultMap;
+    }
+
+    /**
+     * 根据评论ID和订单号列表查询 comment_appeals 记录
      * <p>
-     * 注意:如果 LawyerUserViolation 表有 businessId 字段,直接通过 businessId 关联
-     * 如果没有 businessId 字段,可能需要通过其他字段(如 order_number)间接关联
+     * 查询条件:comment_id=评论ID,appeal_number=订单号
      * </p>
      *
-     * @param commentIds 评论ID列表
-     * @return 评论ID到举报记录的映射,key为评论ID,value为举报记录
+     * @param commentIdToOrderNumberMap 评论ID到订单号的映射
+     * @return 申诉记录映射,key为"commentId_orderNumber"格式的字符串,value为申诉记录
      */
-    private Map<Integer, LawyerUserViolation> queryLawyerUserViolationByCommentIds(List<Integer> commentIds) {
-        if (CollectionUtils.isEmpty(commentIds)) {
+    private Map<String, CommentAppeal> queryCommentAppealsByCommentIdsAndOrderNumbers(
+            Map<Integer, String> commentIdToOrderNumberMap) {
+        if (commentIdToOrderNumberMap == null || commentIdToOrderNumberMap.isEmpty()) {
             return Collections.emptyMap();
         }
 
         try {
-            // 使用 QueryWrapper 构建查询条件,直接使用字段名
-            // 使用 selectMaps 方法获取所有字段(包括 business_id,即使实体类中没有定义)
-            QueryWrapper<LawyerUserViolation> queryWrapper = new QueryWrapper<>();
-            queryWrapper.select("id", "business_id", "report_context_type", "processing_status", "delete_flag")
-                    .eq("report_context_type", "3")
-                    .eq("delete_flag", 0)
-                    .in("business_id", commentIds);
-            
-            // 使用 selectMaps 获取 Map 列表,可以获取所有字段值
-            List<Map<String, Object>> violationMapList = lawyerUserViolationMapper.selectMaps(queryWrapper);
+            // 提取评论ID列表和订单号列表
+            List<Integer> commentIds = new ArrayList<>(commentIdToOrderNumberMap.keySet());
+            List<String> orderNumbers = new ArrayList<>(commentIdToOrderNumberMap.values());
 
-            // 构建评论ID到举报记录的映射
-            // 从 Map 中提取 business_id 和 processing_status,构建 LawyerUserViolation 对象
-            Map<Integer, LawyerUserViolation> resultMap = new HashMap<>();
-            
-            for (Map<String, Object> violationMap : violationMapList) {
-                Object businessIdObj = violationMap.get("business_id");
-                if (businessIdObj == null) {
-                    continue;
-                }
-                
-                Integer businessId;
-                if (businessIdObj instanceof Integer) {
-                    businessId = (Integer) businessIdObj;
-                } else if (businessIdObj instanceof Number) {
-                    businessId = ((Number) businessIdObj).intValue();
-                } else {
-                    try {
-                        businessId = Integer.parseInt(businessIdObj.toString());
-                    } catch (NumberFormatException e) {
-                        log.warn("business_id 转换失败,跳过该记录,businessIdObj={}", businessIdObj);
-                        continue;
-                    }
-                }
-                
-                if (!commentIds.contains(businessId)) {
+            // 构建查询条件
+            LambdaQueryWrapper<CommentAppeal> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.in(CommentAppeal::getCommentId, commentIds)
+                    .in(CommentAppeal::getAppealNumber, orderNumbers)
+                    .eq(CommentAppeal::getDeleteFlag, DELETE_FLAG_NOT_DELETED);
+
+            List<CommentAppeal> appealList = commentAppealMapper.selectList(queryWrapper);
+
+            // 构建映射:key为"commentId_orderNumber",value为申诉记录
+            Map<String, CommentAppeal> resultMap = new HashMap<>();
+
+            for (CommentAppeal appeal : appealList) {
+                if (appeal == null || appeal.getCommentId() == null || appeal.getAppealNumber() == null) {
                     continue;
                 }
-                
-                // 创建 LawyerUserViolation 对象并设置关键字段
-                LawyerUserViolation violation = new LawyerUserViolation();
-                Object idObj = violationMap.get("id");
-                if (idObj instanceof Integer) {
-                    violation.setId((Integer) idObj);
-                } else if (idObj instanceof Number) {
-                    violation.setId(((Number) idObj).intValue());
-                }
-                
-                Object processingStatusObj = violationMap.get("processing_status");
-                if (processingStatusObj != null) {
-                    violation.setProcessingStatus(processingStatusObj.toString());
+
+                // 验证该申诉记录是否匹配对应的订单号
+                String expectedOrderNumber = commentIdToOrderNumberMap.get(appeal.getCommentId());
+                if (expectedOrderNumber != null && expectedOrderNumber.equals(appeal.getAppealNumber())) {
+                    String key = appeal.getCommentId() + "_" + appeal.getAppealNumber();
+                    resultMap.put(key, appeal);
                 }
-                
-                resultMap.put(businessId, violation);
             }
-            
-            log.debug("查询 lawyer_user_violation 记录成功,commentIds={},查询到记录数={}", 
+
+            log.debug("查询 comment_appeals 记录成功,commentIds={},查询到记录数={}",
                     commentIds, resultMap.size());
-            
+
             return resultMap;
-            
         } catch (Exception e) {
-            log.error("查询 lawyer_user_violation 记录异常,commentIds={},异常信息:{}", commentIds, e.getMessage(), e);
-            // 如果查询失败(可能是字段不存在),返回空映射
+            log.error("查询 comment_appeals 记录异常,commentIdToOrderNumberMap={},异常信息:{}",
+                    commentIdToOrderNumberMap, e.getMessage(), e);
             return Collections.emptyMap();
         }
     }
@@ -2254,17 +2287,22 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
     /**
      * 计算订单的评价状态
      * <p>
-     * 根据查询结果计算订单的 commonStatus 值
+     * 根据查询结果计算订单的 commonStatus 值:
+     * 1. 如果 store_comment 表中没有记录,则 commonStatus=1
+     * 2. 如果 comment_appeals 表中没有记录,或者 processing_status 为 0 或 1,则 commonStatus=2
+     * 3. 其他情况 commonStatus=3
      * </p>
      *
-     * @param orderId                 订单ID
-     * @param orderIdToCommentMap     订单ID到评论记录的映射
-     * @param commentIdToViolationMap 评论ID到举报记录的映射
+     * @param orderId               订单ID
+     * @param orderNumber           订单号
+     * @param orderIdToCommentMap   订单ID到评论记录的映射
+     * @param commentAppealMap      申诉记录映射,key为"commentId_orderNumber"格式
      * @return 评价状态字符串("1"、"2"或"3")
      */
     private String calculateCommonStatus(Integer orderId,
+                                        String orderNumber,
                                         Map<Integer, StoreComment> orderIdToCommentMap,
-                                        Map<Integer, LawyerUserViolation> commentIdToViolationMap) {
+                                        Map<String, CommentAppeal> commentAppealMap) {
         // 第一步:查询 store_comment 表
         StoreComment comment = orderIdToCommentMap.get(orderId);
 
@@ -2274,25 +2312,28 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
             return "1";
         }
 
-        // 第二步:查询 lawyer_user_violation 表
-        LawyerUserViolation violation = commentIdToViolationMap.get(comment.getId());
+        // 第二步:查询 comment_appeals 表
+        // 构建查询key:commentId_orderNumber
+        String appealKey = comment.getId() + "_" + orderNumber;
+        CommentAppeal appeal = commentAppealMap.get(appealKey);
 
-        // 如果关联不出来或者关联出来的 processing_status 为 0 或者 1,则 commonStatus=2
-        if (violation == null) {
-            log.debug("评论未找到举报记录,设置 commonStatus=2,orderId={}, commentId={}", orderId, comment.getId());
+        // 如果关联不出来或者关联出来的 status 为 0 或者 1,则 commonStatus=2
+        if (appeal == null) {
+            log.debug("评论未找到申诉记录,设置 commonStatus=2,orderId={}, commentId={}, orderNumber={}",
+                    orderId, comment.getId(), orderNumber);
             return "2";
         }
 
-        String processingStatus = violation.getProcessingStatus();
-        if (processingStatus == null || "0".equals(processingStatus) || "1".equals(processingStatus)) {
-            log.debug("举报记录处理状态为0或1,设置 commonStatus=2,orderId={}, commentId={}, processingStatus={}",
-                    orderId, comment.getId(), processingStatus);
+        Integer status = appeal.getStatus();
+        if (status == null || status == 0 || status == 1) {
+            log.debug("申诉记录处理状态为0或1,设置 commonStatus=2,orderId={}, commentId={}, orderNumber={}, status={}",
+                    orderId, comment.getId(), orderNumber, status);
             return "2";
         }
 
         // 其他情况 commonStatus=3
-        log.debug("设置 commonStatus=3,orderId={}, commentId={}, processingStatus={}",
-                orderId, comment.getId(), processingStatus);
+        log.debug("设置 commonStatus=3,orderId={}, commentId={}, orderNumber={}, status={}",
+                orderId, comment.getId(), orderNumber, status);
         return "3";
     }