refactor(task): 优化任务处理中的余额检查逻辑
This commit is contained in:
@@ -38,21 +38,19 @@ func (w *asyncWorker) handleOne(ctx context.Context, task *entity.ModelGatewayTa
|
||||
rawData []byte
|
||||
result map[string]any
|
||||
err error
|
||||
surplus float64
|
||||
)
|
||||
g.Log().Infof(ctx, "[handleOne] 开始 taskId=%s model=%s", task.TaskID, task.ModelName)
|
||||
|
||||
// ============================================
|
||||
// 1) 查询余额
|
||||
// ============================================
|
||||
var surplus float64
|
||||
if len(model.BillingConfig) > 0 {
|
||||
surplus, _ = gateway.GetTenantSurplus(ctx, task.TenantId)
|
||||
if surplus <= 0 {
|
||||
w.failTask(ctx, task, startTime, "租户余额不足")
|
||||
return
|
||||
}
|
||||
g.Log().Infof(ctx, "[handleOne] 当前余额 tenantId=%d surplus=%.2f", task.TenantId, surplus)
|
||||
surplus, _ = gateway.GetTenantSurplus(ctx, task.TenantId)
|
||||
if surplus <= 0 {
|
||||
w.failTask(ctx, task, startTime, "租户余额不足")
|
||||
return
|
||||
}
|
||||
g.Log().Infof(ctx, "[handleOne] 当前余额 tenantId=%d surplus=%.2f", task.TenantId, surplus)
|
||||
|
||||
// ============================================
|
||||
// 2) 调用模型
|
||||
|
||||
Reference in New Issue
Block a user