feat: add payment gateway and billing plans

This commit is contained in:
Entropy.Xu
2026-05-13 01:18:38 +08:00
parent 0fa97595bf
commit 10285c5eb9
97 changed files with 14797 additions and 404 deletions

View File

@@ -16,6 +16,9 @@ import {
type UserGroupMember,
type UpsertUserGroupRequest,
type ListUserGroupsResponse,
type AdminUserPlanEntitlementsResponse,
type GrantUserPlanRequest,
type GrantUserPlanResponse,
} from '@/api/users'
import { parseApiError } from '@/utils/errorParser'
@@ -248,6 +251,29 @@ export const useUsersStore = defineStore('users', () => {
}
}
async function listUserPlanEntitlements(
userId: string,
): Promise<AdminUserPlanEntitlementsResponse> {
try {
return await usersApi.listUserPlanEntitlements(userId)
} catch (err: unknown) {
error.value = parseApiError(err, '获取用户套餐失败')
throw err
}
}
async function grantUserPlan(
userId: string,
payload: GrantUserPlanRequest,
): Promise<GrantUserPlanResponse> {
try {
return await usersApi.grantUserPlan(userId, payload)
} catch (err: unknown) {
error.value = parseApiError(err, '发放用户套餐失败')
throw err
}
}
async function revokeUserSession(userId: string, sessionId: string): Promise<{ message: string }> {
try {
return await usersApi.revokeUserSession(userId, sessionId)
@@ -291,6 +317,8 @@ export const useUsersStore = defineStore('users', () => {
deleteApiKey,
getFullApiKey,
getUserSessions,
listUserPlanEntitlements,
grantUserPlan,
revokeUserSession,
revokeAllUserSessions,
}