feat(subscription): add support for wallet overflow and downgrade group functionality in subscription plans
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user