package dto

// ========================================
// 代理商佣金查询 DTO
// ========================================

// ShopCommissionSummaryListReq 代理商佣金列表查询请求
type ShopCommissionSummaryListReq struct {
	Page     int    `json:"page" query:"page" validate:"omitempty,min=1" minimum:"1" description:"页码（默认1）"`
	PageSize int    `json:"page_size" query:"page_size" validate:"omitempty,min=1,max=100" minimum:"1" maximum:"100" description:"每页数量（默认20，最大100）"`
	ShopName string `json:"shop_name" query:"shop_name" validate:"omitempty,max=100" maxLength:"100" description:"店铺名称（模糊查询）"`
	Username string `json:"username" query:"username" validate:"omitempty,max=50" maxLength:"50" description:"主账号用户名（模糊查询）"`
}

// ShopCommissionSummaryItem 代理商佣金汇总项
type ShopCommissionSummaryItem struct {
	ShopID                uint   `json:"shop_id" description:"店铺ID"`
	ShopName              string `json:"shop_name" description:"店铺名称"`
	ShopCode              string `json:"shop_code" description:"店铺编码"`
	Username              string `json:"username" description:"主账号用户名"`
	Phone                 string `json:"phone" description:"主账号手机号"`
	TotalCommission       int64  `json:"total_commission" description:"总佣金（分）"`
	WithdrawnCommission   int64  `json:"withdrawn_commission" description:"已提现佣金（分）"`
	UnwithdrawCommission  int64  `json:"unwithdraw_commission" description:"未提现佣金（分）"`
	FrozenCommission      int64  `json:"frozen_commission" description:"冻结中佣金（分）"`
	WithdrawingCommission int64  `json:"withdrawing_commission" description:"提现中佣金（分）"`
	AvailableCommission   int64  `json:"available_commission" description:"可提现佣金（分）"`
	CreatedAt             string `json:"created_at" description:"店铺创建时间"`
}

// ShopCommissionSummaryPageResult 代理商佣金列表分页响应
type ShopCommissionSummaryPageResult struct {
	Items []ShopCommissionSummaryItem `json:"items" description:"代理商佣金列表"`
	Total int64                       `json:"total" description:"总记录数"`
	Page  int                         `json:"page" description:"当前页码"`
	Size  int                         `json:"size" description:"每页数量"`
}

// ========================================
// 代理商提现记录查询 DTO
// ========================================

// ShopWithdrawalRequestListReq 代理商提现记录查询请求
type ShopWithdrawalRequestListReq struct {
	ShopID       uint   `json:"-" params:"shop_id" path:"shop_id" validate:"required" description:"店铺ID"`
	Page         int    `json:"page" query:"page" validate:"omitempty,min=1" minimum:"1" description:"页码（默认1）"`
	PageSize     int    `json:"page_size" query:"page_size" validate:"omitempty,min=1,max=100" minimum:"1" maximum:"100" description:"每页数量（默认20，最大100）"`
	WithdrawalNo string `json:"withdrawal_no" query:"withdrawal_no" validate:"omitempty,max=50" maxLength:"50" description:"提现单号（精确查询）"`
	StartTime    string `json:"start_time" query:"start_time" validate:"omitempty" description:"申请开始时间（格式：2006-01-02 15:04:05）"`
	EndTime      string `json:"end_time" query:"end_time" validate:"omitempty" description:"申请结束时间（格式：2006-01-02 15:04:05）"`
}

// ShopWithdrawalRequestItem 代理商提现记录项
type ShopWithdrawalRequestItem struct {
	ID               uint   `json:"id" description:"提现申请ID"`
	WithdrawalNo     string `json:"withdrawal_no" description:"提现单号"`
	Amount           int64  `json:"amount" description:"提现金额（分）"`
	FeeRate          int64  `json:"fee_rate" description:"手续费比率（基点，100=1%）"`
	Fee              int64  `json:"fee" description:"手续费（分）"`
	ActualAmount     int64  `json:"actual_amount" description:"实际到账金额（分）"`
	Status           int    `json:"status" description:"状态 (1:待审核, 2:已通过, 3:已拒绝, 4:已到账)"`
	StatusName       string `json:"status_name" description:"状态名称"`
	ShopID           uint   `json:"shop_id" description:"店铺ID"`
	ShopName         string `json:"shop_name" description:"店铺名称"`
	ShopHierarchy    string `json:"shop_hierarchy" description:"店铺层级路径（格式：上上级_上级_本身，最多两层上级）"`
	ApplicantID      uint   `json:"applicant_id" description:"申请人账号ID"`
	ApplicantName    string `json:"applicant_name" description:"申请人用户名"`
	ProcessorID      *uint  `json:"processor_id,omitempty" description:"处理人账号ID"`
	ProcessorName    string `json:"processor_name,omitempty" description:"处理人用户名"`
	WithdrawalMethod string `json:"withdrawal_method" description:"提现方式 (alipay:支付宝, wechat:微信, bank:银行卡)"`
	PaymentType      string `json:"payment_type" description:"放款类型 (manual:人工打款)"`
	AccountName      string `json:"account_name" description:"收款账户名称"`
	AccountNumber    string `json:"account_number" description:"收款账号"`
	BankName         string `json:"bank_name,omitempty" description:"银行名称（银行卡提现时）"`
	RejectReason     string `json:"reject_reason,omitempty" description:"拒绝原因"`
	Remark           string `json:"remark,omitempty" description:"备注"`
	CreatedAt        string `json:"created_at" description:"申请时间"`
	ProcessedAt      string `json:"processed_at,omitempty" description:"处理时间"`
	PaidAt           string `json:"paid_at,omitempty" description:"到账时间"`
}

