123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package models
- import (
- "context"
- "fmt"
- mhayaTime "github.com/mhaya/extend/time"
- "github.com/mhaya/game/game_cluster/internal/constant"
- "github.com/mhaya/game/game_cluster/internal/mdb"
- )
- const (
- DailyRecordNewRegistered = iota + 1
- DailyRecordLoggedIn
- DailyRecordNewLogin
- DailyRecordOldLogin
- DailyRecordActiveUsers
- DailyRecordNewActive
- DailyRecordOldActive
- DailyRecordTotalPoints
- DailyRecordUProduced
- DailyRecordUCashout
- )
- type DailyRecord struct {
- Platform string `bson:"platform" json:"platform"` // platform: 用户所在的平台,例如“Android”或“IOS”
- Channel string `bson:"channel" json:"channel"` // channel: 用户来源渠道
- Daily int64 `bson:"daily" json:"daily"` //日期
- Registered int `bson:"registered" json:"registered"` // registered: 新用户注册的数量
- LoggedIn int `bson:"logged_in" json:"logged_in"` // logged_in: 登陆产品的用户数量
- NewLogin int `bson:"new_login" json:"new_login"` // new_login: 登陆产品的新注册用户数量
- OldLogin int `bson:"old_login" json:"old_login"` // old_login: 登陆产品的老用户数量
- ActiveUsers int `bson:"active_users" json:"active_users"` // active_users: 登录游戏后投掷过骰子的用户数量
- NewActive int `bson:"new_active" json:"new_active"` // new_active: 登录游戏后投掷过骰子的新用户数量
- OldActive int `bson:"old_active" json:"old_active"` // old_active: 登录游戏后投掷过骰子的老用户数量
- TotalPoints int `bson:"total_points" json:"total_points"` // total_points: 全服积分产出总值
- UProduced float64 `bson:"u_produced" json:"u_produced"` // u_produced: 全服U的产出总值
- UCashout float64 `bson:"u_cashout" json:"u_cashout"` // u_cashout: 全服U的提现总值
- CreatedAt int64 `bson:"createdAt" json:"createdAt"` // CreatedAt: 数据记录的时间戳
- UpdatedAt int64 `bson:"updatedAt" json:"updatedAt"`
- }
- func GetDailyRecordKey(platform, channel string, op int) string {
- Daily := mhayaTime.Now().DailyTOTimeStamp()
- return fmt.Sprintf("%v:%v:%s:%s:%v", constant.PlayerDailyKey, Daily, platform, channel, op)
- }
- func SetDailyRecord(platform, channel string, op, num int) {
- key := GetDailyRecordKey(platform, channel, op)
- mdb.RDB.IncrBy(context.Background(), key, int64(num))
- }
- func SetDailyRecordUserHash(platform, channel, userName string, op, num int) {
- //key := GetDailyRecordKey(platform, channel, op)
- }
|