user_newusergift.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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) getNewUserGift(msg string) {
  10. resp := client.GetNewUserGiftInfo(this.getUserId())
  11. if resp.RetCode != 1 {
  12. log.Debug("user.getNewUserGift failed %v", resp)
  13. resp.Data = ""
  14. }
  15. this.WriteMsg(msg, resp.Data)
  16. }
  17. func (this *user) receiveNewUserGift(msg, data string) {
  18. retData := ""
  19. var req protocol.ReceiveNewUserGift_req
  20. if err := json.Unmarshal([]byte(data), &req); err != nil {
  21. retData = fmt.Sprintf("er.receiveNewUserGift unmarshal fail %v", err)
  22. log.Error(retData)
  23. this.WriteMsg(msg, retData)
  24. return
  25. }
  26. resp := client.ReceiveNewUserGift(this.getUserId(), req.IsDouble)
  27. if resp.RetCode != 1 {
  28. log.Debug("user.receiveNewUserGift failed %v", resp)
  29. }
  30. this.WriteMsg(msg, resp.Data)
  31. return
  32. }
  33. func (this *user) getNewYearGift(msg string) {
  34. resp := client.GetNewYearGiftInfo(this.getUserId())
  35. if resp.RetCode != 1 {
  36. log.Debug("user.getNewYearGift failed %v", resp)
  37. resp.Data = ""
  38. }
  39. this.WriteMsg(msg, resp.Data)
  40. }
  41. func (this *user) receiveNewYearGift(msg, data string) {
  42. retData := ""
  43. var req protocol.ReceiveNewUserGift_req
  44. if err := json.Unmarshal([]byte(data), &req); err != nil {
  45. retData = fmt.Sprintf("er.receiveNewYearGift unmarshal fail %v", err)
  46. log.Error(retData)
  47. this.WriteMsg(msg, retData)
  48. return
  49. }
  50. resp := client.ReceiveNewYearGift(this.getUserId(), req.IsDouble)
  51. if resp.RetCode != 1 {
  52. log.Debug("user.receiveNewYearGift failed %v", resp)
  53. }
  54. this.WriteMsg(msg, resp.Data)
  55. return
  56. }