同步错误返回
This commit is contained in:
@@ -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) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (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,13 +76,10 @@ func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID in
|
||||
vendorCatID = jxutils.GenFakeID()
|
||||
}
|
||||
storeCat.VendorCatID = utils.Int64ToStr(vendorCatID)
|
||||
if err != nil {
|
||||
failedList = putils.GetErrMsg2FailedSingleList(nil, err, storeID, model.VendorIDEBAI, "创建分类")
|
||||
}
|
||||
return failedList, err
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (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其实会拉取所有的门店分类,是比较耗时的操作
|
||||
@@ -93,21 +90,15 @@ func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID in
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
failedList = putils.GetErrMsg2FailedSingleList(nil, err, storeID, model.VendorIDEBAI, "修改分类")
|
||||
}
|
||||
}
|
||||
return failedList, err
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, vendorCatID string, level int) (failedList []*partner.StoreSkuInfoWithErr, 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))
|
||||
if err != nil {
|
||||
failedList = putils.GetErrMsg2FailedSingleList(nil, err, storeID, model.VendorIDEBAI, "删除分类")
|
||||
}
|
||||
}
|
||||
return failedList, err
|
||||
return err
|
||||
}
|
||||
|
||||
// 门店商品
|
||||
@@ -182,7 +173,7 @@ func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
opResult, err2 := api.EbaiAPI.SkuDelete(ctx.GetTrackInfo(), utils.Int2Str(storeID), partner.BareStoreSkuInfoList(storeSkuList).GetVendorSkuIDIntList(), nil)
|
||||
if err = err2; err2 != nil && opResult != nil {
|
||||
// if len(storeSkuList) > len(opResult.FailedList) {
|
||||
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult, storeID, model.VendorIDEBAI, "删除商品")
|
||||
failedList = SelectStoreSkuListByOpResult(storeSkuList, opResult, storeID, model.VendorIDEBAI, "删除商品")
|
||||
// successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getFailedVendorSkuIDsFromOpResult(opResult))
|
||||
// }
|
||||
}
|
||||
@@ -212,7 +203,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, vendorOr
|
||||
}
|
||||
}
|
||||
if err != nil && opResult != nil {
|
||||
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult, storeID, model.VendorIDEBAI, "更新商品状态")
|
||||
failedList = SelectStoreSkuListByOpResult(storeSkuList, opResult, storeID, model.VendorIDEBAI, "更新商品状态")
|
||||
// failedList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getFailedVendorSkuIDsFromOpResult(opResult))
|
||||
}
|
||||
}
|
||||
@@ -237,12 +228,12 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, vendorOrg
|
||||
if len(storeSkuList) > 1 {
|
||||
opResult, err2 := api.EbaiAPI.SkuPriceUpdateBatch(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList), ebaiapi.SkuIDTypeSkuID)
|
||||
if err = err2; err != nil && opResult != nil {
|
||||
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult, storeID, model.VendorIDEBAI, "更新商品价格")
|
||||
failedList = SelectStoreSkuListByOpResult(storeSkuList, opResult, storeID, model.VendorIDEBAI, "更新商品价格")
|
||||
}
|
||||
} else if len(storeSkuList) == 1 {
|
||||
opResult2, err := api.EbaiAPI.SkuPriceUpdateOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList)[0])
|
||||
if err != nil && opResult2 != nil {
|
||||
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult2, storeID, model.VendorIDEBAI, "更新商品价格")
|
||||
failedList = SelectStoreSkuListByOpResult(storeSkuList, opResult2, storeID, model.VendorIDEBAI, "更新商品价格")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -254,7 +245,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, vendorOrg
|
||||
if len(storeSkuList) > 1 {
|
||||
opResult, err2 := api.EbaiAPI.SkuStockUpdateBatch(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList), ebaiapi.SkuIDTypeSkuID)
|
||||
if err = err2; err != nil && opResult != nil {
|
||||
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult, storeID, model.VendorIDEBAI, "更新商品库存")
|
||||
failedList = SelectStoreSkuListByOpResult(storeSkuList, opResult, storeID, model.VendorIDEBAI, "更新商品库存")
|
||||
// successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getFailedVendorSkuIDsFromOpResult(opResult))
|
||||
}
|
||||
} else if len(storeSkuList) == 1 {
|
||||
@@ -439,3 +430,26 @@ func vendorSkuList2Jx(vendorSkuList []*ebaiapi.SkuInfo) (skuNameList []*partner.
|
||||
func (p *PurchaseHandler) GetSensitiveWordRegexp() *regexp.Regexp {
|
||||
return sensitiveWordRegexp
|
||||
}
|
||||
|
||||
//饿百api返回
|
||||
func SelectStoreSkuListByOpResult(storeSkuList []*partner.StoreSkuInfo, opResult *ebaiapi.BatchOpResult, storeID, vendorID int, syncType string) (selectedStoreSkuList []*partner.StoreSkuInfoWithErr) {
|
||||
opResultMap := make(map[int64]string)
|
||||
if len(opResult.FailedList) > 0 {
|
||||
for _, v := range opResult.FailedList {
|
||||
opResultMap[v.SkuID] = v.ErrorMsg
|
||||
}
|
||||
for _, v := range storeSkuList {
|
||||
if opResultMap[utils.Str2Int64(v.VendorSkuID)] != "" {
|
||||
opFailed := &partner.StoreSkuInfoWithErr{
|
||||
StoreSkuInfo: v,
|
||||
ErrMsg: opResultMap[utils.Str2Int64(v.VendorSkuID)],
|
||||
StoreID: storeID,
|
||||
VendoreID: vendorID,
|
||||
SyncType: syncType,
|
||||
}
|
||||
selectedStoreSkuList = append(selectedStoreSkuList, opFailed)
|
||||
}
|
||||
}
|
||||
}
|
||||
return selectedStoreSkuList
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user