From 705609282f99b21eea927dd2e64cb1672b1e30d5 Mon Sep 17 00:00:00 2001 From: luqingjie <544309509@qq.com> Date: Sat, 17 Oct 2026 22:22:05 -0400 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PaymentDashboardController.java | 21 +++++ .../system/mapper/PaymentDashboardMapper.java | 81 +++++++++++++++++++ .../service/PaymentDashboardService.java | 32 ++++++++ 3 files changed, 134 insertions(+) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/controller/PaymentDashboardController.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/mapper/PaymentDashboardMapper.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/service/PaymentDashboardService.java diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/PaymentDashboardController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/PaymentDashboardController.java new file mode 100644 index 0000000..3337880 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/PaymentDashboardController.java @@ -0,0 +1,21 @@ +package com.ruoyi.system.controller; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.system.service.PaymentDashboardService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** 登录首页支付经营数据。 */ +@RestController +@RequestMapping("/system/dashboard") +public class PaymentDashboardController { + @Autowired + private PaymentDashboardService dashboardService; + + @GetMapping("/overview") + public AjaxResult overview() { + return AjaxResult.success(dashboardService.overview()); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/PaymentDashboardMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/PaymentDashboardMapper.java new file mode 100644 index 0000000..1456630 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/PaymentDashboardMapper.java @@ -0,0 +1,81 @@ +package com.ruoyi.system.mapper; + +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; +import java.util.Map; + +/** 支付首页聚合查询,所有查询都接受服务端确定的用户数据范围。 */ +public interface PaymentDashboardMapper { + @Select({""}) + Map selectAppsSummary(@Param("userId") Long userId); + + @Select({""}) + Map selectWalletSummary(@Param("userId") Long userId); + + @Select({""}) + Map selectPaymentSummary(@Param("userId") Long userId); + + @Select({""}) + Map selectPayoutSummary(@Param("userId") Long userId); + + @Select({""}) + List> selectPaymentTrend(@Param("userId") Long userId); + + @Select({""}) + List> selectPayoutTrend(@Param("userId") Long userId); + + @Select({""}) + List> selectLedgerDistribution(@Param("userId") Long userId); + + @Select({""}) + List> selectTopApps(@Param("userId") Long userId); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/PaymentDashboardService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/PaymentDashboardService.java new file mode 100644 index 0000000..5c7fd10 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/PaymentDashboardService.java @@ -0,0 +1,32 @@ +package com.ruoyi.system.service; + +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.system.mapper.PaymentDashboardMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** 组装首页所需的支付经营指标,避免前端并发请求多个业务接口。 */ +@Service +public class PaymentDashboardService { + @Autowired + private PaymentDashboardMapper mapper; + + public Map overview() { + Long currentUserId = SecurityUtils.getUserId(); + Long scopedUserId = SecurityUtils.isAdmin(currentUserId) ? null : currentUserId; + Map result = new LinkedHashMap(); + result.put("admin", scopedUserId == null); + result.put("apps", mapper.selectAppsSummary(scopedUserId)); + result.put("wallets", mapper.selectWalletSummary(scopedUserId)); + result.put("payments", mapper.selectPaymentSummary(scopedUserId)); + result.put("payouts", mapper.selectPayoutSummary(scopedUserId)); + result.put("paymentTrend", mapper.selectPaymentTrend(scopedUserId)); + result.put("payoutTrend", mapper.selectPayoutTrend(scopedUserId)); + result.put("ledgerDistribution", mapper.selectLedgerDistribution(scopedUserId)); + result.put("topApps", mapper.selectTopApps(scopedUserId)); + return result; + } +}