From 8b09fbc19a96b57bf1d0e4d7c79b51a76aeca554 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期五, 28 三月 2025 19:57:56 +0800
Subject: [PATCH] 修改bug

---
 ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/IncomeMapper.xml |  117 ++++++++++++++++++++++++++--------------------------------
 1 files changed, 53 insertions(+), 64 deletions(-)

diff --git a/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/IncomeMapper.xml b/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/IncomeMapper.xml
index 6f200b8..bece06e 100644
--- a/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/IncomeMapper.xml
+++ b/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/IncomeMapper.xml
@@ -15,76 +15,64 @@
     </resultMap>
     <select  id="getList" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page">
         SELECT
-            date_format(insertTime, '%Y-%m-%d') times,
-            SUM(
-                CASE
-                WHEN type = 1 THEN
-                    money
-                ELSE
-                    0
-                END
-            ) activityMoney,
-            SUM(
-                CASE
-                WHEN type = 1 THEN
-                    0
-                ELSE
-                    money
-                END
-            ) orderMoney
-        FROM
-            t_income
-        WHERE userType=2 AND objectId=#{id}
-        GROUP BY
-            date_format(insertTime, '%Y-%m-%d')
-        ORDER BY date_format(insertTime, '%Y-%m-%d')  DESC
+            aa.times,
+            ROUND(sum(aa.activityMoney), 2) as activityMoney,
+            ROUND(sum(aa.onlineMoney), 2) as onlineMoney,
+            ROUND(sum(aa.cashMoney), 2) as cashMoney
+        FROM (
+	    	SELECT
+		    	date_format(insertTime, '%Y-%m-%d') times,
+		    	SUM(CASE WHEN type = 1 THEN money ELSE 0 END) activityMoney,
+		        SUM(CASE WHEN type = 1 THEN 0 ELSE money END) onlineMoney,
+			    0 cashMoney
+	        FROM
+		    	t_income
+	        WHERE userType=2 AND objectId=#{id} GROUP BY date_format(insertTime, '%Y-%m-%d')
+	        union all
+	        select date_format(travelTime, '%Y-%m-%d') times, 0, 0, ROUND(sum(payMoney), 2) from t_order_private_car where driverId = #{id} and payType = 4 and state in (8, 9) and isDelete = 1 GROUP BY date_format(travelTime, '%Y-%m-%d')
+	        union all
+	        select date_format(travelTime, '%Y-%m-%d') times, 0, 0, ROUND(sum(payMoney), 2) from t_order_logistics where driverId = #{id} and payType = 4 and state in (8, 9) and isDelete = 1 GROUP BY date_format(travelTime, '%Y-%m-%d')
+        ) AS aa GROUP BY aa.times ORDER BY aa.times DESC
     </select>
     <select  id="getExcelList" resultType="map">
-        SELECT
-            date_format(insertTime, '%Y-%m-%d') times,
-            SUM(
-                CASE
-                WHEN type = 1 THEN
-                    money
-                ELSE
-                    0
-                END
-            ) activityMoney,
-            SUM(
-                CASE
-                WHEN type = 1 THEN
-                    0
-                ELSE
-                    money
-                END
-            ) orderMoney
-        FROM
-            t_income
-        WHERE userType=2 AND objectId=#{id}
-        GROUP BY
-            date_format(insertTime, '%Y-%m-%d')
-        ORDER BY date_format(insertTime, '%Y-%m-%d')  DESC
+	    SELECT
+		    aa.times,
+		    ROUND(sum(aa.activityMoney), 2) as activityMoney,
+		    ROUND(sum(aa.onlineMoney), 2) as onlineMoney,
+		    ROUND(sum(aa.cashMoney), 2) as cashMoney
+	    FROM (
+	         SELECT
+		         date_format(insertTime, '%Y-%m-%d') times,
+		         SUM(CASE WHEN type = 1 THEN money ELSE 0 END) activityMoney,
+		         SUM(CASE WHEN type = 1 THEN 0 ELSE money END) onlineMoney,
+		         0 cashMoney
+	         FROM
+		         t_income
+	         WHERE userType=2 AND objectId=#{id} GROUP BY date_format(insertTime, '%Y-%m-%d')
+	         union all
+	         select date_format(travelTime, '%Y-%m-%d') times, 0, 0, ROUND(sum(payMoney), 2) from t_order_private_car where driverId = #{id} and payType = 4 and state in (8, 9) and isDelete = 1 GROUP BY date_format(travelTime, '%Y-%m-%d')
+	         union all
+	         select date_format(travelTime, '%Y-%m-%d') times, 0, 0, ROUND(sum(payMoney), 2) from t_order_logistics where driverId = #{id} and payType = 4 and state in (8, 9) and isDelete = 1 GROUP BY date_format(travelTime, '%Y-%m-%d')
+	    ) AS aa GROUP BY aa.times ORDER BY aa.times DESC
     </select>
     <select  id="getList1" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page">
-            select
-            a.`date` as times,
-            a.driverNum,
-            b.duration as timeNumber
-            from (
-            select `date`, count(driverId) as driverNum from t_driver_online where assessment = 0 group by `date`
-            ) as a
-            left join (
-            select `date`, sum(duration) as duration from t_driver_online where assessment = 0 group by `date`
-            ) as b on (a.date = b.date)
-            ORDER BY a.date DESC
+		    select aa.startTime as times, aa.driverNum, bb.duration as timeNumber from (
+				select a.startTime, count(a.driverId) as driverNum from (
+					select DATE_FORMAT(startTime, '%Y-%m-%d') as startTime, driverId from t_driver_work group by DATE_FORMAT(startTime, '%Y-%m-%d'), driverId
+			    ) as a group by a.startTime
+		    ) as aa
+			left join (
+			    select DATE_FORMAT(startTime, '%Y-%m-%d') as startTime, sum(if(endTime is null, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(endTime)) - UNIX_TIMESTAMP(startTime)) as duration from t_driver_work group by DATE_FORMAT(startTime, '%Y-%m-%d')
+		    ) as bb on (aa.startTime = bb.startTime)
+            ORDER BY aa.startTime DESC
     </select>
     <select  id="getList2" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page">
-        select
-        CONCAT(b.firstName, ' ', b.lastName) as `name`,
-        a.duration as timeNumber
-        from t_driver_online a
-        left join t_driver b on (a.driverId = b.id)
-         where a.assessment = 0 and DATE_FORMAT(a.`date`, '%Y-%m-%d') = #{times}
+	    select
+		CONCAT(b.firstName, ' ', b.lastName) as `name`,
+		a.duration as timeNumber
+	    from (select DATE_FORMAT(startTime, '%Y-%m-%d') as startTime, driverId, sum(if(endTime is null, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(endTime)) - UNIX_TIMESTAMP(startTime)) as duration from t_driver_work group by DATE_FORMAT(startTime, '%Y-%m-%d'), driverId) as a
+		left join t_driver b on (a.driverId = b.id)
+	    where a.startTime = #{times}
     </select>
     <select  id="getTotal" resultType="map">
       SELECT COUNT(o.driverId) driverNum,SUM(o.timeNumber) timeNumber from (SELECT
@@ -125,4 +113,5 @@
 GROUP BY
 	w.driverId) o
     </select>
+
 </mapper>
\ No newline at end of file

--
Gitblit v1.7.1