357 lines
13 KiB
Go
357 lines
13 KiB
Go
// Package host 定义 user-service 内 host/Agency/BD 领域事实。
|
||
package host
|
||
|
||
const (
|
||
// HostStatusActive 表示用户已经拥有长期主播身份。
|
||
HostStatusActive = "active"
|
||
// HostStatusDisabled 表示主播身份已停用;Agency owner 移除普通 Host 后也进入该状态。
|
||
HostStatusDisabled = "disabled"
|
||
|
||
// HostSourceApplication 表示主播身份来自 Agency 申请审核通过。
|
||
HostSourceApplication = "agency_application"
|
||
// HostSourceAgencyInvitation 表示主播身份来自接受 Agency 邀请并成为 Agency owner。
|
||
HostSourceAgencyInvitation = "agency_invitation"
|
||
// HostSourceHostInvitation 表示主播身份来自 Agency owner 邀请加入,本身不具备 Agency owner 身份。
|
||
HostSourceHostInvitation = "host_invitation"
|
||
// HostSourceAdminCreateAgency 表示主播身份来自后台直接创建 Agency。
|
||
HostSourceAdminCreateAgency = "admin_create_agency"
|
||
// HostSourceAdminAddHost 表示主播身份来自后台直接添加到 Agency。
|
||
HostSourceAdminAddHost = "admin_add_host"
|
||
|
||
// AgencyStatusActive 表示 Agency 可参与搜索、邀请和归属。
|
||
AgencyStatusActive = "active"
|
||
// AgencyStatusClosed 表示 Agency 已关闭,历史关系仍保留。
|
||
AgencyStatusClosed = "closed"
|
||
// AgencyStatusDeleted 表示后台删除 Agency 身份;主播身份保留,当前 Agency 归属会被解除。
|
||
AgencyStatusDeleted = "deleted"
|
||
|
||
// BDStatusActive 表示 BD 或 BD Leader 可邀请下级角色。
|
||
BDStatusActive = "active"
|
||
// BDStatusDisabled 表示 BD 或 BD Leader 已停用。
|
||
BDStatusDisabled = "disabled"
|
||
|
||
// ManagerStatusActive 表示经理身份有效,可以进入经理中心并邀请 BD Leader/Admin。
|
||
ManagerStatusActive = "active"
|
||
// ManagerStatusDisabled 表示经理身份已停用,不能继续使用经理中心能力。
|
||
ManagerStatusDisabled = "disabled"
|
||
|
||
// BDRoleBD 是普通拓展角色。
|
||
BDRoleBD = "bd"
|
||
// BDRoleLeader 是 BD Leader,具备邀请 BD 的能力;它与普通 BD 身份分表保存。
|
||
BDRoleLeader = "bd_leader"
|
||
|
||
// CoinSellerStatusActive 表示币商身份有效,可以使用币商金币账户转账能力。
|
||
CoinSellerStatusActive = "active"
|
||
// CoinSellerStatusDisabled 表示币商身份被后台停用,不能继续发起币商转账。
|
||
CoinSellerStatusDisabled = "disabled"
|
||
// CoinSellerMerchantAssetType 是币商专用金币资产,不和玩家普通 COIN 混账。
|
||
CoinSellerMerchantAssetType = "COIN_SELLER_COIN"
|
||
|
||
// MembershipTypeOwner 表示 Agency owner 自动拥有的 membership。
|
||
MembershipTypeOwner = "owner"
|
||
// MembershipTypeMember 表示普通主播加入 Agency 的 membership。
|
||
MembershipTypeMember = "member"
|
||
|
||
// MembershipStatusActive 表示当前有效 Agency 归属。
|
||
MembershipStatusActive = "active"
|
||
// MembershipStatusEnded 表示历史 Agency 归属。
|
||
MembershipStatusEnded = "ended"
|
||
|
||
// ApplicationStatusPending 表示等待 Agency 审核。
|
||
ApplicationStatusPending = "pending"
|
||
// ApplicationStatusApproved 表示申请已通过并创建关系事实。
|
||
ApplicationStatusApproved = "approved"
|
||
// ApplicationStatusRejected 表示申请被拒绝,不创建主播身份。
|
||
ApplicationStatusRejected = "rejected"
|
||
// ApplicationStatusCancelled 表示申请被申请人取消。
|
||
ApplicationStatusCancelled = "cancelled"
|
||
// ApplicationStatusExpired 表示申请已过期。
|
||
ApplicationStatusExpired = "expired"
|
||
|
||
// ApplicationDecisionApprove 是审核通过动作。
|
||
ApplicationDecisionApprove = "approve"
|
||
// ApplicationDecisionReject 是审核拒绝动作。
|
||
ApplicationDecisionReject = "reject"
|
||
|
||
// InvitationTypeAgency 表示邀请用户成为 Agency owner。
|
||
InvitationTypeAgency = "agency"
|
||
// InvitationTypeBD 表示邀请用户成为 BD。
|
||
InvitationTypeBD = "bd"
|
||
// InvitationTypeHost 表示 Agency owner 邀请用户成为本 Agency 的 Host 成员。
|
||
InvitationTypeHost = "host"
|
||
|
||
// InvitationStatusPending 表示等待目标用户处理。
|
||
InvitationStatusPending = "pending"
|
||
// InvitationStatusAccepted 表示目标用户接受并创建角色事实。
|
||
InvitationStatusAccepted = "accepted"
|
||
// InvitationStatusRejected 表示目标用户拒绝。
|
||
InvitationStatusRejected = "rejected"
|
||
// InvitationStatusCancelled 表示邀请人取消。
|
||
InvitationStatusCancelled = "cancelled"
|
||
// InvitationStatusExpired 表示邀请已过期。
|
||
InvitationStatusExpired = "expired"
|
||
|
||
// InvitationActionAccept 是接受邀请动作。
|
||
InvitationActionAccept = "accept"
|
||
// InvitationActionReject 是拒绝邀请动作。
|
||
InvitationActionReject = "reject"
|
||
// InvitationActionCancel 是邀请人取消动作。
|
||
InvitationActionCancel = "cancel"
|
||
|
||
// CommandTypeApplyToAgency 记录用户申请命令。
|
||
CommandTypeApplyToAgency = "apply_to_agency"
|
||
// CommandTypeReviewAgencyApplication 记录申请审核命令。
|
||
CommandTypeReviewAgencyApplication = "review_agency_application"
|
||
// CommandTypeKickAgencyHost 记录 Agency 踢出命令。
|
||
CommandTypeKickAgencyHost = "kick_agency_host"
|
||
// CommandTypeInviteAgency 记录 Agency 邀请命令。
|
||
CommandTypeInviteAgency = "invite_agency"
|
||
// CommandTypeInviteBD 记录 BD 邀请命令。
|
||
CommandTypeInviteBD = "invite_bd"
|
||
// CommandTypeInviteHost 记录 Agency owner 邀请 Host 加入团队的命令。
|
||
CommandTypeInviteHost = "invite_host"
|
||
// CommandTypeProcessRoleInvitation 记录邀请处理命令。
|
||
CommandTypeProcessRoleInvitation = "process_role_invitation"
|
||
// CommandTypeCreateBDLeader 记录后台创建 BD Leader 命令。
|
||
CommandTypeCreateBDLeader = "admin_create_bd_leader"
|
||
// CommandTypeCreateBD 记录后台创建普通 BD 命令。
|
||
CommandTypeCreateBD = "admin_create_bd"
|
||
// CommandTypeSetBDStatus 记录后台停用或恢复 BD/BD Leader 命令。
|
||
CommandTypeSetBDStatus = "admin_set_bd_status"
|
||
// CommandTypeCreateAgency 记录后台直接创建 Agency 命令。
|
||
CommandTypeCreateAgency = "admin_create_agency"
|
||
// CommandTypeCloseAgency 记录后台关闭 Agency 命令。
|
||
CommandTypeCloseAgency = "admin_close_agency"
|
||
// CommandTypeSetAgencyStatus 记录后台显式启用或关闭 Agency 命令。
|
||
CommandTypeSetAgencyStatus = "admin_set_agency_status"
|
||
// CommandTypeDeleteAgency 记录后台删除 Agency 身份命令。
|
||
CommandTypeDeleteAgency = "admin_delete_agency"
|
||
// CommandTypeSetAgencyJoinEnabled 记录后台设置 Agency 入会开关命令。
|
||
CommandTypeSetAgencyJoinEnabled = "admin_set_agency_join_enabled"
|
||
// CommandTypeUpdateAgencyProfile 记录 Agency owner 修改独立资料的命令。
|
||
CommandTypeUpdateAgencyProfile = "update_agency_profile"
|
||
// CommandTypeAdminAddAgencyHost 记录后台直接把用户添加为 Agency Host 的命令。
|
||
CommandTypeAdminAddAgencyHost = "admin_add_agency_host"
|
||
// CommandTypeCreateCoinSeller 记录后台创建币商身份命令。
|
||
CommandTypeCreateCoinSeller = "admin_create_coin_seller"
|
||
// CommandTypeSetCoinSellerStatus 记录后台启用或停用币商身份命令。
|
||
CommandTypeSetCoinSellerStatus = "admin_set_coin_seller_status"
|
||
|
||
// ResultTypeApplication 表示命令结果是 agency_applications 行。
|
||
ResultTypeApplication = "agency_application"
|
||
// ResultTypeMembership 表示命令结果是 agency_memberships 行。
|
||
ResultTypeMembership = "agency_membership"
|
||
// ResultTypeInvitation 表示命令结果是 role_invitations 行。
|
||
ResultTypeInvitation = "role_invitation"
|
||
// ResultTypeBDProfile 表示命令结果是普通 BD 或 BD Leader 身份行。
|
||
ResultTypeBDProfile = "bd_profile"
|
||
// ResultTypeAgency 表示命令结果是 agencies 行。
|
||
ResultTypeAgency = "agency"
|
||
// ResultTypeCoinSellerProfile 表示命令结果是 coin_seller_profiles 行。
|
||
ResultTypeCoinSellerProfile = "coin_seller_profile"
|
||
)
|
||
|
||
// HostProfile 是用户长期主播身份快照。
|
||
type HostProfile struct {
|
||
UserID int64
|
||
Status string
|
||
RegionID int64
|
||
CurrentAgencyID int64
|
||
CurrentMembershipID int64
|
||
// CurrentAgencyOwnerUserID 是当前 Agency 的 owner 用户 ID,供 wallet 在送礼时固化代理工资收款人。
|
||
CurrentAgencyOwnerUserID int64
|
||
Source string
|
||
FirstBecameHostAtMs int64
|
||
CreatedAtMs int64
|
||
UpdatedAtMs int64
|
||
}
|
||
|
||
// Agency 是主播组织事实,由一个用户拥有并归属于 BD。
|
||
type Agency struct {
|
||
AgencyID int64
|
||
OwnerUserID int64
|
||
RegionID int64
|
||
ParentBDUserID int64
|
||
Name string
|
||
Avatar string
|
||
ActiveHostCount int32
|
||
Status string
|
||
JoinEnabled bool
|
||
// MaxHosts 是历史字段,当前 Agency 不再限制主播数量,只保留数据库兼容读写。
|
||
MaxHosts int32
|
||
CreatedByUserID int64
|
||
CreatedAtMs int64
|
||
UpdatedAtMs int64
|
||
}
|
||
|
||
// BDProfile 是 BD/BD Leader 角色事实。
|
||
type BDProfile struct {
|
||
UserID int64
|
||
Role string
|
||
RegionID int64
|
||
ParentLeaderUserID int64
|
||
Status string
|
||
CreatedByUserID int64
|
||
CreatedAtMs int64
|
||
UpdatedAtMs int64
|
||
}
|
||
|
||
// ManagerProfile 是经理身份事实。
|
||
// 经理是 BD Leader/Admin 的上级,和 Host/Agency/BD 链路没有父子关系。
|
||
type ManagerProfile struct {
|
||
UserID int64
|
||
RegionID int64
|
||
Status string
|
||
Contact string
|
||
CanGrantAvatarFrame bool
|
||
CanGrantVehicle bool
|
||
CanGrantBadge bool
|
||
CanGrantVIP bool
|
||
CanUpdateUserLevel bool
|
||
CanAddBDLeader bool
|
||
CanAddAdmin bool
|
||
CanAddSuperadmin bool
|
||
CanBlockUser bool
|
||
CanTransferCountry bool
|
||
CreatedByAdminID int64
|
||
CreatedAtMs int64
|
||
UpdatedAtMs int64
|
||
}
|
||
|
||
// CoinSellerProfile 是币商角色事实,余额不保存在 user-service。
|
||
type CoinSellerProfile struct {
|
||
UserID int64
|
||
Status string
|
||
MerchantAssetType string
|
||
CreatedByUserID int64
|
||
CreatedAtMs int64
|
||
UpdatedAtMs int64
|
||
}
|
||
|
||
// CoinSellerListItem 是 App 充值入口需要的启用币商展示资料。
|
||
// 区域来自 users 当前事实,币商状态来自 coin_seller_profiles,不在 gateway 拼装。
|
||
type CoinSellerListItem struct {
|
||
UserID int64
|
||
DisplayUserID string
|
||
Username string
|
||
Avatar string
|
||
CountryID int64
|
||
CountryCode string
|
||
CountryName string
|
||
CountryDisplayName string
|
||
RegionID int64
|
||
RegionCode string
|
||
RegionName string
|
||
Status string
|
||
MerchantAssetType string
|
||
ContactInfo string
|
||
UpdatedAtMs int64
|
||
}
|
||
|
||
// UserRoleSummary 是面向 App 入口显隐的聚合 read model。
|
||
// 这里不承载团队统计或薪资指标,只表达当前用户是否拥有可用身份和待处理邀请数量。
|
||
type UserRoleSummary struct {
|
||
UserID int64
|
||
IsHost bool
|
||
IsAgency bool
|
||
IsManager bool
|
||
IsBD bool
|
||
IsBDLeader bool
|
||
IsCoinSeller bool
|
||
HostStatus string
|
||
AgencyID int64
|
||
BDID int64
|
||
BDStatus string
|
||
CoinSellerStatus string
|
||
PendingRoleInvitations int64
|
||
}
|
||
|
||
// AgencyMembership 是 host 与 Agency 的有时效归属事实。
|
||
type AgencyMembership struct {
|
||
MembershipID int64
|
||
AgencyID int64
|
||
HostUserID int64
|
||
RegionID int64
|
||
MembershipType string
|
||
Status string
|
||
JoinedAtMs int64
|
||
EndedAtMs int64
|
||
EndedByUserID int64
|
||
EndedReason string
|
||
CreatedAtMs int64
|
||
UpdatedAtMs int64
|
||
}
|
||
|
||
// AgencyApplication 是用户申请加入 Agency 的状态机事实。
|
||
type AgencyApplication struct {
|
||
ApplicationID int64
|
||
CommandID string
|
||
ApplicantUserID int64
|
||
AgencyID int64
|
||
RegionID int64
|
||
Status string
|
||
ReviewedByUserID int64
|
||
ReviewReason string
|
||
ReviewedAtMs int64
|
||
CreatedAtMs int64
|
||
UpdatedAtMs int64
|
||
}
|
||
|
||
// RoleInvitation 是 BD 或 BD Leader 发起的角色邀请事实。
|
||
type RoleInvitation struct {
|
||
InvitationID int64
|
||
CommandID string
|
||
InvitationType string
|
||
Status string
|
||
InviterUserID int64
|
||
InviterBDUserID int64
|
||
TargetUserID int64
|
||
RegionID int64
|
||
AgencyName string
|
||
ParentBDUserID int64
|
||
ParentLeaderUserID int64
|
||
ProcessedByUserID int64
|
||
ProcessReason string
|
||
ProcessedAtMs int64
|
||
CreatedAtMs int64
|
||
UpdatedAtMs int64
|
||
}
|
||
|
||
// CommandResult 是 host_command_results 的轻量投影,用于命令幂等返回已有事实。
|
||
type CommandResult struct {
|
||
CommandID string
|
||
CommandType string
|
||
ResultType string
|
||
ResultID int64
|
||
CreatedAtMs int64
|
||
}
|
||
|
||
// ReviewAgencyApplicationResult 聚合申请审核后需要返回给调用方的事实。
|
||
type ReviewAgencyApplicationResult struct {
|
||
Application AgencyApplication
|
||
HostProfile HostProfile
|
||
Membership AgencyMembership
|
||
}
|
||
|
||
// KickAgencyHostResult 聚合踢出后需要返回给调用方的事实。
|
||
type KickAgencyHostResult struct {
|
||
Membership AgencyMembership
|
||
HostProfile HostProfile
|
||
}
|
||
|
||
// ProcessRoleInvitationResult 聚合邀请处理后可能创建的角色事实。
|
||
type ProcessRoleInvitationResult struct {
|
||
Invitation RoleInvitation
|
||
HostProfile HostProfile
|
||
Agency Agency
|
||
Membership AgencyMembership
|
||
BDProfile BDProfile
|
||
}
|
||
|
||
// CreateAgencyResult 聚合后台创建 Agency 后同步产生的 owner 身份和 owner membership。
|
||
type CreateAgencyResult struct {
|
||
Agency Agency
|
||
HostProfile HostProfile
|
||
Membership AgencyMembership
|
||
}
|