mtwmapi.RetailCatSkuBatchDelete2
This commit is contained in:
@@ -235,6 +235,9 @@ func handleRetailBatchResultByRegexp(result interface{}) (failedFoodList []*AppF
|
||||
}
|
||||
|
||||
// 商品名最长30个字符(非字节)
|
||||
// 此函数可能创建相同foodCode的商品,如下问题的回复中有提到
|
||||
// https://developer.waimai.meituan.com/home/myquestionDetail/6716
|
||||
// 另外这个接口即使不指定operate_type为1,也可能报错:”商品spu名称在该店内分类中已存在“,原因就是已经存在两个相同的SKU了
|
||||
func (a *API) RetailInitData(trackInfo, poiCode, foodCode string, params map[string]interface{}) (err error) {
|
||||
_, err = a.AccessAPI2("retail/initdata", false, utils.MergeMaps(map[string]interface{}{
|
||||
KeyAppPoiCode: poiCode,
|
||||
@@ -387,6 +390,31 @@ func (a *API) RetailCatSkuBatchDelete(trackInfo, poiCode string, catNames []stri
|
||||
return err
|
||||
}
|
||||
|
||||
// 批量删除商品分类及商品
|
||||
// https://developer.waimai.meituan.com/home/docDetail/286
|
||||
func (a *API) RetailCatSkuBatchDelete2(trackInfo, poiCode string, catCodes, catNames, secondaryCatCodes, secondaryCatNames, foodCodes []string) (err error) {
|
||||
params := map[string]interface{}{
|
||||
KeyAppPoiCode: poiCode,
|
||||
}
|
||||
if len(catCodes) > 0 {
|
||||
params["category_codes"] = strings.Join(catCodes, ",")
|
||||
} else if len(catNames) > 0 {
|
||||
params["category_names"] = strings.Join(catNames, ",")
|
||||
}
|
||||
|
||||
if len(secondaryCatCodes) > 0 {
|
||||
params["secondary_category_codes"] = strings.Join(secondaryCatCodes, ",")
|
||||
} else if len(secondaryCatNames) > 0 {
|
||||
params["secondary_category_names"] = strings.Join(secondaryCatNames, ",")
|
||||
}
|
||||
|
||||
if len(foodCodes) > 0 {
|
||||
params["app_food_codes"] = strings.Join(foodCodes, ",")
|
||||
}
|
||||
_, err = a.AccessAPI2("retailCat/batchdelete/catandretail", false, params, resultKeyData, trackInfo)
|
||||
return err
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
// 私有辅助函数
|
||||
func interface2Cat(data interface{}, level int) (cat *RetailCategoryInfo) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
func TestRetailCatList(t *testing.T) {
|
||||
result, err := api.RetailCatList("7875210")
|
||||
result, err := api.RetailCatList(testPoiCode)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -25,7 +25,7 @@ func TestRetailCatUpdate(t *testing.T) {
|
||||
}
|
||||
func TestRetailCatDelete(t *testing.T) {
|
||||
var err error
|
||||
err = api.RetailCatDelete(testPoiCode, "" /*utils.GetUpperUUID()*/, "小月饼111")
|
||||
err = api.RetailCatDelete(testPoiCode, "" /*utils.GetUpperUUID()*/, "猪肉类")
|
||||
if err == nil {
|
||||
t.Fatal("should return error that can not find such cat")
|
||||
}
|
||||
@@ -87,14 +87,14 @@ func TestRetailGetSpTagIds(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRetailCatSkuBatchDelete(t *testing.T) {
|
||||
err := api.RetailCatSkuBatchDelete(utils.GetUUID(), testPoiCode, []string{"测试一级类别"}, nil, nil)
|
||||
err := api.RetailCatSkuBatchDelete2(utils.GetUUID(), testPoiCode, nil, []string{"精品水果2"}, nil, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRetailDelete(t *testing.T) {
|
||||
err := api.RetailDelete(utils.GetUUID(), testPoiCode, "614")
|
||||
err := api.RetailDelete(utils.GetUUID(), testPoiCode, "32427")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user