From b068f5cc0b109b5eb5c452ecb3fc247890405901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Wed, 8 Jul 2020 17:23:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=AC=E4=B8=9C=E4=B8=8A=E5=9F=8E=E5=95=86?= =?UTF-8?q?=E5=93=81=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/jdeclpapi/jdeclpapi.go | 2 +- platformapi/jdshopapi/sku.go | 26 ++++++++++++++++++-------- platformapi/jdshopapi/sku_test.go | 4 ++-- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/platformapi/jdeclpapi/jdeclpapi.go b/platformapi/jdeclpapi/jdeclpapi.go index 6af9ac1d..01b46591 100644 --- a/platformapi/jdeclpapi/jdeclpapi.go +++ b/platformapi/jdeclpapi/jdeclpapi.go @@ -219,7 +219,7 @@ type WaybillReceiveParam struct { // ReceiveCompany string `json:"receiveCompany"` //否 北京市大兴区亦庄经济开发区京东大厦 收件人公司,长度:50,说明:不能为生僻字 // Goods string `json:"goods"` //否 服装、3C等 托寄物名称,长度:200,说明:为避免托运物品在铁路、航空安检中被扣押,请务必下传商品类目或名称,例如:服装、3C等 // GoodsCount int `json:"goodsCount"` //否 无 寄托物数量 - // PromiseTimeType int `json:"promiseTimeType"` //否 无 产品类型(1:特惠送 2:特快送 4:城际闪送 5:同城当日达 6:次晨达 7:微小件 8: 生鲜专送 16:生鲜特快 17、生鲜特惠 21:特惠小包) + PromiseTimeType int `json:"promiseTimeType"` //否 无 产品类型(1:特惠送 2:特快送 4:城际闪送 5:同城当日达 6:次晨达 7:微小件 8: 生鲜专送 16:生鲜特快 17、生鲜特惠 21:特惠小包) // Freight int `json:"freight"` //否 无 运费 // PickUpStartTime time.Time `json:"pickUpStartTime"` //否 1 预约取件开始时间 // PickUpEndTime time.Time `json:"pickUpEndTime"` //否 1 预约取件结束时间 diff --git a/platformapi/jdshopapi/sku.go b/platformapi/jdshopapi/sku.go index 8cc68963..13aff636 100644 --- a/platformapi/jdshopapi/sku.go +++ b/platformapi/jdshopapi/sku.go @@ -599,21 +599,31 @@ func (a *API) UpdateWareSaleAttrvalueAlias(param *UpdateWareSaleAttrvalueAliasPa } type SearchSkuListResult struct { - Status int `json:"status"` - JdPrice float64 `json:"jdPrice"` - SkuID int64 `json:"skuId"` - WareID int64 `json:"wareId"` - OuterID string `json:"outerId"` + Status int `json:"status"` + JdPrice float64 `json:"jdPrice"` + SkuID int64 `json:"skuId"` + WareID int64 `json:"wareId"` + OuterID string `json:"outerId"` + SaleAttrs []struct { + AttrID string `json:"attrId"` + Index int `json:"index"` + AttrValueAlias []string `json:"attrValueAlias"` + AttrValues []string `json:"attrValues"` + } `json:"saleAttrs"` + StockNum int `json:"stockNum"` } //搜索sku //https://open.jd.com/home/home#/doc/api?apiCateId=48&apiId=1227&apiName=jingdong.sku.read.searchSkuList -func (a *API) SearchSkuList(wareId int64) (list []*SearchSkuListResult, err error) { +func (a *API) SearchSkuList(pageNo, pageSize int) (list []*SearchSkuListResult, totalCount int, err error) { result, err := a.AccessAPI2("jingdong.sku.read.searchSkuList", prodURL, map[string]interface{}{ - "wareId": wareId, + "pageNo": pageNo, + "pageSize": pageSize, + "field": "jdPrice,saleAttrs,stockNum", }) if err == nil { utils.Map2StructByJson(result["jingdong_sku_read_searchSkuList_responce"].(map[string]interface{})["page"].(map[string]interface{})["data"], &list, false) + totalCount = int(utils.Interface2Int64WithDefault(result["jingdong_sku_read_searchSkuList_responce"].(map[string]interface{})["page"].(map[string]interface{})["totalItem"], 0)) } - return list, err + return list, totalCount, err } diff --git a/platformapi/jdshopapi/sku_test.go b/platformapi/jdshopapi/sku_test.go index 3fbe9703..c3e3daa2 100644 --- a/platformapi/jdshopapi/sku_test.go +++ b/platformapi/jdshopapi/sku_test.go @@ -319,7 +319,7 @@ func TestImageUpdate(t *testing.T) { } func TestSearchWare4Valid(t *testing.T) { - result, err := api.SearchWare4Valid("猕猴桃 奇异果", 0, 0) + result, err := api.SearchWare4Valid("", 0, 0) if err != nil { t.Fatal(err) } @@ -454,7 +454,7 @@ func TestSearchSkuList(t *testing.T) { } func TestAAAAAA(t *testing.T) { - result, err := api.SearchSkuList(14518860227) + result, _, err := api.SearchSkuList(2, 20) if err != nil { t.Fatal(err) }