DeleteStoreCategory接口添加level参数

mtwm改用RetailCatSkuBatchDelete2来删除商家分类(这样可保证必须能删除)
This commit is contained in:
gazebo
2019-10-24 16:07:09 +08:00
parent d8f9e65e1a
commit 543d14f963
6 changed files with 23 additions and 9 deletions

View File

@@ -82,7 +82,7 @@ func SyncStorCategories(ctx *jxcontext.Context, parentTask tasksch.ITask, vendor
storeCatMap.ID = catInfo.MapID
if model.IsSyncStatusDelete(catInfo.StoreCatSyncStatus) { // 删除
if model.IsSyncStatusDelete(catInfo.StoreCatSyncStatus) && !dao.IsVendorThingIDEmpty(catInfo.VendorCatID) {
err = handler.DeleteStoreCategory(ctx, storeID, vendorStoreID, catInfo.VendorCatID)
err = handler.DeleteStoreCategory(ctx, storeID, vendorStoreID, catInfo.VendorCatID, level)
if err != nil && handler.IsErrCategoryNotExist(err) {
err = nil
}
@@ -707,7 +707,7 @@ func amendAndPruneStoreStuff(ctx *jxcontext.Context, parentTask tasksch.ITask, v
task4Delete := tasksch.NewParallelTask(fmt.Sprintf("删除本地不存在的远程分类,level:%d", level), tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
cat := batchItemList[0].(*partner.BareCategoryInfo)
err = handler.DeleteStoreCategory(ctx, storeID, vendorStoreID, cat.VendorCatID)
err = handler.DeleteStoreCategory(ctx, storeID, vendorStoreID, cat.VendorCatID, level)
return nil, err
}, levelCat2Delete)
tasksch.HandleTask(task4Delete, task, true).Run()

View File

@@ -149,7 +149,7 @@ type ISingleStoreStoreSkuHandler interface {
GetStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, catName string) (cat *BareCategoryInfo, err error)
CreateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error)
UpdateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error)
DeleteStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, vendorCatID string) (err error)
DeleteStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, vendorCatID string, level int) (err error)
DeleteStoreAllCategories(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, isContinueWhenError bool) (err error)
IsErrCategoryExist(err error) (isExist bool)

View File

@@ -95,7 +95,7 @@ func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID in
return err
}
func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, vendorCatID string) (err error) {
func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, vendorCatID string, level int) (err error) {
if globals.EnableEbaiStoreWrite {
err = api.EbaiAPI.ShopCategoryDelete(utils.Int2Str(storeID), utils.Str2Int64WithDefault(vendorCatID, 0))
}

View File

@@ -162,9 +162,23 @@ func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID in
return p.CreateStoreCategory(ctx, storeID, vendorStoreID, storeCat)
}
func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, vendorCatID string) (err error) {
if globals.EnableMtwmStoreWrite {
err = api.MtwmAPI.RetailCatDelete(vendorStoreID, tryCatName2Code(vendorCatID), vendorCatID)
func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, vendorCatID string, level int) (err error) {
if false {
if globals.EnableMtwmStoreWrite {
err = api.MtwmAPI.RetailCatDelete(vendorStoreID, tryCatName2Code(vendorCatID), vendorCatID)
}
} else {
var catCodes []string
if catCode := tryCatName2Code(vendorCatID); catCode != "" {
catCodes = []string{catCode}
}
if globals.EnableMtwmStoreWrite {
if level == 1 {
err = api.MtwmAPI.RetailCatSkuBatchDelete2(ctx.GetTrackInfo(), vendorStoreID, catCodes, []string{vendorCatID}, nil, nil, nil)
} else {
err = api.MtwmAPI.RetailCatSkuBatchDelete2(ctx.GetTrackInfo(), vendorStoreID, nil, nil, catCodes, []string{vendorCatID}, nil)
}
}
}
return err
}

View File

@@ -64,7 +64,7 @@ func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, vendorStor
return err
}
func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, vendorStoreID, vendorCatID string) (err error) {
func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, vendorStoreID, vendorCatID string, level int) (err error) {
if globals.EnableWscStoreWrite {
err = api.WeimobAPI.UpdateClassify(utils.Str2Int64WithDefault(vendorCatID, 0), composeFakeDelName(vendorCatID), "")
}

View File

@@ -58,7 +58,7 @@ func (p *DefSingleStorePlatform) DeleteStoreAllCategories(ctx *jxcontext.Context
vendorCatIDs[k] = v.VendorCatID
}
err = FreeBatchCategoryIDOp(func(vendorCatID string) (err error) {
return p.DeleteStoreCategory(ctx, storeID, vendorStoreID, vendorCatID)
return p.DeleteStoreCategory(ctx, storeID, vendorStoreID, vendorCatID, step)
}, ctx, task, vendorCatIDs, isContinueWhenError)
return nil, err
}, len(levelList))