第三方api接口
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.

113 lines
3.5 KiB

  1. package csjplatform
  2. import (
  3. zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
  4. "fmt"
  5. "strings"
  6. )
  7. //商品类目
  8. func GoodsCate(args map[string]string) (string, error) {
  9. params := map[string]interface{}{"parent_id": zhios_third_party_utils.StrToInt(args["parent_id"])}
  10. send, err := Send(args["app_id"], args["app_secret"], "product/category", params)
  11. fmt.Println(send)
  12. fmt.Println(err)
  13. return send, err
  14. }
  15. //3.2.1 商品列表接口
  16. func GoodsList(args map[string]string) (string, error) {
  17. params := map[string]interface{}{
  18. "page": zhios_third_party_utils.StrToInt(args["page"]),
  19. "page_size": zhios_third_party_utils.StrToInt(args["page_size"]),
  20. }
  21. if args["title"] != "" {
  22. params["title"] = args["title"]
  23. }
  24. if args["first_cids"] != "" {
  25. ex := strings.Split(args["first_cids"], ",")
  26. ids := make([]int, 0)
  27. for _, v := range ex {
  28. ids = append(ids, zhios_third_party_utils.StrToInt(v))
  29. }
  30. params["first_cids"] = ids
  31. }
  32. if args["price_min"] != "" {
  33. params["price_min"] = int(zhios_third_party_utils.StrToFloat64(args["price_min"]) * 100)
  34. }
  35. if args["price_max"] != "" {
  36. params["price_max"] = int(zhios_third_party_utils.StrToFloat64(args["price_max"]) * 100)
  37. }
  38. if args["sell_num_min"] != "" {
  39. params["sell_num_min"] = zhios_third_party_utils.StrToInt(args["sell_num_min"])
  40. }
  41. if args["sell_num_max"] != "" {
  42. params["sell_num_max"] = zhios_third_party_utils.StrToInt(args["sell_num_max"])
  43. }
  44. if args["search_type"] != "" {
  45. params["search_type"] = zhios_third_party_utils.StrToInt(args["search_type"])
  46. }
  47. if args["order_type"] != "" {
  48. params["order_type"] = zhios_third_party_utils.StrToInt(args["order_type"])
  49. }
  50. if args["cos_fee_min"] != "" {
  51. params["cos_fee_min"] = int(zhios_third_party_utils.StrToFloat64(args["cos_fee_min"]) * 100)
  52. }
  53. if args["cos_fee_max"] != "" {
  54. params["cos_fee_max"] = int(zhios_third_party_utils.StrToFloat64(args["cos_fee_max"]) * 100)
  55. }
  56. if args["cos_ratio_min"] != "" {
  57. params["cos_ratio_min"] = int(zhios_third_party_utils.StrToFloat64(args["cos_ratio_min"]) * 100)
  58. }
  59. if args["cos_ratio_max"] != "" {
  60. params["cos_ratio_max"] = int(zhios_third_party_utils.StrToFloat64(args["cos_ratio_max"]) * 100)
  61. }
  62. if args["activity_id"] != "" {
  63. params["activity_id"] = zhios_third_party_utils.StrToInt(args["activity_id"])
  64. }
  65. send, err := Send(args["app_id"], args["app_secret"], "product/search", params)
  66. fmt.Println(send)
  67. fmt.Println(err)
  68. return send, err
  69. }
  70. //商品详情接口
  71. func GoodsDetail(args map[string]string) (string, error) {
  72. params := map[string]interface{}{}
  73. if args["product_ids"] != "" {
  74. ex := strings.Split(args["product_ids"], ",")
  75. ids := make([]int, 0)
  76. for _, v := range ex {
  77. ids = append(ids, zhios_third_party_utils.StrToInt(v))
  78. }
  79. params["product_ids"] = ids
  80. }
  81. send, err := Send(args["app_id"], args["app_secret"], "product/detail", params)
  82. fmt.Println(send)
  83. fmt.Println(err)
  84. return send, err
  85. }
  86. //3.2.2 商品转链接口
  87. func GoodsLink(args map[string]string) (string, error) {
  88. params := map[string]interface{}{
  89. "product_url": args["product_url"],
  90. "product_ext": args["product_ext"],
  91. "external_info": args["external_info"],
  92. }
  93. if args["share_type"] != "" {
  94. ex := strings.Split(args["share_type"], ",")
  95. ids := make([]int, 0)
  96. for _, v := range ex {
  97. ids = append(ids, zhios_third_party_utils.StrToInt(v))
  98. }
  99. params["share_type"] = ids
  100. }
  101. send, err := Send(args["app_id"], args["app_secret"], "product/link", params)
  102. fmt.Println(send)
  103. fmt.Println(err)
  104. return send, err
  105. }