server_signin.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package service
  2. import (
  3. "bet24.com/log"
  4. "bet24.com/servers/coreservice/client"
  5. "bet24.com/servers/coreservice/signin"
  6. "context"
  7. "encoding/json"
  8. "errors"
  9. )
  10. func (s *Server) GetSigninInfo(ctx context.Context, args *client.Request, reply *client.Reply) error {
  11. var req client.Request_base
  12. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  13. log.Debug("Server.GetSigninInfo unmarshal fail %v", err)
  14. return errors.New("unmarshal error")
  15. }
  16. reply.Resp.RetCode = 1
  17. info := signin.GetUserSigninInfo(req.UserId)
  18. if info == nil {
  19. log.Debug("Server.GetSigninInfo no signin info")
  20. reply.Resp.RetCode = 0
  21. } else {
  22. d, _ := json.Marshal(info)
  23. reply.Resp.Data = string(d)
  24. }
  25. return nil
  26. }
  27. func (s *Server) DoSignin(ctx context.Context, args *client.Request, reply *client.Reply) error {
  28. var req client.Request_base
  29. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  30. log.Debug("Server.DoSigninIn unmarshal fail %v", err)
  31. return errors.New("unmarshal error")
  32. }
  33. success, items := signin.DoSignin(req.UserId)
  34. if success {
  35. reply.Resp.RetCode = 1
  36. reply.Resp.Action = append(reply.Resp.Action, client.Action_Item)
  37. d, _ := json.Marshal(items)
  38. reply.Resp.Data = string(d)
  39. }
  40. return nil
  41. }
  42. func (s *Server) GiftContinueAward(ctx context.Context, args *client.Request, reply *client.Reply) error {
  43. var req client.GiftContinueAward_req
  44. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  45. log.Debug("Server.GiftContinueAward unmarshal fail %v", err)
  46. return errors.New("unmarshal error")
  47. }
  48. success, items := signin.GiftContinueAward(req.UserId, req.Day)
  49. if success {
  50. reply.Resp.RetCode = 1
  51. reply.Resp.Action = append(reply.Resp.Action, client.Action_Item)
  52. d, _ := json.Marshal(items)
  53. reply.Resp.Data = string(d)
  54. }
  55. return nil
  56. }