hospital-admin-api/api/model/orderServicePackageProduct.go

38 lines
1.5 KiB
Go

package model
import (
"gorm.io/gorm"
"hospital-admin-api/global"
"time"
)
// OrderServicePackageProduct 订单-服务包-关联商品订单表
type OrderServicePackageProduct struct {
ServiceProductId int64 `gorm:"column:service_product_id;type:bigint(19);primary_key;comment:主键id" json:"service_product_id"`
OrderServiceId int64 `gorm:"column:order_service_id;type:bigint(19);comment:订单-服务包id;NOT NULL" json:"order_service_id"`
OrderProductId int64 `gorm:"column:order_product_id;type:bigint(19);comment:订单-商品id;NOT NULL" json:"order_product_id"`
OrderProductNo string `gorm:"column:order_product_no;type:varchar(100);comment:订单-商品系统编号;NOT NULL" json:"order_product_no"`
ProductItemId int64 `gorm:"column:product_item_id;type:bigint(19);comment:订单-商品明细id;NOT NULL" json:"product_item_id"`
ProductId int64 `gorm:"column:product_id;type:bigint(19);comment:商品id;NOT NULL" json:"product_id"`
UsedQuantity int `gorm:"column:used_quantity;type:int(1);default:0;comment:商品使用数量" json:"used_quantity"`
Model
}
func (m *OrderServicePackageProduct) TableName() string {
return "gdxz_order_service_package_product"
}
func (m *OrderServicePackageProduct) BeforeCreate(tx *gorm.DB) error {
if m.ServiceProductId == 0 {
m.ServiceProductId = 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
}