server_bet.go 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package service
  2. import (
  3. "bet24.com/log"
  4. "bet24.com/servers/coreservice/bet"
  5. "bet24.com/servers/coreservice/client"
  6. "context"
  7. "encoding/json"
  8. "github.com/pkg/errors"
  9. )
  10. // 投注列表
  11. func (s *Server) BetList(ctx context.Context, args *client.Request, reply *client.Reply) error {
  12. var req client.BetList_req
  13. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  14. log.Debug("Server.BetList unmarshal fail %v", err)
  15. return errors.New("unmarshal error")
  16. }
  17. ret := bet.BetList(req.UserId, req.GameID, req.Days, req.PageIndex, req.PageSize, req.BetZone)
  18. reply.Resp.RetCode = 1
  19. d, _ := json.Marshal(ret)
  20. reply.Resp.Data = string(d)
  21. return nil
  22. }
  23. // 游戏历史
  24. func (s *Server) GameHistory(ctx context.Context, args *client.Request, reply *client.Reply) error {
  25. var req client.BetList_req
  26. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  27. log.Debug("Server.GameHistory unmarshal fail %v", err)
  28. return errors.New("unmarshal error")
  29. }
  30. recordCount, list := bet.GameHistory(req.UserId, req.PageIndex, req.PageSize)
  31. reply.Resp.RetCode = 1
  32. d, _ := json.Marshal(struct {
  33. RecordCount int
  34. List []*bet.History
  35. }{
  36. RecordCount: recordCount,
  37. List: list,
  38. })
  39. reply.Resp.Data = string(d)
  40. return nil
  41. }
  42. // 游戏记录
  43. func (s *Server) GetGameCount(ctx context.Context, args *client.Request, reply *client.Reply) error {
  44. var req client.GetGameCount_req
  45. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  46. log.Debug("Server.BetList unmarshal fail %v", err)
  47. return errors.New("unmarshal error")
  48. }
  49. list := bet.GetGameCount(req.UserId, req.GameID)
  50. reply.Resp.RetCode = 1
  51. d, _ := json.Marshal(list)
  52. reply.Resp.Data = string(d)
  53. return nil
  54. }
  55. // 更新domino游戏记录
  56. func (s *Server) UpdateDominoGameCount(ctx context.Context, args *client.Request, reply *client.Reply) error {
  57. var req client.UpdateDominoGameCount_req
  58. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  59. log.Debug("Server.UpdateDominoGameCount unmarshal fail %v", err)
  60. return errors.New("unmarshal error")
  61. }
  62. bet.UpdateDominoGameCount(req.UserId, req.Double, req.Triple, req.Quariter, req.Qunitet, req.CardData)
  63. reply.Resp.RetCode = 1
  64. return nil
  65. }
  66. // 更新qiuqiu游戏记录
  67. func (s *Server) UpdateQiuqiuGameCount(ctx context.Context, args *client.Request, reply *client.Reply) error {
  68. var req client.UpdateQiuqiuGameCount_req
  69. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  70. log.Debug("Server.UpdateQiuqiuGameCount unmarshal fail %v", err)
  71. return errors.New("unmarshal error")
  72. }
  73. bet.UpdateQiuqiuGameCount(req.UserId, req.SixDevil, req.TwinCards, req.SmallCards, req.BigCards, req.QiuQiu, req.CardData)
  74. reply.Resp.RetCode = 1
  75. return nil
  76. }