server_monthlycard.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package service
  2. import (
  3. "bet24.com/log"
  4. "bet24.com/servers/coreservice/client"
  5. "bet24.com/servers/coreservice/monthlycard"
  6. item "bet24.com/servers/micros/item_inventory/proto"
  7. "context"
  8. "encoding/json"
  9. "github.com/pkg/errors"
  10. )
  11. // 月卡系统信息
  12. func (s *Server) MonthlyCardSysInfo(ctx context.Context, args *client.Request, reply *client.Reply) error {
  13. info := monthlycard.GetSysInfo()
  14. d, _ := json.Marshal(info)
  15. reply.Resp.RetCode = 1
  16. reply.Resp.Data = string(d)
  17. return nil
  18. }
  19. // 获取用户月卡信息
  20. func (s *Server) MonthlyCardUserInfo(ctx context.Context, args *client.Request, reply *client.Reply) error {
  21. var req client.Request_base
  22. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  23. log.Debug("Server.MonthlyCardUserInfo unmarshal fail %v", err)
  24. return errors.New("unmarshal error")
  25. }
  26. info := monthlycard.GetUserInfo(req.UserId)
  27. if info != nil {
  28. reply.Resp.RetCode = 1
  29. log.Debug("MonthlyCardUserInfo userId=%d info.userId=%d %+v", req.UserId, info.UserID, info.MonthlyCardInfo)
  30. d, _ := json.Marshal(info.MonthlyCardInfo)
  31. reply.Resp.Data = string(d)
  32. }
  33. return nil
  34. }
  35. // 月卡领取
  36. func (s *Server) MonthlyCardGift(ctx context.Context, args *client.Request, reply *client.Reply) error {
  37. var req client.Request_base
  38. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  39. log.Debug("Server.MonthlyCardGift unmarshal fail %v", err)
  40. return errors.New("unmarshal error")
  41. }
  42. //log.Debug("Server.MonthlyCardGift data ==> %s, req ==> %+v", args.Data, req)
  43. var info struct {
  44. RetCode int
  45. Awards []item.ItemPack
  46. }
  47. info.RetCode, info.Awards = monthlycard.GiftMonth(req.UserId)
  48. reply.Resp.RetCode = 1
  49. d, _ := json.Marshal(info)
  50. reply.Resp.Data = string(d)
  51. return nil
  52. }
  53. // 周卡领取
  54. func (s *Server) WeekCardGift(ctx context.Context, args *client.Request, reply *client.Reply) error {
  55. var req client.Request_base
  56. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  57. log.Debug("Server.WeekCardGift unmarshal fail %v", err)
  58. return errors.New("unmarshal error")
  59. }
  60. var info struct {
  61. RetCode int
  62. Awards []item.ItemPack
  63. }
  64. info.RetCode, info.Awards = monthlycard.GiftWeek(req.UserId)
  65. reply.Resp.RetCode = 1
  66. d, _ := json.Marshal(info)
  67. reply.Resp.Data = string(d)
  68. return nil
  69. }