错误返回
This commit is contained in:
@@ -45,6 +45,7 @@ type StoreSkuInfo struct {
|
||||
|
||||
type StoreSkuInfoWithErr struct {
|
||||
StoreSkuInfo *StoreSkuInfo
|
||||
CategoryName string
|
||||
VendoreID int
|
||||
StoreID int
|
||||
SyncType string
|
||||
@@ -155,9 +156,9 @@ type ISingleStoreStoreSkuHandler interface {
|
||||
|
||||
GetStoreAllCategories(ctx *jxcontext.Context, storeID int, vendorStoreID string) (cats []*BareCategoryInfo, err error)
|
||||
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, level int) (err error)
|
||||
CreateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (failedList []*StoreSkuInfoWithErr, err error)
|
||||
UpdateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (failedList []*StoreSkuInfoWithErr, err error)
|
||||
DeleteStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, vendorCatID string, level int) (failedList []*StoreSkuInfoWithErr, err error)
|
||||
DeleteStoreAllCategories(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, isContinueWhenError bool) (err error)
|
||||
|
||||
IsErrCategoryExist(err error) (isExist bool)
|
||||
|
||||
@@ -68,7 +68,7 @@ func (p *PurchaseHandler) IsErrCategoryNotExist(err error) (isNotExist bool) {
|
||||
return ebaiapi.IsErrCategoryNotExist(err)
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error) {
|
||||
func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
var vendorCatID int64
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
vendorCatID, err = api.EbaiAPI.ShopCategoryCreate(utils.Int2Str(storeID), utils.Str2Int64WithDefault(storeCat.ParentVendorCatID, 0), formatCatName(storeCat.Name), jxCatSeq2Ebai(storeCat.Seq))
|
||||
@@ -76,10 +76,13 @@ func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID in
|
||||
vendorCatID = jxutils.GenFakeID()
|
||||
}
|
||||
storeCat.VendorCatID = utils.Int64ToStr(vendorCatID)
|
||||
return err
|
||||
if err != nil {
|
||||
failedList = putils.GetErrMsg2FailedSingleList(nil, err, storeID, model.VendorIDEBAI, "创建分类")
|
||||
}
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
err = api.EbaiAPI.ShopCategoryUpdate(utils.Int2Str(storeID), utils.Str2Int64WithDefault(storeCat.VendorCatID, 0), formatCatName(storeCat.Name), jxCatSeq2Ebai(storeCat.Seq))
|
||||
// todo, 饿百将一个分类重复改名,也会报分类名重复错,特殊处理一下,不过因为GetStoreCategory其实会拉取所有的门店分类,是比较耗时的操作
|
||||
@@ -90,15 +93,21 @@ func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID in
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
failedList = putils.GetErrMsg2FailedSingleList(nil, err, storeID, model.VendorIDEBAI, "修改分类")
|
||||
}
|
||||
}
|
||||
return err
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, vendorCatID string, level int) (err error) {
|
||||
func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, vendorCatID string, level int) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
err = api.EbaiAPI.ShopCategoryDelete(utils.Int2Str(storeID), utils.Str2Int64WithDefault(vendorCatID, 0))
|
||||
if err != nil {
|
||||
failedList = putils.GetErrMsg2FailedSingleList(nil, err, storeID, model.VendorIDEBAI, "删除分类")
|
||||
}
|
||||
}
|
||||
return err
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
// 门店商品
|
||||
|
||||
@@ -102,7 +102,7 @@ func tryCatName2Code(originName string) (catCodeStr string) {
|
||||
return catCodeStr
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error) {
|
||||
func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
level := 1
|
||||
if storeCat.ParentCatName != "" {
|
||||
level = 2
|
||||
@@ -151,24 +151,27 @@ func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID in
|
||||
Sequence: storeCat.Seq,
|
||||
}
|
||||
err = api.MtwmAPI.RetailCatUpdate(vendorStoreID, catName, param4Update)
|
||||
if err != nil {
|
||||
failedList = putils.GetErrMsg2FailedSingleList(nil, err, storeID, model.VendorIDMTWM, "创建修改分类")
|
||||
}
|
||||
if storeCat.CatSyncStatus&model.SyncFlagNewMask == 0 && // 修改分类名,但分类不存在
|
||||
p.IsErrCategoryNotExist(err) && originName != "" {
|
||||
storeCat.CatSyncStatus |= model.SyncFlagNewMask
|
||||
err = p.CreateStoreCategory(ctx, storeID, vendorStoreID, storeCat)
|
||||
failedList, err = p.CreateStoreCategory(ctx, storeID, vendorStoreID, storeCat)
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
// storeCat.VendorCatID = utils.FilterEmoji(storeCat.Name)
|
||||
storeCat.VendorCatID = utils.Int2Str(storeCat.ID)
|
||||
}
|
||||
return err
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
return p.CreateStoreCategory(ctx, storeID, vendorStoreID, storeCat)
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, vendorCatID string, level int) (err error) {
|
||||
func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, vendorCatID string, level int) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
if false {
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
err = api.MtwmAPI.RetailCatDelete(vendorStoreID, tryCatName2Code(vendorCatID), vendorCatID)
|
||||
@@ -184,9 +187,12 @@ func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, storeID in
|
||||
} else {
|
||||
err = api.MtwmAPI.RetailCatSkuBatchDelete2(ctx.GetTrackInfo(), vendorStoreID, nil, nil, catCodes, []string{vendorCatID}, nil)
|
||||
}
|
||||
if err != nil {
|
||||
failedList = putils.GetErrMsg2FailedSingleList(nil, err, storeID, model.VendorIDMTWM, "删除分类")
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
// 门店商品
|
||||
@@ -411,7 +417,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, vendorOrg
|
||||
if len(failedFoodList) > 0 {
|
||||
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, failedFoodList, storeID, model.VendorIDMTWM, "更新商品库存")
|
||||
}
|
||||
// if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil {
|
||||
//if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil {
|
||||
// successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -64,7 +64,8 @@ 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, step)
|
||||
_, err2 := p.DeleteStoreCategory(ctx, storeID, vendorStoreID, vendorCatID, step)
|
||||
return err2
|
||||
}, ctx, task, vendorCatIDs, isContinueWhenError)
|
||||
return nil, err
|
||||
}, len(levelList))
|
||||
@@ -343,8 +344,7 @@ func GetErrMsg2FailedSingleList(storeSkuList interface{}, err error, storeID, ve
|
||||
SyncType: syncType,
|
||||
}
|
||||
failedList = append(failedList, storeSkuInfoWithErr)
|
||||
}
|
||||
if storeSkuLists, ok := storeSkuList.([]*dao.StoreSkuSyncInfo); ok {
|
||||
} else if storeSkuLists, ok := storeSkuList.([]*dao.StoreSkuSyncInfo); ok {
|
||||
storeSkuInfo := &partner.StoreSkuInfo{
|
||||
SkuID: storeSkuLists[0].SkuID,
|
||||
VendorSkuID: storeSkuLists[0].VendorSkuID,
|
||||
@@ -361,6 +361,14 @@ func GetErrMsg2FailedSingleList(storeSkuList interface{}, err error, storeID, ve
|
||||
SyncType: syncType,
|
||||
}
|
||||
failedList = append(failedList, storeSkuInfoWithErr)
|
||||
} else {
|
||||
storeSkuInfoWithErr := &partner.StoreSkuInfoWithErr{
|
||||
ErrMsg: errExt.ErrMsg(),
|
||||
StoreID: storeID,
|
||||
VendoreID: vendorID,
|
||||
SyncType: syncType,
|
||||
}
|
||||
failedList = append(failedList, storeSkuInfoWithErr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user