chore: Improve subscription billing fallback and UI states

Add a lightweight active-subscription check to skip subscription pre-consume when none exist, reducing unnecessary transactions and locks. In the subscription UI, disable subscription-first options when no active plan is available, show the effective fallback to wallet with a clear notice, and distinguish “invalidated” from “expired” states. Update i18n strings across supported locales to reflect the new messages and status labels.
This commit is contained in:
t0ng7u
2026-02-07 00:57:36 +08:00
parent 8b8ea60b1e
commit 1cc6bf1b45
9 changed files with 92 additions and 12 deletions

View File

@@ -323,6 +323,13 @@ func NewBillingSession(c *gin.Context, relayInfo *relaycommon.RelayInfo, preCons
case "subscription_first":
fallthrough
default:
hasSub, err := model.HasActiveUserSubscription(relayInfo.UserId)
if err != nil {
return nil, types.NewError(err, types.ErrorCodeQueryDataError, types.ErrOptionWithSkipRetry())
}
if !hasSub {
return tryWallet()
}
session, err := trySubscription()
if err != nil {
if err.GetErrorCode() == types.ErrorCodeInsufficientUserQuota {