package model

import (
	"gorm.io/gorm"
)

// ShopPackageAllocation 店铺套餐分配模型
// 记录套餐授权、价格及购买生效条件覆盖配置。
type ShopPackageAllocation struct {
	gorm.Model
	BaseModel               `gorm:"embedded"`
	ShopID                  uint    `gorm:"column:shop_id;index;not null;comment:被分配的店铺ID" json:"shop_id"`
	PackageID               uint    `gorm:"column:package_id;index;not null;comment:套餐ID" json:"package_id"`
	AllocatorShopID         uint    `gorm:"column:allocator_shop_id;index;not null;default:0;comment:分配者店铺ID，0表示平台分配" json:"allocator_shop_id"`
	CostPrice               int64   `gorm:"column:cost_price;type:bigint;not null;comment:该代理的成本价（分）" json:"cost_price"`
	SeriesAllocationID      *uint   `gorm:"column:series_allocation_id;index;comment:关联的系列分配ID" json:"series_allocation_id"`
	Status                  int     `gorm:"column:status;type:int;default:1;not null;comment:状态 0=禁用 1=启用" json:"status"`
	ShelfStatus             int     `gorm:"column:shelf_status;type:int;default:1;not null;comment:上架状态 1-上架 2-下架" json:"shelf_status"`
	RetailPrice             int64   `gorm:"column:retail_price;type:bigint;not null;default:0;comment:代理面向终端客户的零售价（分）" json:"retail_price"`
	RetailPriceConfigStatus int     `gorm:"column:retail_price_config_status;type:int;default:0;not null;comment:零售价配置状态 0-未配置 1-赠送0价 2-已配置非0" json:"retail_price_config_status"`
	ExpiryBaseOverride      *string `gorm:"column:expiry_base_override;type:varchar(30);comment:到期时间基准覆盖，NULL表示跟随套餐默认值" json:"expiry_base_override"`
}

// TableName 指定表名
func (ShopPackageAllocation) TableName() string {
	return "tb_shop_package_allocation"
}
