package dto

// OneTimeCommissionTierDTO 一次性佣金梯度配置
type OneTimeCommissionTierDTO struct {
	Dimension string `json:"dimension" validate:"required,oneof=sales_count sales_amount" required:"true" description:"统计维度 (sales_count:销量, sales_amount:销售额)"`
	StatScope string `json:"stat_scope" validate:"omitempty,oneof=self self_and_sub" description:"统计范围 (self:仅自己, self_and_sub:自己+下级)"`
	Operator  string `json:"operator,omitempty" validate:"omitempty,oneof=> >= < <=" description:"阈值比较运算符（>、>=、<、<=），空值时计算引擎默认 >="`
	Threshold int64  `json:"threshold" validate:"required,min=0" required:"true" minimum:"0" description:"达标阈值"`
	Amount    int64  `json:"amount" validate:"required,min=0" required:"true" minimum:"0" description:"佣金金额（分）"`
}

// SeriesOneTimeCommissionConfigDTO 一次性佣金规则配置
type SeriesOneTimeCommissionConfigDTO struct {
	Enable              bool                       `json:"enable" description:"是否启用一次性佣金"`
	TriggerType         string                     `json:"trigger_type" validate:"omitempty,oneof=first_recharge accumulated_recharge" description:"触发类型 (first_recharge:首充, accumulated_recharge:累计充值)"`
	Threshold           int64                      `json:"threshold" validate:"omitempty,min=0" minimum:"0" description:"触发阈值（分）"`
	CommissionType      string                     `json:"commission_type" validate:"omitempty,oneof=fixed tiered" description:"佣金类型 (fixed:固定, tiered:梯度)"`
	CommissionAmount    int64                      `json:"commission_amount" validate:"omitempty,min=0" minimum:"0" description:"固定佣金金额（分），commission_type=fixed时使用"`
	Tiers               []OneTimeCommissionTierDTO `json:"tiers" validate:"omitempty,dive" description:"梯度配置列表，commission_type=tiered时使用"`
	ValidityType        string                     `json:"validity_type" validate:"omitempty,oneof=permanent fixed_date relative" description:"时效类型 (permanent:永久, fixed_date:固定日期, relative:相对时长)"`
	ValidityValue       string                     `json:"validity_value" validate:"omitempty" description:"时效值（日期或月数）"`
	EnableForceRecharge bool                       `json:"enable_force_recharge" description:"是否启用强充"`
	ForceCalcType       string                     `json:"force_calc_type" validate:"omitempty,oneof=fixed dynamic" description:"强充计算类型 (fixed:固定, dynamic:动态)"`
	ForceAmount         int64                      `json:"force_amount" validate:"omitempty,min=0" minimum:"0" description:"强充金额（分）"`
}

// CreatePackageSeriesRequest 创建套餐系列请求
type CreatePackageSeriesRequest struct {
	SeriesCode              string                            `json:"series_code" validate:"required,min=1,max=100" required:"true" minLength:"1" maxLength:"100" description:"系列编码"`
	SeriesName              string                            `json:"series_name" validate:"required,min=1,max=255" required:"true" minLength:"1" maxLength:"255" description:"系列名称"`
	Description             string                            `json:"description" validate:"omitempty,max=500" maxLength:"500" description:"描述"`
	EnableOneTimeCommission *bool                             `json:"enable_one_time_commission" description:"是否启用一次性佣金"`
	OneTimeCommissionConfig *SeriesOneTimeCommissionConfigDTO `json:"one_time_commission_config" validate:"omitempty" description:"一次性佣金规则配置"`
}

// UpdatePackageSeriesRequest 更新套餐系列请求
type UpdatePackageSeriesRequest struct {
	SeriesName              *string                           `json:"series_name" validate:"omitempty,min=1,max=255" minLength:"1" maxLength:"255" description:"系列名称"`
	Description             *string                           `json:"description" validate:"omitempty,max=500" maxLength:"500" description:"描述"`
	EnableOneTimeCommission *bool                             `json:"enable_one_time_commission" description:"是否启用一次性佣金"`
	OneTimeCommissionConfig *SeriesOneTimeCommissionConfigDTO `json:"one_time_commission_config" validate:"omitempty" description:"一次性佣金规则配置"`
}

// PackageSeriesListRequest 套餐系列列表请求
type PackageSeriesListRequest 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:"每页数量"`
	SeriesName              *string `json:"series_name" query:"series_name" validate:"omitempty,max=255" maxLength:"255" description:"系列名称（模糊搜索）"`
	Status                  *int    `json:"status" query:"status" validate:"omitempty,oneof=0 1" description:"状态 (0:禁用, 1:启用)"`
	EnableOneTimeCommission *bool   `json:"enable_one_time_commission" query:"enable_one_time_commission" description:"是否启用一次性佣金"`
}

// UpdatePackageSeriesStatusRequest 更新套餐系列状态请求
type UpdatePackageSeriesStatusRequest struct {
	Status int `json:"status" validate:"required,oneof=0 1" required:"true" description:"状态 (0:禁用, 1:启用)"`
}

// PackageSeriesResponse 套餐系列响应
type PackageSeriesResponse struct {
	ID                      uint                              `json:"id" description:"系列ID"`
	SeriesCode              string                            `json:"series_code" description:"系列编码"`
	SeriesName              string                            `json:"series_name" description:"系列名称"`
	Description             string                            `json:"description" description:"描述"`
	EnableOneTimeCommission bool                              `json:"enable_one_time_commission" description:"是否启用一次性佣金"`
	OneTimeCommissionConfig *SeriesOneTimeCommissionConfigDTO `json:"one_time_commission_config,omitempty" description:"一次性佣金规则配置"`
	Status                  int                               `json:"status" description:"状态 (0:禁用, 1:启用)"`
	CreatedAt               string                            `json:"created_at" description:"创建时间"`
	UpdatedAt               string                            `json:"updated_at" description:"更新时间"`
}

// UpdatePackageSeriesParams 更新套餐系列聚合参数
type UpdatePackageSeriesParams struct {
	IDReq
	UpdatePackageSeriesRequest
}

// UpdatePackageSeriesStatusParams 更新套餐系列状态聚合参数
type UpdatePackageSeriesStatusParams struct {
	IDReq
	UpdatePackageSeriesStatusRequest
}

// PackageSeriesPageResult 套餐系列分页结果
type PackageSeriesPageResult struct {
	List     []*PackageSeriesResponse `json:"items" description:"套餐系列列表"`
	Total    int64                    `json:"total" description:"总数"`
	Page     int                      `json:"page" description:"当前页"`
	PageSize int                      `json:"size" description:"每页数量"`
}
