From 3d7b7ffc07551c6c7c8236286d5f4f3620aa6a2f Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期五, 17 七月 2026 13:47:08 +0800
Subject: [PATCH] 修改后台报表充电数据查询bug

---
 ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml |   42 ++++++++++++++++++++----------------------
 1 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
index 9eaf884..12ad065 100644
--- a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
+++ b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
@@ -490,7 +490,7 @@
         FROM
         t_charging_order_accounting_strategy t1
         LEFT JOIN t_charging_order t2 on t1.charging_order_id = t2.id
-        where t2.del_flag = 0 and t2.recharge_payment_status = 2 and t2.start_time between #{start} and #{end}
+        where t2.del_flag = 0 and t2.recharge_payment_status = 2 and t2.start_time IS NOT NULL and t2.end_time is not null and t2.pay_time between #{start} and #{end}
         <if test="null != siteIds and siteIds.size() > 0">
             and t2.site_id in
             <foreach collection="siteIds" separator="," open="(" close=")" item="item" index="index">
@@ -502,7 +502,7 @@
     </select>
     <select id="getDateData" resultType="java.util.Map">
         SELECT
-        DATE_FORMAT(a.create_time, '%H:00' ) as time,
+        DATE_FORMAT(a.pay_time, '%H:00' ) as time,
         SUM(CASE
         WHEN a.order_source = 0 THEN b.period_service_price
         WHEN a.order_source = 1 THEN b.period_service_price
@@ -522,8 +522,8 @@
         sum(period_service_price) as period_service_price, sum(period_electric_price + period_service_price) as money
         from t_charging_order_accounting_strategy group by charging_order_id) b on (a.id = b.charging_order_id)
         <where>
-            a.del_flag = 0 and a.recharge_payment_status = 2 and DATE(a.create_time) = CURDATE()
-            and a.start_time between #{start} and #{end}
+            a.del_flag = 0 and a.recharge_payment_status = 2 and a.start_time IS NOT NULL and a.end_time is not null
+            and a.pay_time between #{start} and #{end}
             <if test="null != siteIds and siteIds.size() > 0">
                 and a.site_id in
                 <foreach collection="siteIds" separator="," open="(" close=")" item="item" index="index">
@@ -539,7 +539,7 @@
     </select>
     <select id="getWeekData" resultType="java.util.Map">
         SELECT
-        DATE_FORMAT(a.create_time, '%Y-%m-%d' ) as time,
+        DATE_FORMAT(a.pay_time, '%Y-%m-%d' ) as time,
         SUM(CASE
         WHEN a.order_source = 0 THEN b.period_service_price
         WHEN a.order_source = 1 THEN b.period_service_price
@@ -559,9 +559,8 @@
         sum(period_service_price) as period_service_price, sum(period_electric_price + period_service_price) as money
         from t_charging_order_accounting_strategy group by charging_order_id) b on (a.id = b.charging_order_id)
         <where>
-            a.del_flag = 0 and a.recharge_payment_status = 2 and YEARWEEK(DATE_FORMAT(a.create_time,
-            '%Y-%m-%d'), 1) = YEARWEEK(NOW(), 1)
-            and a.start_time between #{start} and #{end}
+            a.del_flag = 0 and a.recharge_payment_status = 2 and a.start_time IS NOT NULL and a.end_time is not null
+            and a.pay_time between #{start} and #{end}
             <if test="null != siteIds and siteIds.size() > 0">
                 and a.site_id in
                 <foreach collection="siteIds" separator="," open="(" close=")" item="item" index="index">
@@ -577,7 +576,7 @@
     </select>
     <select id="getMonthData" resultType="java.util.Map">
         SELECT
-        DATE_FORMAT(a.create_time, '%Y-%m-%d' ) as time,
+        DATE_FORMAT(a.pay_time, '%Y-%m-%d' ) as time,
         SUM(CASE
         WHEN a.order_source = 0 THEN b.period_service_price
         WHEN a.order_source = 1 THEN b.period_service_price
@@ -597,9 +596,8 @@
         sum(period_service_price) as period_service_price, sum(period_electric_price + period_service_price) as money
         from t_charging_order_accounting_strategy group by charging_order_id) b on (a.id = b.charging_order_id)
         <where>
