38 lines
1.5 KiB
Go
38 lines
1.5 KiB
Go
package model
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
"hospital-admin-api/global"
|
|
"time"
|
|
)
|
|
|
|
// HealthPackage 健康包
|
|
type HealthPackage struct {
|
|
PackageId int64 `gorm:"column:package_id;type:bigint(20);primary_key;comment:主键id" json:"package_id"`
|
|
ServiceCount int `gorm:"column:service_count;type:int(1);comment:总服务次数" json:"service_count"`
|
|
MonthlyFrequency int `gorm:"column:monthly_frequency;type:int(1);comment:每月次数" json:"monthly_frequency"`
|
|
EffectiveDays string `gorm:"column:effective_days;type:varchar(20);comment:服务有效天数" json:"effective_days"`
|
|
ServiceRate string `gorm:"column:service_rate;type:varchar(20);comment:服务费率。100为满值,表示1,正常费率。" json:"service_rate"`
|
|
DiscountProductTotalAmount float64 `gorm:"column:discount_product_total_amount;type:decimal(10,2) unsigned;default:0.00;comment:折扣商品总价格" json:"discount_product_total_amount"`
|
|
Model
|
|
HealthPackageProduct []*HealthPackageProduct `gorm:"foreignKey:PackageId;references:package_id" json:"health_package_product"` // 健康包-关联商品
|
|
}
|
|
|
|
func (m *HealthPackage) TableName() string {
|
|
return "gdxz_health_package"
|
|
}
|
|
|
|
func (m *HealthPackage) BeforeCreate(tx *gorm.DB) error {
|
|
if m.PackageId == 0 {
|
|
m.PackageId = global.Snowflake.Generate().Int64()
|
|
}
|
|
|
|
m.CreatedAt = LocalTime(time.Now())
|
|
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
|
|
|
m.UpdatedAt = LocalTime(time.Now())
|
|
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
|
|
|
return nil
|
|
}
|