Files
nl-game-api/internal/model/point.go
2026-08-14 13:17:03 +08:00

42 lines
1.9 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package model
// 积分流水类型常量
const (
PointTypeSignIn = 1 // 每日签到
PointTypeGame = 2 // 游戏奖励
PointTypeShop = 3 // 商城消费
PointTypeBattle = 4 // 对战奖励
PointTypeProp = 5 // 道具使用
PointTypeRegister = 6 // 注册赠送
PointTypeAdmin = 7 // 后台调整
PointTypeVIP = 8 // 开通/续费VIP
)
// PointRecord 积分流水表:所有积分变动都记一条
type PointRecord struct {
ID int `gorm:"primaryKey" json:"id"` // 流水ID
UserID int `gorm:"index" json:"user_id"` // 用户ID
ChangePoints int `gorm:"default:0" json:"change_points"` // 变动值(正=获得,负=消耗)
Balance int `gorm:"default:0" json:"balance"` // 变动后余额快照
Type int `gorm:"default:1" json:"type"` // 类型1签到 2游戏 3消费 4对战 5道具 6注册 7后台
RelatedID int `gorm:"default:0" json:"related_id"` // 关联业务ID订单/记录ID
Remark string `gorm:"size:255" json:"remark"` // 备注说明
CreatedAt int64 `gorm:"autoCreateTime" json:"created_at"` // 发生时间int 时间戳)
}
// TableName 指定表名
func (PointRecord) TableName() string { return "point_records" }
// SignIn 签到记录表:每人每天一条
type SignIn struct {
ID int `gorm:"primaryKey" json:"id"` // 签到ID
UserID int `json:"user_id"` // 用户ID
SignDay int `json:"sign_day"` // 签到日期yyyymmdd 整数)
Streak int `gorm:"default:1" json:"streak"` // 连续签到天数
Points int `gorm:"default:0" json:"points"` // 本次获得积分
CreatedAt int64 `gorm:"autoCreateTime" json:"created_at"` // 签到时间int 时间戳)
}
// TableName 指定表名
func (SignIn) TableName() string { return "sign_ins" }