package dto

// ========================================
// C1 钱包详情
// ========================================

// WalletDetailRequest C1 钱包详情请求
type WalletDetailRequest struct {
	Identifier string `json:"identifier" query:"identifier" validate:"required,min=1,max=50" required:"true" minLength:"1" maxLength:"50" description:"资产标识符（SN/IMEI/虚拟号/ICCID/MSISDN）"`
}

// WalletDetailResponse C1 钱包详情响应
type WalletDetailResponse 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:"冻结余额（分）"`
	UpdatedAt     string `json:"updated_at" description:"更新时间"`
}

// ========================================
// C2 钱包流水列表
// ========================================

// WalletTransactionListRequest C2 钱包流水列表请求
type WalletTransactionListRequest struct {
	Identifier      string `json:"identifier" query:"identifier" validate:"required,min=1,max=50" required:"true" minLength:"1" maxLength:"50" description:"资产标识符（SN/IMEI/虚拟号/ICCID/MSISDN）"`
	TransactionType string `json:"transaction_type" query:"transaction_type" validate:"omitempty,max=50" maxLength:"50" description:"流水类型"`
	StartTime       string `json:"start_time" query:"start_time" validate:"omitempty,max=32" maxLength:"32" description:"开始时间"`
	EndTime         string `json:"end_time" query:"end_time" validate:"omitempty,max=32" maxLength:"32" description:"结束时间"`
	Page            int    `json:"page" query:"page" validate:"required,min=1" required:"true" minimum:"1" description:"页码"`
	PageSize        int    `json:"page_size" query:"page_size" validate:"required,min=1,max=100" required:"true" minimum:"1" maximum:"100" description:"每页数量"`
}

// WalletTransactionItem C2 钱包流水项
type WalletTransactionItem struct {
	TransactionID uint   `json:"transaction_id" description:"流水ID"`
	Type          string `json:"type" description:"流水类型"`
	Amount        int64  `json:"amount" description:"变动金额（分）"`
	BalanceAfter  int64  `json:"balance_after" description:"变动后余额（分）"`
	CreatedAt     string `json:"created_at" description:"创建时间"`
	Remark        string `json:"remark" description:"备注"`
}

// WalletTransactionListResponse C2 钱包流水列表响应
type WalletTransactionListResponse struct {
	List     []WalletTransactionItem `json:"items" description:"流水列表"`
	Total    int64                   `json:"total" description:"总数"`
	Page     int                     `json:"page" description:"页码"`
	PageSize int                     `json:"size" description:"每页数量"`
}

// ========================================
// C3 充值前校验
// ========================================

// ClientRechargeCheckRequest C3 充值前校验请求
type ClientRechargeCheckRequest struct {
	Identifier string `json:"identifier" query:"identifier" validate:"required,min=1,max=50" required:"true" minLength:"1" maxLength:"50" description:"资产标识符（SN/IMEI/虚拟号/ICCID/MSISDN）"`
}

// ClientRechargeCheckResponse C3 充值前校验响应
type ClientRechargeCheckResponse struct {
	NeedForceRecharge     bool     `json:"need_force_recharge" description:"是否需要强制充值"`
	ForceRechargeAmount   int64    `json:"force_recharge_amount" description:"强制充值金额（分）"`
	TriggerType           string   `json:"trigger_type" description:"触发类型"`
	MinAmount             int64    `json:"min_amount" description:"最小充值金额（分）"`
	MaxAmount             int64    `json:"max_amount" description:"最大充值金额（分）"`
	Message               string   `json:"message" description:"提示信息"`
	AllowedPaymentMethods []string `json:"allowed_payment_methods" description:"当前资产允许的支付方式列表 (wallet:钱包, wechat:微信, alipay:支付宝)"`
}

// ========================================
// C4 创建充值订单
// ========================================

// ClientCreateRechargeRequest C4 创建充值订单请求
type ClientCreateRechargeRequest struct {
	Identifier    string `json:"identifier" validate:"required,min=1,max=50" required:"true" minLength:"1" maxLength:"50" description:"资产标识符（SN/IMEI/虚拟号/ICCID/MSISDN）"`
	Amount        int64  `json:"amount" validate:"required,min=1,max=10000000" required:"true" minimum:"1" maximum:"10000000" description:"充值金额（分）"`
	PaymentMethod string `json:"payment_method" validate:"required,oneof=wechat alipay" required:"true" description:"支付方式 (wechat:微信支付, alipay:支付宝)"`
	// AppType 仅 payment_method=wechat 时必填，alipay 无需传
	AppType string `json:"app_type" validate:"omitempty,oneof=official_account miniapp" description:"应用类型（微信支付必传）(official_account:公众号, miniapp:小程序)"`
}

// ClientRechargeResponse C4 创建充值订单响应
type ClientRechargeResponse struct {
	Recharge    ClientRechargeResult     `json:"recharge" description:"充值信息"`
	PayConfig   *ClientRechargePayConfig `json:"pay_config,omitempty" description:"微信支付配置（payment_method=wechat 时返回）"`
	PaymentLink *ClientPaymentLink       `json:"payment_link,omitempty" description:"支付宝支付链接（payment_method=alipay 时返回）"`
}

// ClientRechargeResult C4 充值信息
type ClientRechargeResult struct {
	RechargeID uint   `json:"recharge_id" description:"充值ID"`
	RechargeNo string `json:"recharge_no" description:"充值单号"`
	Amount     int64  `json:"amount" description:"充值金额（分）"`
	Status     int    `json:"status" description:"状态 (0:待支付, 1:已支付, 2:已关闭)"`
}

// ClientRechargePayConfig C4 支付配置
type ClientRechargePayConfig struct {
	AppID      string `json:"app_id" description:"应用ID"`
	Timestamp  string `json:"timestamp" description:"时间戳"`
	NonceStr   string `json:"nonce_str" description:"随机字符串"`
	PackageVal string `json:"package" description:"预支付参数"`
	SignType   string `json:"sign_type" description:"签名类型"`
	PaySign    string `json:"pay_sign" description:"支付签名"`
}

// ========================================
// C5 充值记录列表
// ========================================

// ClientRechargeListRequest C5 充值记录列表请求
type ClientRechargeListRequest struct {
	Identifier string `json:"identifier" query:"identifier" validate:"required,min=1,max=50" required:"true" minLength:"1" maxLength:"50" description:"资产标识符（SN/IMEI/虚拟号/ICCID/MSISDN）"`
	Status     *int   `json:"status" query:"status" validate:"omitempty,min=0,max=2" minimum:"0" maximum:"2" description:"充值状态 (0:待支付, 1:已支付, 2:已关闭)"`
	Page       int    `json:"page" query:"page" validate:"required,min=1" required:"true" minimum:"1" description:"页码"`
	PageSize   int    `json:"page_size" query:"page_size" validate:"required,min=1,max=100" required:"true" minimum:"1" maximum:"100" description:"每页数量"`
}

// ClientRechargeListItem C5 充值记录项
type ClientRechargeListItem struct {
	RechargeID         uint   `json:"recharge_id" description:"充值ID"`
	RechargeNo         string `json:"recharge_no" description:"充值单号"`
	Amount             int64  `json:"amount" description:"充值金额（分）"`
	Status             int    `json:"status" description:"状态 (0:待支付, 1:已支付, 2:已关闭)"`
	PaymentMethod      string `json:"payment_method" description:"支付方式"`
	CreatedAt          string `json:"created_at" description:"创建时间"`
	AutoPurchaseStatus string `json:"auto_purchase_status" description:"自动购包状态"`
}

// ClientRechargeListResponse C5 充值记录列表响应
type ClientRechargeListResponse struct {
	List     []ClientRechargeListItem `json:"items" description:"充值记录列表"`
	Total    int64                    `json:"total" description:"总数"`
	Page     int                      `json:"page" description:"页码"`
	PageSize int                      `json:"size" description:"每页数量"`
}
