初始提交:OCI 面板后端(含 GenAI 网关一期)
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package oci
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"oci-portal/internal/model"
|
||||
)
|
||||
|
||||
// AccountProfile 是一次云端订阅查询得到的账户信息快照。
|
||||
type AccountProfile struct {
|
||||
AccountType string
|
||||
SubscriptionID string
|
||||
ServiceName string
|
||||
PaymentModel string
|
||||
SubscriptionTier string
|
||||
PromotionStatus string
|
||||
PromotionAmount float32
|
||||
PromotionExpires *time.Time
|
||||
}
|
||||
|
||||
// ClassifyAccount 按订阅字段判定账户类别:
|
||||
// - paymentModel 非空且不是 FREE_TRIAL:付费;
|
||||
// - paymentModel 为 FREE_TRIAL 时,promotion ACTIVE 或 tier FREE_AND_TRIAL
|
||||
// 判为试用;promotion EXPIRED 或 tier FREE 判为免费(试用权益已结束);
|
||||
// - 其余情况无法判定。
|
||||
func ClassifyAccount(paymentModel, subscriptionTier, promotionStatus string) string {
|
||||
pm := strings.ToUpper(strings.TrimSpace(paymentModel))
|
||||
tier := strings.ToUpper(strings.TrimSpace(subscriptionTier))
|
||||
promo := strings.ToUpper(strings.TrimSpace(promotionStatus))
|
||||
if pm != "" && pm != "FREE_TRIAL" {
|
||||
return model.AccountTypePaid
|
||||
}
|
||||
if pm == "FREE_TRIAL" {
|
||||
switch {
|
||||
case promo == "ACTIVE" || tier == "FREE_AND_TRIAL":
|
||||
return model.AccountTypeTrial
|
||||
case promo == "EXPIRED" || tier == "FREE":
|
||||
return model.AccountTypeFree
|
||||
}
|
||||
}
|
||||
return model.AccountTypeUnknown
|
||||
}
|
||||
Reference in New Issue
Block a user