新增金额为0时退还优惠卷
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderInquiryCoupon 订单-问诊-优惠卷表
|
||||
type OrderInquiryCoupon struct {
|
||||
OrderCouponId int64 `gorm:"column:order_coupon_id;type:bigint(19);primary_key;comment:主键id" json:"order_coupon_id"`
|
||||
OrderInquiryId int64 `gorm:"column:order_inquiry_id;type:bigint(19);comment:订单-问诊id;NOT NULL" json:"order_inquiry_id"`
|
||||
UserCouponId int64 `gorm:"column:user_coupon_id;type:bigint(19);comment:用户优惠卷表;NOT NULL" 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 *OrderInquiryCoupon) TableName() string {
|
||||
return "gdxz_order_inquiry_coupon"
|
||||
}
|
||||
|
||||
func (m *OrderInquiryCoupon) 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
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// UserCoupon 用户优惠卷表
|
||||
type UserCoupon struct {
|
||||
UserCouponId int64 `gorm:"column:user_coupon_id;type:bigint(19);primary_key;comment:主键id" json:"user_coupon_id"`
|
||||
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id;NOT NULL" json:"user_id"`
|
||||
PatientId int64 `gorm:"column:patient_id;type:bigint(19);comment:患者id" json:"patient_id"`
|
||||
CouponId int64 `gorm:"column:coupon_id;type:bigint(19);comment:优惠卷id;NOT NULL" json:"coupon_id"`
|
||||
UserCouponStatus int `gorm:"column:user_coupon_status;type:tinyint(1);default:0;comment:状态(0:未使用 1:已使用 3:已过期)" json:"user_coupon_status"`
|
||||
CouponUseDate time.Time `gorm:"column:coupon_use_date;type:datetime;comment:使用时间" json:"coupon_use_date"`
|
||||
ValidStartTime time.Time `gorm:"column:valid_start_time;type:datetime;comment:有效使用时间" json:"valid_start_time"`
|
||||
ValidEndTime time.Time `gorm:"column:valid_end_time;type:datetime;comment:过期使用时间" json:"valid_end_time"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *UserCoupon) TableName() string {
|
||||
return "gdxz_user_coupon"
|
||||
}
|
||||
|
||||
func (m *UserCoupon) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.UserCouponId == 0 {
|
||||
m.UserCouponId = 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