vip.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. package vip
  2. import (
  3. "bet24.com/log"
  4. pb "bet24.com/servers/micros/userservices/proto"
  5. )
  6. func Run() {
  7. mgr = newVipManager()
  8. }
  9. func Dump(cmd, param1 string) {
  10. switch cmd {
  11. case "user":
  12. mgr.dumpGetUserVip(param1)
  13. case "list":
  14. mgr.dumpGetVipList()
  15. case "level":
  16. mgr.dumpGetVipByLevel(param1)
  17. case "packageInfo":
  18. mgr.dumpGetPurchasePackageInfo(param1)
  19. case "purchaseList":
  20. mgr.dumpGetPurchasePackageList(param1)
  21. default:
  22. log.Release("vipservice.Dump unhandled cmd %s", cmd)
  23. }
  24. }
  25. func GetUserVip(userId int) *pb.UserVip {
  26. ret := mgr.getUserVip(userId, true)
  27. if ret == nil {
  28. return nil
  29. }
  30. return &ret.UserVip
  31. }
  32. func AddUser(userId int) {
  33. mgr.onUserEnter(userId)
  34. }
  35. func RemoveUser(userId int) {
  36. mgr.onUserExit(userId)
  37. }
  38. func GetVipList() []pb.VipInfo {
  39. return mgr.getVipList()
  40. }
  41. func GetPurchasePackageList(userId int) []pb.PurchasePackage {
  42. return mgr.getPurchasePackageList(userId)
  43. }
  44. func GetVipByLevel(level int) *pb.VipInfo {
  45. return mgr.getVipByLevel(level)
  46. }
  47. func GetExtraBankruptcy(userId int) int {
  48. return mgr.getPrivilegeValue(userId, pb.VipPrivilege_ExtraBankruptcy)
  49. }
  50. func GetExtraExperience(userId int) int {
  51. return mgr.getPrivilegeValue(userId, pb.VipPrivilege_ExtraExperience)
  52. }
  53. func GetExtraFriendCount(userId int) int {
  54. return mgr.getPrivilegeValue(userId, pb.VipPrivilege_ExtraFriend)
  55. }
  56. func CanBuyPackage(userId int, productId string) bool {
  57. return mgr.canBuyPackage(userId, productId)
  58. }
  59. func BuyPackage(userId int, productId string) {
  60. mgr.buyPackage(userId, productId)
  61. }
  62. func AddVipPoint(userId int, point int) {
  63. mgr.addVipPoint(userId, point)
  64. }
  65. func AddVipSeconds(userId int, purchaseSeconds int) {
  66. mgr.addVipSeconds(userId, purchaseSeconds)
  67. }
  68. func CheckDailyAward(userId int) (bool, int) {
  69. return mgr.checkDailyAward(userId)
  70. }
  71. func GiftDailyAward(userId int) bool {
  72. return mgr.giftDailyAward(userId)
  73. }
  74. func GetUserPrivilegeValue(userId int, privilegeId int) int {
  75. return mgr.getPrivilegeValue(userId, privilegeId)
  76. }
  77. func CanKickPrivateRoomUser(userId int, toUserId int) bool {
  78. return mgr.canKickPrivateRoomUser(userId, toUserId)
  79. }