package sevendaycheckin

const (
	DayCount = 7

	StatusPending = "pending"
	StatusGranted = "granted"
	StatusFailed  = "failed"

	RewardStatusGranted   = "granted"
	RewardStatusAvailable = "available"
	RewardStatusLocked    = "locked"
	RewardStatusPending   = "pending"
	RewardStatusFailed    = "failed"

	ReasonEligible      = "eligible"
	ReasonDisabled      = "disabled"
	ReasonNotConfigured = "not_configured"
	ReasonAlreadySigned = "already_signed"
	ReasonPendingReward = "pending_reward"
	ReasonInvalidConfig = "invalid_config"
)

// Reward 是配置中的某一天资源组奖励；资源组内容仍由 wallet-service 拥有。
type Reward struct {
	DayIndex        int32
	ResourceGroupID int64
}

// Config 是 activity-service 持有的七日签到当前配置。
type Config struct {
	AppCode          string
	Enabled          bool
	ConfigVersion    int64
	Rewards          []Reward
	UpdatedByAdminID int64
	CreatedAtMS      int64
	UpdatedAtMS      int64
}

// Account 是用户连续签到 read model，只在奖励发放成功后推进。
type Account struct {
	AppCode        string
	UserID         int64
	CycleNo        int64
	CycleStartDay  string
	LastCheckinDay string
	LastDayIndex   int32
	ConfigVersion  int64
	UpdatedAtMS    int64
}

// Claim 是用户一次签到和资源组发放事实。
type Claim struct {
	ClaimID         string
	CommandID       string
	UserID          int64
	CycleNo         int64
	CheckinDay      string
	DayIndex        int32
	ConfigVersion   int64
	ResourceGroupID int64
	WalletCommandID string
	WalletGrantID   string
	Status          string
	FailureReason   string
	SignedAtMS      int64
	GrantedAtMS     int64
	CreatedAtMS     int64
	UpdatedAtMS     int64
}

// RewardStatus 是 App 面板中一天奖励的用户侧状态。
type RewardStatus struct {
	Reward
	Status        string
	ClaimID       string
	WalletGrantID string
	GrantedAtMS   int64
}

// StatusResult 是 App 查询七日签到面板的领域结果。
type StatusResult struct {
	Enabled         bool
	CanSign         bool
	Reason          string
	CycleNo         int64
	CurrentDayIndex int32
	NextDayIndex    int32
	CheckinDay      string
	LastCheckinDay  string
	ConfigVersion   int64
	Rewards         []RewardStatus
	ServerTimeMS    int64
	NextRefreshMS   int64
}

// PrepareResult 表达签到 claim 是否需要继续调用 wallet-service 发放资源组。
type PrepareResult struct {
	Claim    Claim
	Prepared bool
	Reason   string
}

// ConfigQuery 是后台领取记录分页筛选条件。
type ClaimQuery struct {
	Status     string
	UserID     int64
	CheckinDay string
	DayIndex   int32
	Page       int32
	PageSize   int32
}
