重构优惠券表结构与功能
This commit is contained in:
@@ -10,20 +10,29 @@ import (
|
||||
// Coupon 优惠券表
|
||||
type Coupon struct {
|
||||
core.Model
|
||||
UserID *int32 `json:"user_id,omitempty" gorm:"column:user_id"` // 用户ID
|
||||
Code string `json:"code" gorm:"column:code"` // 优惠券代码
|
||||
Remark *string `json:"remark,omitempty" gorm:"column:remark"` // 优惠券备注
|
||||
Amount decimal.Decimal `json:"amount" gorm:"column:amount"` // 优惠券金额
|
||||
MinAmount decimal.Decimal `json:"min_amount" gorm:"column:min_amount"` // 最低消费金额
|
||||
Status CouponStatus `json:"status" gorm:"column:status"` // 优惠券状态:0-未使用,1-已使用,2-已过期
|
||||
ExpireAt *time.Time `json:"expire_at,omitempty" gorm:"column:expire_at"` // 过期时间
|
||||
Name string `json:"name" gorm:"column:name"` // 优惠券名称
|
||||
Amount decimal.Decimal `json:"amount" gorm:"column:amount"` // 优惠券金额
|
||||
MinAmount decimal.Decimal `json:"min_amount" gorm:"column:min_amount"` // 最低消费金额
|
||||
Count int32 `json:"count" gorm:"column:count"` // 优惠券数量
|
||||
Status CouponStatus `json:"status" gorm:"column:status"` // 优惠券状态:0-禁用,1-正常
|
||||
ExpireType CouponExpireType `json:"expire_type" gorm:"column:expire_type"` // 过期类型:0-不过期,1-固定日期,2-相对日期(从发放时间算起)
|
||||
ExpireAt *time.Time `json:"expire_at,omitempty" gorm:"column:expire_at"` // 过期时间,固定日期必填
|
||||
ExpireIn *int `json:"expire_in,omitempty" gorm:"column:expire_in"` // 过期时长(天),相对日期必填
|
||||
}
|
||||
|
||||
// CouponStatus 优惠券状态枚举
|
||||
// CouponStatus 优惠券使用状态枚举
|
||||
type CouponStatus int
|
||||
|
||||
const (
|
||||
CouponStatusUnused CouponStatus = 0 // 未使用
|
||||
CouponStatusUsed CouponStatus = 1 // 已使用
|
||||
CouponStatusExpired CouponStatus = 2 // 已过期
|
||||
CouponStatusDisabled CouponStatus = 0 // 禁用
|
||||
CouponStatusEnabled CouponStatus = 1 // 正常
|
||||
)
|
||||
|
||||
// CouponExpireType 优惠券过期类型枚举
|
||||
type CouponExpireType int
|
||||
|
||||
const (
|
||||
CouponExpireTypeNever CouponExpireType = 0 // 不过期
|
||||
CouponExpireTypeFixed CouponExpireType = 1 // 固定日期
|
||||
CouponExpireTypeRelative CouponExpireType = 2 // 相对日期
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user