京东商城修改商品参数增加

This commit is contained in:
苏尹岚
2020-05-15 09:49:17 +08:00
parent 47bd232ce0
commit 28a3cc2585
3 changed files with 74 additions and 37 deletions

View File

@@ -22,6 +22,7 @@ const (
CreateCatType = "3"
UpdateCatType = "1"
VenderID = 10374877
TransportID = 2158480
JxBrandId = 559853
JdShopMaxStock = 9999

View File

@@ -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" {

View File

@@ -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 := `<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{
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)
}