From efd8aa1b879ed7f8f68ab3c961711e5bf4e145a5 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Fri, 26 Jan 2024 18:09:19 +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 | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/csjplatform/goods.go b/csjplatform/goods.go index ed13d61..4e2cac6 100644 --- a/csjplatform/goods.go +++ b/csjplatform/goods.go @@ -95,7 +95,7 @@ func GoodsList(args map[string]string) []tik_tok.TikTokGoods { } //商品详情接口 -func GoodsDetail(args map[string]string) (string, error) { +func GoodsDetail(args map[string]string) tik_tok.TikTokGoods { params := map[string]interface{}{} if args["product_ids"] != "" { @@ -107,9 +107,28 @@ func GoodsDetail(args map[string]string) (string, error) { params["product_ids"] = ids } send, err := Send(args["app_id"], args["app_secret"], "product/detail", params) - fmt.Println(send) - fmt.Println(err) - return send, err + var goodsList = tik_tok.TikTokGoods{} + 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 { + return goodsList + } + for _, v := range lmData.Data.Products { + tmp := tik_tok.CommGoodsDetail(v) + if tmp.GoodsID == args["product_ids"] { + return tmp + } + } + // + return goodsList } //3.2.2 商品转链接口