将全库资金金额从 float64 迁移到 shopspring/decimal,落定边界架构: 入口 NewFromFloat → 内部多步运算全程 decimal → 出口 InexactFloat64; DB NUMERIC(20,10) 走 driver.Valuer 精确直传,Redis 钱包用整数 micro-USD, CNY→USD 换汇仅在 payment.FulfillOrder recharge 分支。 - money.go 重写为 decimal 原生(运算/收敛/比较/边界/micro 工具) - billing/tenant/admin/payment/open/task 各层金额运算 decimal 化 - entity/do 资金列重生成为 decimal.Decimal(可空列 *decimal.Decimal) - 000013 迁移:非金额 NUMERIC 列 → double precision(5 表 13 列) - Res 出口 .InexactFloat64() 收敛,JSONB 快照缝隙显式转 float64 - CLAUDE.md 新增 decimal 强约束;补充迁移基线/完成总结文档
48 lines
7.9 KiB
Go
48 lines
7.9 KiB
Go
// =================================================================================
|
||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||
// =================================================================================
|
||
|
||
package entity
|
||
|
||
import (
|
||
"github.com/gogf/gf/v2/os/gtime"
|
||
"github.com/shopspring/decimal"
|
||
)
|
||
|
||
// BilRecords is the golang structure for table bil_records.
|
||
type BilRecords struct {
|
||
Id int64 `json:"id" orm:"id" description:"主键ID"` // 主键ID
|
||
TenantId int64 `json:"tenant_id" orm:"tenant_id" description:"租户ID"` // 租户ID
|
||
UserId int64 `json:"user_id" orm:"user_id" description:"用户ID"` // 用户ID
|
||
ApiKeyId int64 `json:"api_key_id" orm:"api_key_id" description:"使用的 API Key ID"` // 使用的 API Key ID
|
||
ChannelId int64 `json:"channel_id" orm:"channel_id" description:"使用的渠道ID"` // 使用的渠道ID
|
||
ModelName string `json:"model_name" orm:"model_name" description:"调用的模型名"` // 调用的模型名
|
||
RequestId string `json:"request_id" orm:"request_id" description:"请求唯一ID(关联全链路追踪)"` // 请求唯一ID(关联全链路追踪)
|
||
RelayMode string `json:"relay_mode" orm:"relay_mode" description:"代理模式:chat_completions / embeddings / images_generations 等"` // 代理模式:chat_completions / embeddings / images_generations 等
|
||
InputTokens int `json:"input_tokens" orm:"input_tokens" description:"输入 token 数"` // 输入 token 数
|
||
OutputTokens int `json:"output_tokens" orm:"output_tokens" description:"输出 token 数"` // 输出 token 数
|
||
InputPrice decimal.Decimal `json:"input_price" orm:"input_price" description:"计费时输入单价(快照,防止价格变更影响历史记录)"` // 计费时输入单价(快照,防止价格变更影响历史记录)
|
||
OutputPrice decimal.Decimal `json:"output_price" orm:"output_price" description:"计费时输出单价(快照)"` // 计费时输出单价(快照)
|
||
TotalCost decimal.Decimal `json:"total_cost" orm:"total_cost" description:"最终费用 = 基础价格 × 模型倍率 × 租户倍率"` // 最终费用 = 基础价格 × 模型倍率 × 租户倍率
|
||
Currency string `json:"currency" orm:"currency" description:"货币(USD)"` // 货币(USD)
|
||
Status string `json:"status" orm:"status" description:"状态:pre_deducted(已预扣)/ settled(已结算)/ refunded(已退款)"` // 状态:pre_deducted(已预扣)/ settled(已结算)/ refunded(已退款)
|
||
SettledAt *gtime.Time `json:"settled_at" orm:"settled_at" description:"结算时间"` // 结算时间
|
||
CreatedAt *gtime.Time `json:"created_at" orm:"created_at" description:"创建时间"` // 创建时间
|
||
UpdatedAt *gtime.Time `json:"updated_at" orm:"updated_at" description:"更新时间"` // 更新时间
|
||
BillingMode string `json:"billing_mode" orm:"billing_mode" description:"实际计费模式"` // 实际计费模式
|
||
EffectiveInputPrice decimal.Decimal `json:"effective_input_price" orm:"effective_input_price" description:"实际生效的输入单价(快照)"` // 实际生效的输入单价(快照)
|
||
EffectiveOutputPrice decimal.Decimal `json:"effective_output_price" orm:"effective_output_price" description:"实际生效的输出单价(快照)"` // 实际生效的输出单价(快照)
|
||
DiscountRatio decimal.Decimal `json:"discount_ratio" orm:"discount_ratio" description:"实际折扣比例(快照)"` // 实际折扣比例(快照)
|
||
BillingInputMultiplier decimal.Decimal `json:"billing_input_multiplier" orm:"billing_input_multiplier" description:"梯度定价输入乘数(快照)"` // 梯度定价输入乘数(快照)
|
||
BillingOutputMultiplier decimal.Decimal `json:"billing_output_multiplier" orm:"billing_output_multiplier" description:"梯度定价输出乘数(快照)"` // 梯度定价输出乘数(快照)
|
||
CacheCreationTokens int `json:"cache_creation_tokens" orm:"cache_creation_tokens" description:"缓存创建 token 数"` // 缓存创建 token 数
|
||
CacheReadTokens int `json:"cache_read_tokens" orm:"cache_read_tokens" description:"缓存读取 token 数"` // 缓存读取 token 数
|
||
CacheCreationCost decimal.Decimal `json:"cache_creation_cost" orm:"cache_creation_cost" description:"缓存创建费用"` // 缓存创建费用
|
||
CacheReadCost decimal.Decimal `json:"cache_read_cost" orm:"cache_read_cost" description:"缓存读取费用"` // 缓存读取费用
|
||
ModelMultiplier decimal.Decimal `json:"model_multiplier" orm:"model_multiplier" description:"模型倍率(快照)"` // 模型倍率(快照)
|
||
TenantMultiplier decimal.Decimal `json:"tenant_multiplier" orm:"tenant_multiplier" description:"租户倍率(快照)"` // 租户倍率(快照)
|
||
BaseInputPrice decimal.Decimal `json:"base_input_price" orm:"base_input_price" description:"基础模型输入单价(快照,应用倍率前)"` // 基础模型输入单价(快照,应用倍率前)
|
||
BaseOutputPrice decimal.Decimal `json:"base_output_price" orm:"base_output_price" description:"基础模型输出单价(快照,应用倍率前)"` // 基础模型输出单价(快照,应用倍率前)
|
||
BillingSnapshot string `json:"billing_snapshot" orm:"billing_snapshot" description:"完整计费计算过程快照(JSONB)"` // 完整计费计算过程快照(JSONB)
|
||
}
|