package ledger

// PointWithdrawalCoinSellerConfig 是 POINT 提现可选币商及其服务范围、兑换比例的运行快照。
type PointWithdrawalCoinSellerConfig struct {
	AppCode          string
	SellerUserID     int64
	SortOrder        int
	PointAmount      int64
	SellerCoinAmount int64
	// ServiceRegionIDs 与 ServiceCountryCodes 互斥；都为空表示服务当前 App 的全部用户。
	ServiceRegionIDs    []int64
	ServiceCountryCodes []string
	Status              string
	CreatedAtMS         int64
	UpdatedAtMS         int64
}

// PointToCoinSellerCommand 只接受用户、目标和金额；比例必须由 wallet 数据库的 active 白名单解析。
type PointToCoinSellerCommand struct {
	AppCode      string
	CommandID    string
	SourceUserID int64
	SellerUserID int64
	PointAmount  int64
	// SourceAssetType 为空保持历史 POINT；POINT_DIAMOND 时金额由 GrossUSDMinor 和 Host 政策快照换算。
	SourceAssetType   string
	GrossUSDMinor     int64
	SourceCountryCode string
	RegionID          int64
	Reason            string
}

// PointToCoinSellerReceipt 是 POINT 扣款和币商库存入账的双边稳定回执。
type PointToCoinSellerReceipt struct {
	TransactionID           string
	SourceUserID            int64
	SellerUserID            int64
	SourcePointBalanceAfter int64
	SellerBalanceAfter      int64
	PointAmount             int64
	SellerCoinAmount        int64
	RatioPointAmount        int64
	RatioSellerCoinAmount   int64
	SourceAssetType         string
	GrossUSDMinor           int64
	FeeUSDMinor             int64
	NetUSDMinor             int64
	WithdrawFeeBPS          int32
	PolicyID                uint64
	PolicyVersion           uint64
	CreatedAtMS             int64
}

// PointToCoinCommand 只声明用户和 POINT 数量；region/now 用于在事务内解析同一份已发布 wallet 政策。
type PointToCoinCommand struct {
	AppCode     string
	CommandID   string
	UserID      int64
	PointAmount int64
	// SourceAssetType 为空保持历史 POINT，POINT_DIAMOND 使用 Host 政策中的两组每美元比例。
	SourceAssetType string
	RegionID        int64
	NowMS           int64
}

// PointToCoinReceipt 固化首次成功兑换的比例和双方余额，网络重试必须返回同一快照。
type PointToCoinReceipt struct {
	TransactionID     string
	UserID            int64
	PointAmount       int64
	CoinAmount        int64
	PointBalanceAfter int64
	CoinBalanceAfter  int64
	RatioPointAmount  int64
	RatioCoinAmount   int64
	CreatedAtMS       int64
	SourceAssetType   string
	PolicyID          uint64
	PolicyVersion     uint64
}

// PointWithdrawalRuntimeConfig 是已发布 wallet 政策中钱包页需要展示并用于冻结的 POINT 参数。
type PointWithdrawalRuntimeConfig struct {
	Found              bool
	PointsPerUSD       int64
	CoinsPerUSD        int64
	FeeBPS             int64
	MinimumPoints      int64
	PolicyInstanceCode string
	PolicyType         string
	// MinimumWithdrawUSDMinor 兼容旧客户端，值等于平台提现门槛。
	MinimumWithdrawUSDMinor           int64
	CoinSellerMinimumWithdrawUSDMinor int64
	PlatformMinimumWithdrawUSDMinor   int64
	DiamondExchangeEnabled            bool
	AgencyPointShareBPS               int32
	PolicyID                          uint64
	PolicyVersion                     uint64
	AvailabilityEvaluated             bool
	CoinSellerAvailability            PointWithdrawalActionAvailability
	PlatformAvailability              PointWithdrawalActionAvailability
}

// PointWithdrawalActionAvailability 是钱包按当前 UTC 日期和已消费次数计算的实时能力；
// LimitCount=0/RemainingCount=-1 表示后台配置为不限次数。
type PointWithdrawalActionAvailability struct {
	Allowed        bool
	LimitPeriod    string
	LimitCount     int64
	UsedCount      int64
	RemainingCount int64
	AllowedDays    string
	BlockReason    string
}
