京东上城商品搜索

This commit is contained in:
苏尹岚
2020-07-08 17:23:02 +08:00
parent 5694ab1360
commit b068f5cc0b
3 changed files with 21 additions and 11 deletions

View File

@@ -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 预约取件结束时间

View File

@@ -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
}

View File

@@ -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)
}