Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
- 删除 webhook 死代码模块 (4 文件 + worker,未注册未挂载) - 删除孤立组件 StatusTag.tsx (从未被导入) - authStore 权限模型补全 (scheduler/knowledge/billing 6+ permission key) - authStore 硬编码 logout URL 改为 env 变量 - 清理未使用 service 方法 (agent-templates/billing/roles) - Logs.tsx 代码重复消除 (本地常量 → @/constants/status) - TRUTH.md 数字校准 (Tauri 177→183, SaaS API 131→130)
94 lines
2.2 KiB
TypeScript
94 lines
2.2 KiB
TypeScript
import request, { withSignal } from './request'
|
|
|
|
// === Types ===
|
|
|
|
export interface BillingPlan {
|
|
id: string
|
|
name: string
|
|
display_name: string
|
|
description: string | null
|
|
price_cents: number
|
|
currency: string
|
|
interval: string
|
|
features: Record<string, unknown>
|
|
limits: Record<string, unknown>
|
|
is_default: boolean
|
|
sort_order: number
|
|
status: string
|
|
created_at: string
|
|
updated_at: string
|
|
}
|
|
|
|
export interface Subscription {
|
|
id: string
|
|
account_id: string
|
|
plan_id: string
|
|
status: string
|
|
current_period_start: string
|
|
current_period_end: string
|
|
trial_end: string | null
|
|
canceled_at: string | null
|
|
cancel_at_period_end: boolean
|
|
created_at: string
|
|
updated_at: string
|
|
}
|
|
|
|
export interface UsageQuota {
|
|
id: string
|
|
account_id: string
|
|
period_start: string
|
|
period_end: string
|
|
input_tokens: number
|
|
output_tokens: number
|
|
relay_requests: number
|
|
hand_executions: number
|
|
pipeline_runs: number
|
|
max_input_tokens: number | null
|
|
max_output_tokens: number | null
|
|
max_relay_requests: number | null
|
|
max_hand_executions: number | null
|
|
max_pipeline_runs: number | null
|
|
created_at: string
|
|
updated_at: string
|
|
}
|
|
|
|
export interface SubscriptionInfo {
|
|
plan: BillingPlan
|
|
subscription: Subscription | null
|
|
usage: UsageQuota
|
|
}
|
|
|
|
export interface PaymentResult {
|
|
payment_id: string
|
|
trade_no: string
|
|
pay_url: string
|
|
amount_cents: number
|
|
}
|
|
|
|
export interface PaymentStatus {
|
|
id: string
|
|
method: string
|
|
amount_cents: number
|
|
currency: string
|
|
status: string
|
|
}
|
|
|
|
// === Service ===
|
|
|
|
export const billingService = {
|
|
listPlans: (signal?: AbortSignal) =>
|
|
request.get<BillingPlan[]>('/billing/plans', withSignal({}, signal))
|
|
.then((r) => r.data),
|
|
|
|
getSubscription: (signal?: AbortSignal) =>
|
|
request.get<SubscriptionInfo>('/billing/subscription', withSignal({}, signal))
|
|
.then((r) => r.data),
|
|
|
|
createPayment: (data: { plan_id: string; payment_method: 'alipay' | 'wechat' }) =>
|
|
request.post<PaymentResult>('/billing/payments', data).then((r) => r.data),
|
|
|
|
getPaymentStatus: (id: string, signal?: AbortSignal) =>
|
|
request.get<PaymentStatus>(`/billing/payments/${id}`, withSignal({}, signal))
|
|
.then((r) => r.data),
|
|
}
|