京东商城增加商品规格
This commit is contained in:
@@ -162,6 +162,24 @@ type QueryPictureReuslt struct {
|
|||||||
PictureHeight int `json:"picture_height"`
|
PictureHeight int `json:"picture_height"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UpdateSkusParam struct {
|
||||||
|
WareID int64 `json:"wareId"`
|
||||||
|
Skus []*UpdateSkusParamSkus `json:"skus"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateSkusParamSkus struct {
|
||||||
|
WareID int64 `json:"wareId,omitempty"` //是 11111111111 商品ID(必填)
|
||||||
|
SkuID int64 `json:"skuId,omitempty"` //否 11111558987 skuID(新增的sku可不填写)
|
||||||
|
SaleAttrs []*CreateSkuParamAttrs `json:"saleAttrs,omitempty"` //是 无 SKU销售属性
|
||||||
|
JdPrice float64 `json:"jdPrice,omitempty"` //是 无 京东价必填 单位:元
|
||||||
|
OuterID string `json:"outerId,omitempty"` //否 ww_4567 外部ID,系统不保证唯一性,如需唯一性自行保证
|
||||||
|
StockNum string `json:"stockNum,omitempty"` //是 10 总库存数
|
||||||
|
BarCode string `json:"barCode,omitempty"` //否 45456467777 SKU的条形码
|
||||||
|
Capacity string `json:"capacity,omitempty"` //否 20L 容量,在有特殊要求的类目下必填!最多支持6位小数。
|
||||||
|
Type string `json:"type"` //"com.jd.pop.ware.ic.api.domain.sku"
|
||||||
|
Type2 string `json:"@type"`
|
||||||
|
}
|
||||||
|
|
||||||
//查询商家所有的店内分类
|
//查询商家所有的店内分类
|
||||||
//https://open.jd.com/home/home#/doc/api?apiCateId=88&apiId=2801&apiName=jingdong.vender.shopcategory.findShopCategoriesByVenderId
|
//https://open.jd.com/home/home#/doc/api?apiCateId=88&apiId=2801&apiName=jingdong.vender.shopcategory.findShopCategoriesByVenderId
|
||||||
func (a *API) FindShopCategories() (findShopCategoriesResult []*FindShopCategoriesResult, err error) {
|
func (a *API) FindShopCategories() (findShopCategoriesResult []*FindShopCategoriesResult, err error) {
|
||||||
@@ -414,3 +432,50 @@ func (a *API) ImageUpdate(wareId int64, imgIndex int, imgUrl string) (err error)
|
|||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SearchWare4ValidResult struct {
|
||||||
|
PageSize int `json:"pageSize"`
|
||||||
|
Data []struct {
|
||||||
|
WareID int64 `json:"wareId"`
|
||||||
|
WareStatus int `json:"wareStatus"`
|
||||||
|
CategoryID int `json:"categoryId"`
|
||||||
|
OnlineTime int64 `json:"onlineTime"`
|
||||||
|
OuterID string `json:"outerId"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
ItemNum string `json:"itemNum"`
|
||||||
|
ColType int `json:"colType"`
|
||||||
|
} `json:"data"`
|
||||||
|
PageNo int `json:"pageNo"`
|
||||||
|
TotalItem int `json:"totalItem"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//搜索有效商品
|
||||||
|
//https://open.jd.com/home/home#/doc/api?apiCateId=48&apiId=1587&apiName=jingdong.ware.read.searchWare4Valid
|
||||||
|
func (a *API) SearchWare4Valid(searchKey string) (searchWare4ValidResult *SearchWare4ValidResult, err error) {
|
||||||
|
result, err := a.AccessAPI("jingdong.ware.read.searchWare4Valid", prodURL, map[string]interface{}{
|
||||||
|
"searchKey": searchKey,
|
||||||
|
"searchField": "title",
|
||||||
|
})
|
||||||
|
if err == nil {
|
||||||
|
utils.Map2StructByJson(result["jingdong_ware_read_searchWare4Valid_responce"].(map[string]interface{})["page"], &searchWare4ValidResult, false)
|
||||||
|
}
|
||||||
|
return searchWare4ValidResult, err
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateSkusResult struct {
|
||||||
|
SkuID int64 `json:"skuId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//增加sku
|
||||||
|
//https://open.jd.com/home/home#/doc/api?apiCateId=48&apiId=1383&apiName=jingdong.sku.write.updateSkus
|
||||||
|
func (a *API) UpdateSkus(updateSkusParam *UpdateSkusParam) (vendorSkuID string, err error) {
|
||||||
|
var skus []*UpdateSkusResult
|
||||||
|
data, _ := json.Marshal(updateSkusParam)
|
||||||
|
result, err := a.AccessAPI("jingdong.sku.write.updateSkus", prodURL, map[string]interface{}{
|
||||||
|
"360buy_param_json": string(data),
|
||||||
|
})
|
||||||
|
if err == nil {
|
||||||
|
utils.Map2StructByJson(result["jingdong_sku_write_updateSkus_responce"].(map[string]interface{})["skuList"], &skus, false)
|
||||||
|
}
|
||||||
|
return utils.Int64ToStr(skus[0].SkuID), err
|
||||||
|
}
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ func TestCreateSku(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFindAttrs(t *testing.T) {
|
func TestFindAttrs(t *testing.T) {
|
||||||
result, err := api.FindAttrs(13571)
|
result, err := api.FindAttrs(13573)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -238,7 +238,7 @@ func TestFindAttrs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFindValuesByAttrId(t *testing.T) {
|
func TestFindValuesByAttrId(t *testing.T) {
|
||||||
result, no, err := api.FindValuesByAttrId(102242)
|
result, no, err := api.FindValuesByAttrId(1001027602)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -305,3 +305,50 @@ func TestImageUpdate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// t.Log(utils.Format4Output(result, false))
|
// t.Log(utils.Format4Output(result, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSearchWare4Valid(t *testing.T) {
|
||||||
|
result, err := api.SearchWare4Valid("红薯")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log(utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUpdateSkus(t *testing.T) {
|
||||||
|
_, err := api.UpdateSkus(&UpdateSkusParam{
|
||||||
|
WareID: 14537944716,
|
||||||
|
Skus: []*UpdateSkusParamSkus{
|
||||||
|
&UpdateSkusParamSkus{
|
||||||
|
WareID: 14537944716,
|
||||||
|
JdPrice: 1.5,
|
||||||
|
StockNum: "99",
|
||||||
|
OuterID: "11",
|
||||||
|
SaleAttrs: []*CreateSkuParamAttrs{
|
||||||
|
&CreateSkuParamAttrs{
|
||||||
|
AttrID: "1001027602",
|
||||||
|
AttrValues: []string{"2440977935"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Type: "com.jd.pop.ware.ic.api.domain.sku",
|
||||||
|
Type2: "com.jd.pop.ware.ic.api.domain.Sku",
|
||||||
|
},
|
||||||
|
&UpdateSkusParamSkus{
|
||||||
|
WareID: 14537944716,
|
||||||
|
JdPrice: 1.8,
|
||||||
|
StockNum: "99",
|
||||||
|
OuterID: "123",
|
||||||
|
SaleAttrs: []*CreateSkuParamAttrs{
|
||||||
|
&CreateSkuParamAttrs{
|
||||||
|
AttrID: "1001027602",
|
||||||
|
AttrValues: []string{"2441761921"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Type: "com.jd.pop.ware.ic.api.domain.sku",
|
||||||
|
Type2: "com.jd.pop.ware.ic.api.domain.Sku",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user