package dto

import "time"

// AgentOpenAPICardQueryRequest 开放接口单卡查询请求
type AgentOpenAPICardQueryRequest struct {
	CardNo string `json:"card_no" query:"card_no" validate:"required,min=1,max=100" required:"true" minLength:"1" maxLength:"100" description:"卡标识（支持 ICCID、虚拟号、MSISDN）"`
}

// AgentOpenAPICardResumeRequest 开放接口单卡复机请求
type AgentOpenAPICardResumeRequest struct {
	CardNo string `json:"card_no" validate:"required,min=1,max=100" required:"true" minLength:"1" maxLength:"100" description:"卡标识（支持 ICCID、虚拟号、MSISDN）"`
}

// AgentOpenAPICardResumeResponse 开放接口单卡复机响应
type AgentOpenAPICardResumeResponse struct {
	CardNo         string `json:"card_no" description:"卡标识"`
	CardStatus     string `json:"card_status" description:"卡状态 (normal:正常, stopped:停机)"`
	CardStatusName string `json:"card_status_name" description:"卡状态名称（中文）"`
	GatewayExtend  string `json:"gateway_extend" description:"Gateway 卡状态扩展字段，复机成功后本地清空"`
}

// AgentOpenAPIPackageTrafficItem 开放接口套餐流量项
type AgentOpenAPIPackageTrafficItem struct {
	PackageCode     string     `json:"package_code" description:"套餐编码"`
	PackageName     string     `json:"package_name" description:"套餐名称"`
	SeriesName      string     `json:"series_name" description:"套餐系列名称"`
	PackageType     string     `json:"package_type" description:"套餐类型 (formal:正式套餐, addon:附加套餐)"`
	PackageTypeName string     `json:"package_type_name" description:"套餐类型名称（中文）"`
	TotalFlowMB     int64      `json:"total_flow_mb" description:"套餐总流量(MB)"`
	UsedFlowMB      int64      `json:"used_flow_mb,omitempty" description:"套餐已用流量(MB，仅生效套餐返回)"`
	RemainingFlowMB int64      `json:"remaining_flow_mb,omitempty" description:"套餐剩余流量(MB，仅生效套餐返回)"`
	StartAt         *time.Time `json:"start_at,omitempty" description:"套餐生效时间"`
	ExpiresAt       *time.Time `json:"expires_at,omitempty" description:"套餐过期时间"`
	ValidDays       int        `json:"valid_days,omitempty" description:"套餐有效天数（待生效套餐返回）"`
	Priority        int        `json:"priority,omitempty" description:"生效优先级（数字越小优先级越高）"`
}

// AgentOpenAPICardTrafficResponse 开放接口卡流量响应
type AgentOpenAPICardTrafficResponse struct {
	CardNo                string                           `json:"card_no" description:"卡标识（原始传入值）"`
	DeviceNo              string                           `json:"device_no,omitempty" description:"设备虚拟号（当入参被识别为设备维度时返回，表示该卡/标识关联的设备）"`
	ActiveRemainingFlowMB int64                            `json:"active_remaining_flow_mb" description:"当前生效套餐剩余流量(MB)"`
	ActiveTotalFlowMB     int64                            `json:"active_total_flow_mb" description:"当前生效套餐总流量(MB)"`
	ActiveUsedFlowMB      int64                            `json:"active_used_flow_mb" description:"当前生效套餐已用流量(MB)"`
	ActivePackages        []AgentOpenAPIPackageTrafficItem `json:"active_packages" description:"当前生效套餐列表"`
	PendingPackages       []AgentOpenAPIPackageTrafficItem `json:"pending_packages" description:"待生效套餐列表"`
	ActiveExpiresAt       *time.Time                       `json:"active_expires_at,omitempty" description:"当前生效套餐最晚过期时间"`
}

// AgentOpenAPICardStatusResponse 开放接口卡状态响应
type AgentOpenAPICardStatusResponse struct {
	CardNo         string `json:"card_no" description:"卡标识"`
	CardStatus     string `json:"card_status" description:"卡状态 (normal:正常, stopped:停机)"`
	CardStatusName string `json:"card_status_name" description:"卡状态名称（中文）"`
	GatewayExtend  string `json:"gateway_extend" description:"Gateway 卡状态扩展字段，原样返回上游 extend，用于展示运营商侧实际停机原因"`
	StopReason     string `json:"stop_reason" description:"停机原因"`
	StopReasonName string `json:"stop_reason_name" description:"停机原因名称（中文）"`
}

