command_shop.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package client
  2. import (
  3. "encoding/json"
  4. _ "bet24.com/log"
  5. )
  6. func GetExchangeRateList() Response {
  7. msg := "GetExchangeRateList"
  8. return DoRequest(msg, "")
  9. }
  10. func GetShopList(userId, shopType int, productID string) Response {
  11. msg := "GetShopList"
  12. var req Shop_req
  13. req.UserId = userId
  14. req.ShopType = shopType
  15. req.ProductID = productID
  16. d, _ := json.Marshal(req)
  17. return DoRequest(msg, string(d))
  18. }
  19. func GetShopListByUserId(shopType int, userId int, partnerId int) Response {
  20. msg := "GetShopListByUserId"
  21. var req Shop_req
  22. req.ShopType = shopType
  23. req.UserId = userId
  24. req.PartnerId = partnerId
  25. d, _ := json.Marshal(req)
  26. return DoRequest(msg, string(d))
  27. }
  28. func GetProduct(userId, shopType int, productId string) Response {
  29. msg := "GetProduct"
  30. var req Shop_req
  31. req.UserId = userId
  32. req.ShopType = shopType
  33. req.ProductID = productId
  34. d, _ := json.Marshal(req)
  35. return DoRequest(msg, string(d))
  36. }
  37. func Recharge(userId int, productId string) Response {
  38. msg := "Recharge"
  39. var req Shop_req
  40. req.UserId = userId
  41. req.ProductID = productId
  42. d, _ := json.Marshal(req)
  43. return DoRequest(msg, string(d))
  44. }
  45. func Exchange(userId int, productId string) Response {
  46. msg := "Exchange"
  47. var req Shop_req
  48. req.UserId = userId
  49. req.ProductID = productId
  50. d, _ := json.Marshal(req)
  51. return DoRequest(msg, string(d))
  52. }
  53. func ExchangeInBulk(userId int, productIds []string) Response {
  54. msg := "ExchangeInBulk"
  55. var req Shop_req
  56. req.UserId = userId
  57. req.ProductIDs = productIds
  58. d, _ := json.Marshal(req)
  59. return DoRequest(msg, string(d))
  60. }
  61. func SendFirstChargeItem(userId int) Response {
  62. msg := "SendFirstChargeItem"
  63. var req Shop_req
  64. req.UserId = userId
  65. req.ProductID = "900003"
  66. d, _ := json.Marshal(req)
  67. return DoRequest(msg, string(d))
  68. }
  69. /*
  70. func ExchangeRateInfo(currency string) (string, string) {
  71. msg := "ExchangeRateInfo"
  72. var req Shop_req
  73. req.Currency = currency
  74. d, _ := json.Marshal(req)
  75. rsp := DoRequest(msg, string(d))
  76. return rsp.Action[0], rsp.Action[1]
  77. }
  78. func GetUserPrice(userId int, price float64) float64 {
  79. msg := "GetUserPrice"
  80. var req Shop_req
  81. req.Price = price
  82. req.UserId = userId
  83. d, _ := json.Marshal(req)
  84. rsp := DoRequest(msg, string(d))
  85. var respond Shop_resp
  86. err := json.Unmarshal([]byte(rsp.Data), &respond)
  87. if err != nil {
  88. log.Release("GetUserPrice [%d],[%f] failed", userId, price)
  89. return price
  90. }
  91. return respond.Price
  92. }
  93. */