From 7a7222e69c72ec013a8633aa8a6cbf71e356083c Mon Sep 17 00:00:00 2001 From: luqingjie <544309509@qq.com> Date: Sun, 18 Oct 2026 05:21:01 -0400 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E6=94=AF=E4=BB=98=E6=80=BB?= =?UTF-8?q?=E8=A7=88=20=EF=BC=8C=E5=8F=AF=E4=BB=A5=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=89=80=E6=9C=89=E5=BA=94=E7=94=A8=EF=BC=8C=E4=B9=9F=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E9=80=89=E6=8B=A9=E6=9F=90=E4=B8=AA=E5=BA=94=E7=94=A8?= =?UTF-8?q?=EF=BC=8C=E7=84=B6=E5=90=8E=E6=9F=A5=E7=9C=8B=E6=80=BB=E8=A7=88?= =?UTF-8?q?=EF=BC=8C=E8=AF=B7=E5=B8=AE=E6=88=91=E6=B7=BB=E5=8A=A0=E8=AF=A5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PaymentDashboardController.java | 5 ++- .../system/mapper/PaymentDashboardMapper.java | 36 ++++++++++-------- .../service/PaymentDashboardService.java | 38 +++++++++++++------ 3 files changed, 50 insertions(+), 29 deletions(-) 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 index 3337880..649bc35 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/PaymentDashboardController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/PaymentDashboardController.java @@ -6,6 +6,7 @@ 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; +import org.springframework.web.bind.annotation.RequestParam; /** 登录首页支付经营数据。 */ @RestController @@ -15,7 +16,7 @@ public class PaymentDashboardController { private PaymentDashboardService dashboardService; @GetMapping("/overview") - public AjaxResult overview() { - return AjaxResult.success(dashboardService.overview()); + public AjaxResult overview(@RequestParam(value = "appId", required = false) Long appId) { + return AjaxResult.success(dashboardService.overview(appId)); } } 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 index 5dd55b0..815ad53 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/PaymentDashboardMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/PaymentDashboardMapper.java @@ -14,16 +14,18 @@ public interface PaymentDashboardMapper { "coalesce(sum(usdt_balance),0) usdtBalance, coalesce(sum(trx_balance),0) trxBalance,", "coalesce(sum(usdt_frozen_balance),0) usdtFrozenBalance, coalesce(sum(trx_frozen_balance),0) trxFrozenBalance,", "coalesce(sum(credit_limit),0) creditLimit from apps where deleted_at is null", - " and user_id=#{userId}", ""}) - Map selectAppsSummary(@Param("userId") Long userId); + " and user_id=#{userId}", + " and id=#{appId}", ""}) + Map selectAppsSummary(@Param("userId") Long userId, @Param("appId") Long appId); @Select({""}) - Map selectWalletSummary(@Param("userId") Long userId); + " and user_id=#{userId}", + " and app_id=#{appId}", ""}) + Map selectWalletSummary(@Param("userId") Long userId, @Param("appId") Long appId); @Select({""}) - Map selectPaymentSummary(@Param("userId") Long userId); + " and user_id=#{userId}", + " and app_id=#{appId}", ""}) + Map selectPaymentSummary(@Param("userId") Long userId, @Param("appId") Long appId); @Select({""}) - Map selectPayoutSummary(@Param("userId") Long userId); + " and user_id=#{userId}", + " and app_id=#{appId}", ""}) + Map selectPayoutSummary(@Param("userId") Long userId, @Param("appId") Long appId); @Select({""}) - List> selectPaymentTrend(@Param("userId") Long userId); + List> selectPaymentTrend(@Param("userId") Long userId, @Param("appId") Long appId); @Select({""}) - List> selectPayoutTrend(@Param("userId") Long userId); + List> selectPayoutTrend(@Param("userId") Long userId, @Param("appId") Long appId); @Select({""}) - List> selectLedgerDistribution(@Param("userId") Long userId); + List> selectLedgerDistribution(@Param("userId") Long userId, @Param("appId") Long appId); @Select({""}) - List> selectTopApps(@Param("userId") Long userId); + List> selectTopApps(@Param("userId") Long userId, @Param("appId") Long appId); } 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 index 7c59cbc..2ccec17 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/PaymentDashboardService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/PaymentDashboardService.java @@ -4,6 +4,9 @@ import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.system.mapper.PaymentDashboardMapper; import com.ruoyi.system.domain.UsdtConfig; import com.ruoyi.system.mapper.UsdtConfigMapper; +import com.ruoyi.system.mapper.AppsMapper; +import com.ruoyi.system.domain.Apps; +import com.ruoyi.common.exception.CustomException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -17,12 +20,24 @@ public class PaymentDashboardService { private PaymentDashboardMapper mapper; @Autowired private UsdtConfigMapper usdtConfigMapper; + @Autowired + private AppsMapper appsMapper; - public Map overview() { + public Map overview(Long requestedAppId) { Long currentUserId = SecurityUtils.getUserId(); - Long scopedUserId = SecurityUtils.isAdmin(currentUserId) ? null : currentUserId; + boolean admin = SecurityUtils.isAdmin(currentUserId); + Long scopedUserId = admin ? null : currentUserId; + if (requestedAppId != null) { + Apps app = appsMapper.selectAppsById(requestedAppId); + if (app == null) { + throw new CustomException("应用不存在"); + } + if (!admin && !currentUserId.equals(app.getUserId())) { + throw new CustomException("无权查看该应用"); + } + } Map result = new LinkedHashMap(); - result.put("admin", scopedUserId == null); + result.put("admin", admin); if (scopedUserId == null) { UsdtConfig config = usdtConfigMapper.selectFirst(); Map mainWallet = new LinkedHashMap(); @@ -34,14 +49,15 @@ public class PaymentDashboardService { } result.put("mainWallet", mainWallet); } - 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)); + result.put("selectedAppId", requestedAppId); + result.put("apps", mapper.selectAppsSummary(scopedUserId, requestedAppId)); + result.put("wallets", mapper.selectWalletSummary(scopedUserId, requestedAppId)); + result.put("payments", mapper.selectPaymentSummary(scopedUserId, requestedAppId)); + result.put("payouts", mapper.selectPayoutSummary(scopedUserId, requestedAppId)); + result.put("paymentTrend", mapper.selectPaymentTrend(scopedUserId, requestedAppId)); + result.put("payoutTrend", mapper.selectPayoutTrend(scopedUserId, requestedAppId)); + result.put("ledgerDistribution", mapper.selectLedgerDistribution(scopedUserId, requestedAppId)); + result.put("topApps", mapper.selectTopApps(scopedUserId, requestedAppId)); return result; } }