- 几个平台的获取平台分类信息

This commit is contained in:
gazebo
2019-04-23 17:36:59 +08:00
parent 144aba73f9
commit 0bff70c554
4 changed files with 30 additions and 5 deletions

View File

@@ -6,19 +6,28 @@ import (
"git.rosy.net.cn/baseapi/utils" "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 { type BrandInfo struct {
BrandID int64 `json:"brand_id"` BrandID int64 `json:"brand_id"`
BrandName string `json:"brand_name"` 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{}{ result, err := a.AccessAPI("sku.category.list", map[string]interface{}{
"keyword": keyword, "keyword": keyword,
"depth": depth, "depth": depth,
"parent_id": parentID, "parent_id": parentID,
}) })
if err == nil { 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 return nil, err
} }

View File

@@ -7,7 +7,7 @@ import (
) )
func TestSkuCategoryList(t *testing.T) { func TestSkuCategoryList(t *testing.T) {
result, err := api.SkuCategoryList("", 3, 1491490798176) result, err := api.SkuCategoryList("", 1, 0)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} else { } else {

View File

@@ -180,3 +180,10 @@ func TestUpdateSpuSaleAttr(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
} }
func TestUpdateSpu(t *testing.T) {
err := api.UpdateSpu("8620", nil)
if err != nil {
t.Fatal(err)
}
}

View File

@@ -13,6 +13,13 @@ type RetailCategoryInfo struct {
Children []*RetailCategoryInfo `json:"children"` Children []*RetailCategoryInfo `json:"children"`
} }
type RetailTag struct {
ID int64 `json:"id"`
Name string `json:"name"`
Level int `json:"level"`
NamePath string `json:"namePath"`
}
// 美团分类没有ID就以名字为唯一标识不论级别都必须不能重名 // 美团分类没有ID就以名字为唯一标识不论级别都必须不能重名
// name和originName的长度不能超过10个字符字符不是字节 // name和originName的长度不能超过10个字符字符不是字节
// 创建一级分类originName为空name为新分类名secondaryName为空 // 创建一级分类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) result, err := a.AccessAPI("retail/getSpTagIds", true, nil)
if err == 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 return nil, err
} }