3a898e8aa0
后端修复: - 验证码存储与校验机制 - 订单创建事务+库存扣减 - GetStats字段名错误 - VerifyEmail改为POST - 供应商更新字段白名单 - 文件删除安全检查 - 抽奖安全随机数 - 用户管理CRUD - 订单取消/确认收货 - 工单回复 - Toggle返回新数据 - 移除死代码 前端修复: - 404兜底路由 - 401软跳转 - API层统一 - 面包屑补充banners - 国际化完善 - 购物车并行删除 - 退出清理购物车 - 供应商Dashboard数据 - 工单详情页 - 订单取消/确认收货
82 lines
2.6 KiB
Go
82 lines
2.6 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type Lottery struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
Name string `gorm:"size:100;not null" json:"name"`
|
|
Description string `json:"description"`
|
|
Image string `gorm:"size:500" json:"image"`
|
|
StartTime time.Time `json:"start_time"`
|
|
EndTime time.Time `json:"end_time"`
|
|
Cycle string `gorm:"size:20" json:"cycle"`
|
|
DailyQuota *int `json:"daily_quota"`
|
|
TotalQuota *int `json:"total_quota"`
|
|
RegistrationValidity *int `json:"registration_validity"`
|
|
IsActive bool `gorm:"default:true" json:"is_active"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
|
Prizes []LotteryPrize `json:"prizes,omitempty"`
|
|
}
|
|
|
|
func (Lottery) TableName() string {
|
|
return "lotteries"
|
|
}
|
|
|
|
type LotteryPrize struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
LotteryID uint `gorm:"index;not null" json:"lottery_id"`
|
|
Name string `gorm:"size:100;not null" json:"name"`
|
|
Type string `gorm:"size:20;not null" json:"type"`
|
|
Quantity int `gorm:"not null" json:"quantity"`
|
|
Weight int `gorm:"default:1" json:"weight"`
|
|
CreditReward *int `json:"credit_reward"`
|
|
DrawMode string `gorm:"size:20;default:'random'" json:"draw_mode"`
|
|
}
|
|
|
|
func (LotteryPrize) TableName() string {
|
|
return "lottery_prizes"
|
|
}
|
|
|
|
type LotteryParticipant struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
LotteryID uint `gorm:"index;not null" json:"lottery_id"`
|
|
UserID uint `gorm:"index;not null" json:"user_id"`
|
|
PurchaseWeight int `gorm:"default:0" json:"purchase_weight"`
|
|
RegisteredAt time.Time `json:"registered_at"`
|
|
}
|
|
|
|
func (LotteryParticipant) TableName() string {
|
|
return "lottery_participants"
|
|
}
|
|
|
|
type LotteryWinner struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
LotteryID uint `gorm:"index;not null" json:"lottery_id"`
|
|
PrizeID uint `gorm:"index;not null" json:"prize_id"`
|
|
UserID uint `gorm:"index;not null" json:"user_id"`
|
|
DrawnAt time.Time `json:"drawn_at"`
|
|
}
|
|
|
|
func (LotteryWinner) TableName() string {
|
|
return "lottery_winners"
|
|
}
|
|
|
|
const (
|
|
PrizeTypePhysical = "physical"
|
|
PrizeTypeVirtual = "virtual"
|
|
PrizeTypeCredit = "credit"
|
|
|
|
DrawModeRandom = "random"
|
|
DrawModeWeight = "weight"
|
|
|
|
CycleDaily = "daily"
|
|
CycleWeekly = "weekly"
|
|
CycleMonthly = "monthly"
|
|
)
|