// AgentOpenAPIRealnameStatusResponse 开放接口实名状态响应
type AgentOpenAPIRealnameStatusResponse struct {
	CardNo      string `json:"card_no" description:"卡标识"`
	IsRealnamed bool   `json:"is_realnamed" description:"是否已实名"`
}

// AgentOpenAPIPackageListRequest 开放接口套餐列表请求
type AgentOpenAPIPackageListRequest struct {
	Page        int     `json:"page" query:"page" validate:"omitempty,min=1" minimum:"1" description:"页码"`
	PageSize    int     `json:"page_size" query:"page_size" validate:"omitempty,min=1,max=100" minimum:"1" maximum:"100" description:"每页数量"`
	PackageType *string `json:"package_type" query:"package_type" validate:"omitempty,oneof=formal addon" description:"套餐类型 (formal:正式套餐, addon:附加套餐)"`
	SeriesID    *uint   `json:"series_id" query:"series_id" validate:"omitempty" description:"套餐系列ID"`
	PackageName *string `json:"package_name" query:"package_name" validate:"omitempty,max=255" maxLength:"255" description:"套餐名称（模糊搜索）"`
}

// AgentOpenAPIPackageItem 开放接口套餐列表项
type AgentOpenAPIPackageItem struct {
	PackageID       uint   `json:"package_id" description:"套餐ID"`
	PackageCode     string `json:"package_code" description:"套餐编码"`
	PackageName     string `json:"package_name" description:"套餐名称"`
	SeriesName      string `json:"series_name" description:"套餐系列名称"`
	PackageType     string `json:"package_type" description:"套餐类型 (formal:正式套餐, addon:附加套餐)"`
	PackageTypeName string `json:"package_type_name" description:"套餐类型名称（中文）"`
	CostPrice       int64  `json:"cost_price" description:"套餐结算价(分)"`
	RetailPrice     int64  `json:"retail_price" description:"套餐销售价(分)"`
	TotalFlowMB     int64  `json:"total_flow_mb" description:"总流量(MB)"`
	ValidDays       int    `json:"valid_days" description:"有效天数"`
}

// AgentOpenAPIWalletBalanceResponse 开放接口预充值钱包余额响应
type AgentOpenAPIWalletBalanceResponse struct {
	Balance              int64  `json:"balance" description:"钱包账面余额(分)"`
	FrozenBalance        int64  `json:"frozen_balance" description:"冻结余额(分)"`
	CashAvailableBalance int64  `json:"cash_available_balance" description:"现金可用金额(分)，等于账面余额减冻结余额"`
	CreditEnabled        bool   `json:"credit_enabled" description:"是否启用主钱包信用额度"`
	CreditLimit          int64  `json:"credit_limit" description:"主钱包信用额度(分)"`
	AvailableBalance     int64  `json:"available_balance" description:"总可用金额(分)，等于现金可用金额加生效信用额度"`
	IsInDebt             bool   `json:"is_in_debt" description:"账面余额是否已形成欠款"`
	DebtAmount           int64  `json:"debt_amount" description:"欠款金额(分)，仅取负账面余额绝对值"`
	Version              int    `json:"version" description:"钱包乐观锁版本"`
	Currency             string `json:"currency" description:"币种"`
}

// AgentOpenAPIWalletTransactionListRequest 开放接口预充值钱包流水请求
type AgentOpenAPIWalletTransactionListRequest struct {
	Page            int    `json:"page" query:"page" validate:"omitempty,min=1" minimum:"1" description:"页码"`
	PageSize        int    `json:"page_size" query:"page_size" validate:"omitempty,min=1,max=100" minimum:"1" maximum:"100" description:"每页数量"`
	TransactionType string `json:"transaction_type" query:"transaction_type" validate:"omitempty,max=50" maxLength:"50" description:"交易类型过滤（recharge:充值入账, deduct:套餐扣款, refund:退款）"`
	StartDate       string `json:"start_date" query:"start_date" validate:"omitempty" description:"开始日期（YYYY-MM-DD）"`
	EndDate         string `json:"end_date" query:"end_date" validate:"omitempty" description:"结束日期（YYYY-MM-DD）"`
}

