fengsilin
387f6c1ae0
feat(pricing): 定价数据源切换到渠道表,新增缓存价格展示
- 后端 pricing API 从 channel_pricings 表获取实际定价,选取最便宜渠道
- 提取 applyGlobalDefault 辅助函数消除全局回退逻辑重复
- price.go 重构扩展比率为局部变量,简化回退逻辑
- 定价卡片新增缓存读取/创建价格,改为两行布局防止溢出
- ChannelPricingCard 缓存列显示实际价格而非倍率
- 修复移动端 hero 区域 padding 过大
- 默认标签页标题改为 Loading...
- 新增缓存读取/创建 i18n 翻译(7 语言)
Co-Authored-By: Claude <noreply@anthropic.com>
2 weeks ago
fengsilin
00058cd671
refactor(channel-pricing): 提取辅助方法消除重复代码,修复缓存一致性
- 提取 PriceData.ApplyChannelPricingRatios 消除 ModelPriceHelper 和
UpdatePriceDataForChannelPricing 中重复的 ~30 行比率回退逻辑
- 提取 ChannelPricing.ApplyFields 消除 controller 中 4 处相同的字段赋值
- 提取 setCache/removeCache 辅助函数统一写穿透缓存操作
- 将 claudeCacheCreation1hMultiplier 常量移至 types 包避免循环依赖
- 修复 BatchUpsertChannelPricing 成功后未刷新内存缓存的 bug
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3 weeks ago
fengsilin
3a24fd598f
feat(channel-pricing): ModelPriceHelper + UpdatePriceDataForChannelPricing 适配新签名,支持扩展比率覆盖
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3 weeks ago
fengsilin
97485bfede
feat: 移植上游 Param Override 增强系统
从上游移植 override.go 的完整增强功能(603行→2057行),包括:
新增 9 种 Operation Mode:
- return_error: 规则直接返回 HTTP 错误中断请求
- prune_objects: 按 JSON Schema 过滤数组元素
- set_header / delete_header / copy_header / move_header: 动态管理上游请求头
- pass_headers: 透传下游请求头到上游
- sync_fields: 请求体不同路径间同步字段值
- 通配符路径支持: messages.*.role 等
新增核心模块:
- Header Override 系统:从上下文取值、正则匹配、列表追加
- Audit 审计系统:关键操作自动记录到 RelayInfo.ParamOverrideAudit
- Return Error 机制:含状态码/错误类型/跳过重试控制
- Legacy 兼容层:同时执行旧格式和新格式 param override
- RelayInfo 集成:丰富上下文(retry_index、last_error、request_headers 等)
RelayInfo 新增字段:RetryIndex, LastError, RequestHeaders,
RuntimeHeadersOverride, UseRuntimeHeadersOverride, ParamOverrideAudit
所有 handler 统一使用 ApplyParamOverrideWithRelayInfo,
全部测试通过(100+ test cases)。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4 weeks ago
fengsilin
296edf0f71
fix: 移植上游关键 bug 修复
从 QuantumNous/new-api 上游移植以下修复:
- fix(ssrf): 加固视频代理和 MJ 图片代理的 SSRF 防护,FetchModels 提权至 RootAuth
- fix(claude): 流式断流时不再整份覆盖 usage,保留 cache 计费字段
- fix(pricing): 定价接口增加用户可用分组过滤
- fix(ratio): compact 模型优先匹配精确定价再回退通配符
- fix(ali): 接受 task polling 返回的字符串类型 usage 值
- fix(gemini): 从 URL 路径 :streamGenerateContent 检测流式请求
- fix(zhipu_4v): coding plan 图片生成使用正确的 OpenAI endpoint
- fix(openai): MessageImageUrl.Detail 字段添加 omitempty
- fix(channel-affinity): skip_retry_on_failure 配置项为 false 时不再丢失
- fix(document-renderer): 使用 useMemo 替代 useState 处理 HTML payload
- fix(fetch-setting): ApplyIPFilterForDomain 默认值改为 true
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4 weeks ago
fengsilin
1cecd5349d
feat: 跨区域配额同步(Master-Slave Region Sync)
实现 Master-Slave 架构的跨区域用户和配额同步功能,支持国内主节点与
海外从节点之间的用户创建推送、余额同步、预扣费批量回传。
主要变更:
- 新增 region_sync 服务层(SyncManager/SyncClient/推送逻辑)
- User 模型扩展 Source/RemoteUserId/SyncedQuota/LastSyncAt 字段
- BillingSession 支持 SyncedUserFunding 资金来源
- 新增 SyncAuth 中间件(X-Sync-API-Key + 常量时间比较)
- 新增 PendingSyncRecord/QuotaSyncLog 数据模型
- 前端新增区域同步配置面板
- 支持 SESSION_NAME 环境变量避免多节点 cookie 冲突
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4 weeks ago
fengsilin
b99337dab7
fix(pricing): 修复渠道定价优先级问题
当模型配置了渠道定价但全局定价未设置时,不再提前报错。
将全局定价检查延迟到渠道选择后执行。
Co-Authored-By: Claude <noreply@anthropic.com>
1 month ago
fengsilin
15a99da48e
fix: channel pricing not working correctly
This PR fixes three issues:
1. Token bound_channel_id not updating: Add bound field to Update() method
2. Channel pricing quota_type detection: Use QuotaTypeByCall constant instead of magic number 1
3. Log display for ratio-based pricing: Set ModelPrice=-1 for ratio-based pricing
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 month ago
fengsilin
db939deb79
feat: integrate channel pricing into ModelPriceHelper
Integrate channel-specific pricing into the billing logic.
- First tries to get channel pricing using model.GetEffectivePricing
- If found, uses channel pricing (modelRatio, completionRatio, modelPrice, usePrice)
- If not found, falls back to global pricing from ratio_setting
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 month ago
winter
08164cd0ae
fix
2 months ago