user_giftpack.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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) getGiftPacks(msg string) {
  10. resp := client.GetGiftPacks()
  11. if resp.RetCode != 1 {
  12. log.Debug("user.getGiftPacks failed %v", resp)
  13. }
  14. this.WriteMsg(msg, resp.Data)
  15. }
  16. func (this *user) getBuyableGiftPacks(msg string) {
  17. resp := client.GetBuyableGiftPacks(this.getUserId())
  18. if resp.RetCode != 1 {
  19. log.Debug("user.getBuyableGiftPacks failed %v", resp)
  20. }
  21. this.WriteMsg(msg, resp.Data)
  22. }
  23. func (this *user) getGrowthPacks(msg string) {
  24. resp := client.GetGrowthGiftPacks()
  25. if resp.RetCode != 1 {
  26. log.Debug("user.getGrowthPacks failed %v", resp)
  27. }
  28. this.WriteMsg(msg, resp.Data)
  29. }
  30. func (this *user) getGrowthPackTerms(msg string) {
  31. resp := client.GetUserGrowthTerms(this.getUserId())
  32. if resp.RetCode != 1 {
  33. log.Debug("user.getGrowthPackTerms failed %v", resp)
  34. }
  35. this.WriteMsg(msg, resp.Data)
  36. }
  37. func (this *user) awardGrowthPack(msg string, data string) {
  38. var req protocol.GrowthPackAward_req
  39. if err := json.Unmarshal([]byte(data), &req); err != nil {
  40. retData := fmt.Sprintf("getGrowthPackAward Unmarshal data failed %v", data)
  41. log.Release(retData)
  42. this.WriteMsg(msg, retData)
  43. return
  44. }
  45. resp := client.UserAwardTerm(this.getUserId(), req.GiftPackId, req.Index)
  46. if resp.RetCode != 1 {
  47. log.Debug("user.getGrowthPackAward failed %v", resp)
  48. }
  49. this.WriteMsg(msg, resp.Data)
  50. }