user_shop.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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) getExchangeRateList(msg, data string) {
  10. this.WriteMsg(msg, "")
  11. }
  12. func (this *user) getShopList(msg, data string) {
  13. retData := ""
  14. var req protocol.GetShopList_req
  15. if err := json.Unmarshal([]byte(data), &req); err != nil {
  16. retData = fmt.Sprintf("getShopList Unmarshal data failed %v", err)
  17. log.Error(retData)
  18. this.WriteMsg(msg, retData)
  19. return
  20. }
  21. resp := client.GetShopListByUserId(req.ShopType, this.getUserId(), this.getPartnerId())
  22. if resp.RetCode != 1 {
  23. log.Debug("user.getShopList failed %v", resp)
  24. }
  25. this.WriteMsg(msg, resp.Data)
  26. }
  27. func (this *user) exchangeGold(msg, data string) {
  28. log.Debug("user.exchangeGold %d %s", this.getUserId(), data)
  29. resp := client.Exchange(this.getUserId(), data)
  30. if resp.RetCode != 1 {
  31. log.Debug("user.Exchange failed %v", resp)
  32. }
  33. this.WriteMsg(msg, resp.Data)
  34. }
  35. func (this *user) exchangeGoldInBulk(msg, data string) {
  36. log.Debug("user.exchangeGoldInBulk %d %s", this.getUserId(), data)
  37. var productIds []string
  38. if err := json.Unmarshal([]byte(data), &productIds); err != nil {
  39. retData := fmt.Sprintf("exchangeGoldInBulk Unmarshal data failed %v", err)
  40. log.Release(retData)
  41. this.WriteMsg(msg, retData)
  42. return
  43. }
  44. resp := client.ExchangeInBulk(this.getUserId(), productIds)
  45. if resp.RetCode != 1 {
  46. log.Debug("user.ExchangeInBulk failed %v", resp)
  47. }
  48. this.WriteMsg(msg, resp.Data)
  49. }
  50. func (this *user) getLocalPrice(msg, data string) {
  51. var req struct {
  52. Price float64
  53. }
  54. if err := json.Unmarshal([]byte(data), &req); err != nil {
  55. log.Error("getLocalPrice Unmarshal data failed %v", err)
  56. //this.WriteMsg(msg, retData)
  57. return
  58. }
  59. this.WriteMsg(msg, fmt.Sprintf("%02f%s", req.Price, this.getCurrency()))
  60. }
  61. func (this *user) getUserFirstCharge(msg, data string) {
  62. client.SendFirstChargeItem(this.getUserId())
  63. this.WriteMsg(msg, "")
  64. }