user_newVip.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package gatesink
  2. import (
  3. "bet24.com/log"
  4. vipservice "bet24.com/servers/micros/userservices/proto"
  5. "encoding/json"
  6. )
  7. func (this *user) onNewVipMsg(msg, data string) {
  8. // 新版vip体系
  9. switch msg {
  10. case "getNewVipUser": // 获取vip 用户状态
  11. this.getNewVipUser(msg)
  12. case "getNewVipList": // 获取vip 列表
  13. this.getNewVipList(msg)
  14. case "getNewVipPurchasePackage": // 获取购买礼包列表
  15. this.getNewVipPurchasePackage(msg)
  16. case "giftNewVipDailyAward": // 领取每日奖励
  17. this.giftNewVipDailyAward(msg)
  18. case "checkNewVipDailyAward": // 检查是否能够领取每日礼包
  19. this.checkNewVipDailyAward(msg)
  20. default:
  21. log.Release("user.onNewVipMsg unhandled msg %s", msg)
  22. }
  23. }
  24. // 获取vip 用户状态
  25. func (this *user) getNewVipUser(msg string) {
  26. resp := vipservice.GetUserVip(this.getUserId())
  27. if resp == "" {
  28. log.Release("user.getNewVipUser user not found, userId = %d", this.getUserId())
  29. }
  30. this.WriteMsg(msg, resp)
  31. return
  32. }
  33. // 获取vip 列表
  34. func (this *user) getNewVipList(msg string) {
  35. resp := vipservice.GetVipList()
  36. if resp == "" {
  37. log.Release("user.getNewVipList vip config list not found")
  38. }
  39. this.WriteMsg(msg, resp)
  40. return
  41. }
  42. // 获取购买礼包列表
  43. func (this *user) getNewVipPurchasePackage(msg string) {
  44. resp := vipservice.GetPurchasePackageList(this.getUserId())
  45. if resp == "" {
  46. log.Release("user.getNewVipPurchasePackage purchase package list not found")
  47. }
  48. this.WriteMsg(msg, resp)
  49. return
  50. }
  51. // 领取每日奖励
  52. func (this *user) giftNewVipDailyAward(msg string) {
  53. resp := vipservice.GiftDailyAward(this.getUserId())
  54. this.WriteMsg(msg, resp)
  55. return
  56. }
  57. // 检查是否能够领取每日礼包
  58. func (this *user) checkNewVipDailyAward(msg string) {
  59. var info struct {
  60. Success bool
  61. Code int
  62. }
  63. info.Success, info.Code = vipservice.CheckDailyAward(this.getUserId())
  64. d, _ := json.Marshal(info)
  65. this.WriteMsg(msg, string(d))
  66. return
  67. }