From c7593607f40c669f5086789338b24d9655b604d6 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Tue, 27 Apr 2021 17:09:32 +0800 Subject: [PATCH] =?UTF-8?q?pdd=E7=89=A9=E6=96=99=E6=8E=A8=E8=8D=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/pddapi/sku.go | 58 ++++++++++++++++++++++++++++++++++ platformapi/pddapi/sku_test.go | 8 +++++ 2 files changed, 66 insertions(+) diff --git a/platformapi/pddapi/sku.go b/platformapi/pddapi/sku.go index a79d466f..c6656d5d 100644 --- a/platformapi/pddapi/sku.go +++ b/platformapi/pddapi/sku.go @@ -181,3 +181,61 @@ func (a *API) GoodsDetail(goodsID string) (goodsDetailResult *GoodsDetailResult, } return goodsDetailResult, err } + +type GoodsRecommendGetResult struct { + Total int `json:"total"` + ListID string `json:"list_id"` + List []struct { + CategoryName string `json:"category_name"` + CouponRemainQuantity int `json:"coupon_remain_quantity"` + PromotionRate int `json:"promotion_rate"` + CatIds []int `json:"cat_ids"` + CouponMinOrderAmount int `json:"coupon_min_order_amount"` + CategoryID string `json:"category_id"` + MallID int `json:"mall_id"` + MallName string `json:"mall_name"` + CouponTotalQuantity int `json:"coupon_total_quantity"` + MerchantType string `json:"merchant_type"` + LgstTxt string `json:"lgst_txt"` + GoodsName string `json:"goods_name"` + SalesTip string `json:"sales_tip"` + GoodsID int64 `json:"goods_id"` + DescTxt string `json:"desc_txt"` + PredictPromotionRate int `json:"predict_promotion_rate"` + GoodsDesc string `json:"goods_desc"` + OptName string `json:"opt_name"` + GoodsThumbnailURL string `json:"goods_thumbnail_url"` + ShareRate int `json:"share_rate"` + OptID string `json:"opt_id"` + OptIds []int `json:"opt_ids"` + SearchID string `json:"search_id"` + GoodsImageURL string `json:"goods_image_url"` + ActivityTags []int `json:"activity_tags"` + HasCoupon bool `json:"has_coupon"` + MinNormalPrice int `json:"min_normal_price"` + ServTxt string `json:"serv_txt"` + UnifiedTags []interface{} `json:"unified_tags"` + CouponStartTime int `json:"coupon_start_time"` + MinGroupPrice int `json:"min_group_price"` + CouponDiscount int `json:"coupon_discount"` + GoodsSign string `json:"goods_sign"` + CouponEndTime int `json:"coupon_end_time"` + ExtraCouponAmount int `json:"extra_coupon_amount,omitempty"` + } `json:"list"` + RequestID string `json:"request_id"` + SearchID string `json:"search_id"` +} + +//多多进宝商品推荐查询 +func (a *API) GoodsRecommendGet(goodsID string, rcmmdType, offset, pageSize int) (goodsSearchResult *GoodsRecommendGetResult, err error) { + result, err := a.AccessAPI("pdd.ddk.goods.recommend.get", false, map[string]interface{}{ + "goods_sign_list": []string{"\"" + goodsID + "\""}, + "channel_type": rcmmdType, + "limit": pageSize, + "offset": offset, + }) + if err == nil { + utils.Map2StructByJson(result["goods_basic_detail_response"], &goodsSearchResult, false) + } + return goodsSearchResult, err +} diff --git a/platformapi/pddapi/sku_test.go b/platformapi/pddapi/sku_test.go index eba9cb8d..bf7bb58a 100644 --- a/platformapi/pddapi/sku_test.go +++ b/platformapi/pddapi/sku_test.go @@ -32,3 +32,11 @@ func TestGoodsDetail(t *testing.T) { } t.Log(utils.Format4Output(result, false)) } + +func TestGoodsRecommendGet(t *testing.T) { + result, err := api.GoodsRecommendGet("Y9j2gIAgrxpKWDjRwfDZdyHfazgTDQpH_JyzHgT6ly", 3, 0, 10) + if err != nil { + t.Fatal(err) + } + t.Log(utils.Format4Output(result, false)) +}