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

kuaishou_goods.go 3.0 KiB

1 year ago
11 months ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package zhimeng
  2. import (
  3. "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
  4. zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
  5. "encoding/json"
  6. )
  7. func KuaiShouGoods(tikTokArgs map[string]interface{}) []map[string]string {
  8. var goods = make([]map[string]string, 0)
  9. args := map[string]interface{}{
  10. "appkey": tikTokArgs["appkey"],
  11. "secret_key": tikTokArgs["secret_key"],
  12. "title": tikTokArgs["keyword"],
  13. "first_cids": tikTokArgs["category_id"],
  14. "price_min": zhios_third_party_utils.AnyToString(tikTokArgs["start_price"]),
  15. "price_max": zhios_third_party_utils.AnyToString(tikTokArgs["end_price"]),
  16. "sell_num_min": zhios_third_party_utils.AnyToString(tikTokArgs["start_sales"]),
  17. "sell_num_max": zhios_third_party_utils.AnyToString(tikTokArgs["end_sales"]),
  18. "sort": tikTokArgs["sort"],
  19. "cos_ratio_min": zhios_third_party_utils.AnyToString(tikTokArgs["start_commission"]),
  20. "cos_ratio_max": zhios_third_party_utils.AnyToString(tikTokArgs["end_commission"]),
  21. "page": tikTokArgs["p"],
  22. "page_size": tikTokArgs["size"],
  23. }
  24. for k, v := range args {
  25. if v == nil || v == "<nil>" {
  26. args[k] = ""
  27. }
  28. }
  29. resp, err := Send("kuaishou", "getGoods", args)
  30. if err != nil {
  31. return goods
  32. }
  33. var tmp struct {
  34. Data []TikTokData `json:"data"`
  35. }
  36. if err = json.Unmarshal(resp, &tmp); err != nil {
  37. return goods
  38. }
  39. for _, v := range tmp.Data {
  40. var tmp = map[string]string{
  41. "gid": v.GoodsID,
  42. "title": v.GoodsTitle,
  43. "img": v.GoodsImg,
  44. "sales": v.GoodsSales,
  45. "price": v.Price,
  46. "cost_price": v.CostPrice,
  47. "coupon": v.YhqPrice,
  48. "commission_rate": zhios_third_party_utils.AnyToString(v.Commission),
  49. "commission": zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(v.Price) * (zhios_third_party_utils.AnyToFloat64(v.Commission) / 100)),
  50. "pvd": md.PVD_KUAISHOU,
  51. "share_content": "",
  52. }
  53. goods = append(goods, tmp)
  54. }
  55. return goods
  56. }
  57. func KuaiShouKlGoods(tikTokArgs map[string]interface{}) (*TikTokDetailData, error) {
  58. args := map[string]interface{}{
  59. "appkey": tikTokArgs["appkey"],
  60. "secret_key": tikTokArgs["secret_key"],
  61. "content": tikTokArgs["content"],
  62. }
  63. resp, err := Send("kuaishou", "getKlGoods", args)
  64. if err != nil {
  65. return nil, err
  66. }
  67. var tmp struct {
  68. Data TikTokDetailData `json:"data"`
  69. }
  70. if err = json.Unmarshal(resp, &tmp); err != nil {
  71. return nil, err
  72. }
  73. return &tmp.Data, nil
  74. }
  75. func KuaiShouDetail(tikTokArgs map[string]interface{}) (*TikTokDetailData, error) {
  76. args := map[string]interface{}{
  77. "appkey": tikTokArgs["appkey"],
  78. "secret_key": tikTokArgs["secret_key"],
  79. "id": tikTokArgs["gid"],
  80. }
  81. resp, err := Send("kuaishou", "getGoodsDetail", args)
  82. if err != nil {
  83. return nil, err
  84. }
  85. var tmp struct {
  86. Data TikTokDetailData `json:"data"`
  87. }
  88. if err = json.Unmarshal(resp, &tmp); err != nil {
  89. return nil, err
  90. }
  91. return &tmp.Data, nil
  92. }