package dto

type AllocateCardsPreviewReq struct {
	ID     uint     `json:"-" params:"id" path:"id" validate:"required" required:"true" description:"企业ID"`
	ICCIDs []string `json:"iccids" validate:"required,min=1,max=1000,dive,required" required:"true" description:"需要授权的 ICCID 列表（最多1000个）"`
}

type StandaloneCard struct {
	ICCID      string `json:"iccid" description:"ICCID"`
	IotCardID  uint   `json:"iot_card_id" description:"卡ID"`
	MSISDN     string `json:"msisdn" description:"手机号"`
	CarrierID  uint   `json:"carrier_id" description:"运营商ID"`
	StatusName string `json:"status_name" description:"状态名称"`
}

type FailedItem struct {
	ICCID  string `json:"iccid" description:"ICCID"`
	Reason string `json:"reason" description:"失败原因"`
}

type AllocatePreviewSummary struct {
	StandaloneCardCount int `json:"standalone_card_count" description:"独立卡数量"`
	DeviceCount         int `json:"device_count" description:"设备数量"`
	DeviceCardCount     int `json:"device_card_count" description:"设备卡数量"`
	TotalCardCount      int `json:"total_card_count" description:"总卡数量"`
	FailedCount         int `json:"failed_count" description:"失败数量"`
}

type AllocateCardsPreviewResp struct {
	StandaloneCards []StandaloneCard       `json:"standalone_cards" description:"可直接授权的卡（未绑定设备）"`
	FailedItems     []FailedItem           `json:"failed_items" description:"失败的卡"`
	Summary         AllocatePreviewSummary `json:"summary" description:"汇总信息"`
}

type AllocateCardsReq struct {
	ID            uint     `json:"-" params:"id" path:"id" validate:"required" required:"true" description:"企业ID"`
	SelectionType string   `json:"selection_type" validate:"required,oneof=list range filter" required:"true" description:"选取模式 (list:指定ICCID列表, range:号段范围, filter:按条件过滤)"`
	ICCIDs        []string `json:"iccids" validate:"omitempty,max=1000,dive,required" description:"[list模式] ICCID列表（最多1000个）"`
	ICCIDStart    string   `json:"iccid_start" validate:"omitempty,max=20" maxLength:"20" description:"[range模式] 号段起始ICCID"`
	ICCIDEnd      string   `json:"iccid_end" validate:"omitempty,max=20" maxLength:"20" description:"[range模式] 号段结束ICCID"`
	ICCID         string   `json:"iccid" validate:"omitempty,max=20" maxLength:"20" description:"[filter模式] ICCID模糊匹配"`
	BatchNo       string   `json:"batch_no" validate:"omitempty,max=100" maxLength:"100" description:"[filter模式] 批次号"`
	CarrierID     *uint    `json:"carrier_id" description:"[filter模式] 运营商ID"`
	ShopID        *uint    `json:"shop_id" description:"[filter模式] 店铺ID"`
	ShopIDs       []uint   `json:"shop_ids" description:"[filter模式] 店铺ID列表"`
	Remark        string   `json:"remark" validate:"omitempty,max=500" maxLength:"500" description:"授权备注（所有模式均可选）"`
}

type AllocateCardsResp struct {
	SuccessCount int          `json:"success_count" description:"成功数量"`
	FailCount    int          `json:"fail_count" description:"失败数量"`
	FailedItems  []FailedItem `json:"failed_items" description:"失败详情"`
}

