feat(usage): 使用记录增加计费模式字段 — 记录/展示/筛选 token/按次/图片
- DB: usage_logs 表新增 billing_mode VARCHAR(20) 列 - 后端: RecordUsage 写入时根据 image_count 判定计费模式 - 前端: 使用记录表格新增计费模式 badge 列 + 筛选下拉
This commit is contained in:
@@ -7863,6 +7863,17 @@ func (s *GatewayService) RecordUsage(ctx context.Context, input *RecordUsageInpu
|
||||
CreatedAt: time.Now(),
|
||||
}
|
||||
|
||||
// 设置计费模式
|
||||
if result.MediaType != "image" && result.MediaType != "video" && result.MediaType != "prompt" {
|
||||
if result.ImageCount > 0 {
|
||||
billingMode := "image"
|
||||
usageLog.BillingMode = &billingMode
|
||||
} else {
|
||||
billingMode := "token"
|
||||
usageLog.BillingMode = &billingMode
|
||||
}
|
||||
}
|
||||
|
||||
// 添加 UserAgent
|
||||
if input.UserAgent != "" {
|
||||
usageLog.UserAgent = &input.UserAgent
|
||||
@@ -8073,6 +8084,15 @@ func (s *GatewayService) RecordUsageWithLongContext(ctx context.Context, input *
|
||||
CreatedAt: time.Now(),
|
||||
}
|
||||
|
||||
// 设置计费模式
|
||||
if result.ImageCount > 0 {
|
||||
billingMode := "image"
|
||||
usageLog.BillingMode = &billingMode
|
||||
} else {
|
||||
billingMode := "token"
|
||||
usageLog.BillingMode = &billingMode
|
||||
}
|
||||
|
||||
// 添加 UserAgent
|
||||
if input.UserAgent != "" {
|
||||
usageLog.UserAgent = &input.UserAgent
|
||||
|
||||
Reference in New Issue
Block a user