商品rpc数据格式及调用方法
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
2.3 KiB

  1. package productrpc
  2. import (
  3. "encoding/json"
  4. // "strconv"
  5. // "time"
  6. )
  7. /**
  8. * 获取商品进行中活动
  9. * 2021/10/06
  10. * GZ
  11. */
  12. func GetActivity(site_id, dbname, id string, sku_id string, url ...string) ([]map[string]string, error) {
  13. conn, err := rpc_server_conn(url...)
  14. if err != nil {
  15. return nil, err
  16. }
  17. defer conn.Close()
  18. arg := GetActivityParam{site_id, dbname, id, sku_id}
  19. req, err := SetReqData(arg)
  20. if err != nil {
  21. return nil, err
  22. }
  23. res := &Response{}
  24. err = conn.GetActivity(req, res)
  25. if err != nil {
  26. return nil, err
  27. }
  28. res_data_de, err := GetResData(res)
  29. if err != nil {
  30. return nil, err
  31. }
  32. if res_data_de == "" {
  33. return nil, nil
  34. }
  35. var res_arr []map[string]string
  36. err = json.Unmarshal([]byte(res_data_de), &res_arr)
  37. if err != nil {
  38. return nil, err
  39. }
  40. return res_arr, nil
  41. }
  42. /**
  43. * 获取商品预热中活动
  44. * 2021/10/06
  45. * GZ
  46. */
  47. func GetWarmingActivity(site_id, dbname, id string, sku_id string, url ...string) ([]map[string]string, error) {
  48. conn, err := rpc_server_conn(url...)
  49. if err != nil {
  50. return nil, err
  51. }
  52. defer conn.Close()
  53. arg := GetActivityParam{site_id, dbname, id, sku_id}
  54. req, err := SetReqData(arg)
  55. if err != nil {
  56. return nil, err
  57. }
  58. res := &Response{}
  59. err = conn.GetWarmingActivity(req, res)
  60. if err != nil {
  61. return nil, err
  62. }
  63. res_data_de, err := GetResData(res)
  64. if err != nil {
  65. return nil, err
  66. }
  67. if res_data_de == "" {
  68. return nil, nil
  69. }
  70. var res_arr []map[string]string
  71. err = json.Unmarshal([]byte(res_data_de), &res_arr)
  72. if err != nil {
  73. return nil, err
  74. }
  75. return res_arr, nil
  76. }
  77. /**
  78. * 获取商品进行中活动
  79. * 2021/10/06
  80. * GZ
  81. */
  82. func GetAllActivity(site_id, dbname, id string, sku_id string, url ...string) ([]map[string]string, error) {
  83. conn, err := rpc_server_conn(url...)
  84. if err != nil {
  85. return nil, err
  86. }
  87. defer conn.Close()
  88. arg := GetActivityParam{site_id, dbname, id, sku_id}
  89. req, err := SetReqData(arg)
  90. if err != nil {
  91. return nil, err
  92. }
  93. res := &Response{}
  94. err = conn.GetAllActivity(req, res)
  95. if err != nil {
  96. return nil, err
  97. }
  98. res_data_de, err := GetResData(res)
  99. if err != nil {
  100. return nil, err
  101. }
  102. if res_data_de == "" {
  103. return nil, nil
  104. }
  105. var res_arr []map[string]string
  106. err = json.Unmarshal([]byte(res_data_de), &res_arr)
  107. if err != nil {
  108. return nil, err
  109. }
  110. return res_arr, nil
  111. }