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,20 +17,20 @@ const TableNameCoupon = "coupons"
// Coupon mapped from table <coupons>
type Coupon struct {
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
TenantID int64 `gorm:"column:tenant_id;type:bigint;not null" json:"tenant_id"`
Title string `gorm:"column:title;type:character varying(255);not null" json:"title"`
Description string `gorm:"column:description;type:text" json:"description"`
Type string `gorm:"column:type;type:character varying(32);not null" json:"type"`
Value int64 `gorm:"column:value;type:bigint;not null" json:"value"`
MinOrderAmount int64 `gorm:"column:min_order_amount;type:bigint;not null" json:"min_order_amount"`
MaxDiscount int64 `gorm:"column:max_discount;type:bigint" json:"max_discount"`
TotalQuantity int32 `gorm:"column:total_quantity;type:integer;not null" json:"total_quantity"`
UsedQuantity int32 `gorm:"column:used_quantity;type:integer;not null" json:"used_quantity"`
StartAt time.Time `gorm:"column:start_at;type:timestamp with time zone" json:"start_at"`
EndAt time.Time `gorm:"column:end_at;type:timestamp with time zone" json:"end_at"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;not null;default:now()" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp with time zone;not null;default:now()" json:"updated_at"`
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
TenantID int64 `gorm:"column:tenant_id;type:bigint;not null" json:"tenant_id"`
Title string `gorm:"column:title;type:character varying(255);not null" json:"title"`
Description string `gorm:"column:description;type:text" json:"description"`
Type consts.CouponType `gorm:"column:type;type:character varying(32);not null" json:"type"`
Value int64 `gorm:"column:value;type:bigint;not null" json:"value"`
MinOrderAmount int64 `gorm:"column:min_order_amount;type:bigint;not null" json:"min_order_amount"`
MaxDiscount int64 `gorm:"column:max_discount;type:bigint" json:"max_discount"`
TotalQuantity int32 `gorm:"column:total_quantity;type:integer;not null" json:"total_quantity"`
UsedQuantity int32 `gorm:"column:used_quantity;type:integer;not null" json:"used_quantity"`
StartAt time.Time `gorm:"column:start_at;type:timestamp with time zone" json:"start_at"`
EndAt time.Time `gorm:"column:end_at;type:timestamp with time zone" json:"end_at"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;not null;default:now()" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp with time zone;not null;default:now()" json:"updated_at"`
}
// Quick operations without importing query package