feat(billing): 统一计价与候选冻结估算

新增 effective-pricing-v2、9 位十进制定点计算、显式免费校验和结构化缺价错误。估价与生产预处理覆盖全部可用候选,并按最大候选费用冻结;规则优先级为平台模型、平台、基准模型。\n\n同步计价契约和 OpenAPI,补充 Token 参数别名、视频五秒向上取整及缺价回归测试。\n\n验证:go test ./...、pnpm openapi、Web 测试与构建通过。
This commit is contained in:
2026-07-20 23:22:45 +08:00
parent 01a013c809
commit 5114686c35
14 changed files with 1192 additions and 28 deletions
+10
View File
@@ -184,6 +184,7 @@ export interface PricingRule {
| string;
unit: '1k_tokens' | 'image' | '5s' | 'second' | 'character_1k' | 'item' | string;
basePrice: number;
isFree: boolean;
currency: 'resource' | 'credit' | 'cny' | 'usd' | string;
baseWeight?: Record<string, unknown>;
dynamicWeight?: Record<string, unknown>;
@@ -193,6 +194,8 @@ export interface PricingRule {
priority: number;
status: 'active' | 'deprecated' | 'hidden' | string;
metadata?: Record<string, unknown>;
effectiveFrom?: string;
effectiveTo?: string;
createdAt: string;
updatedAt: string;
}
@@ -203,6 +206,7 @@ export interface PricingRuleInput {
resourceType: string;
unit: string;
basePrice: number;
isFree?: boolean;
currency?: string;
baseWeight?: Record<string, unknown>;
dynamicWeight?: Record<string, unknown>;
@@ -212,6 +216,8 @@ export interface PricingRuleInput {
priority?: number;
status?: 'active' | 'deprecated' | 'hidden' | string;
metadata?: Record<string, unknown>;
effectiveFrom?: string;
effectiveTo?: string;
}
export interface PricingRuleSet {
@@ -548,7 +554,11 @@ export interface GatewayPricingEstimate {
items: GatewayPricingEstimateItem[];
resolver: string;
totalAmount?: number;
reservationAmount?: number;
currency?: string;
candidateCount: number;
pricingVersion: string;
requestFingerprint: string;
}
export interface GatewayWalletAccount {