From 7dabc03a08375488632b42440fb46edeed3c2a34 Mon Sep 17 00:00:00 2001 From: zyssyz123 <916125788@qq.com> Date: Tue, 10 Feb 2026 12:08:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20When=20the=20user=20is=20a=20non-sandbox?= =?UTF-8?q?=20user=20and=20has=20a=20paid=20balance,=20the=20=E2=80=A6=20(?= =?UTF-8?q?#32173)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- api/services/workspace_service.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/services/workspace_service.py b/api/services/workspace_service.py index 3ee41c2e8d..84a8b03329 100644 --- a/api/services/workspace_service.py +++ b/api/services/workspace_service.py @@ -1,6 +1,7 @@ from flask_login import current_user from configs import dify_config +from enums.cloud_plan import CloudPlan from extensions.ext_database import db from models.account import Tenant, TenantAccountJoin, TenantAccountRole from services.account_service import TenantService @@ -53,7 +54,12 @@ class WorkspaceService: from services.credit_pool_service import CreditPoolService paid_pool = CreditPoolService.get_pool(tenant_id=tenant.id, pool_type="paid") - if paid_pool: + # if the tenant is not on the sandbox plan and the paid pool is not full, use the paid pool + if ( + feature.billing.subscription.plan != CloudPlan.SANDBOX + and paid_pool is not None + and (paid_pool.quota_limit == -1 or paid_pool.quota_limit > paid_pool.quota_used) + ): tenant_info["trial_credits"] = paid_pool.quota_limit tenant_info["trial_credits_used"] = paid_pool.quota_used else: