diff --git a/platformapi/jdshopapi/jdshopapi.go b/platformapi/jdshopapi/jdshopapi.go index a196b86f..4a603676 100644 --- a/platformapi/jdshopapi/jdshopapi.go +++ b/platformapi/jdshopapi/jdshopapi.go @@ -22,6 +22,7 @@ const ( CreateCatType = "3" UpdateCatType = "1" + VenderID = 10374877 TransportID = 2158480 JxBrandId = 559853 JdShopMaxStock = 9999 diff --git a/platformapi/jdshopapi/sku.go b/platformapi/jdshopapi/sku.go index 8aed68c7..6afa33aa 100644 --- a/platformapi/jdshopapi/sku.go +++ b/platformapi/jdshopapi/sku.go @@ -142,8 +142,9 @@ type CreateSkuResult struct { } type UpdateWareParam struct { - WareID int64 `json:"wareId"` - Title string `json:"title"` //否 标题 商品名称 限制45个字符内 + WareID int64 `json:"wareId"` + Title string `json:"title"` //否 标题 商品名称 限制45个字符内 + VenderID int64 `json:"venderId"` // 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 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{}{ - "ware": string(result2), + "360buy_param_json": string(result3), }) if err == nil { if result["jingdong_ware_write_updateWare_responce"].(map[string]interface{})["success"] != "success" { diff --git a/platformapi/jdshopapi/sku_test.go b/platformapi/jdshopapi/sku_test.go index a1ecb630..160dfe30 100644 --- a/platformapi/jdshopapi/sku_test.go +++ b/platformapi/jdshopapi/sku_test.go @@ -107,21 +107,22 @@ func TestGetFeightMb(t *testing.T) { func TestAA(t *testing.T) { ware := &CreateSkuParamWare{ - Title: "测试商品1", - CategoryID: 13577, - TransportID: TransportID, - MobileDesc: "测试", - Introduction: "测试", - WareStatus: 8, - OuterID: "1", - Weight: 2300, - Height: 100, - Length: 100, - Width: 100, - JdPrice: 20, - MarketPrice: 10, - VenderID: 0, - BrandID: JxBrandId, + Title: "测试商品1", + ShopCategorys: []int{11}, + CategoryID: 13577, + TransportID: TransportID, + MobileDesc: "测试", + Introduction: "测试", + WareStatus: 8, + OuterID: "1", + Weight: 2300, + Height: 100, + Length: 100, + Width: 100, + JdPrice: 20, + MarketPrice: 10, + VenderID: 0, + BrandID: JxBrandId, } result, _ := json.Marshal(ware) fmt.Println(string(result)) @@ -133,25 +134,36 @@ func TestCreateSku(t *testing.T) { var attrs []*CreateSkuParamAttrs var attrs2 []*CreateSkuParamAttrs var attrs3 []*CreateSkuParamAttrs + var features []*CreateSkuParamFeatures + feature := &CreateSkuParamFeatures{ + Key: "is7ToReturn", + Value: "0", + } + features = append(features, feature) + // desc = "aa" + // desc := `

因生鲜比较脆弱,发货途中如果有磕碰损坏,请收到联系客服,闪电赔付。请核对好地址,发货后不可修改地址,因改地址导致损坏不能赔付,谢谢理解



` + desc := `

因生鲜比较脆弱,发货途中如果有磕碰损坏,请收到联系客服,闪电赔付。请核对好地址,发货后不可修改地址,因改地址导致损坏不能赔付,谢谢理解



` ware := &CreateSkuParamWare{ Title: "测试商品1", // ShopCategorys: []int{11}, - CategoryID: 13577, - TransportID: TransportID, - MobileDesc: "测试", - Introduction: "测试", - WareStatus: 8, - OuterID: "1", - Weight: 2300, - Height: 100, - Length: 100, - Width: 100, - JdPrice: 20, - MarketPrice: 10, - VenderID: 0, - BrandID: JxBrandId, - Is7ToReturn: 0, + CategoryID: 13577, + TransportID: TransportID, + // MobileDesc: "测试", + // Introduction: "测试", + WareStatus: 8, + OuterID: "1", + Weight: 2300, + Height: 100, + Length: 100, + Width: 100, + JdPrice: 20, + MarketPrice: 10, + VenderID: 0, + BrandID: JxBrandId, } + ware.Features = features + ware.MobileDesc = "aa" + ware.Introduction = desc image := &CreateSkuParamImages{ ColorID: "0000000000", ImgIndex: 1, @@ -217,7 +229,7 @@ func TestCreateSku(t *testing.T) { } func TestFindAttrs(t *testing.T) { - result, err := api.FindAttrs(13577) + result, err := api.FindAttrs(13571) if err != nil { t.Fatal(err) } @@ -225,7 +237,7 @@ func TestFindAttrs(t *testing.T) { } func TestFindValuesByAttrId(t *testing.T) { - result, no, err := api.FindValuesByAttrId(109692) + result, no, err := api.FindValuesByAttrId(102242) if err != nil { t.Fatal(err) } @@ -242,7 +254,27 @@ func TestSaveVenderAttrValue(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 { t.Fatal(err) }