package model

import (
	"gorm.io/datatypes"
	"gorm.io/gorm"
	"gorm.io/plugin/soft_delete"
)

type BundleProfile struct {
	gorm.Model
	UUID             string  `json:"uuid" gorm:"column:uuid;type:varchar(1024);comment:套餐UUID"`
	Name             string  `json:"name" gorm:"column:name;type:varchar(2048);comment:套餐名称"`
	Price            float32 `json:"price" gorm:"column:price;type:decimal(12,2);comment:套餐价格"`
	PriceType        int64   `json:"priceType" gorm:"column:price_type;type:int;comment:套餐类型 1:人民币 2:美元"`
	Contract         string  `json:"contract" gorm:"type:varchar(1024);comment:合同"`
	ContractDuration int     `json:"contractDuration" gorm:"column:contract_duration;type:int;comment:合同有效时长"`
	Content          string  `json:"content" gorm:"column:content;type:text;comment:套餐内容"`
	CompanySign      string  `json:"companySign" gorm:"column:company_sign;type:varchar(1024);comment:公司签名"`
	Language         string  `json:"language" gorm:"column:language;type:varchar(32);comment:套餐语言 zh-CN EN"`
	BundleCommonUid  string  `json:"bundleCommonUid" gorm:"column:bundle_common_uid;type:varchar(1024);comment:套餐公共ID"`

	Sort                    int64                     `json:"sort" gorm:"column:sort;type:int;comment:套餐排序"` //数字越小越靠前,同大小后创建优先
	ShelfStatus             int64                     `json:"shelfStatus" gorm:"column:shelf_status;type:int;default:2;comment:上架状态  1:上架 2:下架"`
	BgImg1                  string                    `json:"bgImg1" gorm:"column:bg_img1;type:varchar(1024);comment:背景图-首页"`
	BgImg2                  string                    `json:"bgImg2" gorm:"column:bg_img2;type:varchar(1024);comment:背景图-我的"`
	BundleToValueAddService []BundleToValueAddService `gorm:"foreignKey:BundleUuid;references:UUID" json:"bundleToValueAddService"`
	BundleProfileLang       []BundleProfileLang       `gorm:"foreignKey:UUID;references:UUID" json:"bundleProfileLang"`
}
type BundleProfileLang struct {
	Id        int32   `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"`
	UUID      string  `json:"uuid" gorm:"column:uuid;type:varchar(1024);comment:套餐UUID"`
	Name      string  `json:"name" gorm:"column:name;type:varchar(2048);comment:套餐名称"`
	Price     float32 `json:"price" gorm:"column:price;type:decimal(12,2);comment:套餐价格"`
	PriceType int64   `json:"priceType" gorm:"column:price_type;type:int;comment:套餐类型 1:人民币 2:美元"`
	Content   string  `json:"content" gorm:"column:content;type:text;comment:套餐内容"`
	Language  string  `json:"language" gorm:"column:language;type:varchar(32);comment:套餐语言 zh-CN zh-TW EN de-DE js-JP(中繁英德日)"`
	CreatedAt int64   `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt int64   `gorm:"column:updated_at;autoCreateTime"`
	DeletedAt soft_delete.DeletedAt
}
type BundleToValueAddService struct {
	Id              int32           `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"`
	BundleUuid      string          `json:"bundleUuid" gorm:"column:bundle_uuid;type:varchar(1024);comment:套餐UUID"`
	BundleProfile   BundleProfile   `gorm:"foreignKey:BundleUuid;references:UUID" json:"bundleProfile"`
	ValueUid        string          `json:"valueUid" gorm:"column:value_uid;type:varchar(1024);comment:增值服务UUID"`
	ValueAddService ValueAddService `gorm:"foreignKey:ValueUid;references:UUID" json:"valueAddService"`
	IsDisplay       bool            `json:"isDisplay" gorm:"column:is_display;type:tinyint(1);comment:是否显示"`
	CreatedAt       int64           `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt       int64           `gorm:"column:updated_at;autoCreateTime"`
	DeletedAt       soft_delete.DeletedAt
}

// todo套餐修改历史
type BundleProfileHistory struct {
	Id              int32          `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"`
	Uuid            string         `json:"uuid" gorm:"column:uuid;type:varchar(1024);comment:UUID"`
	BundleProfile   datatypes.JSON `json:"bundleProfile" gorm:"column:bundle_profile;type:json;comment:套餐信息"`
	ValueAddService datatypes.JSON `json:"valueAddService" gorm:"column:value_add_service;type:json;comment:增值服务信息"`
	Operator        string         `json:"operator" gorm:"column:operator;type:varchar(1024);comment:操作人"`
	OperatorId      uint64         `json:"operatorId" gorm:"column:operator_id;type:int;comment:操作人ID"`
	CreatedAt       int64          `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt       int64          `gorm:"column:updated_at;autoCreateTime"`
	DeletedAt       soft_delete.DeletedAt
}

func (m *BundleProfile) TableName() string {
	return "bundle_profile"
}
func (m *BundleProfileLang) TableName() string {
	return "bundle_profile_lang"
}
func (m *BundleToValueAddService) TableName() string {
	return "bundle_to_value_add_service"
}
func (m *BundleProfileHistory) TableName() string {
	return "bundle_profile_history"
}