// AgentOpenAPIWalletPackageOrderRequest 开放接口钱包套餐购买请求
type AgentOpenAPIWalletPackageOrderRequest struct {
	CardNos     []string `json:"card_nos" validate:"required,min=1,max=100,dive,min=1,max=100" required:"true" minItems:"1" maxItems:"100" description:"卡标识列表（支持 ICCID、虚拟号、MSISDN、设备 IMEI；传入设备 IMEI 时自动转为设备维度购买）"`
	PackageCode string   `json:"package_code" validate:"required,min=1,max=100" required:"true" minLength:"1" maxLength:"100" description:"套餐编码（一次只能购买一个套餐）"`
}

// AgentOpenAPIWalletPackageOrderItem 开放接口钱包套餐购买成功项
type AgentOpenAPIWalletPackageOrderItem struct {
	CardNo  string `json:"card_no" description:"卡标识"`
	OrderNo string `json:"order_no" description:"订单号"`
}

// AgentOpenAPIWalletPackageOrderFailure 开放接口钱包套餐购买失败项
type AgentOpenAPIWalletPackageOrderFailure struct {
	CardNo  string `json:"card_no" description:"卡标识"`
	Code    int    `json:"code" description:"错误码"`
	Message string `json:"message" description:"失败原因"`
}

// AgentOpenAPIWalletPackageOrderResponse 开放接口钱包套餐购买响应
type AgentOpenAPIWalletPackageOrderResponse struct {
	BatchNo      string                                  `json:"batch_no" description:"批次号"`
	PackageCode  string                                  `json:"package_code" description:"套餐编码"`
	SuccessCount int                                     `json:"success_count" description:"成功数量"`
	FailedCount  int                                     `json:"failed_count" description:"失败数量"`
	Orders       []AgentOpenAPIWalletPackageOrderItem    `json:"orders" description:"成功订单列表"`
	FailedCards  []AgentOpenAPIWalletPackageOrderFailure `json:"failed_cards" description:"失败卡列表"`
}

// AgentOpenAPIDeviceQueryRequest 开放接口设备查询请求
type AgentOpenAPIDeviceQueryRequest struct {
	DeviceNo string `json:"device_no" query:"device_no" validate:"required,min=1,max=100" required:"true" minLength:"1" maxLength:"100" description:"设备标识（支持虚拟号、IMEI）"`
}

// AgentOpenAPIDeviceSwitchCardRequest 开放接口设备切网请求
type AgentOpenAPIDeviceSwitchCardRequest struct {
	DeviceNo string `json:"device_no" validate:"required,min=1,max=100" required:"true" minLength:"1" maxLength:"100" description:"设备标识（支持虚拟号、IMEI）"`
	ICCID    string `json:"iccid" validate:"required,min=1,max=100" required:"true" minLength:"1" maxLength:"100" description:"目标卡 ICCID"`
}

// AgentOpenAPIDeviceOperationRequest 开放接口设备操作请求（重启/恢复出厂）
type AgentOpenAPIDeviceOperationRequest struct {
	DeviceNo string `json:"device_no" validate:"required,min=1,max=100" required:"true" minLength:"1" maxLength:"100" description:"设备标识（支持虚拟号、IMEI）"`
}

// AgentOpenAPIDeviceTrafficResponse 开放接口设备流量响应
type AgentOpenAPIDeviceTrafficResponse struct {
	DeviceNo              string                           `json:"device_no" description:"设备标识"`
	ActiveRemainingFlowMB int64                            `json:"active_remaining_flow_mb" description:"当前生效套餐剩余流量(MB)"`
	ActiveTotalFlowMB     int64                            `json:"active_total_flow_mb" description:"当前生效套餐总流量(MB)"`
	ActiveUsedFlowMB      int64                            `json:"active_used_flow_mb" description:"当前生效套餐已用流量(MB)"`
	ActivePackages        []AgentOpenAPIPackageTrafficItem `json:"active_packages" description:"当前生效套餐列表"`
	PendingPackages       []AgentOpenAPIPackageTrafficItem `json:"pending_packages" description:"待生效套餐列表"`
	ActiveExpiresAt       *time.Time                       `json:"active_expires_at,omitempty" description:"当前生效套餐最晚过期时间"`
}
