refactor(utils): 修复密码哈希比较逻辑错误 feat(user): 新增按状态筛选优惠券接口 docs: 添加虚拟发货与任务中心相关文档 fix(wechat): 修正Code2Session上下文传递问题 test: 补充订单折扣与积分转换测试用例 build: 更新配置文件与构建脚本 style: 清理多余的空行与注释
86 lines
3.0 KiB
Go
86 lines
3.0 KiB
Go
package task_center
|
|
|
|
import (
|
|
"time"
|
|
"gorm.io/datatypes"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type Task struct {
|
|
ID int64 `gorm:"primaryKey;autoIncrement"`
|
|
Name string `gorm:"size:64;not null"`
|
|
Description string `gorm:"type:text"`
|
|
Status int32 `gorm:"not null"`
|
|
StartTime *time.Time `gorm:"index"`
|
|
EndTime *time.Time `gorm:"index"`
|
|
Visibility int32 `gorm:"not null"`
|
|
ConditionsSchema datatypes.JSON `gorm:"type:json"`
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
func (Task) TableName() string { return "task_center_tasks" }
|
|
|
|
type TaskTier struct {
|
|
ID int64 `gorm:"primaryKey;autoIncrement"`
|
|
TaskID int64 `gorm:"index;not null"`
|
|
Metric string `gorm:"size:32;not null"`
|
|
Operator string `gorm:"size:8;not null"`
|
|
Threshold int64 `gorm:"not null"`
|
|
Window string `gorm:"size:32;not null"`
|
|
Repeatable int32 `gorm:"not null"`
|
|
Priority int32 `gorm:"not null"`
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
func (TaskTier) TableName() string { return "task_center_task_tiers" }
|
|
|
|
type TaskReward struct {
|
|
ID int64 `gorm:"primaryKey;autoIncrement"`
|
|
TaskID int64 `gorm:"index;not null"`
|
|
TierID int64 `gorm:"index;not null"`
|
|
RewardType string `gorm:"size:32;not null"`
|
|
RewardPayload datatypes.JSON `gorm:"type:json"`
|
|
Quantity int64 `gorm:"not null"`
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
func (TaskReward) TableName() string { return "task_center_task_rewards" }
|
|
|
|
type UserTaskProgress struct {
|
|
ID int64 `gorm:"primaryKey;autoIncrement"`
|
|
UserID int64 `gorm:"index;not null"`
|
|
TaskID int64 `gorm:"index;not null"`
|
|
OrderCount int64 `gorm:"not null"`
|
|
InviteCount int64 `gorm:"not null"`
|
|
FirstOrder int32 `gorm:"not null"`
|
|
ClaimedTiers datatypes.JSON `gorm:"type:json"`
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
func (UserTaskProgress) TableName() string { return "task_center_user_progress" }
|
|
|
|
type TaskEventLog struct {
|
|
ID int64 `gorm:"primaryKey;autoIncrement"`
|
|
EventID string `gorm:"size:64;index"`
|
|
SourceType string `gorm:"size:16"`
|
|
SourceID int64 `gorm:"index"`
|
|
UserID int64 `gorm:"index"`
|
|
TaskID int64 `gorm:"index"`
|
|
TierID int64 `gorm:"index"`
|
|
IdempotencyKey string `gorm:"size:128;uniqueIndex"`
|
|
Status string `gorm:"size:16"`
|
|
Result datatypes.JSON `gorm:"type:json"`
|
|
CreatedAt time.Time
|
|
}
|
|
|
|
func (TaskEventLog) TableName() string { return "task_center_event_logs" }
|
|
|
|
func AutoMigrate(db *gorm.DB) error {
|
|
return db.AutoMigrate(&Task{}, &TaskTier{}, &TaskReward{}, &UserTaskProgress{}, &TaskEventLog{})
|
|
}
|
|
|