From f9725033648c4bcf7738aef414902aef0f3f006e 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, 15 May 2020 16:08:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=AC=E4=B8=9C=E5=95=86=E5=9F=8E=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E9=97=A8=E5=BA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/jdshopapi/jdshopapi.go | 10 ++++++---- platformapi/jdshopapi/store.go | 9 ++++++--- platformapi/jdshopapi/store_test.go | 6 +++--- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/platformapi/jdshopapi/jdshopapi.go b/platformapi/jdshopapi/jdshopapi.go index 4a603676..ae2fcab0 100644 --- a/platformapi/jdshopapi/jdshopapi.go +++ b/platformapi/jdshopapi/jdshopapi.go @@ -14,10 +14,12 @@ import ( ) const ( - prodURL = "https://api.jd.com/routerjson" - sigKey = "sign" - JdsImgURL = "//img10.360buyimg.com/imgzone/" - JdsImgDescURL = `` + prodURL = "https://api.jd.com/routerjson" + sigKey = "sign" + JdsImgURL = "//img10.360buyimg.com/imgzone/" + JdsImgDescURL = `` + JdsStoreImg = "http://image.jxc4.com/image/b90ae8585e8cf2f3871f6e8318bde1dc.tem.png" + JdsStoreCategoryName = "pop-mendian-Selfdelivery" CreateCatType = "3" UpdateCatType = "1" diff --git a/platformapi/jdshopapi/store.go b/platformapi/jdshopapi/store.go index 265db187..3232bc58 100644 --- a/platformapi/jdshopapi/store.go +++ b/platformapi/jdshopapi/store.go @@ -33,9 +33,12 @@ type GetAddressCodeResult struct { //创建门店 //https://open.jd.com/home/home#/doc/api?apiCateId=351&apiId=2224&apiName=jingdong.createEntityStore -func (a *API) CreateEntityStore(createEntityStoreParam *CreateEntityStoreParam) (err error) { - _, err = a.AccessAPI("jingdong.createEntityStore", prodURL, utils.Struct2FlatMap(createEntityStoreParam)) - return err +func (a *API) CreateEntityStore(createEntityStoreParam *CreateEntityStoreParam) (vendorStoreID string, err error) { + result, err := a.AccessAPI("jingdong.createEntityStore", prodURL, utils.Struct2FlatMap(createEntityStoreParam)) + if err == nil { + return result["jingdong_createEntityStore_responce"].(map[string]interface{})["createentitystore_result"].(map[string]interface{})["result"].(map[string]interface{})["name"].(string), err + } + return vendorStoreID, err } //修改门店 diff --git a/platformapi/jdshopapi/store_test.go b/platformapi/jdshopapi/store_test.go index 4798aa52..44efe82e 100644 --- a/platformapi/jdshopapi/store_test.go +++ b/platformapi/jdshopapi/store_test.go @@ -9,14 +9,14 @@ import ( func TestCreateEntityStore(t *testing.T) { data, _, err := DownloadFileByURL("http://image.jxc4.com/image/b90ae8585e8cf2f3871f6e8318bde1dc.tem.png") - err = api.CreateEntityStore(&CreateEntityStoreParam{ + result, err := api.CreateEntityStore(&CreateEntityStoreParam{ Name: "京西菜市门店1", AddCode: 50946, AddCodeName: "金牛区", AddName: "成都金牛区@!加州湾v派", Coordinate: "29.707870,115.980868", Phone: "18160030913", - ExtendJSON: `{"businessBeginTime":"09:00","businessEndTime":"22:00"}`, + ExtendJSON: `{"businessBeginTime":"9:00","businessEndTime":"22:00"}`, ImageFile: base64.StdEncoding.EncodeToString(data), CategoryName: "pop-mendian-Selfdelivery", CustomerID: "666934", @@ -24,7 +24,7 @@ func TestCreateEntityStore(t *testing.T) { if err != nil { t.Fatal(err) } - // t.Log(utils.Format4Output(result, false)) + t.Log(utils.Format4Output(result, false)) } func TestGetProvince(t *testing.T) {