Procházet zdrojové kódy

律师订单接口修改

zhangchen před 1 měsícem
rodič
revize
cbc39f342d

+ 17 - 1
alien-entity/src/main/java/shop/alien/mapper/LawyerConsultationOrderMapper.java

@@ -16,6 +16,7 @@ import shop.alien.entity.store.vo.LifeCouponVo;
 import shop.alien.entity.store.vo.LifeUserExpertOrderVo;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -176,7 +177,7 @@ public interface LawyerConsultationOrderMapper extends BaseMapper<LawyerConsulta
             "        lco.lawyer_user_id,\n" +
             "        lco.problem_scenario_id,\n" +
             "        lco.problem_description,\n" +
-            "        ROUND(IFNULL(lco.order_amount, 0) / 100, 2) as order_amount,\n" +
+            "        lco.order_amount,\n" +
             "        lco.consultation_fee,\n" +
             "        lco.start_time,\n" +
             "        lco.end_time,\n" +
@@ -218,6 +219,21 @@ public interface LawyerConsultationOrderMapper extends BaseMapper<LawyerConsulta
             IPage<LawyerConsultationOrderVO> page, @Param(Constants.WRAPPER) QueryWrapper<LawyerConsultationOrderVO> queryWrapper
     );
 
+    @Select("select\n" +
+            "lco.order_status,\n" +
+            "count(*) as order_count\n" +
+            "FROM\n" +
+            "\tlawyer_consultation_order lco\n" +
+            "LEFT JOIN lawyer_user lu ON\n" +
+            "\tlco.lawyer_user_id = lu.id\n" +
+            "\tAND lu.delete_flag = 0\n" +
+            "left join lawyer_expertise_area lea on\n" +
+            "\tlea.id = lu.lawyer_expertise_area_id\n" +
+            "\tand lea.delete_flag = 0\n" +
+            "left join life_user lur on\n" +
+            "\tlur.id = lco.client_user_id ${ew.customSqlSegment}")
+    @MapKey("order_status")
+    Map<String, Map<String, Object>> getLawyerStatisticsInfo(@Param(Constants.WRAPPER) QueryWrapper<LawyerConsultationOrderVO> queryWrapper);
 
 }
 

+ 16 - 26
alien-lawyer/src/main/java/shop/alien/lawyer/service/impl/LawyerConsultationOrderServiceImpl.java

@@ -768,13 +768,15 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
         QueryWrapper<LawyerConsultationOrderVO> queryWrapper = new QueryWrapper<>();
         if(StringUtils.hasText(orderStatus)){
             queryWrapper.in("lco.order_status", Collections.singletonList(orderStatus));
+        } else {
+            queryWrapper.in("lco.order_status", Arrays.asList("2", "3"));
         }
-        queryWrapper.in("lco.order_status", Arrays.asList("2", "3"));
         queryWrapper.eq("lco.lawyer_user_id", lawyerId);
         if(StringUtils.hasText(clientUserName)){
             queryWrapper.like("lur.user_name", clientUserName);
         }
         queryWrapper.eq("lco.delete_flag", 0);
+        queryWrapper.orderByDesc("lco.created_time");
 
         // 时间范围查询:如果开始时间和结束时间都存在,则进行范围查询
         if (StringUtils.hasText(startDate) && StringUtils.hasText(endDate)) {
@@ -791,17 +793,20 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
             calculateCountdownForPendingOrders(voPage);
         }
 
-        // 统计订单总数
-        long totalCount = voPage != null ? voPage.getTotal() : 0L;
-        resultMap.put("lawyerOrderCount", totalCount);
-
-        // 统计进行中订单数量
-        int inProgressCount = countOrdersByStatus(lawyerId, LawyerStatusEnum.INPROGRESS.getStatus());
-        resultMap.put("lawyerInProgressOrderCount", inProgressCount);
+        //获取统计信息
+        queryWrapper.groupBy("lco.order_status");
+        Map<String, Map<String, Object>> statisticsInfo =  consultationOrderMapper.getLawyerStatisticsInfo(queryWrapper);
 
-        // 统计已完成订单数量
-        int completeCount = countOrdersByStatus(lawyerId, LawyerStatusEnum.COMPLETE.getStatus());
-        resultMap.put("lawyerCompleteOrderCount", completeCount);
+//        // 统计进行中订单数量
+//        int inProgressCount = statisticsInfo.containsKey("2")?Integer.parseInt(statisticsInfo.get("2").toString()): 0;
+//        resultMap.put("lawyerInProgressOrderCount", inProgressCount);
+//
+//        // 统计已完成订单数量
+//        int completeCount = statisticsInfo.containsKey("3")?Integer.parseInt(statisticsInfo.get("3").toString()): 0;
+//        resultMap.put("lawyerCompleteOrderCount", completeCount);
+//
+//        // 统计订单总数
+//        resultMap.put("lawyerOrderCount", inProgressCount + completeCount);
 
         // 设置订单列表
         List<LawyerConsultationOrderVO> orderList = voPage != null && voPage.getRecords() != null
@@ -844,21 +849,6 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
     }
 
     /**
-     * 根据律师ID和订单状态统计订单数量
-     *
-     * @param lawyerId    律师ID
-     * @param orderStatus 订单状态
-     * @return 订单数量
-     */
-    private int countOrdersByStatus(String lawyerId, Integer orderStatus) {
-        LambdaQueryWrapper<LawyerConsultationOrder> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(LawyerConsultationOrder::getLawyerUserId, lawyerId);
-        queryWrapper.eq(LawyerConsultationOrder::getDeleteFlag, 0);
-        queryWrapper.eq(LawyerConsultationOrder::getOrderStatus, orderStatus);
-        return consultationOrderMapper.selectCount(queryWrapper);
-    }
-
-    /**
      * 填充律师信息到订单VO
      *
      * @param orderVO 订单VO对象