package user

import (
	"gorm.io/datatypes"
	"time"
)

type UserRecordLog struct {
	GameNo      string                      `gorm:"primaryKey;type:String" json:"game_no"`
	GameId      int32                       `gorm:"type:Int32;default:0" json:"game_id"`
	RoomId      int32                       `gorm:"type:Int32;default:0" json:"room_id"`
	RoomType    int32                       `gorm:"type:Int32;default:0" json:"room_type"`
	StartTime   time.Time                   `gorm:"type:DateTime;default:now()" json:"start_time"` // 开始时间
	EndTime     time.Time                   `gorm:"type:DateTime;default:now()" json:"end_time"`   // 结束时间
	Users       datatypes.JSONType[UserLog] `json:"user"`
	TotalBet    int64                       `gorm:"type:Int64;default:0" json:"total_bet"`     // 玩家总投注额
	TotalNetWin int64                       `gorm:"type:Int64;default:0" json:"total_net_win"` // 玩家总净胜分
	Tax         int64                       `gorm:"type:Int64;default:0" json:"tax"`           // 税
	GameData    string                      `gorm:"type:String" json:"game_data"`              // 游戏数据(JSON格式)
}

func (u UserRecordLog) GetId() int64 {
	return 0
}

func (u UserRecordLog) GetIdName() string {
	return "game_no"
}

func (u UserRecordLog) TableName() string {
	return "user_record_log"
}

func (u UserRecordLog) TableOptions() string {
	return `ENGINE=MergeTree() 
			ORDER BY (game_no, game_id, room_type)
			PARTITION BY toYYYYMM(start_time)
			`
}
