user_bet.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package gatesink
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "bet24.com/log"
  6. "bet24.com/servers/coreservice/client"
  7. "bet24.com/servers/fishhall/protocol"
  8. )
  9. // betlist 下注记录
  10. func (this *user) betlist(msg, data string) {
  11. retData := ""
  12. var req protocol.BetList_req
  13. if err := json.Unmarshal([]byte(data), &req); err != nil {
  14. retData = fmt.Sprintf("betlist unmarshal fail %v", err)
  15. log.Release(retData)
  16. this.WriteMsg(msg, retData)
  17. return
  18. }
  19. resp := client.BetList(this.getUserId(), req.GameID, req.Days, req.PageIndex, req.PageSize, req.BetZone)
  20. if resp.RetCode != 1 {
  21. log.Debug("user.betList failed %v", resp)
  22. }
  23. this.WriteMsg(msg, resp.Data)
  24. }
  25. // gameHistory 游戏历史
  26. func (this *user) gameHistory(msg, data string) {
  27. retData := ""
  28. var req protocol.BetList_req
  29. if err := json.Unmarshal([]byte(data), &req); err != nil {
  30. retData = fmt.Sprintf("gameHistory unmarshal fail %v", err)
  31. log.Release(retData)
  32. this.WriteMsg(msg, retData)
  33. return
  34. }
  35. // 页索引
  36. if req.PageIndex == 0 {
  37. req.PageIndex = 1
  38. }
  39. // 每页显示50条记录
  40. if req.PageSize == 0 {
  41. req.PageSize = 50
  42. }
  43. resp := client.GameHistory(this.getUserId(), req.PageIndex, req.PageSize)
  44. if resp.RetCode != 1 {
  45. log.Debug("user.gameHistory failed %v", resp)
  46. }
  47. this.WriteMsg(msg, resp.Data)
  48. }
  49. // 游戏记录
  50. func (this *user) getGameCount(msg, data string) {
  51. var userId int
  52. if data != "" {
  53. retData := ""
  54. var req protocol.GetGameCount_req
  55. if err := json.Unmarshal([]byte(data), &req); err != nil {
  56. retData = fmt.Sprintf("getGameCount unmarshal fail %v", err)
  57. log.Release(retData)
  58. this.WriteMsg(msg, retData)
  59. return
  60. }
  61. userId = req.UserID
  62. } else {
  63. userId = this.getUserId()
  64. }
  65. resp := client.GetGameCount(userId, 0)
  66. if resp.RetCode != 1 {
  67. log.Debug("user.getGameCount failed %v", resp)
  68. }
  69. this.WriteMsg(msg, resp.Data)
  70. }