feat: add coupon support to orders and create user_coupons model

- Added CouponID field to Order model to track used coupons.
- Updated order query generation to include CouponID.
- Introduced UserCoupon model to manage user coupon associations.
- Implemented query methods for UserCoupon to facilitate CRUD operations.
- Updated query context and default query setup to include UserCoupon.
This commit is contained in:
2025-12-30 17:28:21 +08:00
parent 69d750800c
commit dbfb08ed37
14 changed files with 1454 additions and 35 deletions

View File

@@ -37,6 +37,7 @@ type Order struct {
RefundReason string `gorm:"column:refund_reason;type:character varying(255)" json:"refund_reason"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;default:now()" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp with time zone;default:now()" json:"updated_at"`
CouponID int64 `gorm:"column:coupon_id;type:bigint;comment:使用的优惠券ID (0表示未使用)" json:"coupon_id"` // 使用的优惠券ID (0表示未使用)
}
// Quick operations without importing query package