user_exchange.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. func (this *user) getExchangeList(msg, data string) {
  10. resp := client.GetExchangeList(this.getUserId())
  11. if resp.RetCode != 1 {
  12. log.Debug("user.getExchangeList failed %v", resp)
  13. }
  14. this.WriteMsg(msg, resp.Data)
  15. }
  16. func (this *user) exchangeGift(msg string, data string) {
  17. var req protocol.ExchangeGift_req
  18. if err := json.Unmarshal([]byte(data), &req); err != nil {
  19. retData := fmt.Sprintf("exchangeGift Unmarshal data failed %v", data)
  20. log.Release(retData)
  21. this.WriteMsg(msg, retData)
  22. return
  23. }
  24. resp := client.UserExchange(this.getUserId(), req.ExchangeId, req.Num, req.Remark)
  25. if resp.RetCode != 1 {
  26. log.Debug("user.exchangeGift failed %v", resp)
  27. }
  28. this.WriteMsg(msg, resp.Data)
  29. }
  30. func (this *user) getExchangeHistory(msg, data string) {
  31. var req protocol.ExchangeHistory_req
  32. if err := json.Unmarshal([]byte(data), &req); err != nil {
  33. retData := fmt.Sprintf("getExchangeHistory Unmarshal data failed %v", data)
  34. log.Release(retData)
  35. this.WriteMsg(msg, retData)
  36. return
  37. }
  38. resp := client.GetExchangeHistory(this.getUserId(), req.PageIndex, req.PageSize)
  39. if resp.RetCode != 1 {
  40. log.Debug("user.getExchangeHistory failed %v", resp)
  41. }
  42. this.WriteMsg(msg, resp.Data)
  43. return
  44. }