type RecallCardsReq struct {
	ID            uint     `json:"-" params:"id" path:"id" validate:"required" required:"true" description:"企业ID"`
	SelectionType string   `json:"selection_type" validate:"required,oneof=list range filter" required:"true" description:"选取模式 (list:指定ICCID列表, range:号段范围, filter:按条件过滤)"`
	ICCIDs        []string `json:"iccids" validate:"omitempty,max=1000,dive,required" description:"[list模式] 需要回收授权的ICCID列表"`
	ICCIDStart    string   `json:"iccid_start" validate:"omitempty,max=20" maxLength:"20" description:"[range模式] 号段起始ICCID"`
	ICCIDEnd      string   `json:"iccid_end" validate:"omitempty,max=20" maxLength:"20" description:"[range模式] 号段结束ICCID"`
	ICCID         string   `json:"iccid" validate:"omitempty,max=20" maxLength:"20" description:"[filter模式] ICCID模糊匹配"`
	BatchNo       string   `json:"batch_no" validate:"omitempty,max=100" maxLength:"100" description:"[filter模式] 批次号"`
	CarrierID     *uint    `json:"carrier_id" description:"[filter模式] 运营商ID"`
}

type RecalledDevice struct {
	DeviceID  uint     `json:"device_id" description:"设备ID"`
	VirtualNo string   `json:"virtual_no" description:"设备虚拟号"`
	CardCount int      `json:"card_count" description:"卡数量"`
	ICCIDs    []string `json:"iccids" description:"卡ICCID列表"`
}

type RecallCardsResp struct {
	SuccessCount    int              `json:"success_count" description:"成功数量"`
	FailCount       int              `json:"fail_count" description:"失败数量"`
	FailedItems     []FailedItem     `json:"failed_items" description:"失败详情"`
	RecalledDevices []RecalledDevice `json:"recalled_devices" description:"连带回收的设备列表"`
}

type EnterpriseCardListReq struct {
	ID        uint   `json:"-" params:"id" path:"id" validate:"required" required:"true" description:"企业ID"`
	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:"每页数量"`
	Status    *int   `json:"status" query:"status" description:"卡状态"`
	CarrierID *uint  `json:"carrier_id" query:"carrier_id" description:"运营商ID"`
	ICCID     string `json:"iccid" query:"iccid" description:"ICCID（模糊查询）"`
	VirtualNo string `json:"virtual_no" query:"virtual_no" description:"卡虚拟号（模糊查询）"`
	MSISDN    string `json:"msisdn" query:"msisdn" description:"手机号（模糊查询）"`
}

type EnterpriseCardItem struct {
	ID                uint   `json:"id" description:"卡ID"`
	ICCID             string `json:"iccid" description:"ICCID"`
	MSISDN            string `json:"msisdn" description:"手机号"`
	DeviceID          *uint  `json:"device_id,omitempty" description:"设备ID"`
	VirtualNo         string `json:"virtual_no" description:"卡虚拟号"`
	CarrierID         uint   `json:"carrier_id" description:"运营商ID"`
	CarrierName       string `json:"carrier_name" description:"运营商名称"`
	PackageID         *uint  `json:"package_id,omitempty" description:"套餐ID"`
	PackageName       string `json:"package_name" description:"套餐名称"`
	Status            int    `json:"status" description:"状态"`
	StatusName        string `json:"status_name" description:"状态名称"`
	NetworkStatus     int    `json:"network_status" description:"网络状态"`
	NetworkStatusName string `json:"network_status_name" description:"网络状态名称"`
	GatewayExtend     string `json:"gateway_extend" description:"Gateway 卡状态扩展字段，原样返回上游 extend，用于展示运营商侧实际停机原因"`
}

type EnterpriseCardPageResult struct {
	Items []EnterpriseCardItem `json:"items" description:"卡列表"`
	Total int64                `json:"total" description:"总记录数"`
	Page  int                  `json:"page" description:"当前页码"`
	Size  int                  `json:"size" description:"每页数量"`
}

// SuspendCardReq 停机卡请求
type SuspendCardReq struct {
	ID     uint `json:"-" params:"id" path:"id" validate:"required" required:"true" description:"企业ID"`
	CardID uint `json:"-" params:"card_id" path:"card_id" validate:"required" required:"true" description:"卡ID"`
}

// ResumeCardReq 复机卡请求
type ResumeCardReq struct {
	ID     uint `json:"-" params:"id" path:"id" validate:"required" required:"true" description:"企业ID"`
	CardID uint `json:"-" params:"card_id" path:"card_id" validate:"required" required:"true" description:"卡ID"`
}
