package cpweeklyrank

const (
	ActivityCode = "cp_weekly_rank"

	SettlementStatusPending = "pending"
	SettlementStatusRunning = "running"
	SettlementStatusGranted = "granted"
	SettlementStatusFailed  = "failed"

	GrantSourceCPWeeklyRank = "cp_weekly_rank"
)

// Reward maps one CP weekly rank to the resource group granted to both relationship users.
type Reward struct {
	AppCode         string
	RankNo          int32
	ResourceGroupID int64
	CreatedAtMS     int64
	UpdatedAtMS     int64
}

// Config is the activity-service owned switch and reward definition for CP weekly rank.
type Config struct {
	AppCode          string
	ActivityCode     string
	Enabled          bool
	RelationType     string
	TopCount         int32
	UpdatedByAdminID int64
	CreatedAtMS      int64
	UpdatedAtMS      int64
	Rewards          []Reward
}

// User is a user-service profile snapshot included in leaderboard reads.
type User struct {
	UserID        int64
	DisplayUserID string
	Username      string
	Avatar        string
}

// Entry is one relationship score inside a concrete UTC week window.
type Entry struct {
	Rank            int64
	RelationshipID  string
	RelationType    string
	Score           int64
	UserA           User
	UserB           User
	FormedAtMS      int64
	UpdatedAtMS     int64
	FirstScoredAtMS int64
	LastScoredAtMS  int64
}

// Settlement is one resource-group grant job; every winning relationship creates two rows, one for each user.
type Settlement struct {
	AppCode         string
	SettlementID    string
	PeriodStartMS   int64
	PeriodEndMS     int64
	RankNo          int32
	RelationshipID  string
	UserID          int64
	Score           int64
	ResourceGroupID int64
	WalletCommandID string
	WalletGrantID   string
	Status          string
	FailureReason   string
	AttemptCount    int32
	CreatedAtMS     int64
	UpdatedAtMS     int64
}

// Status is the H5 read model for current week leaderboard and configured rewards.
type Status struct {
	Config          Config
	Entries         []Entry
	PreviousEntries []Entry
	PeriodStartMS   int64
	PeriodEndMS     int64
	ServerTimeMS    int64
}
