增加了药品订单详情的优惠卷数据
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderProductCoupon 订单-商品-优惠卷表
|
||||
type OrderProductCoupon struct {
|
||||
OrderCouponId int64 `gorm:"column:order_coupon_id;type:bigint(19);primary_key;comment:主键id" json:"order_coupon_id"`
|
||||
OrderProductId int64 `gorm:"column:order_product_id;type:bigint(19);comment:订单-商品id" json:"order_product_id"`
|
||||
UserCouponId int64 `gorm:"column:user_coupon_id;type:bigint(19);comment:用户优惠卷表id" json:"user_coupon_id"`
|
||||
CouponName string `gorm:"column:coupon_name;type:varchar(255);comment:优惠卷名称" json:"coupon_name"`
|
||||
CouponUsePrice float64 `gorm:"column:coupon_use_price;type:decimal(10,2);default:0.00;comment:优惠卷使用金额" json:"coupon_use_price"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *OrderProductCoupon) TableName() string {
|
||||
return "gdxz_order_product_coupon"
|
||||
}
|
||||
|
||||
func (m *OrderProductCoupon) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.OrderCouponId == 0 {
|
||||
m.OrderCouponId = 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
|
||||
}
|
||||
Reference in New Issue
Block a user