diff --git a/platformapi/jdshopapi/jxshopapi_test.go b/platformapi/jdshopapi/jxshopapi_test.go index d93d6a59..36c4718a 100644 --- a/platformapi/jdshopapi/jxshopapi_test.go +++ b/platformapi/jdshopapi/jxshopapi_test.go @@ -14,10 +14,10 @@ func init() { logger, _ := zap.NewDevelopment() sugarLogger = logger.Sugar() baseapi.Init(sugarLogger) - api = New("de8157b447584885910f429011e49cb93yjq", "E1D746D42474D5F1F1A10CECE75D99F6", "efa7e1d1a22640fa990e6cf164b28608") - // api = New("9ad9cf5fc8b140b19a1dbbb700b47676kown", "D5E8352BE0786ED16F77B4548F62F09A", "71e1061ac2f246f6ac27efb900edba12") + // api = New("de8157b447584885910f429011e49cb93yjq", "E1D746D42474D5F1F1A10CECE75D99F6", "efa7e1d1a22640fa990e6cf164b28608") + api = New("9ad9cf5fc8b140b19a1dbbb700b47676kown", "D5E8352BE0786ED16F77B4548F62F09A", "71e1061ac2f246f6ac27efb900edba12") // api.SetCookieWithStr(` // thor=5E1D1AE7BBC42FACA3496D9C54AF9F879CF4836860E75FF70BFCDEAC5A75C1C53633AB511CD9AA7FDDF502F48AE9683E660B3FCBF8EDC500734ADE8D7CE4BAB4B2947AD7610768EA07E5A6D3B88CDA3EBB7D998FEBA0B113F040A36B044CC4B9310C7953F2DDC2DE15C56C8839EFE493FE4CD8F9CECED7EE4097AE7F83EE6D447050842AB44A715BAB2666C6BE3AB085; // `) - api.SetCookie("thor", "5E1D1AE7BBC42FACA3496D9C54AF9F879CF4836860E75FF70BFCDEAC5A75C1C58EAB54F4C674330367C5A17888A4FB0BA1EA349F99E49B87787205B2F0BA715979DE02766356E7182C810344BB3A72ADD1F2C8CE8F88206E69A92C4B4F64C8A2FFA5A08FF31923DF3C659E8C9E3A4032816E7407ABE2463499AD76B83A3F78C662530B11F26052D1D195EF91E8C4A689") + api.SetCookie("thor", "5E1D1AE7BBC42FACA3496D9C54AF9F879CF4836860E75FF70BFCDEAC5A75C1C5E43030CF54E4A3A8F5E760492948E69B763D115FE234A59948BA538A4F7E18F38B80F818E28EAE71F1CF5BFE2D0DC456D56E8BEAEF10D398C709D9A4EB46923C7E63867435BD42996F1570A816FD1B0B247CD9756A1184DD61317D28BBF77F828691684AD6E60801B2BB38F9DE086D73") } diff --git a/platformapi/jdshopapi/sku_test.go b/platformapi/jdshopapi/sku_test.go index e3552a41..cc404331 100644 --- a/platformapi/jdshopapi/sku_test.go +++ b/platformapi/jdshopapi/sku_test.go @@ -297,7 +297,7 @@ func TestImageUpdate(t *testing.T) { } func TestSearchWare4Valid(t *testing.T) { - result, err := api.SearchWare4Valid("", 0, 0) + result, err := api.SearchWare4Valid("奶白菜", 1, 100) if err != nil { t.Fatal(err) } diff --git a/platformapi/jdshopapi/store_page.go b/platformapi/jdshopapi/store_page.go index de536821..33b655fb 100644 --- a/platformapi/jdshopapi/store_page.go +++ b/platformapi/jdshopapi/store_page.go @@ -976,12 +976,20 @@ type WareSaveResult struct { } //创建商品 -//https://porder.shop.jd.com/order/orderlist/allOrders func (a *API) WareSave(wareSaveParam *WareSaveParam) (wareSaveResult []*WareSaveResult, err error) { params := utils.Struct2FlatMap(wareSaveParam) result, err := a.AccessStorePage2("https://ware.shop.jd.com/rest/shop/ware/save", params, true) - if err == nil { + if err == nil && result["data"] != nil { utils.Map2StructByJson(result["data"].(map[string]interface{})["skus"], &wareSaveResult, false) } return wareSaveResult, err } + +//商品上下架 +func (a *API) WareDoUpdate(op string, updateWareIds string) (err error) { + _, err = a.AccessStorePage("https://ware.shop.jd.com/rest/ware/list/doUpdate", map[string]interface{}{ + "op": op, + "updateWareIds": updateWareIds + ",", + }, true) + return err +} diff --git a/platformapi/jdshopapi/store_page_test.go b/platformapi/jdshopapi/store_page_test.go index f297eb42..f265feae 100644 --- a/platformapi/jdshopapi/store_page_test.go +++ b/platformapi/jdshopapi/store_page_test.go @@ -204,20 +204,20 @@ func TestShopList(t *testing.T) { } func TestWareSave(t *testing.T) { - desc := `

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



` + // desc := `

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



` params := &WareSaveParam{ - WareID: 10020528071531, - Height: 120, - CategoryID: 12247, - VenderID: 10569615, - BrandID: 44259, - Length: 200, - Wide: 100, - WareStatus: 2, + WareID: 10020528071531, + Height: 120, + CategoryID: 12247, + VenderID: 10569615, + BrandID: 44259, + Length: 200, + Wide: 100, + // WareStatus: 2, Title: "三线肉", Weight: "3", ShopCategorys: []int{15602360}, - Notes: desc, + // Notes: desc, Skus: []*WareSaveSkus{ &WareSaveSkus{ SkuID: 10024685331653, @@ -232,7 +232,7 @@ func TestWareSave(t *testing.T) { }, }, &WareSaveSkus{ - JdPrice: "30", + JdPrice: "31", StockNum: 5, Props: []*WareSaveSkusProp{ &WareSaveSkusProp{ @@ -248,20 +248,28 @@ func TestWareSave(t *testing.T) { PropsSet: []interface{}{}, SaleAttrs: []interface{}{}, } - params.ImageMap.Num0000000000 = append(params.ImageMap.Num0000000000, &CreateSkuParamImages{ - ColorID: "0000000000", - ImgIndex: 1, - ImgURL: "jfs/t1/142006/30/15024/504060/5fb636d4Ef12079f7/2adad323cbcf7c52.jpg", - // ImgZoneID: "0000000000", - }, &CreateSkuParamImages{ - ColorID: "0000000000", - ImgIndex: 2, - ImgURL: "jfs/t1/142006/30/15024/504060/5fb636d4Ef12079f7/2adad323cbcf7c52.jpg", - // ImgZoneID: "0000000000", - }) + // params.ImageMap.Num0000000000 = append(params.ImageMap.Num0000000000, &CreateSkuParamImages{ + // ColorID: "0000000000", + // ImgIndex: 1, + // ImgURL: "jfs/t1/142006/30/15024/504060/5fb636d4Ef12079f7/2adad323cbcf7c52.jpg", + // // ImgZoneID: "0000000000", + // }, &CreateSkuParamImages{ + // ColorID: "0000000000", + // ImgIndex: 2, + // ImgURL: "jfs/t1/142006/30/15024/504060/5fb636d4Ef12079f7/2adad323cbcf7c52.jpg", + // // ImgZoneID: "0000000000", + // }) result, err := api.WareSave(params) if err != nil { t.Fatal(err) } t.Log(utils.Format4Output(result, false)) } + +func TestWareDoUpdate(t *testing.T) { + err := api.WareDoUpdate("up", "10020528071531") + if err != nil { + t.Fatal(err) + } + // t.Log(utils.Format4Output(result, false)) +}