package model

import (
	"time"

	"gorm.io/gorm"
)

// ShopPackageAllocationPriceHistory 套餐成本价变更历史模型
// 记录成本价调整历史，支持审计和纠纷处理
// 每次成本价变更都会自动创建历史记录
type ShopPackageAllocationPriceHistory struct {
	gorm.Model
	AllocationID  uint      `gorm:"column:allocation_id;index;not null;comment:关联的套餐分配ID(tb_shop_package_allocation.id)" json:"allocation_id"`
	OldCostPrice  int64     `gorm:"column:old_cost_price;type:bigint;not null;comment:原成本价(分)" json:"old_cost_price"`
	NewCostPrice  int64     `gorm:"column:new_cost_price;type:bigint;not null;comment:新成本价(分)" json:"new_cost_price"`
	ChangeReason  string    `gorm:"column:change_reason;type:varchar(255);comment:变更原因" json:"change_reason"`
	ChangedBy     uint      `gorm:"column:changed_by;type:bigint;not null;comment:变更人ID" json:"changed_by"`
	EffectiveFrom time.Time `gorm:"column:effective_from;type:timestamptz;not null;comment:生效时间" json:"effective_from"`
}

// TableName 指定表名
func (ShopPackageAllocationPriceHistory) TableName() string {
	return "tb_shop_package_allocation_price_history"
}
