From 656908e36f2d6163e501ca038eba8c55c2df8276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Fri, 22 May 2020 14:36:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=95=86=E5=93=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/jdshopapi/sku.go | 18 ++++++++++++++++-- platformapi/jdshopapi/sku_test.go | 11 ++++++----- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/platformapi/jdshopapi/sku.go b/platformapi/jdshopapi/sku.go index 13ad5bd2..e2ce69de 100644 --- a/platformapi/jdshopapi/sku.go +++ b/platformapi/jdshopapi/sku.go @@ -451,13 +451,18 @@ type SearchWare4ValidResult struct { //搜索有效商品 //https://open.jd.com/home/home#/doc/api?apiCateId=48&apiId=1587&apiName=jingdong.ware.read.searchWare4Valid -func (a *API) SearchWare4Valid(searchKey string) (searchWare4ValidResult *SearchWare4ValidResult, err error) { +func (a *API) SearchWare4Valid(searchKey string, pageNo, pageSize int) (searchWare4ValidResult *SearchWare4ValidResult, err error) { param := make(map[string]interface{}) if searchKey != "" { param["searchKey"] = searchKey param["searchField"] = "title" } - param["pageSize"] = 100 + if pageNo != 0 { + param["pageNo"] = pageNo + } + if pageSize != 0 { + param["pageSize"] = pageSize + } result, err := a.AccessAPI("jingdong.ware.read.searchWare4Valid", prodURL, param) if err == nil { utils.Map2StructByJson(result["jingdong_ware_read_searchWare4Valid_responce"].(map[string]interface{})["page"], &searchWare4ValidResult, false) @@ -538,3 +543,12 @@ func (a *API) UpdateWareMarketPrice(wareId int64, marketPrice float64) (err erro }) return err } + +//获取商品下架原因 +//https://open.jd.com/home/home#/doc/api?apiCateId=48&apiId=1225&apiName=jingdong.ware.read.findOpReason +func (a *API) FindOpReason(wareId int64) (err error) { + _, err = a.AccessAPI2("jingdong.ware.read.findOpReason", prodURL, map[string]interface{}{ + "wareId": wareId, + }) + return err +} diff --git a/platformapi/jdshopapi/sku_test.go b/platformapi/jdshopapi/sku_test.go index ccaf4e30..58280472 100644 --- a/platformapi/jdshopapi/sku_test.go +++ b/platformapi/jdshopapi/sku_test.go @@ -307,7 +307,7 @@ func TestImageUpdate(t *testing.T) { } func TestSearchWare4Valid(t *testing.T) { - result, err := api.SearchWare4Valid("") + result, err := api.SearchWare4Valid("红薯", 0, 0) if err != nil { t.Fatal(err) } @@ -377,9 +377,10 @@ func TestUpdateWareMarketPrice(t *testing.T) { // t.Log(utils.Format4Output(result, false)) } -func TestBB(t *testing.T) { - result, _ := api.SearchWare4Valid("") - for _, v := range result.Data { - api.UpdateWareMarketPrice(v.WareID, 500) +func TestFindOpReason(t *testing.T) { + err := api.FindOpReason(14519009105) + if err != nil { + t.Fatal(err) } + // t.Log(utils.Format4Output(result, false)) }