From e2ec753e232106f336894f58d585e58c27bf1f29 Mon Sep 17 00:00:00 2001
From: longz <longzhaoz@qq.com>
Date: 星期四, 30 七月 2026 17:04:43 +0800
Subject: [PATCH] 各类修复

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java             |    4 +
 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java            |    2 
 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingLotController.java     |    9 +++
 ruoyi-service/ruoyi-chargingPile/src/test/java/com/ruoyi/chargingPile/controller/TParkingLotControllerTest.java |   39 +++++++++++++
 ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml                              |    8 +-
 ruoyi-service/ruoyi-order/src/test/java/com/ruoyi/order/mapper/PayOrderQueryPerformanceMapperTest.java          |   38 ++++++++++++
 ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TAccountingStrategyMapper.xml           |   21 ++++++
 7 files changed, 115 insertions(+), 6 deletions(-)

diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java
index 50ef6bd..714fbb3 100644
--- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java
+++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java
@@ -522,7 +522,7 @@
 		return AjaxResult.success(siteService.getSiteListGun());
 	}
 
-	@RequiresPermissions(value = {"/chargingPile", "/chargingPile/select"}, logical = Logical.OR)
+	@RequiresPermissions(value = {"/site", "/chargingPile", "/chargingPile/select"}, logical = Logical.OR)
 	@GetMapping("/chargingPileFilterOptions")
 	@ApiOperation(value = "获取充电桩筛选级联选项", tags = {"管理后台-充电桩管理"})
 	public AjaxResult<ChargingPileFilterOptionsDTO> getChargingPileFilterOptions() {
diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingLotController.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingLotController.java
index 36aa792..6d617fb 100644
--- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingLotController.java
+++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingLotController.java
@@ -15,6 +15,7 @@
 import com.ruoyi.chargingPile.service.TParkingRecordService;
 import com.ruoyi.chargingPile.service.TVehicleRampService;
 import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.exception.ServiceException;
 import com.ruoyi.common.core.web.domain.AjaxResult;
 import com.ruoyi.common.core.web.domain.BaseDelete;
 import com.ruoyi.common.core.web.page.PageInfo;
@@ -90,6 +91,7 @@
     @ApiOperation(tags = {"后台-停车场"},value = "添加停车场")
     @PostMapping(value = "/add")
     public AjaxResult<Boolean> add(@RequestBody TParkingLotDTO dto) {
+        validateBarrierBrand(dto);
         return AjaxResult.ok(parkingLotService.save(dto));
     }
 
@@ -101,9 +103,16 @@
     @ApiOperation(tags = {"后台-停车场"},value = "修改停车场")
     @PostMapping(value = "/update")
     public AjaxResult<Boolean> update(@RequestBody TParkingLotDTO dto) {
+        validateBarrierBrand(dto);
         return AjaxResult.ok(parkingLotService.updateById(dto));
     }
 
+    private void validateBarrierBrand(TParkingLotDTO dto) {
+        if (Integer.valueOf(1).equals(dto.getBarrierBrand()) && !Integer.valueOf(1).equals(dto.getType())) {
+            throw new ServiceException("顺捷道闸品牌仅支持直营停车场");
+        }
+    }
+
     /**
      * 查看停车场详情
      */
diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TAccountingStrategyMapper.xml b/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TAccountingStrategyMapper.xml
index 1c7e24c..5ef5c69 100644
--- a/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TAccountingStrategyMapper.xml
+++ b/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TAccountingStrategyMapper.xml
@@ -39,7 +39,26 @@
                 AND tas.audit_status = #{query.auditStatus}
             </if>
             <if test="query.partnerId != null">
-                AND tas.partner_id = #{query.partnerId}
+                AND (
+                    tas.partner_id = #{query.partnerId}
+                    OR EXISTS (
+                        SELECT 1
+                        FROM t_accounting_strategy audit_tas
+                        WHERE audit_tas.parent_id = tas.id
+                          AND audit_tas.partner_id = #{query.partnerId}
+                          AND audit_tas.audit_status IN (1, 2, 4)
+                          AND audit_tas.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
+                          AND audit_tas.id = (
+                              SELECT latest_audit_tas.id
+                              FROM t_accounting_strategy latest_audit_tas
+                              WHERE latest_audit_tas.parent_id = tas.id
+                                AND latest_audit_tas.audit_status IN (1, 2, 4)
+                                AND latest_audit_tas.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
+                              ORDER BY latest_audit_tas.create_time DESC, latest_audit_tas.id DESC
+                              LIMIT 1
+                          )
+                    )
+                )
             </if>
             AND tas.site_id IS NULL
             AND (tas.parent_id IS NULL OR tas.audit_status = 3 OR tas.audit_status = 4)
diff --git a/ruoyi-service/ruoyi-chargingPile/src/test/java/com/ruoyi/chargingPile/controller/TParkingLotControllerTest.java b/ruoyi-service/ruoyi-chargingPile/src/test/java/com/ruoyi/chargingPile/controller/TParkingLotControllerTest.java
new file mode 100644
index 0000000..eca7415
--- /dev/null
+++ b/ruoyi-service/ruoyi-chargingPile/src/test/java/com/ruoyi/chargingPile/controller/TParkingLotControllerTest.java
@@ -0,0 +1,39 @@
+package com.ruoyi.chargingPile.controller;
+
+import com.ruoyi.chargingPile.api.dto.TParkingLotDTO;
+import com.ruoyi.chargingPile.service.TCarportService;
+import com.ruoyi.chargingPile.service.TParkingLotService;
+import com.ruoyi.chargingPile.service.TVehicleRampService;
+import com.ruoyi.common.core.exception.ServiceException;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.Mockito.mock;
+
+class TParkingLotControllerTest {
+
+    private final TParkingLotController controller = new TParkingLotController(
+            mock(TParkingLotService.class),
+            mock(TVehicleRampService.class),
+            mock(TCarportService.class)
+    );
+
+    @Test
+    void rejectsShunjieForCooperativeParkingLot() {
+        TParkingLotDTO dto = new TParkingLotDTO();
+        dto.setType(2);
+        dto.setBarrierBrand(1);
+
+        assertThrows(ServiceException.class, () -> controller.add(dto));
+    }
+
+    @Test
+    void allowsShunjieForDirectParkingLot() {
+        TParkingLotDTO dto = new TParkingLotDTO();
+        dto.setType(1);
+        dto.setBarrierBrand(1);
+
+        assertDoesNotThrow(() -> controller.add(dto));
+    }
+}
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
index d69e43a..454a40b 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -5623,6 +5623,10 @@
 				finishManualChargingRefund(tChargingOrder, chargingOrderRefund, manualRefundAmount, balanceRefundAmount, thirdRefundAmount);
 			}
 			else if (isIcbcOrder(tChargingOrder)) {
+				R shareRefund = refundIcbcShareBeforeMainRefund(tChargingOrder, chargingOrderRefund, thirdRefundAmount);
+				if (shareRefund.getCode() != 200) {
+					return shareRefund;
+				}
 				refundByIcbcAndFinish(tChargingOrder, chargingOrderRefund, thirdRefundAmount, "取消订单", true,
 						manualRefundAmount, balanceRefundAmount);
 			}
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 d3bef1e..b41c21c 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
@@ -195,7 +195,7 @@
         a.app_user_id
         FROM
         charging_pile_order.t_charging_order a
