Pārlūkot izejas kodu

中台 对账 订单数量 订单金额

qxy 5 dienas atpakaļ
vecāks
revīzija
3f8f94949d

+ 15 - 11
alien-entity/src/main/resources/mapper/LawFirmMapper.xml

@@ -71,17 +71,19 @@
                 SELECT
                     COUNT(DISTINCT lco.id) as order_count,
                     COALESCE(SUM(lco.order_amount), 0) as total_amount
-                FROM law_firm lf
-                LEFT JOIN lawyer_consultation_order lco ON lco.place_id = lf.id
-                    AND lco.delete_flag = 0
-                    AND lco.order_status = 3
+                FROM lawyer_consultation_order lco
+                INNER JOIN lawyer_user lu ON lco.lawyer_user_id = lu.id
+                AND lu.delete_flag = 0
+                LEFT JOIN law_firm lf ON lf.id = lu.firm_id
+                    AND lf.delete_flag = 0
                     <if test="startDate != null">
                         AND lco.order_time &gt;= CONCAT(#{startDate}, ' 00:00:00')
                     </if>
                     <if test="endDate != null">
                         AND lco.order_time &lt;= CONCAT(#{endDate}, ' 23:59:59')
                     </if>
-                WHERE lf.delete_flag = 0
+                WHERE lco.delete_flag = 0
+                    AND lco.order_status = 3
                     AND lf.id = #{firmId}
             </when>
             <otherwise>
@@ -90,8 +92,10 @@
                     COUNT(DISTINCT lco.id) as order_count,
                     COALESCE(SUM(lco.order_amount), 0) as total_amount
                 FROM lawyer_consultation_order lco
-                LEFT JOIN law_firm lf ON lco.place_id = lf.id
-                    AND lf.delete_flag = 0
+                INNER JOIN lawyer_user lu ON lco.lawyer_user_id = lu.id
+                AND lu.delete_flag = 0
+                LEFT JOIN law_firm lf ON lf.id = lu.firm_id
+                AND lf.delete_flag = 0
                 WHERE
                 <include refid="Order_Common_Where"/>
                 <if test="firmName != null and firmName != ''">
@@ -130,7 +134,8 @@
             COUNT(DISTINCT lco.id) as order_count,
             CAST(ROUND(COALESCE(SUM(lco.order_amount), 0) / 100.0, 2) AS CHAR) as total_amount_yuan
         FROM law_firm lf
-        LEFT JOIN lawyer_consultation_order lco ON lco.place_id = lf.id
+        LEFT JOIN lawyer_user lu ON lf.id = lu.firm_id
+        LEFT JOIN lawyer_consultation_order lco ON lco.lawyer_user_id = lu.id
             AND lco.delete_flag = 0
             AND lco.order_status = 3
             <if test="startDate != null">
@@ -144,7 +149,7 @@
             AND lf.firm_name LIKE CONCAT('%', #{firmName}, '%')
         </if>
         GROUP BY lf.id, lf.firm_name
-        ORDER BY COALESCE(SUM(lco.lawyer_earnings), 0) DESC
+        ORDER BY COALESCE(SUM(lco.order_amount), 0) DESC
     </select>
 
     <!-- 查询律所下所有律师的对账统计信息(按律师分组) -->
@@ -194,7 +199,6 @@
             AND lf.delete_flag = 0
             AND lf.id = #{firmId}
         LEFT JOIN lawyer_consultation_order lco ON lco.lawyer_user_id = lu.id
-            AND lco.place_id = #{firmId}
             AND lco.delete_flag = 0
             AND lco.order_status = 3
             <if test="startDate != null">
@@ -208,7 +212,7 @@
             AND lu.name LIKE CONCAT('%', #{lawyerName}, '%')
         </if>
         GROUP BY lu.id, lu.name, lu.head_img, lu.lawyer_certificate_no, lf.id, lf.firm_name
-        ORDER BY COALESCE(SUM(lco.lawyer_earnings), 0) DESC
+        ORDER BY COALESCE(SUM(lco.order_amount), 0) DESC
     </select>
 
     <!-- 查询律师的已完成订单列表(分页) -->

+ 1 - 1
alien-store/src/main/java/shop/alien/store/controller/LawyerLegalProblemScenarioController.java

@@ -1,4 +1,4 @@
-package shop.alien.lawyer.controller;
+package shop.alien.store.controller;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import io.swagger.annotations.*;