From a332aa438b1dfe992f095fd36e7c72c62c3446ec Mon Sep 17 00:00:00 2001 From: WangLiZhao <1838393649@qq.com> Date: Wed, 1 Jul 2026 18:47:13 +0800 Subject: [PATCH] =?UTF-8?q?refactor(task):=20=E4=BC=98=E5=8C=96=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=A4=84=E7=90=86=E4=B8=AD=E7=9A=84=E4=BD=99=E9=A2=9D?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/task/worker.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/service/task/worker.go b/service/task/worker.go index f1229c0..7ae433b 100644 --- a/service/task/worker.go +++ b/service/task/worker.go @@ -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) 调用模型