京东商城修改商品参数增加
This commit is contained in:
@@ -22,6 +22,7 @@ const (
|
|||||||
CreateCatType = "3"
|
CreateCatType = "3"
|
||||||
UpdateCatType = "1"
|
UpdateCatType = "1"
|
||||||
|
|
||||||
|
VenderID = 10374877
|
||||||
TransportID = 2158480
|
TransportID = 2158480
|
||||||
JxBrandId = 559853
|
JxBrandId = 559853
|
||||||
JdShopMaxStock = 9999
|
JdShopMaxStock = 9999
|
||||||
|
|||||||
@@ -142,8 +142,9 @@ type CreateSkuResult struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type UpdateWareParam struct {
|
type UpdateWareParam struct {
|
||||||
WareID int64 `json:"wareId"`
|
WareID int64 `json:"wareId"`
|
||||||
Title string `json:"title"` //否 标题 商品名称 限制45个字符内
|
Title string `json:"title"` //否 标题 商品名称 限制45个字符内
|
||||||
|
VenderID int64 `json:"venderId"`
|
||||||
// Weight int `json:"weight"` //否 无 商品重量,单位kg
|
// Weight int `json:"weight"` //否 无 商品重量,单位kg
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,9 +256,12 @@ func (a *API) GetAttrsByCategoryId(currPage, pageSize int) (err error) {
|
|||||||
//修改商品基础信息
|
//修改商品基础信息
|
||||||
//https://open.jd.com/home/home#/doc/api?apiCateId=48&apiId=1380&apiName=jingdong.ware.write.updateWare
|
//https://open.jd.com/home/home#/doc/api?apiCateId=48&apiId=1380&apiName=jingdong.ware.write.updateWare
|
||||||
func (a *API) UpdateWare(updateWareParam *UpdateWareParam) (err error) {
|
func (a *API) UpdateWare(updateWareParam *UpdateWareParam) (err error) {
|
||||||
result2, _ := json.Marshal(utils.Struct2FlatMap(updateWareParam))
|
mapP := map[string]interface{}{
|
||||||
|
"ware": updateWareParam,
|
||||||
|
}
|
||||||
|
result3, _ := json.Marshal(mapP)
|
||||||
result, err := a.AccessAPI("jingdong.ware.write.updateWare", prodURL, map[string]interface{}{
|
result, err := a.AccessAPI("jingdong.ware.write.updateWare", prodURL, map[string]interface{}{
|
||||||
"ware": string(result2),
|
"360buy_param_json": string(result3),
|
||||||
})
|
})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if result["jingdong_ware_write_updateWare_responce"].(map[string]interface{})["success"] != "success" {
|
if result["jingdong_ware_write_updateWare_responce"].(map[string]interface{})["success"] != "success" {
|
||||||
|
|||||||
@@ -107,21 +107,22 @@ func TestGetFeightMb(t *testing.T) {
|
|||||||
|
|
||||||
func TestAA(t *testing.T) {
|
func TestAA(t *testing.T) {
|
||||||
ware := &CreateSkuParamWare{
|
ware := &CreateSkuParamWare{
|
||||||
Title: "测试商品1",
|
Title: "测试商品1",
|
||||||
CategoryID: 13577,
|
ShopCategorys: []int{11},
|
||||||
TransportID: TransportID,
|
CategoryID: 13577,
|
||||||
MobileDesc: "测试",
|
TransportID: TransportID,
|
||||||
Introduction: "测试",
|
MobileDesc: "测试",
|
||||||
WareStatus: 8,
|
Introduction: "测试",
|
||||||
OuterID: "1",
|
WareStatus: 8,
|
||||||
Weight: 2300,
|
OuterID: "1",
|
||||||
Height: 100,
|
Weight: 2300,
|
||||||
Length: 100,
|
Height: 100,
|
||||||
Width: 100,
|
Length: 100,
|
||||||
JdPrice: 20,
|
Width: 100,
|
||||||
MarketPrice: 10,
|
JdPrice: 20,
|
||||||
VenderID: 0,
|
MarketPrice: 10,
|
||||||
BrandID: JxBrandId,
|
VenderID: 0,
|
||||||
|
BrandID: JxBrandId,
|
||||||
}
|
}
|
||||||
result, _ := json.Marshal(ware)
|
result, _ := json.Marshal(ware)
|
||||||
fmt.Println(string(result))
|
fmt.Println(string(result))
|
||||||
@@ -133,25 +134,36 @@ func TestCreateSku(t *testing.T) {
|
|||||||
var attrs []*CreateSkuParamAttrs
|
var attrs []*CreateSkuParamAttrs
|
||||||
var attrs2 []*CreateSkuParamAttrs
|
var attrs2 []*CreateSkuParamAttrs
|
||||||
var attrs3 []*CreateSkuParamAttrs
|
var attrs3 []*CreateSkuParamAttrs
|
||||||
|
var features []*CreateSkuParamFeatures
|
||||||
|
feature := &CreateSkuParamFeatures{
|
||||||
|
Key: "is7ToReturn",
|
||||||
|
Value: "0",
|
||||||
|
}
|
||||||
|
features = append(features, feature)
|
||||||
|
// desc = "aa"
|
||||||
|
// desc := `<p>因生鲜比较脆弱,发货途中如果有磕碰损坏,请收到联系客服,闪电赔付。请核对好地址,发货后不可修改地址,因改地址导致损坏不能赔付,谢谢理解</p><p><img style="width:auto;height:auto;max-width:100%;" src="//img10.360buyimg.com/imgzone/jfs/t1/111969/32/6692/171733/5ebbb9daE5bedb5b2/38350dca19e2b9d2.jpg"><br></p><p><br></p>`
|
||||||
|
desc := `<p>因生鲜比较脆弱,发货途中如果有磕碰损坏,请收到联系客服,闪电赔付。请核对好地址,发货后不可修改地址,因改地址导致损坏不能赔付,谢谢理解</p><p><img style="width:auto;height:auto;max-width:100%;" src="//img10.360buyimg.com/imgzone/jfs/t1/126814/22/1326/472568/5ebb888dEa2cfb5f6/c0c81db660994246.jpg"><br></p><p><br></p>`
|
||||||
ware := &CreateSkuParamWare{
|
ware := &CreateSkuParamWare{
|
||||||
Title: "测试商品1",
|
Title: "测试商品1",
|
||||||
// ShopCategorys: []int{11},
|
// ShopCategorys: []int{11},
|
||||||
CategoryID: 13577,
|
CategoryID: 13577,
|
||||||
TransportID: TransportID,
|
TransportID: TransportID,
|
||||||
MobileDesc: "测试",
|
// MobileDesc: "测试",
|
||||||
Introduction: "测试",
|
// Introduction: "测试",
|
||||||
WareStatus: 8,
|
WareStatus: 8,
|
||||||
OuterID: "1",
|
OuterID: "1",
|
||||||
Weight: 2300,
|
Weight: 2300,
|
||||||
Height: 100,
|
Height: 100,
|
||||||
Length: 100,
|
Length: 100,
|
||||||
Width: 100,
|
Width: 100,
|
||||||
JdPrice: 20,
|
JdPrice: 20,
|
||||||
MarketPrice: 10,
|
MarketPrice: 10,
|
||||||
VenderID: 0,
|
VenderID: 0,
|
||||||
BrandID: JxBrandId,
|
BrandID: JxBrandId,
|
||||||
Is7ToReturn: 0,
|
|
||||||
}
|
}
|
||||||
|
ware.Features = features
|
||||||
|
ware.MobileDesc = "aa"
|
||||||
|
ware.Introduction = desc
|
||||||
image := &CreateSkuParamImages{
|
image := &CreateSkuParamImages{
|
||||||
ColorID: "0000000000",
|
ColorID: "0000000000",
|
||||||
ImgIndex: 1,
|
ImgIndex: 1,
|
||||||
@@ -217,7 +229,7 @@ func TestCreateSku(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFindAttrs(t *testing.T) {
|
func TestFindAttrs(t *testing.T) {
|
||||||
result, err := api.FindAttrs(13577)
|
result, err := api.FindAttrs(13571)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -225,7 +237,7 @@ func TestFindAttrs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFindValuesByAttrId(t *testing.T) {
|
func TestFindValuesByAttrId(t *testing.T) {
|
||||||
result, no, err := api.FindValuesByAttrId(109692)
|
result, no, err := api.FindValuesByAttrId(102242)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -242,7 +254,27 @@ func TestSaveVenderAttrValue(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDeleteWare(t *testing.T) {
|
func TestDeleteWare(t *testing.T) {
|
||||||
err := api.DeleteWare(14509148757)
|
err := api.DeleteWare(14518369562)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
// t.Log(utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUpOrDown(t *testing.T) {
|
||||||
|
err := api.UpOrDown(14518369562, 2)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
// t.Log(utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUpdateWare(t *testing.T) {
|
||||||
|
err := api.UpdateWare(&UpdateWareParam{
|
||||||
|
WareID: 14521014949,
|
||||||
|
Title: "大青菜1",
|
||||||
|
VenderID: 10374877,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user