fix(task): 修复任务执行中租户余额检查的参数传递错误

- 修正了 GetTenantSurplus 函数调用中的参数,从 task.TenantId 改为 model.TenantId
- 注释掉了模型调用中重复的余额检查逻辑以避免冗余验证
This commit is contained in:
WangLiZhao
2026-07-01 18:55:16 +08:00
parent a332aa438b
commit 4d95ff75d2
+6 -1
View File
@@ -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