package dto

// BaseCommissionConfig 基础返佣配置
type BaseCommissionConfig struct {
	Mode  string `json:"mode" validate:"required,oneof=fixed percent" required:"true" description:"返佣模式 (fixed:固定金额, percent:百分比)"`
	Value int64  `json:"value" validate:"required,min=0" required:"true" minimum:"0" description:"返佣值（分或千分比，如200=20%）"`
}

// OneTimeCommissionConfig 一次性佣金配置
type OneTimeCommissionConfig struct {
	Type      string                       `json:"type" validate:"required,oneof=fixed tiered" required:"true" description:"一次性佣金类型 (fixed:固定, tiered:梯度)"`
	Trigger   string                       `json:"trigger" validate:"required,oneof=single_recharge accumulated_recharge" required:"true" description:"触发条件 (single_recharge:单次充值, accumulated_recharge:累计充值)"`
	Threshold int64                        `json:"threshold" validate:"required,min=1" required:"true" minimum:"1" description:"最低阈值（分）"`
	Mode      string                       `json:"mode" validate:"omitempty,oneof=fixed percent" description:"返佣模式 (fixed:固定金额, percent:百分比) - 固定类型时必填"`
	Value     int64                        `json:"value" validate:"omitempty,min=1" minimum:"1" description:"佣金金额（分）或比例（千分比）- 固定类型时必填"`
	Tiers     []OneTimeCommissionTierEntry `json:"tiers" validate:"omitempty,dive" description:"梯度档位列表 - 梯度类型时必填"`
}

// OneTimeCommissionTierEntry 一次性佣金梯度档位条目
type OneTimeCommissionTierEntry struct {
	TierType  string `json:"tier_type" validate:"required,oneof=sales_count sales_amount" required:"true" description:"梯度类型 (sales_count:销量, sales_amount:销售额)"`
	Threshold int64  `json:"threshold" validate:"required,min=1" required:"true" minimum:"1" description:"梯度阈值（销量或销售额分）"`
	Mode      string `json:"mode" validate:"required,oneof=fixed percent" required:"true" description:"返佣模式 (fixed:固定金额, percent:百分比)"`
	Value     int64  `json:"value" validate:"required,min=1" required:"true" minimum:"1" description:"返佣值（分或千分比）"`
}

// CreateShopSeriesAllocationRequest 创建套餐系列分配请求
type CreateShopSeriesAllocationRequest struct {
	ShopID                   uint                     `json:"shop_id" validate:"required" required:"true" description:"被分配的店铺ID"`
	SeriesID                 uint                     `json:"series_id" validate:"required" required:"true" description:"套餐系列ID"`
	BaseCommission           BaseCommissionConfig     `json:"base_commission" validate:"required" required:"true" description:"基础返佣配置"`
	EnableOneTimeCommission  bool                     `json:"enable_one_time_commission" description:"是否启用一次性佣金"`
	OneTimeCommissionConfig  *OneTimeCommissionConfig `json:"one_time_commission_config" validate:"omitempty" description:"一次性佣金配置（启用一次性佣金时必填）"`
	EnableForceRecharge      *bool                    `json:"enable_force_recharge,omitempty" description:"是否启用强充(累计充值强充)"`
	ForceRechargeAmount      *int64                   `json:"force_recharge_amount,omitempty" description:"强充金额(分,0表示使用阈值金额)"`
	ForceRechargeTriggerType *int                     `json:"force_recharge_trigger_type,omitempty" description:"强充触发类型(1:单次充值, 2:累计充值)"`
}

// UpdateShopSeriesAllocationRequest 更新套餐系列分配请求
type UpdateShopSeriesAllocationRequest struct {
	BaseCommission           *BaseCommissionConfig    `json:"base_commission" validate:"omitempty" description:"基础返佣配置"`
	EnableOneTimeCommission  *bool                    `json:"enable_one_time_commission" description:"是否启用一次性佣金"`
	OneTimeCommissionConfig  *OneTimeCommissionConfig `json:"one_time_commission_config" validate:"omitempty" description:"一次性佣金配置"`
	EnableForceRecharge      *bool                    `json:"enable_force_recharge,omitempty" description:"是否启用强充(累计充值强充)"`
	ForceRechargeAmount      *int64                   `json:"force_recharge_amount,omitempty" description:"强充金额(分,0表示使用阈值金额)"`
	ForceRechargeTriggerType *int                     `json:"force_recharge_trigger_type,omitempty" description:"强充触发类型(1:单次充值, 2:累计充值)"`
}

// ShopSeriesAllocationListRequest 套餐系列分配列表请求
type ShopSeriesAllocationListRequest 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"`
	SeriesID *uint `json:"series_id" query:"series_id" validate:"omitempty" description:"套餐系列ID"`
	Status   *int  `json:"status" query:"status" validate:"omitempty,oneof=1 2" description:"状态 (1:启用, 2:禁用)"`
}

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

// ShopSeriesAllocationResponse 套餐系列分配响应
type ShopSeriesAllocationResponse struct {
	ID                       uint                     `json:"id" description:"分配ID"`
	ShopID                   uint                     `json:"shop_id" description:"被分配的店铺ID"`
	ShopName                 string                   `json:"shop_name" description:"被分配的店铺名称"`
	SeriesID                 uint                     `json:"series_id" description:"套餐系列ID"`
	SeriesName               string                   `json:"series_name" description:"套餐系列名称"`
	AllocatorShopID          uint                     `json:"allocator_shop_id" description:"分配者店铺ID"`
	AllocatorShopName        string                   `json:"allocator_shop_name" description:"分配者店铺名称"`
	BaseCommission           BaseCommissionConfig     `json:"base_commission" description:"基础返佣配置"`
	EnableOneTimeCommission  bool                     `json:"enable_one_time_commission" description:"是否启用一次性佣金"`
	OneTimeCommissionConfig  *OneTimeCommissionConfig `json:"one_time_commission_config,omitempty" description:"一次性佣金配置"`
	EnableForceRecharge      bool                     `json:"enable_force_recharge" description:"是否启用强充"`
	ForceRechargeAmount      int64                    `json:"force_recharge_amount" description:"强充金额(分)"`
	ForceRechargeTriggerType int                      `json:"force_recharge_trigger_type" description:"强充触发类型(1:单次充值, 2:累计充值)"`
	Status                   int                      `json:"status" description:"状态 (1:启用, 2:禁用)"`
	CreatedAt                string                   `json:"created_at" description:"创建时间"`
	UpdatedAt                string                   `json:"updated_at" description:"更新时间"`
}

// ShopSeriesAllocationPageResult 套餐系列分配分页结果
type ShopSeriesAllocationPageResult struct {
	List       []*ShopSeriesAllocationResponse `json:"list" description:"分配列表"`
	Total      int64                           `json:"total" description:"总数"`
	Page       int                             `json:"page" description:"当前页"`
	PageSize   int                             `json:"page_size" description:"每页数量"`
	TotalPages int                             `json:"total_pages" description:"总页数"`
}

// UpdateShopSeriesAllocationParams 更新套餐系列分配聚合参数
type UpdateShopSeriesAllocationParams struct {
	IDReq
	UpdateShopSeriesAllocationRequest
}

// UpdateShopSeriesAllocationStatusParams 更新套餐系列分配状态聚合参数
type UpdateShopSeriesAllocationStatusParams struct {
	IDReq
	UpdateShopSeriesAllocationStatusRequest
}
