feat(subscription): add support for wallet overflow and downgrade group functionality in subscription plans

This commit is contained in:
CaIon
2026-06-18 16:44:12 +08:00
parent 4e8b5e9b13
commit f6c260437c
17 changed files with 291 additions and 59 deletions
+9 -1
View File
@@ -425,7 +425,15 @@ func NewBillingSession(c *gin.Context, relayInfo *relaycommon.RelayInfo, preCons
session, apiErr := trySubscription()
if apiErr != nil {
if apiErr.GetErrorCode() == types.ErrorCodeInsufficientUserQuota {
return tryWallet()
// 仅当用户的活跃订阅允许钱包回退时才回退到钱包,否则返回订阅额度不足错误
allowOverflow, overflowErr := model.UserActiveSubscriptionsAllowWalletOverflow(relayInfo.UserId)
if overflowErr != nil {
return nil, types.NewError(overflowErr, types.ErrorCodeQueryDataError, types.ErrOptionWithSkipRetry())
}
if allowOverflow {
return tryWallet()
}
return nil, apiErr
}
return nil, apiErr
}