package dto

// CommissionRecordResponse 佣金记录响应
type CommissionRecordResponse struct {
	ID               uint   `json:"id" description:"佣金记录ID"`
	ShopID           uint   `json:"shop_id" description:"店铺ID"`
	ShopName         string `json:"shop_name" description:"店铺名称"`
	OrderID          uint   `json:"order_id" description:"订单ID"`
	OrderNo          string `json:"order_no" description:"订单号"`
	IotCardID        *uint  `json:"iot_card_id" description:"关联卡ID"`
	IotCardICCID     string `json:"iot_card_iccid" description:"卡ICCID"`
	DeviceID         *uint  `json:"device_id" description:"关联设备ID"`
	VirtualNo        string `json:"virtual_no" description:"设备虚拟号"`
	CommissionSource string `json:"commission_source" description:"佣金来源 (cost_diff:成本价差, one_time:一次性佣金)"`
	Amount           int64  `json:"amount" description:"佣金金额（分）"`
	BalanceAfter     int64  `json:"balance_after" description:"入账后钱包余额（分）"`
	Status           int    `json:"status" description:"状态 (1:已冻结, 2:解冻中, 3:已发放, 4:已失效, 99:待人工修正)"`
	StatusName       string `json:"status_name" description:"状态名称（中文）"`
	ReleasedAt       string `json:"released_at" description:"入账时间"`
	Remark           string `json:"remark" description:"备注"`
	CreatedAt        string `json:"created_at" description:"创建时间"`
}

// CommissionRecordListRequest 佣金记录列表请求
type CommissionRecordListRequest 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:"每页数量"`
	ShopID           *uint   `json:"shop_id" query:"shop_id" validate:"omitempty" description:"店铺ID"`
	CommissionSource *string `json:"commission_source" query:"commission_source" validate:"omitempty,oneof=cost_diff one_time" description:"佣金来源 (cost_diff:成本价差, one_time:一次性佣金)"`
	StartTime        *string `json:"start_time" query:"start_time" validate:"omitempty" description:"开始时间"`
	EndTime          *string `json:"end_time" query:"end_time" validate:"omitempty" description:"结束时间"`
	Status           *int    `json:"status" query:"status" validate:"omitempty,oneof=1 2 3 4 99" description:"状态 (1:已冻结, 2:解冻中, 3:已发放, 4:已失效, 99:待人工修正)"`
}

// CommissionRecordPageResult 佣金记录分页结果
type CommissionRecordPageResult struct {
	List     []*CommissionRecordResponse `json:"items" description:"佣金记录列表"`
	Total    int64                       `json:"total" description:"总数"`
	Page     int                         `json:"page" description:"当前页"`
	PageSize int                         `json:"size" description:"每页数量"`
}

// CommissionStatsResponse 佣金统计响应
type CommissionStatsResponse struct {
	TotalAmount     int64 `json:"total_amount" description:"总收入（分）"`
	CostDiffAmount  int64 `json:"cost_diff_amount" description:"成本价差收入（分）"`
	OneTimeAmount   int64 `json:"one_time_amount" description:"一次性佣金收入（分）"`
	CostDiffPercent int64 `json:"cost_diff_percent" description:"成本价差占比（千分比）"`
	OneTimePercent  int64 `json:"one_time_percent" description:"一次性佣金占比（千分比）"`
	TotalCount      int64 `json:"total_count" description:"总笔数"`
	CostDiffCount   int64 `json:"cost_diff_count" description:"成本价差笔数"`
	OneTimeCount    int64 `json:"one_time_count" description:"一次性佣金笔数"`
}

// DailyCommissionStatsResponse 每日佣金统计响应
type DailyCommissionStatsResponse struct {
	Date        string `json:"date" description:"日期（YYYY-MM-DD）"`
	TotalAmount int64  `json:"total_amount" description:"当日总收入（分）"`
	TotalCount  int64  `json:"total_count" description:"当日总笔数"`
}

// CommissionStatsRequest 佣金统计请求
type CommissionStatsRequest struct {
	ShopID    uint    `json:"-" path:"shop_id" description:"店铺ID" required:"true"`
	StartTime *string `json:"start_time" query:"start_time" validate:"omitempty" description:"开始时间"`
	EndTime   *string `json:"end_time" query:"end_time" validate:"omitempty" description:"结束时间"`
}

// DailyCommissionStatsRequest 每日佣金统计请求
type DailyCommissionStatsRequest struct {
	ShopID    uint    `json:"-" path:"shop_id" description:"店铺ID" required:"true"`
	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）"`
	Days      *int    `json:"days" query:"days" validate:"omitempty,min=1,max=365" minimum:"1" maximum:"365" description:"查询天数（默认30天）"`
}

// CommissionRecordResolveRequest 佣金记录修正请求
type CommissionRecordResolveRequest struct {
	ID     uint   `json:"-" path:"id" description:"佣金记录ID" required:"true"`
	Action string `json:"action" validate:"required,oneof=release invalidate" required:"true" description:"操作 (release:入账, invalidate:作废)"`
	Amount *int64 `json:"amount" validate:"omitempty,min=1" minimum:"1" description:"佣金金额（分），release 时必填"`
	Remark string `json:"remark" validate:"omitempty,max=500" maxLength:"500" description:"处理备注"`
}
