package firstrecharge

const (
	TierStatusActive   = "active"
	TierStatusInactive = "inactive"

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

	ReasonEligible       = "eligible"
	ReasonNotConfigured  = "not_configured"
	ReasonDisabled       = "disabled"
	ReasonInvalidConfig  = "invalid_config"
	ReasonTierNotMatched = "tier_not_matched"
	ReasonAlreadyGranted = "already_granted"
	ReasonPendingReward  = "pending_reward"

	RechargeEventWalletRecorded = "WalletRechargeRecorded"
	RechargeTypeCoinSeller      = "coin_seller_transfer"
)

// Tier 是首冲奖励的 Google 商品档位；旧金币区间字段只用于兼容老配置。
type Tier struct {
	TierID          int64
	TierCode        string
	TierName        string
	MinCoinAmount   int64
	MaxCoinAmount   int64
	ResourceGroupID int64
	Status          string
	SortOrder       int32
	CreatedAtMS     int64
	UpdatedAtMS     int64
	USDMinorAmount  int64
	GoogleProductID string
	DiscountPercent int32
}

// Config 是首冲奖励当前配置；档位快照由 activity-service 持有。
type Config struct {
	AppCode          string
	Enabled          bool
	Tiers            []Tier
	UpdatedByAdminID int64
	CreatedAtMS      int64
	UpdatedAtMS      int64
}

// Claim 是首充档位购买后的发奖事实；app_code + user_id + tier_id 唯一。
type Claim struct {
	ClaimID            string
	EventID            string
	TransactionID      string
	CommandID          string
	UserID             int64
	TierID             int64
	TierCode           string
	ResourceGroupID    int64
	RechargeCoinAmount int64
	RechargeSequence   int64
	RechargeType       string
	Status             string
	WalletCommandID    string
	WalletGrantID      string
	FailureReason      string
	RechargedAtMS      int64
	GrantedAtMS        int64
	CreatedAtMS        int64
	UpdatedAtMS        int64
	TierUSDMinorAmount int64
	GoogleProductID    string
	RechargeUSDMinor   int64
}

// StatusResult 是 App 首冲奖励面板读取的稳定投影。
type StatusResult struct {
	Enabled      bool
	Tiers        []Tier
	Rewarded     bool
	Claim        Claim
	Claims       []Claim
	ServerTimeMS int64
}

// RechargeEvent 是 wallet_outbox 中的成功充值事实。
type RechargeEvent struct {
	AppCode            string
	EventID            string
	EventType          string
	TransactionID      string
	CommandID          string
	UserID             int64
	RechargeCoinAmount int64
	RechargeSequence   int64
	RechargeType       string
	RechargeUSDMinor   int64
	GoogleProductID    string
	PayloadJSON        string
	OccurredAtMS       int64
}

// PrepareResult 表达 activity 事务是否已经创建或复用 pending claim。
type PrepareResult struct {
	Claim          Claim
	Prepared       bool
	AlreadyGranted bool
	Reason         string
}

// ClaimQuery 是后台发放记录分页查询条件。
type ClaimQuery struct {
	Status   string
	UserID   int64
	Page     int32
	PageSize int32
}
