From c9bcbceb7112358c780688ffbd0ebb3ef528e65e Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期五, 07 四月 2023 18:40:06 +0800
Subject: [PATCH] 首页管理

---
 management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TRevenueMapper.xml |   32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TRevenueMapper.xml b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TRevenueMapper.xml
index d36f124..4d42051 100644
--- a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TRevenueMapper.xml
+++ b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TRevenueMapper.xml
@@ -126,7 +126,7 @@
             cw.type = 2 AND cw.businessType = #{type} AND cw.code = #{code}
     </select>
     <select id="getDataStatisticsIncomeOrCommission" resultType="com.stylefeng.guns.modular.system.controller.resp.PerformanceTableResp">
-        SELECT date_format(r.createTime, '%Y-%m') AS monthTime,COUNT(o.id) AS amount,d.name AS userName
+        SELECT date_format(r.createTime, '%Y-%m') AS monthTime,SUM(r.amount) AS amount,d.name AS userName
         FROM t_revenue r
         LEFT JOIN t_driver d ON r.userId = d.id
         LEFT JOIN t_order o ON r.orderId = o.id
@@ -137,10 +137,14 @@
             <if test="monthDate != null and monthDate != ''">
                 AND date_format(r.createTime, '%Y-%m') LIKE concat('',#{monthDate},'%')
             </if>
-            AND r.type = 1
+            <if test="type != null">
+                AND r.type = #{type}
+            </if>
             AND r.userType = 2
         </where>
         GROUP BY monthTime,userName
+        ORDER BY amount DESC
+        LIMIT 10
     </select>
 
     <select id="getDataStatisticsCommission" resultType="com.stylefeng.guns.modular.system.controller.resp.PerformanceTableResp">
@@ -163,5 +167,29 @@
         GROUP BY monthTime,userName
         ORDER BY amount DESC
     </select>
+    <select id="getDataStatisticsIncomeOrCommissionByIds" resultType="com.stylefeng.guns.modular.system.controller.resp.PerformanceTableResp">
+        SELECT date_format(r.createTime, '%Y-%m') AS monthTime,SUM(r.amount) AS amount,d.name AS userName
+        FROM t_revenue r
+        LEFT JOIN t_driver d ON r.userId = d.id
+        LEFT JOIN t_order o ON r.orderId = o.id
+        <where>
+            <if test="ids != null and ids.size() > 0">
+                AND o.agentId IN
+                <foreach collection="ids" close=")" open="(" item="id" separator=",">
+                    #{id}
+                </foreach>
+            </if>
+            <if test="monthDate != null and monthDate != ''">
+                AND date_format(r.createTime, '%Y-%m') LIKE concat('',#{monthDate},'%')
+            </if>
+            <if test="type != null">
+                AND r.type = #{type}
+            </if>
+            AND r.userType = 2
+        </where>
+        GROUP BY monthTime,userName
+        ORDER BY amount DESC
+        LIMIT 10
+    </select>
 
 </mapper>

--
Gitblit v1.7.1