新增了:发放系统优惠卷

This commit is contained in:
2024-05-31 17:21:26 +08:00
parent d207720a4c
commit 7b021906a2
14 changed files with 767 additions and 24 deletions
+39
View File
@@ -0,0 +1,39 @@
package model
import (
"gorm.io/gorm"
"hospital-admin-api/global"
"time"
)
// CouponGrant 优惠卷发放记录表
type CouponGrant struct {
GrantId int64 `gorm:"column:grant_id;type:bigint(19);primary_key;comment:主键id" json:"grant_id"`
CouponId int64 `gorm:"column:coupon_id;type:bigint(19);comment:优惠卷id" json:"coupon_id"`
GrantType int `gorm:"column:grant_type;type:tinyint(1);default:1;comment:发放类型(1:具体用户 2:未拥有用户)" json:"grant_type"`
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id(发放类型为具体用户时存在)" json:"user_id"`
TotalQuantity int `gorm:"column:total_quantity;type:int(5);default:0;comment:目标发放数量" json:"total_quantity"`
GrantQuantity int `gorm:"column:grant_quantity;type:int(5);comment:已发放数量" json:"grant_quantity"`
GrantResult int `gorm:"column:grant_result;type:tinyint(1);default:2;comment:发放结果(1:成功 2:发放中 3:部分 4:失败)" json:"grant_result"`
StopReason string `gorm:"column:stop_reason;type:varchar(255);comment:停止原因" json:"stop_reason"`
AdminUserId int64 `gorm:"column:admin_user_id;type:bigint(19);comment:后台操作用户id" json:"admin_user_id"`
Model
}
func (m *CouponGrant) TableName() string {
return "gdxz_coupon_grant"
}
func (m *CouponGrant) BeforeCreate(tx *gorm.DB) error {
if m.GrantId == 0 {
m.GrantId = 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
}
+40
View File
@@ -0,0 +1,40 @@
package model
import (
"gorm.io/gorm"
"hospital-admin-api/global"
"time"
)
// Popup 弹窗表
type Popup struct {
PopupId int64 `gorm:"column:popup_id;type:bigint(19);primary_key;comment:主键id" json:"popup_id"`
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id" json:"user_id"`
AppType int `gorm:"column:app_type;type:tinyint(4);comment:应用程序类型(1:小程序 2:app;NOT NULL" json:"app_type"`
ClientType int `gorm:"column:client_type;type:tinyint(4);comment:客户端类型(1:患者端 2:医生端 3:药师端);NOT NULL" json:"client_type"`
Status int `gorm:"column:status;type:tinyint(4);default:0;comment:状态(0:未弹 1:已弹)" json:"status"`
PopupType int `gorm:"column:popup_type;type:tinyint(4);comment:弹窗类型(1:结算费用规则 2:新优惠卷弹窗);NOT NULL" json:"popup_type"`
PopupTitle string `gorm:"column:popup_title;type:varchar(255);comment:标题" json:"popup_title"`
PopupContent string `gorm:"column:popup_content;type:varchar(1000);comment:内容" json:"popup_content"`
PopupImg string `gorm:"column:popup_img;type:varchar(255);comment:封面图片" json:"popup_img"`
PopupLink string `gorm:"column:popup_link;type:varchar(255);comment:跳转地址" json:"popup_link"`
Model
}
func (m *Popup) TableName() string {
return "gdxz_popup"
}
func (m *Popup) BeforeCreate(tx *gorm.DB) error {
if m.PopupId == 0 {
m.PopupId = 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
}
+9 -8
View File
@@ -8,16 +8,17 @@ import (
// 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"`
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
Coupon *Coupon `gorm:"foreignKey:CouponId;references:coupon_id" json:"coupon"`
User *User `gorm:"foreignKey:UserId;references:user_id" json:"user"` // 用户
}
func (m *UserCoupon) TableName() string {