command_exchange.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package client
  2. import (
  3. "bet24.com/log"
  4. item "bet24.com/servers/micros/item_inventory/proto"
  5. "encoding/json"
  6. )
  7. type ExchangeType struct {
  8. Id int
  9. ExchangeType int // 兑换类型(1=奖券兑换金币 2=代理兑换元宝 3=代理兑换电话卡 4=代理兑换RP 5=金币提现)
  10. Price int // 价格
  11. Memo string // 描述
  12. }
  13. type ExchangeHistory struct {
  14. ExchangeId int //兑换ID
  15. ExchangeType int // 兑换类型(1=奖券兑换金币 2=代理兑换元宝 3=代理兑换电话卡 4=代理兑换RP)
  16. Price int // 价格
  17. Items []item.ItemPack
  18. Remark string //备注
  19. Status int //状态(0=待发货 1=已发货)
  20. Crdate string //时间
  21. }
  22. func GetExchangeType() []ExchangeType {
  23. var list []ExchangeType
  24. msg := "GetExchangeType"
  25. resp := DoRequest(msg, "")
  26. if resp.RetCode == 1 {
  27. if err := json.Unmarshal([]byte(resp.Data), &list); err != nil {
  28. log.Error("GetExchangeType json unmarshal err %v", err)
  29. }
  30. }
  31. return list
  32. }
  33. // 获取兑换信息
  34. func GetExchangeList(userId int) Response {
  35. msg := "GetExchangeList"
  36. var req Request_base
  37. req.UserId = userId
  38. d, _ := json.Marshal(req)
  39. return DoRequest(msg, string(d))
  40. }
  41. func UserExchange(userId, exchangeId, num int, remark string) Response {
  42. msg := "UserExchange"
  43. var req UserExchange_req
  44. req.UserId = userId
  45. req.ExchangeId = exchangeId
  46. req.Num = num
  47. req.Remark = remark
  48. d, _ := json.Marshal(req)
  49. return DoRequest(msg, string(d))
  50. }
  51. func GetExchangeHistory(userId, pageIndex, pageSize int) Response {
  52. msg := "GetExchangeHistory"
  53. var req UserExchangeHistory_req
  54. req.UserId = userId
  55. req.PageIndex = pageIndex
  56. req.PageSize = pageSize
  57. d, _ := json.Marshal(req)
  58. return DoRequest(msg, string(d))
  59. }