优惠券相关逻辑

This commit is contained in:
yan.y
2024-08-12 13:37:43 +08:00
parent e2fb325452
commit 3cd4e4b335
11 changed files with 369 additions and 84 deletions
+53 -23
View File
@@ -8,18 +8,19 @@ import "time"
// User 用户
type User struct {
Id int64 `gorm:"primaryKey;autoIncrement" json:"id"` //用户ID
NickName string `json:"nickName"` //昵称
HeadImgUrl string `json:"headImgUrl"` //用户头像URL
Amount int `json:"amount"` //用户余额
OpenId string `gorm:"index;unique;not null" json:"openId"` //三方openid
UnionId string `gorm:"index;unique;not null" json:"unionId"` //三方unionid
UserType int `json:"userType"` //用户类型 0微信 1手机号
Mobile string `json:"mobile"` //手机号
Role int `json:"role"` //用户角色 0普通用户 1护理人员
Discount int `json:"discount"` //折扣
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP;not null" json:"createTime"` //创建时间
Status int `json:"status"` //信息状态
Id int64 `gorm:"primaryKey;autoIncrement" json:"id"` //用户ID
NickName string `json:"nickName"` //昵称
HeadImgUrl string `json:"headImgUrl"` //用户头像URL
Amount int `json:"amount"` //用户余额
OpenId string `gorm:"index;unique;not null" json:"openId"` //三方openid
UnionId string `gorm:"index;unique;not null" json:"unionId"` //三方unionid
UserType int `json:"userType"` //用户类型 0微信 1手机号
Mobile string `json:"mobile"` //手机号
Role int `json:"role"` //用户角色 0普通用户 1护理人员
Discount int `json:"discount"` //折扣
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP;not null" json:"createTime"` //创建时间
Status int `json:"status"` //信息状态
InviteUserId int64 `json:"inviteUserId"` //邀请用户
}
// Pet 宠物信息
@@ -83,17 +84,18 @@ type UserServiceAddr struct {
// Goods 商品信息
type Goods struct {
Id int64 `gorm:"primaryKey;autoIncrement" json:"id"` //商品ID
Name string `gorm:"not null" json:"name"` //商品名称
GoodsType int `gorm:"not null" json:"goodsType"` //商品类型 1基础服务 2附加产品 3附加服务
Time string `json:"time"` //时间
Price int `gorm:"not null" json:"price"` //价格
ParentId int64 `gorm:"not null" json:"parentId"` //商品父ID
BuyMany int `gorm:"not null" json:"buyMany"` //同类型是否可购买多个 0否 1是
GoodsDetail string `gorm:"not null" json:"goodsDetail"` //商品详情 图片URL
GoodsIcon string `json:"goodsIcon"` //iconUrl
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"-"` //创建时间
Status int `json:"status"` //信息状态
Id int64 `gorm:"primaryKey;autoIncrement" json:"id"` //商品ID
Name string `gorm:"not null" json:"name"` //商品名称
GoodsType int `gorm:"not null" json:"goodsType"` //商品类型 1基础服务 2附加产品 3附加服务
Time string `json:"time"` //时间
Price int `gorm:"not null" json:"price"` //价格
ParentId int64 `gorm:"not null" json:"parentId"` //商品父ID
BuyMany int `gorm:"not null" json:"buyMany"` //同类型是否可购买多个 0否 1是
GoodsDetail string `gorm:"not null" json:"goodsDetail"` //商品详情 图片URL
GoodsIcon string `json:"goodsIcon"` //iconUrl
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"-"` //创建时间
Status int `json:"status"` //信息状态
GoodsSubType int `gorm:"not null" json:"goodsSubType"` //商品子类型
}
// PetGoods 宠物商品
@@ -167,6 +169,8 @@ type OrderSub struct {
// OrderDetail 订单明细
type OrderDetail struct {
Id int64 `gorm:"primaryKey;autoIncrement" json:"id"` //id
Cid int `json:"cid"` //子订单ID
Discount int `json:"discount"` //折扣
SubOrderId string `gorm:"index;not null" json:"subOrderId"` //子订单ID
GoodsId int64 `gorm:"index;not null" json:"goodsId"` //商品ID
Amount int `gorm:"not null" json:"amount"` //价格
@@ -263,3 +267,29 @@ type AddrServiceTime struct {
ServiceAddrId int64 `gorm:"not null" json:"ServiceAddrId"` //服务地址ID
Times string `gorm:"not null" json:"times"` //时间列表
}
// Coupons 优惠券
type Coupons struct {
Id int `gorm:"primaryKey;autoIncrement" json:"id"` //id
Name string `gorm:"not null" json:"name"`
GoodsSubType int `gorm:"not null" json:"goodsSubType"` //商品子类型
Discount int `gorm:"not null" json:"discount"` //折扣
Source string `gorm:"not null" json:"source"` //来源
PeriodType int `gorm:"not null" json:"periodType"` //使用类型 0、无 1、星期 2、截至时间 3、指定日期可用
Period string `json:"-"` //使用信息 具体时间 星期类型:1,2,3截止日期:2024-09-01 23:59:59指定日期:2024-08-10
PeriodInfo []string `gorm:"-" json:"periodInfo"`
ExpireTime int64 `json:"expireTime"` //优惠券过期时间
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"createTime"` //创建时间
UpdateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP" json:"-"` //更新时间
Status int `gorm:"default:1" json:"-"` //数据状态
}
type UserCoupons struct {
Id int `gorm:"primaryKey;autoIncrement" json:"id"` //id
Uid int64 `gorm:"not null" json:"uid"` //用户id
Cid int `gorm:"not null" json:"cid"` //优惠券ID
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"createTime"` //创建时间
UpdateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP" json:"-"` //更新时间
Status int `gorm:"default:1" json:"-"`
CouponsStatus int `gorm:"default:1" json:"status"` //状态 1未使用 2已使用 3已过期
}