package model

// Category 菜品分类
type Category struct {
	BaseModel
	Name     string `json:"name" gorm:"size:32;not null"`
	ParentID *uint  `json:"parent_id" gorm:"index;default:null"`
	Sort     int    `json:"sort" gorm:"default:0"`
	Status   int    `json:"status" gorm:"default:1"`
}

func (Category) TableName() string {
	return "categories"
}

// Dish 菜品
type Dish struct {
	BaseModel
	CategoryID    uint    `json:"category_id" gorm:"index;not null"`
	Name          string  `json:"name" gorm:"size:64;not null"`
	Subtitle      string  `json:"subtitle" gorm:"size:128"`
	Description   string  `json:"description" gorm:"type:text"`
	Images        string  `json:"images" gorm:"type:text"` // JSON数组，最多5张
	Price         float64 `json:"price" gorm:"type:decimal(10,2);not null"`      // 原价(普通价)
	VIPPrice      float64 `json:"vip_price" gorm:"type:decimal(10,2);not null"`  // 会员价
	ActivityPrice float64 `json:"activity_price" gorm:"type:decimal(10,2);default:0"`
	ActivityStart *string `json:"activity_start" gorm:"type:datetime"`
	ActivityEnd   *string `json:"activity_end" gorm:"type:datetime"`
	Tags          string  `json:"tags" gorm:"size:256"`      // JSON数组: 热销/新品/招牌推荐
	DailyLimit    int     `json:"daily_limit" gorm:"default:0"` // 0表示不限
	SoldToday     int     `json:"sold_today" gorm:"default:0"`
	Status        int     `json:"status" gorm:"default:1"` // 1上架 0下架
	Sort          int     `json:"sort" gorm:"default:0"`
}

func (Dish) TableName() string {
	return "dishes"
}

// Activity 营销活动配置
type Activity struct {
	BaseModel
	Name     string  `json:"name" gorm:"size:64;not null"`
	Type     string  `json:"type" gorm:"size:24;not null"` // time_price/combo/full_reduce/coupon
	Rule     string  `json:"rule" gorm:"type:text"`        // JSON规则配置
	StartAt  string  `json:"start_at" gorm:"type:datetime"`
	EndAt    string  `json:"end_at" gorm:"type:datetime"`
	Status   int     `json:"status" gorm:"default:1"` // 1启用 0停用
}

func (Activity) TableName() string {
	return "activities"
}
