package registrationreward

const (
	RewardTypeCoin          = "coin"
	RewardTypeResourceGroup = "resource_group"

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

	ReasonEligible          = "eligible"
	ReasonNotConfigured     = "not_configured"
	ReasonDisabled          = "disabled"
	ReasonInvalidConfig     = "invalid_config"
	ReasonAlreadyClaimed    = "already_claimed"
	ReasonDailyLimitReached = "daily_limit_reached"
)

// Config 是注册奖励配置的 owner-side 快照；daily_limit=0 表达 UTC 当天不限份数。
type Config struct {
	AppCode          string
	Enabled          bool
	RewardType       string
	CoinAmount       int64
	ResourceGroupID  int64
	DailyLimit       int64
	UpdatedByAdminID int64
	CreatedAtMS      int64
	UpdatedAtMS      int64
}

// Claim 是注册奖励领取事实；每个 app_code + user_id 只允许一个有效事实。
type Claim struct {
	ClaimID             string
	CommandID           string
	UserID              int64
	RewardDay           string
	RewardType          string
	CoinAmount          int64
	ResourceGroupID     int64
	Status              string
	WalletCommandID     string
	WalletTransactionID string
	ResourceGrantID     string
	FailureReason       string
	ClaimedAtMS         int64
	CreatedAtMS         int64
	UpdatedAtMS         int64
}

// Eligibility 是 App 查询使用的稳定结果；reason 让客户端能区分未配置、关闭、已领取和当日超额。
type Eligibility struct {
	CanReceive      bool
	Reason          string
	Enabled         bool
	RewardType      string
	CoinAmount      int64
	ResourceGroupID int64
	DailyLimit      int64
	DailyUsed       int64
	DailyRemaining  int64
	RewardDay       string
	ServerTimeMS    int64
}

// IssueCommand 是 user-service 注册完成后传入的幂等命令。
type IssueCommand struct {
	UserID    int64
	CommandID string
}

// PrepareResult 表达 activity 事务是否已经成功预留每日份数并创建/复用 pending claim。
type PrepareResult struct {
	Claim          Claim
	Prepared       bool
	AlreadyGranted bool
	Reason         string
}

// ClaimQuery 是后台领取记录分页查询条件；用户搜索由 admin-server 先解析成 user_id，领取时间筛选按 claimed_at_ms 优先、created_at_ms 兜底的页面展示口径执行。
type ClaimQuery struct {
	Status         string
	UserID         int64
	ClaimedStartMS int64
	ClaimedEndMS   int64
	Page           int32
	PageSize       int32
}
