From 0bff70c554089a12a6b1b75a194b1375ed2b21ae Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 23 Apr 2019 17:36:59 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E5=87=A0=E4=B8=AA=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E7=9A=84=E8=8E=B7=E5=8F=96=E5=B9=B3=E5=8F=B0=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/ebaiapi/sku.go | 13 +++++++++++-- platformapi/ebaiapi/sku_test.go | 2 +- platformapi/jdapi/sku_test.go | 7 +++++++ platformapi/mtwmapi/retail.go | 13 +++++++++++-- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/platformapi/ebaiapi/sku.go b/platformapi/ebaiapi/sku.go index 702d53d1..939d164b 100644 --- a/platformapi/ebaiapi/sku.go +++ b/platformapi/ebaiapi/sku.go @@ -6,19 +6,28 @@ import ( "git.rosy.net.cn/baseapi/utils" ) +type VendorCategoryInfo struct { + CatID string `json:"cat_id"` + CatName string `json:"cat_name"` + Depth int `json:"depth"` + ParentID string `json:"parent_id"` +} + type BrandInfo struct { BrandID int64 `json:"brand_id"` BrandName string `json:"brand_name"` } -func (a *API) SkuCategoryList(keyword string, depth int, parentID int64) (cats []interface{}, err error) { +func (a *API) SkuCategoryList(keyword string, depth int, parentID int64) (cats []*VendorCategoryInfo, err error) { result, err := a.AccessAPI("sku.category.list", map[string]interface{}{ "keyword": keyword, "depth": depth, "parent_id": parentID, }) if err == nil { - return utils.Interface2Slice(result.Data), nil + if err = utils.Map2StructByJson(result.Data, &cats, true); err == nil { + return cats, nil + } } return nil, err } diff --git a/platformapi/ebaiapi/sku_test.go b/platformapi/ebaiapi/sku_test.go index 80665331..c9f262ae 100644 --- a/platformapi/ebaiapi/sku_test.go +++ b/platformapi/ebaiapi/sku_test.go @@ -7,7 +7,7 @@ import ( ) func TestSkuCategoryList(t *testing.T) { - result, err := api.SkuCategoryList("", 3, 1491490798176) + result, err := api.SkuCategoryList("", 1, 0) if err != nil { t.Fatal(err) } else { diff --git a/platformapi/jdapi/sku_test.go b/platformapi/jdapi/sku_test.go index da9c4a52..797744f9 100644 --- a/platformapi/jdapi/sku_test.go +++ b/platformapi/jdapi/sku_test.go @@ -180,3 +180,10 @@ func TestUpdateSpuSaleAttr(t *testing.T) { t.Fatal(err) } } + +func TestUpdateSpu(t *testing.T) { + err := api.UpdateSpu("8620", nil) + if err != nil { + t.Fatal(err) + } +} diff --git a/platformapi/mtwmapi/retail.go b/platformapi/mtwmapi/retail.go index 4b8e114b..dd500381 100644 --- a/platformapi/mtwmapi/retail.go +++ b/platformapi/mtwmapi/retail.go @@ -13,6 +13,13 @@ type RetailCategoryInfo struct { Children []*RetailCategoryInfo `json:"children"` } +type RetailTag struct { + ID int64 `json:"id"` + Name string `json:"name"` + Level int `json:"level"` + NamePath string `json:"namePath"` +} + // 美团分类没有ID,就以名字为唯一标识,不论级别都必须不能重名 // name(和originName)的长度不能超过10个字符(字符,不是字节) // 创建一级分类,originName为空,name为新分类名,secondaryName为空 @@ -157,10 +164,12 @@ func (a *API) RetailSkuDelete(poiCode, foodCode, skuID string) (err error) { } // 就是厂商商品类别 -func (a *API) RetailGetSpTagIds() (tagIds []map[string]interface{}, err error) { +func (a *API) RetailGetSpTagIds() (tagIds []*RetailTag, err error) { result, err := a.AccessAPI("retail/getSpTagIds", true, nil) if err == nil { - return utils.Slice2MapSlice(result.([]interface{})), nil + if err = utils.Map2StructByJson(result, &tagIds, false); err == nil { + return tagIds, nil + } } return nil, err }