From e41cf73a7bd534a3d23212229a792a78de9afde6 Mon Sep 17 00:00:00 2001
From: 18650502300 <18650502300@163.com>
Date: Wed, 19 Jun 2024 10:00:59 +0800
Subject: [PATCH] =?UTF-8?q?1.=20=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../controller/system/EtRefundController.java |  4 +--
 .../system/service/IEtRefundService.java      |  8 ++++++
 .../service/impl/EtOrderServiceImpl.java      |  4 +--
 .../service/impl/EtRefundServiceImpl.java     | 15 +++++++++++
 .../mapper/system/EtRefundMapper.xml          | 27 ++++++++++++-------
 5 files changed, 44 insertions(+), 14 deletions(-)

diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/system/EtRefundController.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/system/EtRefundController.java
index 3ff33db..84e88ab 100644
--- a/electripper-admin/src/main/java/com/ruoyi/web/controller/system/EtRefundController.java
+++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/system/EtRefundController.java
@@ -42,7 +42,7 @@ public class EtRefundController extends BaseController
     public TableDataInfo list(EtRefund etRefund)
     {
         startPage();
-        List<EtRefund> list = etRefundService.selectEtRefundList(etRefund);
+        List<EtRefund> list = etRefundService.selectEtRefundListWithIsolate(etRefund);
         return getDataTable(list);
     }
 
@@ -54,7 +54,7 @@ public class EtRefundController extends BaseController
     @PostMapping("/export")
     public void export(HttpServletResponse response, EtRefund etRefund)
     {
-        List<EtRefund> list = etRefundService.selectEtRefundList(etRefund);
+        List<EtRefund> list = etRefundService.selectEtRefundListWithIsolate(etRefund);
         ExcelUtil<EtRefund> util = new ExcelUtil<EtRefund>(EtRefund.class);
         util.exportExcel(response, list, "退款订单数据");
     }
diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/IEtRefundService.java b/electripper-system/src/main/java/com/ruoyi/system/service/IEtRefundService.java
index e12b57a..a118429 100644
--- a/electripper-system/src/main/java/com/ruoyi/system/service/IEtRefundService.java
+++ b/electripper-system/src/main/java/com/ruoyi/system/service/IEtRefundService.java
@@ -43,6 +43,14 @@ public interface IEtRefundService
      */
     public List<EtRefund> selectEtRefundList(EtRefund etRefund);
 
+    /**
+     * 查询退款订单列表(带数据隔离)
+     *
+     * @param etRefund 退款订单
+     * @return 退款订单集合
+     */
+    public List<EtRefund> selectEtRefundListWithIsolate(EtRefund etRefund);
+
     /**
      * 新增退款订单
      *
diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java
index 8da4b6c..a844d35 100644
--- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java
+++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java
@@ -219,7 +219,7 @@ public class EtOrderServiceImpl implements IEtOrderService
     }
 
     /**
-     * 查询充值/退款订单列表  资本 capital flow  收支  业务
+     * 查询充值/退款订单列表
      */
     @Override
     @DataScope(deptAlias = "d")
@@ -239,7 +239,7 @@ public class EtOrderServiceImpl implements IEtOrderService
         EtRefund refund = new EtRefund();
         refund.setType(ServiceConstants.REFUND_TYPE_DEPOSIT);
         refund.setRefundResult(Constants.SUCCESS2);
-        List<EtRefund> etRefunds = etRefundService.selectEtRefundList(refund);
+        List<EtRefund> etRefunds = etRefundService.selectEtRefundListWithIsolate(refund);
         etRefunds.forEach(etRefund -> {
             AsUser asUser = asUserService.selectUserById(etRefund.getUserId());
             RechargeVo rechargeVo = new RechargeVo();
diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtRefundServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtRefundServiceImpl.java
index 57f3c73..e5bba6a 100644
--- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtRefundServiceImpl.java
+++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtRefundServiceImpl.java
@@ -1,6 +1,8 @@
 package com.ruoyi.system.service.impl;
 
 import java.util.List;
+
+import com.ruoyi.common.annotation.DataScope;
 import com.ruoyi.common.utils.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -69,6 +71,19 @@ public class EtRefundServiceImpl implements IEtRefundService
         return etRefundMapper.selectEtRefundList(etRefund);
     }
 
+    /**
+     * 查询退款订单列表
+     *
+     * @param etRefund 退款订单
+     * @return 退款订单
+     */
+    @DataScope(deptAlias = "d")
+    @Override
+    public List<EtRefund> selectEtRefundListWithIsolate(EtRefund etRefund)
+    {
+        return etRefundMapper.selectEtRefundList(etRefund);
+    }
+
     /**
      * 新增退款订单
      *
diff --git a/electripper-system/src/main/resources/mapper/system/EtRefundMapper.xml b/electripper-system/src/main/resources/mapper/system/EtRefundMapper.xml
index 879a784..5f602ed 100644
--- a/electripper-system/src/main/resources/mapper/system/EtRefundMapper.xml
+++ b/electripper-system/src/main/resources/mapper/system/EtRefundMapper.xml
@@ -26,16 +26,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </sql>
 
     <select id="selectEtRefundList" parameterType="EtRefund" resultMap="EtRefundResult">
-        <include refid="selectEtRefundVo"/>
-        <where>
-            <if test="refundNo != null  and refundNo != ''"> and refund_no = #{refundNo}</if>
-            <if test="orderNo != null  and orderNo != ''"> and order_no like concat('%', #{orderNo}, '%')</if>
-            <if test="userId != null "> and user_id like concat('%', #{userId}, '%')</if>
-            <if test="amount != null "> and amount = #{amount}</if>
-            <if test="itemDesc != null  and itemDesc != ''"> and item_desc like concat('%', #{itemDesc}, '%')</if>
-            <if test="refundResult != null "> and refund_result = #{refundResult}</if>
-            <if test="type != null "> and type = #{type}</if>
-        </where>
+        select r.id, r.refund_no, r.order_no, r.user_id, r.amount, r.dispatch_fee, r.manage_fee,
+               r.riding_fee, r.appointment_fee, r.type, r.reason, r.create_time, r.item_desc,r.refund_result from et_refund r
+        INNER JOIN et_order o on o.order_no = r.order_no
+        LEFT JOIN et_operating_area oa ON o.area_id = oa.area_id
+        LEFT join et_area_dept ad on ad.area_id = oa.area_id
+        LEFT join sys_dept d on d.dept_id = ad.dept_id
+        where 1 = 1
+        <if test="refundNo != null  and refundNo != ''"> and r.refund_no = #{refundNo}</if>
+        <if test="orderNo != null  and orderNo != ''"> and r.order_no like concat('%', #{orderNo}, '%')</if>
+        <if test="userId != null "> and r.user_id like concat('%', #{userId}, '%')</if>
+        <if test="amount != null "> and r.amount = #{amount}</if>
+        <if test="itemDesc != null  and itemDesc != ''"> and r.item_desc like concat('%', #{itemDesc}, '%')</if>
+        <if test="refundResult != null "> and r.refund_result = #{refundResult}</if>
+        <if test="type != null "> and r.type = #{type}</if>
+        <!-- 数据范围过滤 -->
+        ${params.dataScope}
+        order by o.create_time desc
     </select>
 
     <select id="selectEtRefundById" parameterType="Long" resultMap="EtRefundResult">