From 22c740f0f310c3f9fb60b34330ed05cb5f8c477d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Tue, 19 May 2020 15:22:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=AC=E4=B8=9C=E5=95=86=E5=9F=8E=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=9B=BE=E7=89=87=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/jdshopapi/sku.go | 23 ++++++++++++++++++----- platformapi/jdshopapi/sku_test.go | 8 ++++++++ platformapi/jdshopapi/store_page.go | 3 --- platformapi/jdshopapi/store_page_test.go | 2 +- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/platformapi/jdshopapi/sku.go b/platformapi/jdshopapi/sku.go index 52455b84..8a918536 100644 --- a/platformapi/jdshopapi/sku.go +++ b/platformapi/jdshopapi/sku.go @@ -142,11 +142,12 @@ type CreateSkuResult struct { } type UpdateWareParam struct { - WareID int64 `json:"wareId"` - Title string `json:"title"` //否 标题 商品名称 限制45个字符内 - VenderID int64 `json:"venderId"` - PromiseID int `json:"promiseId"` // 否 无 配送时效 - // Weight int `json:"weight"` //否 无 商品重量,单位kg + WareID int64 `json:"wareId"` + Title string `json:"title"` //否 标题 商品名称 限制45个字符内 + VenderID int64 `json:"venderId"` + PromiseID int `json:"promiseId"` // 否 无 配送时效 + MobileDesc string `json:"mobileDesc"` // 是 无 移动版的商品介绍 长度限制10W个字符 + Introduction string `json:"introduction"` // 是 无 PC版的商品介绍 长度限制10W个字符 } type QueryPictureReuslt struct { @@ -401,3 +402,15 @@ func (a *API) FindSkuStock(skuId int64) (err error) { }) return err } + +//修改商品图片 +//https://open.jd.com/home/home#/doc/api?apiCateId=48&apiId=1258&apiName=jingdong.image.write.update +func (a *API) ImageUpdate(wareId int64, imgIndex int, imgUrl string) (err error) { + _, err = a.AccessAPI("jingdong.image.write.update", prodURL, map[string]interface{}{ + "wareId": wareId, + "imgIndex": imgIndex, + "imgUrl": imgUrl, + "colorId": "0000000000", + }) + return err +} diff --git a/platformapi/jdshopapi/sku_test.go b/platformapi/jdshopapi/sku_test.go index 1b5a1413..763e6078 100644 --- a/platformapi/jdshopapi/sku_test.go +++ b/platformapi/jdshopapi/sku_test.go @@ -297,3 +297,11 @@ func TestQueryPicture(t *testing.T) { } t.Log(utils.Format4Output(result, false)) } + +func TestImageUpdate(t *testing.T) { + err := api.ImageUpdate(14535527473, 1, "jfs/t1/116844/10/7385/198098/5ec3853bEa53d0730/168e5654c6309c96.jpg") + if err != nil { + t.Fatal(err) + } + // t.Log(utils.Format4Output(result, false)) +} diff --git a/platformapi/jdshopapi/store_page.go b/platformapi/jdshopapi/store_page.go index f5e7a39b..73d043a0 100644 --- a/platformapi/jdshopapi/store_page.go +++ b/platformapi/jdshopapi/store_page.go @@ -23,9 +23,6 @@ func (a *API) AccessStorePage(fullURL string, bizParams map[string]interface{}, request.Header.Set("Content-Type", "application/x-www-form-urlencoded") } else { request, _ = http.NewRequest(http.MethodGet, utils.GenerateGetURL(fullURL, "", bizParams), nil) - request.Header.Set("Content-Type", "application/json;charset=UTF-8") - request.Header.Set("referer", "https://stores.shop.jd.com/") - request.Header.Set("origin", "https://stores.shop.jd.com/") } a.FillRequestCookies(request) return request diff --git a/platformapi/jdshopapi/store_page_test.go b/platformapi/jdshopapi/store_page_test.go index 945ee045..d0ed2e97 100644 --- a/platformapi/jdshopapi/store_page_test.go +++ b/platformapi/jdshopapi/store_page_test.go @@ -29,7 +29,7 @@ func TestUpdateStoreStatus(t *testing.T) { } func TestNewInfoList(t *testing.T) { - result, err := api.NewInfoList(24332466) + result, err := api.NewInfoList(1) if err != nil { t.Fatal(err) }