181 lines
5.7 KiB
Go
181 lines
5.7 KiB
Go
// Package cp 定义 CP/兄弟/姐妹关系的领域事实和值对象。
|
||
package cp
|
||
|
||
const (
|
||
RelationTypeCP = "cp"
|
||
RelationTypeBrother = "brother"
|
||
RelationTypeSister = "sister"
|
||
|
||
ApplicationStatusPending = "pending"
|
||
ApplicationStatusAccepted = "accepted"
|
||
ApplicationStatusRejected = "rejected"
|
||
ApplicationStatusExpired = "expired"
|
||
ApplicationStatusBlocked = "blocked"
|
||
|
||
RelationshipStatusActive = "active"
|
||
RelationshipStatusEnded = "ended"
|
||
|
||
BreakupStatusPending = "pending"
|
||
BreakupStatusConfirmed = "confirmed"
|
||
BreakupStatusCanceled = "canceled"
|
||
|
||
GiftTypeCodeCP = "cp"
|
||
|
||
EventTypeApplicationCreated = "UserCPApplicationCreated"
|
||
EventTypeApplicationAccepted = "UserCPApplicationAccepted"
|
||
EventTypeApplicationRejected = "UserCPApplicationRejected"
|
||
EventTypeRelationshipCreated = "UserCPRelationshipCreated"
|
||
EventTypeRelationshipIntimacyChanged = "UserCPRelationshipIntimacyChanged"
|
||
EventTypeRelationshipLevelUp = "UserCPRelationshipLevelUp"
|
||
EventTypeRelationshipEnded = "UserCPRelationshipEnded"
|
||
)
|
||
|
||
// UserProfile 是 CP 申请和关系展示用的用户快照。
|
||
type UserProfile struct {
|
||
UserID int64
|
||
DisplayUserID string
|
||
Username string
|
||
Avatar string
|
||
}
|
||
|
||
// AvatarFrameSnapshot 是用户当前佩戴头像框的展示快照;数据来自 wallet-service 资源佩戴读模型。
|
||
type AvatarFrameSnapshot struct {
|
||
ResourceID int64 `json:"resource_id,omitempty"`
|
||
ResourceCode string `json:"resource_code,omitempty"`
|
||
Name string `json:"name,omitempty"`
|
||
AssetURL string `json:"asset_url,omitempty"`
|
||
PreviewURL string `json:"preview_url,omitempty"`
|
||
AnimationURL string `json:"animation_url,omitempty"`
|
||
MetadataJSON string `json:"metadata_json,omitempty"`
|
||
EntitlementID string `json:"entitlement_id,omitempty"`
|
||
}
|
||
|
||
// IntimacyLeaderboardUser 是 CP 亲密值排行榜中一方用户的展示资料。
|
||
type IntimacyLeaderboardUser struct {
|
||
UserID int64 `json:"user_id"`
|
||
DisplayUserID string `json:"display_user_id"`
|
||
Username string `json:"username"`
|
||
Avatar string `json:"avatar"`
|
||
AvatarFrame *AvatarFrameSnapshot `json:"avatar_frame,omitempty"`
|
||
}
|
||
|
||
// IntimacyLeaderboardEntry 是 Redis zset member 保存的一对 active 关系快照。
|
||
type IntimacyLeaderboardEntry struct {
|
||
Rank int64 `json:"rank,omitempty"`
|
||
RelationshipID string `json:"relationship_id"`
|
||
RelationType string `json:"relation_type"`
|
||
IntimacyValue int64 `json:"intimacy_value"`
|
||
Level int32 `json:"level"`
|
||
UserA IntimacyLeaderboardUser `json:"user_a"`
|
||
UserB IntimacyLeaderboardUser `json:"user_b"`
|
||
FormedAtMS int64 `json:"formed_at_ms"`
|
||
UpdatedAtMS int64 `json:"updated_at_ms"`
|
||
}
|
||
|
||
// IntimacyLeaderboardPage 是 CP 亲密值排行榜分页读模型。
|
||
type IntimacyLeaderboardPage struct {
|
||
Items []IntimacyLeaderboardEntry
|
||
Total int64
|
||
Page int32
|
||
PageSize int32
|
||
ServerTimeMS int64
|
||
}
|
||
|
||
// GiftSnapshot 固化触发申请或亲密值增长的礼物展示信息。
|
||
type GiftSnapshot struct {
|
||
GiftID string
|
||
GiftName string
|
||
GiftIconURL string
|
||
GiftAnimationURL string
|
||
GiftCount int32
|
||
GiftValue int64
|
||
BillingReceiptID string
|
||
}
|
||
|
||
// Application 表达一次关系申请,只有 target 用户可以处理 pending 状态。
|
||
type Application struct {
|
||
ApplicationID string
|
||
RelationType string
|
||
Status string
|
||
Requester UserProfile
|
||
Target UserProfile
|
||
RoomID string
|
||
RoomRegionID int64
|
||
Gift GiftSnapshot
|
||
CreatedAtMS int64
|
||
UpdatedAtMS int64
|
||
ExpiresAtMS int64
|
||
DecidedAtMS int64
|
||
SourceEventID string
|
||
SourceCommandID string
|
||
}
|
||
|
||
// Relationship 表达 A/B 已建立的一种 active 关系;展示时由 service 填充 me/partner。
|
||
type Relationship struct {
|
||
RelationshipID string
|
||
RelationType string
|
||
Status string
|
||
UserAID int64
|
||
UserBID int64
|
||
Me UserProfile
|
||
Partner UserProfile
|
||
IntimacyValue int64
|
||
Level int32
|
||
CurrentLevelThreshold int64
|
||
NextLevelThreshold int64
|
||
NeededForNextLevel int64
|
||
LevelProgressPercent int32
|
||
MaxLevel bool
|
||
SourceApplicationID string
|
||
FormedAtMS int64
|
||
EndedAtMS int64
|
||
BreakupCostCoins int64
|
||
UpdatedAtMS int64
|
||
}
|
||
|
||
// RelationshipBreakup 是一次解除关系命令的占位事实;pending 阻止同一关系被并发重复扣费。
|
||
type RelationshipBreakup struct {
|
||
CommandID string
|
||
RelationshipID string
|
||
RequesterUserID int64
|
||
RelationType string
|
||
BreakupCostCoins int64
|
||
Status string
|
||
WalletTransactionID string
|
||
CoinBalanceAfter int64
|
||
Reason string
|
||
CreatedAtMS int64
|
||
UpdatedAtMS int64
|
||
ConfirmedAtMS int64
|
||
CanceledAtMS int64
|
||
}
|
||
|
||
// GiftEvent 是 room outbox 中 RoomGiftSent 转换后的 CP 关系消费输入。
|
||
type GiftEvent struct {
|
||
AppCode string
|
||
EventID string
|
||
RoomID string
|
||
RoomVersion int64
|
||
OccurredAtMS int64
|
||
SenderUserID int64
|
||
TargetUserID int64
|
||
GiftID string
|
||
GiftCount int32
|
||
GiftValue int64
|
||
BillingReceiptID string
|
||
VisibleRegionID int64
|
||
CommandID string
|
||
GiftTypeCode string
|
||
CPRelationType string
|
||
GiftName string
|
||
GiftIconURL string
|
||
GiftAnimationURL string
|
||
}
|
||
|
||
// ConsumeResult 汇总一次送礼事件对 CP 领域产生的变化。
|
||
type ConsumeResult struct {
|
||
Consumed bool
|
||
Application Application
|
||
Relationship Relationship
|
||
}
|