package dto

import "time"

// AssetWalletResponse 资产钱包概况响应
type AssetWalletResponse struct {
	WalletID         uint      `json:"wallet_id" description:"钱包数据库ID"`
	ResourceType     string    `json:"resource_type" description:"资源类型：iot_card 或 device"`
	ResourceID       uint      `json:"resource_id" description:"对应卡或设备的数据库ID"`
	Balance          int64     `json:"balance" description:"总余额（分）"`
	FrozenBalance    int64     `json:"frozen_balance" description:"冻结余额（分）"`
	AvailableBalance int64     `json:"available_balance" description:"可用余额 = balance - frozen_balance（分）"`
	Currency         string    `json:"currency" description:"币种，目前固定 CNY"`
	Status           int       `json:"status" description:"钱包状态：1-正常 2-冻结 3-关闭"`
	StatusText       string    `json:"status_text" description:"状态文本"`
	CreatedAt        time.Time `json:"created_at" description:"创建时间（RFC3339）"`
	UpdatedAt        time.Time `json:"updated_at" description:"更新时间（RFC3339）"`
}

// AssetWalletTransactionListRequest 资产钱包流水列表请求（路径参数 + 查询参数）
type AssetWalletTransactionListRequest struct {
	Identifier      string     `path:"identifier" description:"资产标识符（ICCID 或 VirtualNo）" required:"true"`
	Page            int        `json:"page" query:"page" description:"页码，默认1"`
	PageSize        int        `json:"page_size" query:"page_size" validate:"omitempty,min=1,max=100" description:"每页数量，默认20，最大100"`
	TransactionType *string    `json:"transaction_type" query:"transaction_type" validate:"omitempty,oneof=recharge deduct refund exchange" description:"交易类型过滤：recharge/deduct/refund/exchange"`
	StartTime       *time.Time `json:"start_time" query:"start_time" description:"开始时间（RFC3339）"`
	EndTime         *time.Time `json:"end_time" query:"end_time" description:"结束时间（RFC3339）"`
}

// AssetWalletTransactionItem 单条流水记录
type AssetWalletTransactionItem struct {
	ID                  uint      `json:"id" description:"流水记录ID"`
	TransactionType     string    `json:"transaction_type" description:"交易类型：recharge/deduct/refund/exchange"`
	TransactionTypeText string    `json:"transaction_type_text" description:"交易类型文本：充值/扣款/退款/换货迁移"`
	Amount              int64     `json:"amount" description:"变动金额（分），充值为正数，扣款/退款为负数"`
	BalanceBefore       int64     `json:"balance_before" description:"变动前余额（分）"`
	BalanceAfter        int64     `json:"balance_after" description:"变动后余额（分）"`
	ReferenceType       *string   `json:"reference_type,omitempty" description:"关联业务类型：recharge、order 或 exchange（可空）"`
	ReferenceNo         *string   `json:"reference_no,omitempty" description:"关联业务编号：充值单号（CRCH…）或订单号（ORD…）（可空）"`
	Remark              *string   `json:"remark,omitempty" description:"备注（可空）"`
	CreatedAt           time.Time `json:"created_at" description:"流水创建时间（RFC3339）"`
}

// AssetWalletTransactionListResponse 资产钱包流水列表响应
type AssetWalletTransactionListResponse struct {
	List     []*AssetWalletTransactionItem `json:"items" description:"流水列表"`
	Total    int64                         `json:"total" description:"总记录数"`
	Page     int                           `json:"page" description:"当前页码"`
	PageSize int                           `json:"size" description:"每页数量"`
}
