You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.8 KiB
46 lines
1.8 KiB
package goods
|
|
|
|
func (Coupon) TableName() string {
|
|
return "coupon"
|
|
}
|
|
|
|
// Coupon 结构体表示优惠券信息
|
|
type Coupon struct {
|
|
ID int64 `json:"id"` // 优惠券ID
|
|
Name string `json:"name"` // 优惠券名称
|
|
Type string `json:"type"` // 优惠券类型
|
|
GoodsIds string `json:"goods_ids"` // 关联商品ID
|
|
Amount string `json:"amount"` // 优惠金额
|
|
Enough string `json:"enough"` // 满足条件金额
|
|
Stock int64 `json:"stock"` // 库存
|
|
Limit int64 `json:"limit"` // 领取限制
|
|
Usetimestart int64 `json:"usetimestart"` // 可使用时间段开始
|
|
Usetimeend int64 `json:"usetimeend"` // 可使用时间段结束
|
|
Gettimestart int64 `json:"gettimestart"` // 可领取时间段开始
|
|
Gettimeend int64 `json:"gettimeend"` // 可领取时间段结束
|
|
Description string `json:"description"` // 优惠券描述
|
|
StatusCode string `json:"status_code"` // 优惠券状态代码
|
|
StatusName string `json:"status_name"` // 优惠券状态名称
|
|
GetTime TimeRange `json:"gettime" xorm:"-"` // 可领取时间段
|
|
UseTime TimeRange `json:"usetime" xorm:"-"` // 可使用时间段
|
|
UserCoupons []string `json:"user_coupons" xorm:"-"` // 用户优惠券列表
|
|
}
|
|
|
|
type TimeRange struct {
|
|
Start int64 `json:"start"` // 开始时间
|
|
End int64 `json:"end"` // 结束时间
|
|
}
|
|
|
|
func (coupon *Coupon) AfterQuery() error {
|
|
coupon.GetTime = TimeRange{
|
|
coupon.Gettimestart,
|
|
coupon.Gettimeend,
|
|
}
|
|
coupon.UseTime = TimeRange{
|
|
coupon.Usetimestart,
|
|
coupon.Usetimeend,
|
|
}
|
|
|
|
return nil
|
|
}
|