package model

import "time"

// AgentWalletReservation 记录代理主钱包资金预占及其唯一终态。
type AgentWalletReservation struct {
	ID              uint       `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
	AgentWalletID   uint       `gorm:"column:agent_wallet_id;not null;index:idx_agent_wallet_reservation_wallet" json:"agent_wallet_id"`
	ShopID          uint       `gorm:"column:shop_id;not null;index:idx_agent_wallet_reservation_shop" json:"shop_id"`
	Amount          int64      `gorm:"column:amount;type:bigint;not null" json:"amount"`
	Status          int        `gorm:"column:status;type:int;not null;default:1;index:idx_agent_wallet_reservation_status" json:"status"`
	ReferenceType   string     `gorm:"column:reference_type;type:varchar(50);not null;uniqueIndex:uq_agent_wallet_reservation_reference" json:"reference_type"`
	ReferenceID     uint       `gorm:"column:reference_id;not null;uniqueIndex:uq_agent_wallet_reservation_reference" json:"reference_id"`
	Creator         uint       `gorm:"column:creator;not null;default:0" json:"creator"`
	CompletedAt     *time.Time `gorm:"column:completed_at" json:"completed_at,omitempty"`
	CreatedAt       time.Time  `gorm:"column:created_at;not null;autoCreateTime" json:"created_at"`
	UpdatedAt       time.Time  `gorm:"column:updated_at;not null;autoUpdateTime" json:"updated_at"`
	ShopIDTag       uint       `gorm:"column:shop_id_tag;not null;index" json:"shop_id_tag"`
	EnterpriseIDTag *uint      `gorm:"column:enterprise_id_tag;index" json:"enterprise_id_tag,omitempty"`
}

// TableName 返回代理主钱包预占事实表名。
func (AgentWalletReservation) TableName() string {
	return "tb_agent_wallet_reservation"
}
