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 } //商品详情接口