feat: implement coupon management and receive flow

This commit is contained in:
2026-01-13 18:19:29 +08:00
parent 9b06f768ab
commit 4f315cc2db
18 changed files with 1787 additions and 246 deletions

View File

@@ -8,6 +8,8 @@ import (
"context"
"time"
"quyun/v2/pkg/consts"
"go.ipao.vip/gen"
)
@@ -15,13 +17,13 @@ const TableNameUserCoupon = "user_coupons"
// UserCoupon mapped from table <user_coupons>
type UserCoupon struct {
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
UserID int64 `gorm:"column:user_id;type:bigint;not null" json:"user_id"`
CouponID int64 `gorm:"column:coupon_id;type:bigint;not null" json:"coupon_id"`
OrderID int64 `gorm:"column:order_id;type:bigint" json:"order_id"`
Status string `gorm:"column:status;type:character varying(32);not null;default:unused" json:"status"`
UsedAt time.Time `gorm:"column:used_at;type:timestamp with time zone" json:"used_at"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;not null;default:now()" json:"created_at"`
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
UserID int64 `gorm:"column:user_id;type:bigint;not null" json:"user_id"`
CouponID int64 `gorm:"column:coupon_id;type:bigint;not null" json:"coupon_id"`
OrderID int64 `gorm:"column:order_id;type:bigint" json:"order_id"`
Status consts.UserCouponStatus `gorm:"column:status;type:character varying(32);not null;default:unused" json:"status"`
UsedAt time.Time `gorm:"column:used_at;type:timestamp with time zone" json:"used_at"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;not null;default:now()" json:"created_at"`
}
// Quick operations without importing query package