jdapi.AddSku2 and UpdateSku2
This commit is contained in:
@@ -166,6 +166,34 @@ type SkuMain struct {
|
||||
Weight float64 `json:"weight"`
|
||||
}
|
||||
|
||||
const (
|
||||
IsSaleYes = 1
|
||||
IsSaleNo = -1
|
||||
)
|
||||
|
||||
type OpSkuParam struct {
|
||||
TraceID string `json:"traceId"`
|
||||
OutSkuID string `json:"outSkuId"`
|
||||
ShopCategories []int64 `json:"shopCategories,omitempty"`
|
||||
CategoryID int64 `json:"categoryId,omitempty"`
|
||||
BrandID int64 `json:"brandId,omitempty"`
|
||||
SkuName string `json:"skuName,omitempty"`
|
||||
SkuPrice int `json:"skuPrice,omitempty"`
|
||||
Weight float64 `json:"weight,omitempty"`
|
||||
FixedStatus int `json:"fixedStatus,omitempty"` // 商家商品上下架状态(1:上架;2:下架;4:删除;)
|
||||
IsSale int `json:"-"` // 创建:0,1可售,-1不可售,更新:0忽略,1可售,-1不可售
|
||||
DontUseThisFieldDirectlyIsSale bool `json:"isSale"` // 门店商品可售状态(true/false);新建商品时,如果为true,门店商品可售状态初始为可售,如果为false, 门店商品可售状态初始为不可售。后续修改各个门店商品可售状态时,请使用根据京东到家商品编码批量修改门店商品可售状态接口。
|
||||
|
||||
Upc string `json:"upc,omitempty"` // UPC编码(商品条码),限1-35个字符,包装类的商品要求UPC编码必填,且要符合条码编写的校验,否则商品会不予通过,接口返回错误状态码code为10059。
|
||||
Images []string `json:"images,omitempty"`
|
||||
ProductDesc string `json:"productDesc,omitempty"`
|
||||
IfViewDesc int `json:"ifViewDesc"`
|
||||
Slogan string `json:"slogan,omitempty"`
|
||||
SloganStartTime string `json:"sloganStartTime,omitempty"`
|
||||
SloganEndTime string `json:"sloganEndTime,omitempty"`
|
||||
SellCities []int64 `json:"sellCities,omitempty"`
|
||||
}
|
||||
|
||||
type QueryListBySkuIdsParam struct {
|
||||
SkuIDs []int64 `json:"skuIds"`
|
||||
ImgType int `json:"imgType,omitempty"`
|
||||
@@ -351,6 +379,20 @@ func (a *API) AddSku(outSkuId string, cagtegoryId int, shopCategories []int64, b
|
||||
return "", err
|
||||
}
|
||||
|
||||
func translateIsSale(isSale int) bool {
|
||||
return isSale == 0 || isSale == IsSaleYes
|
||||
}
|
||||
|
||||
func (a *API) AddSku2(param *OpSkuParam) (skuID string, err error) {
|
||||
param.DontUseThisFieldDirectlyIsSale = translateIsSale(param.IsSale)
|
||||
mapData := utils.Struct2MapByJson(param)
|
||||
result, err := a.AccessAPINoPage("pms/sku/addSku", mapData, nil, nil, nil)
|
||||
if err == nil {
|
||||
return (result.(map[string]interface{}))["skuId"].(string), nil
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
|
||||
// 根据商家商品编码修改商品信息接口
|
||||
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=180&apiid=290bdb0ea8a44e10b86b05591254ad68
|
||||
func (a *API) UpdateSku(outSkuId string, params map[string]interface{}) (skuId string, err error) {
|
||||
@@ -361,6 +403,16 @@ func (a *API) UpdateSku(outSkuId string, params map[string]interface{}) (skuId s
|
||||
return "", err
|
||||
}
|
||||
|
||||
func (a *API) UpdateSku2(param *OpSkuParam) (skuID string, err error) {
|
||||
param.DontUseThisFieldDirectlyIsSale = translateIsSale(param.IsSale)
|
||||
mapData := utils.Struct2MapByJson(param)
|
||||
result, err := a.AccessAPINoPage("pms/sku/updateSku", mapData, nil, nil, nil)
|
||||
if err == nil {
|
||||
return (result.(map[string]interface{}))["skuId"].(string), nil
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
|
||||
// 根据到家商品编码批量更新商家商品编码接口
|
||||
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=180&apiid=4155d29bbdf649b69c67473b705ce7e7
|
||||
func (a *API) BatchUpdateOutSkuId(skuInfoList []*SkuIDPair) (retVal interface{}, err error) {
|
||||
|
||||
Reference in New Issue
Block a user