dailyRecord.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package models
  2. import (
  3. "context"
  4. "fmt"
  5. mhayaTime "github.com/mhaya/extend/time"
  6. "github.com/mhaya/game/game_cluster/internal/constant"
  7. "github.com/mhaya/game/game_cluster/internal/mdb"
  8. )
  9. const (
  10. DailyRecordNewRegistered = iota + 1
  11. DailyRecordLoggedIn
  12. DailyRecordNewLogin
  13. DailyRecordOldLogin
  14. DailyRecordActiveUsers
  15. DailyRecordNewActive
  16. DailyRecordOldActive
  17. DailyRecordTotalPoints
  18. DailyRecordUProduced
  19. DailyRecordUCashout
  20. )
  21. type DailyRecord struct {
  22. Platform string `bson:"platform" json:"platform"` // platform: 用户所在的平台,例如“Android”或“IOS”
  23. Channel string `bson:"channel" json:"channel"` // channel: 用户来源渠道
  24. Daily int64 `bson:"daily" json:"daily"` //日期
  25. Registered int `bson:"registered" json:"registered"` // registered: 新用户注册的数量
  26. LoggedIn int `bson:"logged_in" json:"logged_in"` // logged_in: 登陆产品的用户数量
  27. NewLogin int `bson:"new_login" json:"new_login"` // new_login: 登陆产品的新注册用户数量
  28. OldLogin int `bson:"old_login" json:"old_login"` // old_login: 登陆产品的老用户数量
  29. ActiveUsers int `bson:"active_users" json:"active_users"` // active_users: 登录游戏后投掷过骰子的用户数量
  30. NewActive int `bson:"new_active" json:"new_active"` // new_active: 登录游戏后投掷过骰子的新用户数量
  31. OldActive int `bson:"old_active" json:"old_active"` // old_active: 登录游戏后投掷过骰子的老用户数量
  32. TotalPoints int `bson:"total_points" json:"total_points"` // total_points: 全服积分产出总值
  33. UProduced float64 `bson:"u_produced" json:"u_produced"` // u_produced: 全服U的产出总值
  34. UCashout float64 `bson:"u_cashout" json:"u_cashout"` // u_cashout: 全服U的提现总值
  35. CreatedAt int64 `bson:"createdAt" json:"createdAt"` // CreatedAt: 数据记录的时间戳
  36. UpdatedAt int64 `bson:"updatedAt" json:"updatedAt"`
  37. }
  38. func GetDailyRecordKey(platform, channel string, op int) string {
  39. Daily := mhayaTime.Now().DailyTOTimeStamp()
  40. return fmt.Sprintf("%v:%v:%s:%s:%v", constant.PlayerDailyKey, Daily, platform, channel, op)
  41. }
  42. func SetDailyRecord(platform, channel string, op, num int) {
  43. key := GetDailyRecordKey(platform, channel, op)
  44. mdb.RDB.IncrBy(context.Background(), key, int64(num))
  45. }
  46. func SetDailyRecordUserHash(platform, channel, userName string, op, num int) {
  47. //key := GetDailyRecordKey(platform, channel, op)
  48. }