商户看板需要支持筛选:全部 / 本商户 / 各子商户,默认"全部"(本商户+子商户),今日数据和近30天数据两张卡片同步联动。
现有查询通过 merchant_id IN (SELECT id FROM merchant WHERE id = #{tenantId} OR parent_merchant_id = #{tenantId}) 实现租户级聚合。在此之上叠加一个 scopeId 参数:当非空时追加 AND merchant_id = #{scopeId},精确过滤到指定商户。
scopeId = null → 全部(当前行为不变)scopeId = loggedInMerchantId → 仅本商户自己的交易scopeId = subMerchantId → 仅该子商户selectSubMerchants(@Param("merchantId") Long merchantId) 返回 List<Map<String,Object>>SELECT id, merchant_name AS merchantName FROM merchant WHERE parent_merchant_id = #{merchantId} AND status = 1 ORDER BY idgetTenantTodayStats — 加 @Param("scopeId") Long scopeIdgetTenantTodayRefundStats — 同上getTenantTodayDisputeCount — 同上getTransactionTrend — 同上getPaymentMethodDistribution — 同上getStatusDistribution — 同上每个查询在 tenantId 条件之后追加:
<if test="scopeId != null">AND merchant_id = #{scopeId}</if>
@GetMapping("/merchants") 返回子商户列表供下拉框/today 端点:merchantId → resolvedId(根据 scopeId 决定),所有 mapper 调用传入 scopeId/transaction-trend、/payment-method-distribution、/status-distribution 各加 @RequestParam(required = false) Long scopeIdgetSubMerchants() 新增getTransactionTrend(params) — 已有 params,传 scopeIdgetPaymentMethodDistribution(params) — 加 paramsgetStatusDistribution(params) — 加 paramsgetTodayStats(params) — 加 paramsel-select 三个 option:全部、本商户、各子商户watch 监听变化,重新 fetch 全部数据