Merge pull request #2879 from QuantumNous/fix/subscription-preference-fallback

 chore: Improve subscription billing fallback and UI states
This commit is contained in:
Calcium-Ion
2026-02-07 13:55:37 +08:00
committed by GitHub
9 changed files with 96 additions and 16 deletions

View File

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