From 88580dae55106dcf4a8f80693b90638e07af02fa Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期三, 14 十月 2026 09:20:23 +0800
Subject: [PATCH] 修改bug

---
 ruoyi-service/ruoyi-account/src/test/java/com/ruoyi/account/service/impl/TAppUserWhitelistServiceImplTest.java |   78 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 78 insertions(+), 0 deletions(-)

diff --git a/ruoyi-service/ruoyi-account/src/test/java/com/ruoyi/account/service/impl/TAppUserWhitelistServiceImplTest.java b/ruoyi-service/ruoyi-account/src/test/java/com/ruoyi/account/service/impl/TAppUserWhitelistServiceImplTest.java
index 6621aa1..e763e60 100644
--- a/ruoyi-service/ruoyi-account/src/test/java/com/ruoyi/account/service/impl/TAppUserWhitelistServiceImplTest.java
+++ b/ruoyi-service/ruoyi-account/src/test/java/com/ruoyi/account/service/impl/TAppUserWhitelistServiceImplTest.java
@@ -50,6 +50,7 @@
 import java.util.concurrent.atomic.AtomicLong;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
@@ -259,6 +260,83 @@
         assertEquals(null, result.getFleetId());
     }
 
+    // ---------------- 白名单账户可用余额解析(充电页余额显示) ----------------
+
+    @Test
+    void resolveWhitelistAccountBalanceReturnsCompanyBalanceForSharedMode() {
+        TGroupCompany company = new TGroupCompany();
+        company.setAccountMode(1);
+        company.setAvailableBalance(new BigDecimal("500.50"));
+        when(groupCompanyClient.getCompanyById(12)).thenReturn(R.ok(company));
+
+        AppUserWhitelistMatchVO match = new AppUserWhitelistMatchVO();
+        match.setMatched(true);
+        match.setCompanyId(12);
+        match.setBalance(new BigDecimal("100.00"));
+
+        BigDecimal result = service.resolveWhitelistAccountBalance(match);
+
+        assertEquals(new BigDecimal("500.50"), result);
+    }
+
+    @Test
+    void resolveWhitelistAccountBalanceReturnsWhitelistBalanceForAllocationMode() {
+        TGroupCompany company = new TGroupCompany();
+        company.setAccountMode(2);
+        company.setAvailableBalance(new BigDecimal("500.50"));
+        when(groupCompanyClient.getCompanyById(12)).thenReturn(R.ok(company));
+
+        AppUserWhitelistMatchVO match = new AppUserWhitelistMatchVO();
+        match.setMatched(true);
+        match.setCompanyId(12);
+        match.setBalance(new BigDecimal("100.00"));
+
+        BigDecimal result = service.resolveWhitelistAccountBalance(match);
+
+        assertEquals(new BigDecimal("100.00"), result);
+    }
+
+    @Test
+    void resolveWhitelistAccountBalanceTreatsNullAccountModeAsShared() {
+        TGroupCompany company = new TGroupCompany();
+        company.setAccountMode(null);
+        company.setAvailableBalance(new BigDecimal("500.50"));
+        when(groupCompanyClient.getCompanyById(12)).thenReturn(R.ok(company));
+
+        AppUserWhitelistMatchVO match = new AppUserWhitelistMatchVO();
+        match.setMatched(true);
+        match.setCompanyId(12);
+        match.setBalance(new BigDecimal("100.00"));
+
+        BigDecimal result = service.resolveWhitelistAccountBalance(match);
+
+        assertEquals(new BigDecimal("500.50"), result);
+    }
+
+    @Test
+    void resolveWhitelistAccountBalanceReturnsNullWhenCompanyQueryFails() {
+        when(groupCompanyClient.getCompanyById(12)).thenReturn(R.fail("公司信息查询失败"));
+
+        AppUserWhitelistMatchVO match = new AppUserWhitelistMatchVO();
+        match.setMatched(true);
+        match.setCompanyId(12);
+        match.setBalance(new BigDecimal("100.00"));
+
+        BigDecimal result = service.resolveWhitelistAccountBalance(match);
+
+        assertNull(result);
+    }
+
+    @Test
+    void resolveWhitelistAccountBalanceReturnsNullWhenNotMatched() {
+        AppUserWhitelistMatchVO match = new AppUserWhitelistMatchVO();
+        match.setMatched(false);
+
+        BigDecimal result = service.resolveWhitelistAccountBalance(match);
+
+        assertNull(result);
+    }
+
     // ---------------- 额度分配 ----------------
 
     @Test

--
Gitblit v1.7.1