package model import ( "gorm.io/gorm" "hepa-calc-api/global" "time" ) // SystemMember 配置-会员配置 type SystemMember struct { SystemMemberId int64 `gorm:"column:system_member_id;type:bigint(19);primary_key;comment:主键id" json:"system_member_id"` MemberDays uint `gorm:"column:member_days;type:int(10) unsigned;default:0;comment:会员天数" json:"member_days"` Price float64 `gorm:"column:price;type:decimal(10,2);default:0.00;comment:价格(原价)" json:"price"` DiscountPrice *float64 `gorm:"column:discount_price;type:decimal(10,2);comment:优惠价格" json:"discount_price"` DiscountEndTime *LocalTime `gorm:"column:discount_end_time;type:datetime;comment:优惠截止时间" json:"discount_end_time"` ReductionAmount *float64 `gorm:"column:reduction_amount;type:decimal(10,2);comment:首单立减金额" json:"reduction_amount"` Model } func (m *SystemMember) TableName() string { return "system_member" } func (m *SystemMember) BeforeCreate(tx *gorm.DB) error { if m.SystemMemberId == 0 { m.SystemMemberId = 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 }