284 lines
7.5 KiB
Go
284 lines
7.5 KiB
Go
package growth
|
||
|
||
const (
|
||
TrackWealth = "wealth"
|
||
TrackGame = "game"
|
||
TrackCharm = "charm"
|
||
|
||
StatusActive = "active"
|
||
StatusDisabled = "disabled"
|
||
|
||
RewardStatusPending = "pending"
|
||
RewardStatusRunning = "running"
|
||
RewardStatusGranted = "granted"
|
||
RewardStatusFailed = "failed"
|
||
|
||
RewardSourceLevel = "level"
|
||
RewardSourceTier = "tier"
|
||
|
||
EventStatusConsumed = "consumed"
|
||
EventStatusDuplicate = "duplicate"
|
||
|
||
MetricGiftSpendCoin = "gift_spend_coin"
|
||
MetricReceivedGiftValue = "received_gift_value"
|
||
MetricGameSpendCoin = "game_spend_coin"
|
||
|
||
GrantSourceGrowthLevel = "growth_level"
|
||
)
|
||
|
||
// Track 是等级体系的一条成长轨道;默认有 wealth/game/charm 三条。
|
||
type Track struct {
|
||
AppCode string
|
||
Track string
|
||
Name string
|
||
Status string
|
||
SortOrder int32
|
||
DisplayConfigJSON string
|
||
CreatedAtMS int64
|
||
UpdatedAtMS int64
|
||
}
|
||
|
||
// Rule 是单个等级的阈值和可选奖励配置。
|
||
type Rule struct {
|
||
AppCode string
|
||
Track string
|
||
Level int32
|
||
RequiredValue int64
|
||
Name string
|
||
Status string
|
||
RewardResourceGroupID int64
|
||
SortOrder int32
|
||
DisplayConfigJSON string
|
||
CreatedByAdminID int64
|
||
UpdatedByAdminID int64
|
||
CreatedAtMS int64
|
||
UpdatedAtMS int64
|
||
}
|
||
|
||
// Tier 是等级段展示配置;等级段奖励通常用于永久头像框和徽章。
|
||
type Tier struct {
|
||
AppCode string
|
||
TierID int64
|
||
Track string
|
||
MinLevel int32
|
||
MaxLevel int32
|
||
Name string
|
||
DisplayAvatarFrameResourceID int64
|
||
DisplayBadgeResourceID int64
|
||
RewardResourceGroupID int64
|
||
Status string
|
||
DisplayConfigJSON string
|
||
CreatedByAdminID int64
|
||
UpdatedByAdminID int64
|
||
CreatedAtMS int64
|
||
UpdatedAtMS int64
|
||
}
|
||
|
||
// Account 是用户在某条轨道上的累计值和当前等级。
|
||
type Account struct {
|
||
AppCode string
|
||
UserID int64
|
||
Track string
|
||
TotalValue int64
|
||
CurrentLevel int32
|
||
CurrentTierID int64
|
||
LevelUpdatedAtMS int64
|
||
TierUpdatedAtMS int64
|
||
Version int64
|
||
UpdatedAtMS int64
|
||
}
|
||
|
||
// TrackOverview 是 App 等级页展示的单轨道摘要。
|
||
type TrackOverview struct {
|
||
Track string
|
||
Name string
|
||
Level int32
|
||
TierID int64
|
||
TotalValue int64
|
||
CurrentLevelRequiredValue int64
|
||
NextLevel int32
|
||
NextLevelRequiredValue int64
|
||
DisplayAvatarFrameResourceID int64
|
||
DisplayBadgeResourceID int64
|
||
DisplayBadgeSourceLevel int32
|
||
RewardPendingCount int64
|
||
SortOrder int32
|
||
}
|
||
|
||
// LevelDisplayTrackProfile 是房间资料、资料卡这类轻量展示面读取的单轨道投影。
|
||
type LevelDisplayTrackProfile struct {
|
||
Track string
|
||
Level int32
|
||
TierID int64
|
||
AvatarFrameResourceID int64
|
||
BadgeResourceID int64
|
||
BadgeSourceLevel int32
|
||
UpdatedAtMS int64
|
||
}
|
||
|
||
// UserLevelDisplayProfile 固定携带 wealth/game/charm 三条轨道,避免展示层按数组顺序猜含义。
|
||
type UserLevelDisplayProfile struct {
|
||
UserID int64
|
||
Wealth LevelDisplayTrackProfile
|
||
Game LevelDisplayTrackProfile
|
||
Charm LevelDisplayTrackProfile
|
||
}
|
||
|
||
// LevelDisplayProfiles 是批量用户展示投影的只读快照。
|
||
type LevelDisplayProfiles struct {
|
||
Profiles []UserLevelDisplayProfile
|
||
ServerTimeMS int64
|
||
}
|
||
|
||
// RegistrationLevelBadgeGrant 是注册后按等级规则补发的 1 级等级徽章发放结果。
|
||
type RegistrationLevelBadgeGrant struct {
|
||
Track string
|
||
Level int32
|
||
ResourceID int64
|
||
GrantID string
|
||
}
|
||
|
||
type RegistrationLevelBadgeGrants struct {
|
||
Grants []RegistrationLevelBadgeGrant
|
||
ServerTimeMS int64
|
||
}
|
||
|
||
// TrackDetail 返回一个轨道的完整阈值、等级段和当前用户进度。
|
||
type TrackDetail struct {
|
||
Overview TrackOverview
|
||
Rules []Rule
|
||
Tiers []Tier
|
||
ServerTimeMS int64
|
||
}
|
||
|
||
// Config 是后台等级配置页读取的完整配置快照;它不携带任何用户进度。
|
||
type Config struct {
|
||
Tracks []Track
|
||
Rules []Rule
|
||
Tiers []Tier
|
||
ServerTimeMS int64
|
||
}
|
||
|
||
// ConfigQuery 约束后台等级配置读取范围;status 为空时返回全部状态。
|
||
type ConfigQuery struct {
|
||
Track string
|
||
Status string
|
||
}
|
||
|
||
// Overview 是 App 我的等级总览。
|
||
type Overview struct {
|
||
Tracks []TrackOverview
|
||
ServerTimeMS int64
|
||
}
|
||
|
||
// ValueEvent 是事件 relay 投递给等级系统的幂等等级增量。
|
||
type ValueEvent struct {
|
||
EventID string
|
||
SourceEventID string
|
||
SourceService string
|
||
SourceEventType string
|
||
UserID int64
|
||
Track string
|
||
MetricType string
|
||
ValueDelta int64
|
||
OccurredAtMS int64
|
||
DimensionsJSON string
|
||
}
|
||
|
||
// EventResult 表达等级事件消费结果;重复事件也返回成功语义。
|
||
type EventResult struct {
|
||
EventID string
|
||
Status string
|
||
LevelChanged bool
|
||
PreviousLevel int32
|
||
NewLevel int32
|
||
RewardJobCount int64
|
||
}
|
||
|
||
// SetUserLevelCommand 描述经理中心直接设置用户等级的事实输入。
|
||
// TotalValue 不由调用方提交,activity-service 会读取目标等级阈值后在事务内写入。
|
||
type SetUserLevelCommand struct {
|
||
CommandID string
|
||
UserID int64
|
||
Track string
|
||
Level int32
|
||
OperatorUserID int64
|
||
Reason string
|
||
}
|
||
|
||
// SetUserLevelResult 返回经理设置等级后的账户事实和补发奖励数量。
|
||
type SetUserLevelResult struct {
|
||
EventID string
|
||
Status string
|
||
Track string
|
||
PreviousLevel int32
|
||
NewLevel int32
|
||
TotalValue int64
|
||
RewardJobCount int64
|
||
ServerTimeMS int64
|
||
}
|
||
|
||
// RewardJob 是等级奖励资源组的异步发放任务。
|
||
type RewardJob struct {
|
||
AppCode string
|
||
RewardJobID string
|
||
UserID int64
|
||
Track string
|
||
RewardSourceType string
|
||
RewardSourceID string
|
||
ResourceGroupID int64
|
||
WalletCommandID string
|
||
WalletGrantID string
|
||
Status string
|
||
AttemptCount int32
|
||
FailureReason string
|
||
CreatedAtMS int64
|
||
UpdatedAtMS int64
|
||
}
|
||
|
||
// RewardQuery 是用户奖励记录分页筛选。
|
||
type RewardQuery struct {
|
||
UserID int64
|
||
Track string
|
||
Status string
|
||
Page int32
|
||
PageSize int32
|
||
}
|
||
|
||
// TrackCommand 是后台创建或更新轨道配置的命令。
|
||
type TrackCommand struct {
|
||
Track string
|
||
Name string
|
||
Status string
|
||
SortOrder int32
|
||
DisplayConfigJSON string
|
||
}
|
||
|
||
// RuleCommand 是后台创建或更新等级规则的命令。
|
||
type RuleCommand struct {
|
||
Track string
|
||
Level int32
|
||
RequiredValue int64
|
||
Name string
|
||
Status string
|
||
RewardResourceGroupID int64
|
||
SortOrder int32
|
||
DisplayConfigJSON string
|
||
OperatorAdminID int64
|
||
}
|
||
|
||
// TierCommand 是后台创建或更新等级段配置的命令。
|
||
type TierCommand struct {
|
||
TierID int64
|
||
Track string
|
||
MinLevel int32
|
||
MaxLevel int32
|
||
Name string
|
||
DisplayAvatarFrameResourceID int64
|
||
DisplayBadgeResourceID int64
|
||
RewardResourceGroupID int64
|
||
Status string
|
||
DisplayConfigJSON string
|
||
OperatorAdminID int64
|
||
}
|