From 2485a4875adda2ffd0e8cfccdf749f15fe8d48cb Mon Sep 17 00:00:00 2001
From: huliguo <2023611923@qq.com>
Date: 星期四, 17 七月 2025 08:47:48 +0800
Subject: [PATCH] bug修改

---
 ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml |  178 ++++++++++++++++++++++++++++++----------------------------
 1 files changed, 92 insertions(+), 86 deletions(-)

diff --git a/ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml b/ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml
index c1a5b93..0c4e091 100644
--- a/ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml
@@ -7,86 +7,84 @@
         select  COALESCE(SUM(commission_price), 0.00) AS total_commission from tb_order where status in (4,5) and share_user_id =#{id}
     </select>
     <select id="getOrderPage" resultType="com.ruoyi.system.pojo.vo.OrderPageVO">
-        select
-            c.id,
-            o.order_no,
-            publish.user_name as publishName,
-            publish.phone as publishPhone,
-            o.price,
-            book.user_name as bookName,
-            book.phone as bookPhone,
-            c.create_time as createTime,
-            o.create_time as bookTime,
-            o.finish_time as finishTime,
-            -- 状态映射逻辑
+        SELECT
+        c.id,
+        o.order_no,
+        publish.user_name AS publishName,
+        publish.phone AS publishPhone,
+        o.price,
+        book.user_name AS bookName,
+        book.phone AS bookPhone,
+        c.create_time AS createTime,
+        o.create_time AS bookTime,
+        o.finish_time AS finishTime,
+        -- 状态映射逻辑
+        CASE
+        WHEN c.status = -1 THEN -1
+        WHEN c.status = 1 THEN 1
+        WHEN c.status = 2 THEN 7
+        WHEN c.status = 3 THEN 6
+        WHEN c.status = 4 THEN
+        CASE
+        WHEN o.status = 1 THEN 1
+        WHEN o.status = 2 THEN 2
+        WHEN o.status = 3 THEN 3
+        WHEN o.status IN (4, 5) THEN 4
+        WHEN o.status = 6 THEN 6
+        ELSE c.status
+        END
+        ELSE c.status
+        END AS status
+        FROM
+        tb_company c
+        LEFT JOIN tb_order o ON o.company_id = c.id AND o.status != -1
+        LEFT JOIN (SELECT id, user_name, phone FROM tb_user GROUP BY id) publish ON c.user_id = publish.id
+        LEFT JOIN (SELECT id, user_name, phone FROM tb_user GROUP BY id) book ON o.user_id = book.id
+        WHERE
+        c.is_delete = 0
+        <if test="null != dto.orderNo">
+            AND o.order_no LIKE CONCAT('%', #{dto.orderNo}, '%')
+        </if>
+        <if test="null != dto.publishName and '' != dto.publishName">
+            AND publish.user_name LIKE CONCAT('%', #{dto.publishName}, '%')
+        </if>
+        <if test="null != dto.publishPhone and '' != dto.publishPhone">
+            AND publish.phone LIKE CONCAT('%', #{dto.publishPhone}, '%')
+        </if>
+        <if test="null != dto.bookName and '' != dto.bookName">
+            AND book.user_name LIKE CONCAT('%', #{dto.bookName}, '%')
+        </if>
+        <if test="null != dto.bookPhone and '' != dto.bookPhone">
+            AND book.phone LIKE CONCAT('%', #{dto.bookPhone}, '%')
+        </if>
+        <if test="null != dto.createTimeStart and null != dto.createTimeEnd">
+            AND c.create_time BETWEEN #{dto.createTimeStart} AND #{dto.createTimeEnd}
+        </if>
+        <if test="null != dto.bookTimeStart and null != dto.bookTimeEnd">
+            AND o.create_time BETWEEN #{dto.bookTimeStart} AND #{dto.bookTimeEnd}
+        </if>
+        <if test="null != dto.finishTimeStart and null != dto.finishTimeEnd">
+            AND o.finish_time BETWEEN #{dto.finishTimeStart} AND #{dto.finishTimeEnd}
+        </if>
+        <if test="null != dto.status">
+            AND (
+            -- 直接匹配原始状态
+            (c.status IN (1,2,3) AND
             CASE
-                WHEN c.status = 1 THEN 1
-                WHEN c.status = 2 THEN 6
-                WHEN c.status = 3 THEN 5
-                WHEN c.status = 4 THEN
-                    CASE
-                        WHEN o.status = 2 THEN 2
-                        WHEN o.status = 3 THEN 3
-                        WHEN o.status IN (4, 5) THEN 4
-                        ELSE c.status  -- 默认保持原状态(可根据需求调整)
-                        END
-                ELSE c.status  -- 其他状态保持不变
-                END AS status
-        from
-            tb_company c
-        left join tb_order o on c.id = o.company_id and o.status != -1
-        left join (select id,user_name,phone from tb_user group by id) publish on c.user_id = publish.id
-        left join (select id,user_name,phone from tb_user group by id) book on o.user_id = book.id
-        where
-            c.is_delete=0
-
-            <if test="null != dto.orderNo">
-                and o.order_no like concat('%',#{dto.orderNo},'%')
-            </if>
-            <if test="null != dto.publishName and '' != dto.publishName">
-                and publish.user_name like concat('%',#{dto.publishName},'%')
-            </if>
-            <if test="null != dto.publishPhone and '' != dto.publishPhone">
-                and publish.phone like concat('%',#{dto.publishPhone},'%')
-            </if>
-
-            <if test="null != dto.bookName and '' != dto.bookName">
-                and book.user_name like concat('%',#{dto.bookName},'%')
-            </if>
-            <if test="null != dto.bookPhone and '' != dto.bookPhone">
-                and book.phone like concat('%',#{dto.bookPhone},'%')
-            </if>
-
-            <if test="null != dto.createTimeStart and null != dto.createTimeEnd">
-                and c.create_time between #{dto.createTimeStart} and  #{dto.createTimeEnd}
-            </if>
-
-            <if test="null != dto.bookTimeStart and null != dto.bookTimeEnd">
-                and o.create_time between #{dto.bookTimeStart} and  #{dto.bookTimeEnd}
-            </if>
-
-            <if test="null != dto.finishTimeStart and null != dto.finishTimeEnd">
-                and o.finish_time between #{dto.finishTimeStart} and  #{dto.finishTimeEnd}
-            </if>
-
-            <if test="null != dto.status">
-                AND (
-                <!-- 直接匹配原始状态 -->
-                (c.status IN (1,2,3) AND
-                CASE
-                WHEN c.status = 1 THEN 1
-                WHEN c.status = 2 THEN 6
-                WHEN c.status = 3 THEN 5
-                ELSE c.status
-                END = #{dto.status})
-                <!-- 匹配映射后的状态4(c.status=4且o.status=4/5) -->
-                OR (c.status = 4 AND o.status IN (4,5) AND 4 = #{dto.status})
-                <!-- 匹配映射后的状态2(c.status=4且o.status=2) -->
-                OR (c.status = 4 AND o.status = 2 AND 2 = #{dto.status})
-                <!-- 匹配映射后的状态3(c.status=4且o.status=3) -->
-                OR (c.status = 4 AND o.status = 3 AND 3 = #{dto.status})
-                )
-            </if>
+            WHEN c.status = 1 THEN 1
+            WHEN c.status = 2 THEN 6
+            WHEN c.status = 3 THEN 5
+            ELSE c.status
+            END = #{dto.status})
+            -- 匹配映射后的状态4(c.status=4且o.status=4/5)
+            OR (c.status = 4 AND o.status IN (4,5) AND 4 = #{dto.status})
+            -- 匹配映射后的状态2(c.status=4且o.status=2)
+            OR (c.status = 4 AND o.status = 2 AND 2 = #{dto.status})
+            -- 匹配映射后的状态3(c.status=4且o.status=3)
+            OR (c.status = 4 AND o.status = 3 AND 3 = #{dto.status})
+            )
+        order by c.create_time,o.create_time
+        </if>
     </select>
     <select id="getDetailById" resultType="com.ruoyi.system.pojo.vo.OrderDetailVO">
 
@@ -95,8 +93,8 @@
             -- 状态映射逻辑
             CASE
                 WHEN c.status = 1 THEN 1
-                WHEN c.status = 2 THEN 6
-                WHEN c.status = 3 THEN 5
+                WHEN c.status = 2 THEN 7
+                WHEN c.status = 3 THEN 6
                 WHEN c.status = 4 THEN
                     CASE
                         WHEN o.status = 2 THEN 2
@@ -107,6 +105,7 @@
                 ELSE c.status  -- 其他状态保持不变
                 END AS status,
             o.id as orderId,
+
             c.company_name,
             c.establish_time,
             concat(c.city,c.province,c.area) as place,
@@ -144,8 +143,8 @@
                     (
                         CASE
                             WHEN c.status = 1 THEN 1
-                            WHEN c.status = 2 THEN 6
-                            WHEN c.status = 3 THEN 5
+                            WHEN c.status = 2 THEN 7
+                            WHEN c.status = 3 THEN 6
                             WHEN c.status = 4 THEN
                                 CASE
                                     WHEN o.status = 2 THEN 2
@@ -204,6 +203,13 @@
         FROM tb_order
         WHERE status IN (4, 5, 6)
           AND is_refund = 0
+        <if test="null != dto.orderNo and '' != dto.orderNo">
+            and order_no LIKE CONCAT('%', #{dto.orderNo}, '%')
+        </if>
+        <if test="null != dto.operateTimeStart and null != dto.operateTimeEnd">
+            and pay_time between #{dto.operateTimeStart} and #{dto.operateTimeEnd}
+        </if>
+        AND ( #{dto.type} IS NULL  OR 1 = #{dto.type} )
     </select>
     <select id="flowsPage" resultType="com.ruoyi.system.pojo.vo.FinanceFlowsPageVO">
         SELECT
@@ -225,7 +231,7 @@
             <if test="null != dto.operateTimeStart and null != dto.operateTimeEnd">
                 and pay_time between #{dto.operateTimeStart} and #{dto.operateTimeEnd}
             </if>
-        AND ( #{dto.type} IS NULL OR 1 = #{dto.type} )
+        AND ( #{dto.type} IS NULL  OR 1 = #{dto.type} )
         UNION ALL
         SELECT
             order_no,
@@ -243,9 +249,9 @@
         <if test="null != dto.operateTimeStart and null != dto.operateTimeEnd">
             and refund_time between #{dto.operateTimeStart} and #{dto.operateTimeEnd}
         </if>
-        AND ( #{dto.type} IS NULL OR 2 = #{dto.type} )
+        AND ( #{dto.type} IS NULL  OR 2 = #{dto.type} )
         ORDER BY operateTime DESC
-        LIMIT #{dto.pageNum}, #{dto.pageSize};
+        LIMIT #{dto.offset}, #{dto.pageSize};
     </select>
     <select id="countFlowsPage" resultType="java.lang.Long">
         SELECT COUNT(*) FROM (

--
Gitblit v1.7.1