From d29d80b808f9b0ae7baf5527985aad262e6b20e2 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 15:38:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=AC=E4=B8=9C=E5=95=86=E5=9F=8E=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E5=BE=85=E5=94=AE=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/jdshopapi/jdshopapi.go | 15 +++++++++++++++ platformapi/jdshopapi/sku.go | 9 ++++++--- platformapi/jdshopapi/sku_test.go | 4 ++-- platformapi/jdshopapi/store_page.go | 3 +++ 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/platformapi/jdshopapi/jdshopapi.go b/platformapi/jdshopapi/jdshopapi.go index 39c91896..780d4b62 100644 --- a/platformapi/jdshopapi/jdshopapi.go +++ b/platformapi/jdshopapi/jdshopapi.go @@ -33,6 +33,21 @@ const ( JxBrandId = 559853 JdShopMaxStock = 9999 JdsPromiseID = 13725637 + + JdsSkuStatus1 = 1 //从未上架 + JdsSkuStatus2 = 2 //自主下架 + JdsSkuStatus4 = 4 //系统下架 + JdsSkuStatus8 = 8 //在售 + JdsSkuStatus513 = 513 //从未上架 待审核 + JdsSkuStatus514 = 514 //自主下架 待审核 + JdsSkuStatus516 = 516 //系统下架 待审核 + JdsSkuStatus520 = 520 //在售 待审核 + JdsSkuStatus1025 = 1025 //从未上架 审核不通过 暂时没用 + JdsSkuStatus1026 = 1026 //自主下架 审核不通过 暂时没用 + JdsSkuStatus1028 = 1028 //系统下架 审核不通过 + JdsSkuStatus1032 = 1032 //在售 审核不通过 + + PassReason = "审核通过" ) var ( diff --git a/platformapi/jdshopapi/sku.go b/platformapi/jdshopapi/sku.go index a6aa75f8..47bbfc4e 100644 --- a/platformapi/jdshopapi/sku.go +++ b/platformapi/jdshopapi/sku.go @@ -548,9 +548,12 @@ func (a *API) UpdateWareMarketPrice(wareId int64, marketPrice float64) (err erro //获取商品下架原因 //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{}{ +func (a *API) FindOpReason(wareId int64) (reason string, err error) { + result, err := a.AccessAPI2("jingdong.ware.read.findOpReason", prodURL, map[string]interface{}{ "wareId": wareId, }) - return err + if err == nil { + reason = result["jingdong_ware_read_findOpReason_responce"].(map[string]interface{})["opReason"].(map[string]interface{})["note"].(string) + } + return reason, err } diff --git a/platformapi/jdshopapi/sku_test.go b/platformapi/jdshopapi/sku_test.go index 58280472..abbec81d 100644 --- a/platformapi/jdshopapi/sku_test.go +++ b/platformapi/jdshopapi/sku_test.go @@ -378,9 +378,9 @@ func TestUpdateWareMarketPrice(t *testing.T) { } func TestFindOpReason(t *testing.T) { - err := api.FindOpReason(14519009105) + result, err := api.FindOpReason(14519009105) if err != nil { t.Fatal(err) } - // t.Log(utils.Format4Output(result, false)) + t.Log(utils.Format4Output(result, false)) } diff --git a/platformapi/jdshopapi/store_page.go b/platformapi/jdshopapi/store_page.go index 73d043a0..db7959c0 100644 --- a/platformapi/jdshopapi/store_page.go +++ b/platformapi/jdshopapi/store_page.go @@ -32,6 +32,9 @@ func (a *API) AccessStorePage(fullURL string, bizParams map[string]interface{}, if jsonResult1 == nil { return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil") } + if strings.Contains(bodyStr, "登录") { + return platformapi.ErrLevelRecoverableErr, fmt.Errorf("cookie可能过期了!") + } if err == nil { if jsonResult1["error_response"] != nil { errLevel = platformapi.ErrLevelGeneralFail