112 lines
2.7 KiB
Go
112 lines
2.7 KiB
Go
package ledger
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
// VipRewardItem 是 VIP 资源组权益的轻量展示投影。
|
|
type VipRewardItem struct {
|
|
ResourceID int64
|
|
ResourceCode string
|
|
ResourceType string
|
|
Name string
|
|
Quantity int64
|
|
ExpiresAtMS int64
|
|
AssetURL string
|
|
PreviewURL string
|
|
AnimationURL string
|
|
}
|
|
|
|
// VipLevel 是可购买 VIP 等级配置。
|
|
type VipLevel struct {
|
|
Level int32
|
|
Name string
|
|
Status string
|
|
PriceCoin int64
|
|
DurationMS int64
|
|
RewardResourceGroupID int64
|
|
RequiredRechargeCoinAmount int64
|
|
UserRechargeCoinAmount int64
|
|
RechargeGateRequired bool
|
|
PurchaseLockedReason string
|
|
RewardItems []VipRewardItem
|
|
CanPurchase bool
|
|
SortOrder int32
|
|
CreatedAtMS int64
|
|
UpdatedAtMS int64
|
|
}
|
|
|
|
// UserVip 是用户当前会员状态。是否有效以 ExpiresAtMS 和当前时间判断。
|
|
type UserVip struct {
|
|
UserID int64
|
|
Level int32
|
|
Name string
|
|
Active bool
|
|
StartedAtMS int64
|
|
ExpiresAtMS int64
|
|
UpdatedAtMS int64
|
|
}
|
|
|
|
// PurchaseVipCommand 是 App 购买或升级 VIP 的账务命令。
|
|
type PurchaseVipCommand struct {
|
|
AppCode string
|
|
CommandID string
|
|
UserID int64
|
|
Level int32
|
|
}
|
|
|
|
// PurchaseVipReceipt 是购买 VIP 成功后的稳定回执。
|
|
type PurchaseVipReceipt struct {
|
|
OrderID string
|
|
TransactionID string
|
|
Vip UserVip
|
|
CoinSpent int64
|
|
CoinBalanceAfter int64
|
|
RewardItems []VipRewardItem
|
|
}
|
|
|
|
// GrantVipCommand 是活动或后台发放 VIP 的统一入口命令。
|
|
type GrantVipCommand struct {
|
|
AppCode string
|
|
CommandID string
|
|
TargetUserID int64
|
|
Level int32
|
|
GrantSource string
|
|
OperatorUserID int64
|
|
Reason string
|
|
}
|
|
|
|
// GrantVipReceipt 是赠送 VIP 成功后的稳定回执。
|
|
type GrantVipReceipt struct {
|
|
TransactionID string
|
|
Vip UserVip
|
|
RewardItems []VipRewardItem
|
|
}
|
|
|
|
// AdminVipLevelCommand 是后台保存 VIP 等级配置的完整事实输入。
|
|
type AdminVipLevelCommand struct {
|
|
Level int32
|
|
Name string
|
|
Status string
|
|
PriceCoin int64
|
|
DurationMS int64
|
|
RewardResourceGroupID int64
|
|
RequiredRechargeCoinAmount int64
|
|
SortOrder int32
|
|
}
|
|
|
|
func NormalizeVipGrantSource(source string) string {
|
|
switch strings.ToLower(strings.TrimSpace(source)) {
|
|
case VipGrantSourcePurchase:
|
|
return VipGrantSourcePurchase
|
|
case VipGrantSourceActivity:
|
|
return VipGrantSourceActivity
|
|
case VipGrantSourceAdmin:
|
|
return VipGrantSourceAdmin
|
|
case VipGrantSourceManagerCenter:
|
|
return VipGrantSourceManagerCenter
|
|
default:
|
|
return ""
|
|
}
|
|
}
|