fix: When the user is a non-sandbox user and has a paid balance, the paid limit will be displayed, otherwise the trail limit will be displayed.

This commit is contained in:
Yansong Zhang 2026-02-10 11:08:41 +08:00
parent ff8d7855b1
commit 5c05f09e23
1 changed files with 7 additions and 1 deletions

View File

@ -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 > paid_pool.quota_used
):
tenant_info["trial_credits"] = paid_pool.quota_limit
tenant_info["trial_credits_used"] = paid_pool.quota_used
else: