Files
platform/web/models/coupon.go

39 lines
1.5 KiB
Go
Raw Normal View History

package models
import (
"platform/web/core"
"time"
"github.com/shopspring/decimal"
)
// Coupon 优惠券表
type Coupon struct {
core.Model
2026-04-09 14:58:20 +08:00
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"` // 过期时长(天),相对日期必填
}
2026-04-09 14:58:20 +08:00
// CouponStatus 优惠券使用状态枚举
type CouponStatus int
const (
2026-04-09 14:58:20 +08:00
CouponStatusDisabled CouponStatus = 0 // 禁用
CouponStatusEnabled CouponStatus = 1 // 正常
)
// CouponExpireType 优惠券过期类型枚举
type CouponExpireType int
const (
CouponExpireTypeNever CouponExpireType = 0 // 不过期
CouponExpireTypeFixed CouponExpireType = 1 // 固定日期
CouponExpireTypeRelative CouponExpireType = 2 // 相对日期
)