feat: 新增会话与结果管理功能及扩展字段

重构执行列表树状结构,扁平化日期节点下的输出项,新增会话列表查询、结果删除与软删除标记,引入扩展字段与模板配置,升级依赖版本。
This commit is contained in:
2026-07-08 09:22:53 +08:00
parent d46f163cfd
commit b8006329d1
2 changed files with 16 additions and 22 deletions
+2 -20
View File
@@ -117,23 +117,8 @@ func calculateVideoResolutionBilling(config map[string]any, data map[string]any)
}
func calculateTTSBilling(config map[string]any, data map[string]any) map[string]any {
unit, _ := config["unit"].(string)
usage := gconv.Float64(data["usage"])
tiers := config["pricing"].(map[string]any)["tiers"].([]any)
var matched map[string]any
for _, t := range tiers {
tier := t.(map[string]any)
if usage >= gconv.Float64(tier["min"]) && usage <= gconv.Float64(tier["max"]) {
matched = tier
break
}
}
if matched == nil {
return nil
}
unitPrice := gconv.Float64(matched["unit_price"])
usage := gconv.Float64(data["synthesize_text_length"])
unitPrice := gconv.Float64(config["pricing"])
totalFee := usage * unitPrice
return map[string]any{
@@ -143,10 +128,7 @@ func calculateTTSBilling(config map[string]any, data map[string]any) map[string]
// 明细
"prompt_tokens": 0,
"completion_tokens": int64(usage),
"usage": usage,
"unit": unit,
"unit_price": unitPrice,
"tier": fmt.Sprintf("[%v, %v]", matched["min"], matched["max"]),
}
}
+14 -2
View File
@@ -126,7 +126,13 @@ func (w *asyncWorker) handleOne(ctx context.Context, task *entity.ModelGatewayTa
task.BillingData[0] = billingResult
totalFee := gconv.Float64(billingResult["total_fee"])
if totalFee > 0 {
_ = gateway.DeductBalance(util.AsyncCtx(ctx), model.TenantId, -totalFee)
for attempt := 0; attempt <= maxRetry; attempt++ {
err = gateway.DeductBalance(util.AsyncCtx(ctx), model.TenantId, -totalFee)
if err == nil {
break
}
g.Log().Warningf(ctx, "[handleOne] 扣除余额失败 taskId=%s attempt=%d/%d err=%v", task.TaskID, attempt, maxRetry, err)
}
}
}
}
@@ -337,7 +343,13 @@ func (w *asyncWorker) parseAndRetry(ctx context.Context, body map[string]any, mo
task.BillingData = append(task.BillingData, billingResult)
totalFee := gconv.Float64(billingResult["total_fee"])
if totalFee > 0 {
_ = gateway.DeductBalance(util.AsyncCtx(ctx), task.TenantId, -totalFee)
for a := 0; a <= maxRetry; a++ {
errr := gateway.DeductBalance(util.AsyncCtx(ctx), task.TenantId, -totalFee)
if errr == nil {
break
}
g.Log().Warningf(ctx, "[handleOne] 扣除余额失败 taskId=%s attempt=%d/%d err=%v", task.TaskID, a, maxRetry, errr)
}
}
}