-        where a.recharge_payment_status = 2
+        where (a.recharge_payment_status = 2 OR #{data.invoiceId} IS NOT NULL)
 
         UNION ALL
 
@@ -216,7 +216,7 @@
         a.app_user_id
         FROM
         charging_pile_order.t_shopping_order a
-        where a.payment_status = 2
+        where (a.payment_status = 2 OR #{data.invoiceId} IS NOT NULL)
 
         UNION ALL
 
@@ -237,7 +237,7 @@
         a.app_user_id
         FROM
         charging_pile_order.t_vip_order a
-        where a.payment_status = 2
+        where (a.payment_status = 2 OR #{data.invoiceId} IS NOT NULL)
 
         UNION ALL
 
@@ -291,7 +291,7 @@
             </if>
 
         </where>
-        ORDER BY o.create_time desc
+        ORDER BY COALESCE(o.pay_time, o.create_time, o.end_time) DESC, o.create_time DESC, o.id DESC
 
     </select>
     <select id="getRefundList" resultType="com.ruoyi.order.api.model.TChargingOrderRefund">
diff --git a/ruoyi-service/ruoyi-order/src/test/java/com/ruoyi/order/mapper/PayOrderQueryPerformanceMapperTest.java b/ruoyi-service/ruoyi-order/src/test/java/com/ruoyi/order/mapper/PayOrderQueryPerformanceMapperTest.java
index bf49137..6fbe7e7 100644
--- a/ruoyi-service/ruoyi-order/src/test/java/com/ruoyi/order/mapper/PayOrderQueryPerformanceMapperTest.java
+++ b/ruoyi-service/ruoyi-order/src/test/java/com/ruoyi/order/mapper/PayOrderQueryPerformanceMapperTest.java
@@ -37,6 +37,44 @@
     }
 
     @Test
+    void invoiceOrderViewRetainsLinkedOrdersAfterPaymentStatusChanges() throws IOException {
+        InputStream input = getClass().getClassLoader()
+                .getResourceAsStream("mapper/order/TChargingOrderMapper.xml");
+        assertNotNull(input);
+
+        String mapper;
+        try (BufferedReader reader = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8))) {
+            mapper = reader.lines().collect(Collectors.joining("\n"));
+        }
+
+        String payOrderQuery = mapper.substring(
+                mapper.indexOf("<select id=\"payOrderQuery\""),
+                mapper.indexOf("<select id=\"getRefundList\""));
+        assertEquals(3, countOccurrences(payOrderQuery, "#{data.invoiceId} IS NOT NULL"));
+        assertTrue(payOrderQuery.contains("a.recharge_payment_status = 2 OR #{data.invoiceId} IS NOT NULL"));
+        assertEquals(2, countOccurrences(payOrderQuery,
+                "a.payment_status = 2 OR #{data.invoiceId} IS NOT NULL"));
+    }
+
+    @Test
+    void paymentOrderListUsesLatestPaymentTimeAsItsDefaultSort() throws IOException {
+        InputStream input = getClass().getClassLoader()
+                .getResourceAsStream("mapper/order/TChargingOrderMapper.xml");
+        assertNotNull(input);
+
+        String mapper;
+        try (BufferedReader reader = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8))) {
+            mapper = reader.lines().collect(Collectors.joining("\n"));
+        }
+
+        String payOrderQuery = mapper.substring(
+                mapper.indexOf("<select id=\"payOrderQuery\""),
+                mapper.indexOf("<select id=\"getRefundList\""));
+        assertTrue(payOrderQuery.contains(
+                "ORDER BY COALESCE(o.pay_time, o.create_time, o.end_time) DESC, o.create_time DESC, o.id DESC"));
+    }
+
+    @Test
     void refundListAppliesPartnerSiteScopeInsidePagedQuery() throws IOException {
         InputStream input = getClass().getClassLoader()
                 .getResourceAsStream("mapper/order/TChargingOrderMapper.xml");

--
Gitblit v1.7.1