// ShopWithdrawalRequestPageResult 代理商提现记录分页响应
type ShopWithdrawalRequestPageResult struct {
	Items []ShopWithdrawalRequestItem `json:"items" description:"提现记录列表"`
	Total int64                       `json:"total" description:"总记录数"`
	Page  int                         `json:"page" description:"当前页码"`
	Size  int                         `json:"size" description:"每页数量"`
}

// ========================================
// 代理商佣金明细查询 DTO
// ========================================

// ShopCommissionRecordListReq 代理商佣金明细查询请求
type ShopCommissionRecordListReq struct {
	ShopID           uint   `json:"-" params:"shop_id" path:"shop_id" validate:"required" description:"店铺ID"`
	Page             int    `json:"page" query:"page" validate:"omitempty,min=1" minimum:"1" description:"页码（默认1）"`
	PageSize         int    `json:"page_size" query:"page_size" validate:"omitempty,min=1,max=100" minimum:"1" maximum:"100" description:"每页数量（默认20，最大100）"`
	CommissionSource string `json:"commission_source" query:"commission_source" validate:"omitempty,oneof=cost_diff one_time tier_bonus" description:"佣金来源 (cost_diff:成本价差, one_time:一次性佣金, tier_bonus(已废弃):梯度奖励)"`
	ICCID            string `json:"iccid" query:"iccid" validate:"omitempty,max=50" maxLength:"50" description:"ICCID（模糊查询）"`
	DeviceNo         string `json:"device_no" query:"device_no" validate:"omitempty,max=50" maxLength:"50" description:"设备号（模糊查询）"`
	OrderNo          string `json:"order_no" query:"order_no" validate:"omitempty,max=50" maxLength:"50" description:"订单号（模糊查询）"`
}

// ShopCommissionRecordItem 代理商佣金明细项
type ShopCommissionRecordItem struct {
	ID               uint   `json:"id" description:"佣金记录ID"`
	Amount           int64  `json:"amount" description:"佣金金额（分）"`
	BalanceAfter     int64  `json:"balance_after" description:"入账后佣金余额（分）"`
	CommissionSource string `json:"commission_source" description:"佣金来源 (cost_diff:成本价差, one_time:一次性佣金, tier_bonus(已废弃):梯度奖励)"`
	Status           int    `json:"status" description:"状态 (1:已入账, 2:已失效)"`
	StatusName       string `json:"status_name" description:"状态名称"`
	OrderID          uint   `json:"order_id" description:"订单ID"`
	OrderNo          string `json:"order_no" description:"订单号"`
	DeviceNo         string `json:"device_no,omitempty" description:"设备号"`
	ICCID            string `json:"iccid,omitempty" description:"ICCID"`
	OrderCreatedAt   string `json:"order_created_at" description:"订单创建时间"`
	CreatedAt        string `json:"created_at" description:"佣金入账时间"`
}

// ShopCommissionRecordPageResult 代理商佣金明细分页响应
type ShopCommissionRecordPageResult struct {
	Items []ShopCommissionRecordItem `json:"items" description:"佣金明细列表"`
	Total int64                      `json:"total" description:"总记录数"`
	Page  int                        `json:"page" description:"当前页码"`
	Size  int                        `json:"size" description:"每页数量"`
}

// ========================================
// 路由参数 DTO
// ========================================

// ShopIDPathParam 店铺ID路径参数
type ShopIDPathParam struct {
	ShopID uint `path:"shop_id" description:"店铺ID" required:"true"`
}