-            a.del_flag = 0 and a.recharge_payment_status = 2 and MONTH(a.create_time) = MONTH(NOW())
-            AND YEAR(a.create_time) = YEAR(NOW())
-            and a.start_time between #{start} and #{end}
+            a.del_flag = 0 and a.recharge_payment_status = 2 and a.start_time IS NOT NULL and a.end_time is not null
+            and a.pay_time between #{start} and #{end}
             <if test="null != siteIds and siteIds.size() > 0">
                 and a.site_id in
                 <foreach collection="siteIds" separator="," open="(" close=")" item="item" index="index">
@@ -615,7 +613,7 @@
     </select>
     <select id="getYearData" resultType="java.util.Map">
         SELECT
-        DATE_FORMAT(a.create_time, '%Y-%m-%d' ) as time,
+        DATE_FORMAT(a.pay_time, '%Y-%m-%d' ) as time,
         SUM(CASE
         WHEN a.order_source = 0 THEN b.period_service_price
         WHEN a.order_source = 1 THEN b.period_service_price
@@ -635,8 +633,8 @@
         sum(period_service_price) as period_service_price, sum(period_electric_price + period_service_price) as money
         from t_charging_order_accounting_strategy group by charging_order_id) b on (a.id = b.charging_order_id)
         <where>
-            a.del_flag = 0 and a.recharge_payment_status = 2 and YEAR(a.create_time) = YEAR(NOW())
-            and a.start_time between #{start} and #{end}
+            a.del_flag = 0 and a.recharge_payment_status = 2 and a.start_time IS NOT NULL and a.end_time is not null
+            and a.pay_time between #{start} and #{end}
             <if test="null != siteIds and siteIds.size() > 0">
                 and a.site_id in
                 <foreach collection="siteIds" separator="," open="(" close=")" item="item" index="index">
@@ -651,7 +649,7 @@
     </select>
     <select id="getByDate" resultType="java.util.Map">
         SELECT
-        DATE_FORMAT(a.create_time, '%Y-%m-%d' ) as time,
+        DATE_FORMAT(a.pay_time, '%Y-%m-%d' ) as time,
         SUM(CASE
         WHEN a.order_source = 0 THEN b.period_service_price
         WHEN a.order_source = 1 THEN b.period_service_price
@@ -671,8 +669,8 @@
         sum(period_service_price) as period_service_price, sum(period_electric_price + period_service_price) as money
         from t_charging_order_accounting_strategy group by charging_order_id) b on (a.id = b.charging_order_id)
         <where>
-            a.del_flag = 0 and a.recharge_payment_status = 2
-            and a.start_time between #{start} and #{end}
+            a.del_flag = 0 and a.recharge_payment_status = 2 and a.start_time IS NOT NULL and a.end_time is not null
+            and a.pay_time between #{start} and #{end}
             <if test="null != siteIds and siteIds.size() > 0">
                 and a.site_id in
                 <foreach collection="siteIds" separator="," open="(" close=")" item="item" index="index">
@@ -1110,7 +1108,7 @@
             and a.site_id = #{req.siteId}
         </if>
         <if test="startTime1 != null and startTime1!=''">
-            and (a.create_time between #{startTime1} and #{startTime2})
+            and (a.pay_time between #{startTime1} and #{startTime2})
         </if>
         <if test="endTime1 != null and endTime1!=''">
             and (a.end_time between #{endTime1} and #{endTime2})
@@ -1240,7 +1238,7 @@
                 and b.site_id = #{req.siteId}
             </if>
             <if test="startTime1 != null and startTime1!=''">
-                and b.start_time between #{startTime1} and #{startTime2}
+                and b.pay_time between #{startTime1} and #{startTime2}
             </if>
             <if test="endTime1 != null and endTime2!=''">
                 and b.end_time between #{endTime1} and #{endTime2}
@@ -1315,7 +1313,7 @@
                 and co.site_id = #{req.siteId}
             </if>
             <if test="startTime1 != null and startTime1!=''">
-                and co.start_time between #{startTime1} and #{startTime2}
+                and co.pay_time between #{startTime1} and #{startTime2}
             </if>
             <if test="endTime1 != null and endTime2!=''">
                 and co.end_time between #{endTime1} and #{endTime2}
@@ -1371,7 +1369,7 @@
             and co.site_id = #{req.siteId}
         </if>
         <if test="startTime1 != null and startTime1!=''">
-            and co.start_time between #{startTime1} and #{startTime2}
+            and co.pay_time between #{startTime1} and #{startTime2}
         </if>
         <if test="endTime1 != null and endTime2!=''">
             and co.end_time between #{endTime1} and #{endTime2}

--
Gitblit v1.7.1