From 4d95ff75d29298ef5ad3597adfd7ba0f8c14e2d8 Mon Sep 17 00:00:00 2001 From: WangLiZhao <1838393649@qq.com> Date: Wed, 1 Jul 2026 18:55:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(task):=20=E4=BF=AE=E5=A4=8D=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=89=A7=E8=A1=8C=E4=B8=AD=E7=A7=9F=E6=88=B7=E4=BD=99?= =?UTF-8?q?=E9=A2=9D=E6=A3=80=E6=9F=A5=E7=9A=84=E5=8F=82=E6=95=B0=E4=BC=A0?= =?UTF-8?q?=E9=80=92=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修正了 GetTenantSurplus 函数调用中的参数,从 task.TenantId 改为 model.TenantId - 注释掉了模型调用中重复的余额检查逻辑以避免冗余验证 --- service/task/worker.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/service/task/worker.go b/service/task/worker.go index 7ae433b..79d7b2e 100644 --- a/service/task/worker.go +++ b/service/task/worker.go @@ -45,7 +45,7 @@ func (w *asyncWorker) handleOne(ctx context.Context, task *entity.ModelGatewayTa // ============================================ // 1) 查询余额 // ============================================ - surplus, _ = gateway.GetTenantSurplus(ctx, task.TenantId) + surplus, _ = gateway.GetTenantSurplus(ctx, model.TenantId) if surplus <= 0 { w.failTask(ctx, task, startTime, "租户余额不足") return @@ -401,6 +401,11 @@ func injectErrorMessage(payload map[string]any, err error) map[string]any { // InvokeModel 调用模型服务,返回二进制结果 // modelKey 用于覆盖/补充模型配置 head_msg(例如每次请求携带不同的 X-API-Key) func InvokeModel(ctx context.Context, model *entity.ModelGatewayModel, body map[string]any) ([]byte, error) { + //surplus, _ := gateway.GetTenantSurplus(ctx, model.TenantId) + //if surplus <= 0 { + // return nil, fmt.Errorf("租户余额不足") + //} + // 3)构建请求 URL 和超时 baseURL := strings.TrimRight(model.BaseURL, "/") timeout := time.Duration(model.TimeoutSeconds) * time.Second