feat: add platform tenant detail audit console

This commit is contained in:
Codex
2026-06-30 04:38:36 +08:00
parent e62653025c
commit d5d32e84b3
16 changed files with 688 additions and 111 deletions

View File

@@ -54,6 +54,60 @@ export interface PlatformTenantItem {
openBalanceCents?: number | string | null;
}
export interface PlatformTenantBillingProfile {
tenantId?: string | null;
billingName?: string | null;
taxId?: string | null;
contactName?: string | null;
contactPhone?: string | null;
contactEmail?: string | null;
billingAddress?: string | null;
invoiceTitle?: string | null;
invoiceType?: string | null;
bankName?: string | null;
bankAccountMasked?: string | null;
metadata?: Record<string, unknown> | null;
}
export interface PlatformTenantDetailTenant extends PlatformTenantItem, PlatformTenantBillingProfile {
shortName?: string | null;
serviceWechat?: string | null;
ownerUserId?: string | null;
metadata?: Record<string, unknown> | null;
createdAt?: string | null;
updatedAt?: string | null;
}
export interface PlatformTenantDomain {
id: string;
host?: string | null;
domainType?: string | null;
status?: string | null;
isPrimary?: boolean | null;
verifiedAt?: string | null;
createdAt?: string | null;
}
export interface PlatformTenantSubscription {
id: string;
planCode?: string | null;
status?: string | null;
startsAt?: string | null;
expiresAt?: string | null;
billingCycle?: string | null;
amountCents?: number | string | null;
metadata?: Record<string, unknown> | null;
createdAt?: string | null;
}
export interface PlatformTenantDetail {
tenant?: PlatformTenantDetailTenant | null;
domains?: PlatformTenantDomain[];
subscriptions?: PlatformTenantSubscription[];
invoices?: PlatformInvoiceItem[];
usage?: PlatformUsageItem[];
}
export interface PlatformInvoiceItem {
id: string;
tenantId: string;
@@ -113,6 +167,24 @@ export interface PlatformQuestionBankGrant {
expiresAt?: string | null;
}
export interface PlatformAuditLogItem {
id: string;
tenantId?: string | null;
tenantSlug?: string | null;
tenantName?: string | null;
actorUserId?: string | null;
actorUsername?: string | null;
actorName?: string | null;
actorPhone?: string | null;
action?: string | null;
targetType?: string | null;
targetId?: string | null;
details?: Record<string, unknown> | null;
ipAddress?: string | null;
userAgent?: string | null;
createdAt?: string | null;
}
export interface CreatePlatformTenantInput {
slug: string;
name: string;
@@ -133,6 +205,10 @@ export interface UpdatePlatformTenantStatusInput {
reason?: string;
}
export interface UpsertPlatformTenantBillingProfileInput extends PlatformTenantBillingProfile {
tenantId: string;
}
export interface CreatePlatformSubscriptionInput {
tenantId: string;
planCode: string;
@@ -198,6 +274,20 @@ export async function loadPlatformTenants(query: { q?: string; status?: string;
});
}
export async function loadPlatformTenantDetail(tenantId: string) {
return apiRequest<{ item?: PlatformTenantDetail }>('/api/platform-admin/tenants/detail', {
query: { tenantId },
tenantId: null,
});
}
export async function loadPlatformAuditLogs(query: { tenantId?: string; action?: string; targetType?: string; actorUserId?: string; q?: string; limit?: number } = {}) {
return apiRequest<{ items?: PlatformAuditLogItem[] }>('/api/platform-admin/audit-logs', {
query: { ...query, limit: query.limit || 100 },
tenantId: null,
});
}
export async function loadPlatformInvoices(query: { tenantId?: string; status?: string; limit?: number } = {}) {
return apiRequest<{ items?: PlatformInvoiceItem[] }>('/api/platform-admin/invoices', {
query: { ...query, limit: query.limit || 80 },
@@ -242,6 +332,14 @@ export async function updatePlatformTenantStatus(input: UpdatePlatformTenantStat
});
}
export async function upsertPlatformTenantBillingProfile(input: UpsertPlatformTenantBillingProfileInput) {
return apiRequest<{ item?: PlatformTenantBillingProfile }>('/api/platform-admin/tenants/billing-profile', {
method: 'PUT',
body: input,
tenantId: null,
});
}
export async function createPlatformSubscription(input: CreatePlatformSubscriptionInput) {
return apiRequest<{ item?: Record<string, unknown> }>('/api/platform-admin/subscriptions', {
method: 'POST',