server_signinwheel.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package service
  2. import (
  3. "bet24.com/log"
  4. "bet24.com/servers/coreservice/client"
  5. "bet24.com/servers/coreservice/signinwheel"
  6. "context"
  7. "encoding/json"
  8. "errors"
  9. )
  10. func (s *Server) GetSigninWheelInfo(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.GetSigninWheelInfo unmarshal fail %v", err)
  14. return errors.New("unmarshal error")
  15. }
  16. reply.Resp.RetCode = 1
  17. info := signinwheel.GetSigninWheelInfo(req.UserId)
  18. d, _ := json.Marshal(info)
  19. reply.Resp.Data = string(d)
  20. return nil
  21. }
  22. func (s *Server) DoSigninWheel(ctx context.Context, args *client.Request, reply *client.Reply) error {
  23. var req client.Request_SigninWheel
  24. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  25. log.Debug("Server.DoSigninWheel unmarshal fail %v", err)
  26. return errors.New("unmarshal error")
  27. }
  28. var ret struct {
  29. signinwheel.SigninWheelResult
  30. MyPlayTimes int
  31. }
  32. info, myPlayTimes := signinwheel.DoSignin(req.UserId, req.IpAddress, req.UserGold)
  33. ret.SigninWheelResult = info
  34. ret.MyPlayTimes = myPlayTimes
  35. reply.Resp.RetCode = 1
  36. d, _ := json.Marshal(ret)
  37. reply.Resp.Data = string(d)
  38. return nil
  39. }
  40. func (s *Server) GetSigninWheelHistory(ctx context.Context, args *client.Request, reply *client.Reply) error {
  41. result := signinwheel.GetHistory()
  42. reply.Resp.RetCode = 1
  43. d, _ := json.Marshal(result)
  44. reply.Resp.Data = string(d)
  45. return nil
  46. }