京东上城商品搜索
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user