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

59 line
2.1 KiB

  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. }