From d87162f1104389d43a3013b45e67995420247b12 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Fri, 26 Jan 2024 16:41:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=96=E9=9F=B3=E7=A9=BF=E5=B1=B1=E7=94=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- csjplatform/goods.go | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/csjplatform/goods.go b/csjplatform/goods.go index ce66780..c2a3778 100644 --- a/csjplatform/goods.go +++ b/csjplatform/goods.go @@ -1,8 +1,11 @@ package csjplatform import ( + "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/tik_tok" zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" + "encoding/json" "fmt" + "github.com/tidwall/gjson" "strings" ) @@ -16,7 +19,7 @@ func GoodsCate(args map[string]string) (string, error) { } //3.2.1 商品列表接口 -func GoodsList(args map[string]string) (string, error) { +func GoodsList(args map[string]string) []tik_tok.TikTokGoods { params := map[string]interface{}{ "page": zhios_third_party_utils.StrToInt(args["page"]), "page_size": zhios_third_party_utils.StrToInt(args["page_size"]), @@ -67,9 +70,27 @@ func GoodsList(args map[string]string) (string, error) { params["activity_id"] = zhios_third_party_utils.StrToInt(args["activity_id"]) } send, err := Send(args["app_id"], args["app_secret"], "product/search", params) - fmt.Println(send) - fmt.Println(err) - return send, err + var goodsList = make([]tik_tok.TikTokGoods, 0) + product := gjson.Get(send, "data.products").String() + if err != nil || product == "" { + return goodsList + } + var lmData struct { + Data struct { + Products []tik_tok.TikTokGoodsLm `json:"products"` + } `json:"data"` + } + err = json.Unmarshal([]byte(send), &lmData) + if err != nil { + fmt.Println("抖音商品1", err) + + return goodsList + } + for _, v := range lmData.Data.Products { + tmp := tik_tok.CommGoodsDetail(v) + goodsList = append(goodsList, tmp) + } + return goodsList } //商品详情接口