diff --git a/src/Application/TakeoutSaaS.Application/App/Merchants/Handlers/GetCurrentMerchantCenterQueryHandler.cs b/src/Application/TakeoutSaaS.Application/App/Merchants/Handlers/GetCurrentMerchantCenterQueryHandler.cs
index af8db2a..c285672 100644
--- a/src/Application/TakeoutSaaS.Application/App/Merchants/Handlers/GetCurrentMerchantCenterQueryHandler.cs
+++ b/src/Application/TakeoutSaaS.Application/App/Merchants/Handlers/GetCurrentMerchantCenterQueryHandler.cs
@@ -57,7 +57,7 @@ public sealed class GetCurrentMerchantCenterQueryHandler(
}
// 4. 解析当前用户可访问商户
- var merchantId = await ResolveMerchantIdAsync(currentUser.MerchantId, currentTenantId, cancellationToken);
+ var merchantId = ResolveMerchantId(currentUser.MerchantId);
// 5. 读取商户主体与租户信息
var merchant = await merchantRepository.FindByIdAsync(merchantId, currentTenantId, cancellationToken)
@@ -87,29 +87,19 @@ public sealed class GetCurrentMerchantCenterQueryHandler(
}
///
- /// 解析当前用户对应的商户标识。
+ /// 解析当前用户绑定的商户标识。
///
/// 当前用户绑定的商户 ID。
- /// 当前租户 ID。
- /// 取消标记。
/// 商户 ID。
- private async Task ResolveMerchantIdAsync(long? currentUserMerchantId, long tenantId, CancellationToken cancellationToken)
+ private static long ResolveMerchantId(long? currentUserMerchantId)
{
- // 1. 优先使用用户显式绑定的商户
+ // 1. 严格使用用户绑定商户
if (currentUserMerchantId is > 0)
{
return currentUserMerchantId.Value;
}
- // 2. 兜底读取租户下最新商户
- var merchants = await merchantRepository.SearchAsync(tenantId, status: null, cancellationToken);
- var merchantId = merchants.FirstOrDefault()?.Id;
- if (!merchantId.HasValue || merchantId.Value <= 0)
- {
- throw new BusinessException(ErrorCodes.NotFound, "当前租户尚未创建商户信息");
- }
-
- // 3. 返回商户标识
- return merchantId.Value;
+ // 2. 未绑定商户直接拒绝访问
+ throw new BusinessException(ErrorCodes.Forbidden, "当前用户未绑定商户,禁止访问商户中心");
}
}