- 适应门店商品修复API,添加trackInfo参数

This commit is contained in:
gazebo
2019-07-28 12:39:40 +08:00
parent 6892467f4d
commit b0c3fa3ca3
10 changed files with 56 additions and 57 deletions

View File

@@ -231,7 +231,7 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks
if storeSku.NameID == 0 || storeSku.EbaiSyncStatus&model.SyncFlagDeletedMask != 0 {
if storeSku.EbaiSyncStatus&model.SyncFlagNewMask == 0 && !jxutils.IsEmptyID(storeSku.EbaiID) {
if globals.EnableEbaiStoreWrite {
opResult, err2 := api.EbaiAPI.SkuDelete(strStoreID, []int64{storeSku.EbaiID}, nil)
opResult, err2 := api.EbaiAPI.SkuDelete(ctx.GetTrackInfo(), strStoreID, []int64{storeSku.EbaiID}, nil)
if err = err2; err != nil {
if ebaiapi.IsErrSkuNotExist(err) || (opResult != nil && len(opResult.FailedList) == 1) {
err = nil
@@ -255,7 +255,7 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks
if mergedStoreSkuStatus == model.SkuStatusNormal { // 待创建且不可售的,暂不新建
if storeSku.Img != "" {
if globals.EnableEbaiStoreWrite {
if storeSku.EbaiID, err = api.EbaiAPI.SkuCreate(strStoreID, storeSku.SkuID, genSkuParamsFromStoreSkuInfo(pricePercentage, storeSku)); err == nil {
if storeSku.EbaiID, err = api.EbaiAPI.SkuCreate(ctx.GetTrackInfo(), strStoreID, storeSku.SkuID, genSkuParamsFromStoreSkuInfo(pricePercentage, storeSku)); err == nil {
utils.AfterFuncWithRecover(5*time.Second, func() {
api.EbaiAPI.SkuShopCategoryMap(strStoreID, storeSku.EbaiID, "", storeSku.CatEbaiID, ebaiapi.MaxSkuCatRank-storeSku.Price)
})
@@ -269,7 +269,7 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks
if storeSku.EbaiID = api.EbaiAPI.GetEbaiSkuIDFromCustomID(strStoreID, utils.Int2Str(storeSku.SkuID)); storeSku.EbaiID > 0 {
err = nil
updateFields = append(updateFields, model.FieldEbaiID)
if err2 := skuUpdate(strStoreID, pricePercentage, storeSku); err2 != nil {
if err2 := skuUpdate(ctx, strStoreID, pricePercentage, storeSku); err2 != nil {
syncStatus = model.SyncFlagStoreSkuModifiedMask
}
}
@@ -285,7 +285,7 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks
err = fmt.Errorf("京西数据异常,修改一个没有创建的饿百商品:%d, store:%s", storeSku.SkuID, strStoreID)
} else {
if storeSku.Img != "" {
err = skuUpdate(strStoreID, pricePercentage, storeSku)
err = skuUpdate(ctx, strStoreID, pricePercentage, storeSku)
} else {
err = fmt.Errorf("SKUANME%d:%s没有图片同步失败", storeSku.NameID, storeSku.Name)
}
@@ -314,14 +314,14 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks
return rootTask.ID, err
}
func skuUpdate(strStoreID string, pricePercentage int, storeSku *tStoreSkuFullInfo) (err error) {
func skuUpdate(ctx *jxcontext.Context, strStoreID string, pricePercentage int, storeSku *tStoreSkuFullInfo) (err error) {
if globals.EnableEbaiStoreWrite {
if _, err = api.EbaiAPI.SkuUpdate(strStoreID, storeSku.EbaiID, genSkuParamsFromStoreSkuInfo(pricePercentage, storeSku)); err != nil {
if _, err = api.EbaiAPI.SkuUpdate(ctx.GetTrackInfo(), strStoreID, storeSku.EbaiID, genSkuParamsFromStoreSkuInfo(pricePercentage, storeSku)); err != nil {
// 如果是改价错误,尝试把价格标志去掉再同步
if isErrModifyPrice(err) {
storeSku.EbaiSyncStatus = storeSku.EbaiSyncStatus & ^model.SyncFlagPriceMask
if storeSku.EbaiSyncStatus != 0 {
if _, err2 := api.EbaiAPI.SkuUpdate(strStoreID, storeSku.EbaiID, genSkuParamsFromStoreSkuInfo(pricePercentage, storeSku)); err2 != nil {
if _, err2 := api.EbaiAPI.SkuUpdate(ctx.GetTrackInfo(), strStoreID, storeSku.EbaiID, genSkuParamsFromStoreSkuInfo(pricePercentage, storeSku)); err2 != nil {
err = err2
}
}

View File

@@ -108,7 +108,7 @@ func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, storeID int, v
storeSku := storeSkuList[0]
strStoreID := utils.Int2Str(storeID)
if globals.EnableEbaiStoreWrite {
_, err = api.EbaiAPI.SkuUpdate(strStoreID, utils.Str2Int64(storeSku.VendorSkuID), genSkuParamsFromStoreSkuInfo2(storeSku))
_, err = api.EbaiAPI.SkuUpdate(ctx.GetTrackInfo(), strStoreID, utils.Str2Int64(storeSku.VendorSkuID), genSkuParamsFromStoreSkuInfo2(storeSku))
utils.CallFuncAsync(func() {
api.EbaiAPI.SkuShopCategoryMap(strStoreID, utils.Str2Int64(storeSku.VendorSkuID), "", utils.Str2Int64(storeSku.VendorCatID), genSkuCatRank(storeSku))
})
@@ -122,7 +122,7 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
var vendorSkuID int64
if globals.EnableEbaiStoreWrite {
strStoreID := utils.Int2Str(storeID)
if vendorSkuID, err = api.EbaiAPI.SkuCreate(strStoreID, storeSku.SkuID, genSkuParamsFromStoreSkuInfo2(storeSku)); err == nil {
if vendorSkuID, err = api.EbaiAPI.SkuCreate(ctx.GetTrackInfo(), strStoreID, storeSku.SkuID, genSkuParamsFromStoreSkuInfo2(storeSku)); err == nil {
utils.AfterFuncWithRecover(5*time.Second, func() {
api.EbaiAPI.SkuShopCategoryMap(strStoreID, vendorSkuID, "", utils.Str2Int64(storeSku.VendorCatID), genSkuCatRank(storeSku))
})
@@ -145,7 +145,7 @@ func getFailedVendorSkuIDsFromOpResult(opResult *ebaiapi.BatchOpResult) (skuIDs
func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (successList []*partner.StoreSkuInfo, err error) {
if globals.EnableEbaiStoreWrite {
opResult, err2 := api.EbaiAPI.SkuDelete(utils.Int2Str(storeID), partner.BareStoreSkuInfoList(storeSkuList).GetVendorSkuIDIntList(), nil)
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) == 1 && len(storeSkuList) == len(opResult.FailedList) { // 饿百现在删除不存在错在上层通过IsErrSkuNotExist很难准备判断暂时这里直接处理
err = nil
@@ -163,15 +163,15 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID
var opResult *ebaiapi.BatchOpResult
if status == model.SkuStatusNormal {
if len(vendorSkuIDs) > 1 {
opResult, err = api.EbaiAPI.SkuOnline(utils.Int2Str(storeID), vendorSkuIDs, nil, nil)
opResult, err = api.EbaiAPI.SkuOnline(ctx.GetTrackInfo(), utils.Int2Str(storeID), vendorSkuIDs, nil, nil)
} else if len(vendorSkuIDs) == 1 {
err = api.EbaiAPI.SkuOnlineOne(utils.Int2Str(storeID), vendorSkuIDs[0], "", "")
err = api.EbaiAPI.SkuOnlineOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), vendorSkuIDs[0], "", "")
}
} else {
if len(vendorSkuIDs) > 1 {
opResult, err = api.EbaiAPI.SkuOffline(utils.Int2Str(storeID), vendorSkuIDs, nil, nil)
opResult, err = api.EbaiAPI.SkuOffline(ctx.GetTrackInfo(), utils.Int2Str(storeID), vendorSkuIDs, nil, nil)
} else if len(vendorSkuIDs) == 1 {
err = api.EbaiAPI.SkuOfflineOne(utils.Int2Str(storeID), vendorSkuIDs[0], "", "")
err = api.EbaiAPI.SkuOfflineOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), vendorSkuIDs[0], "", "")
}
}
if err != nil && opResult != nil {
@@ -197,12 +197,12 @@ func StoreSkuInfoList2Ebai(storeSkuList []*partner.StoreSkuInfo) (outList ebaiap
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (successList []*partner.StoreSkuInfo, err error) {
if globals.EnableEbaiStoreWrite {
if len(storeSkuList) > 1 {
opResult, err2 := api.EbaiAPI.SkuPriceUpdateBatch(utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList), ebaiapi.SkuIDTypeSkuID)
opResult, err2 := api.EbaiAPI.SkuPriceUpdateBatch(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList), ebaiapi.SkuIDTypeSkuID)
if err = err2; err != nil && opResult != nil {
successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getFailedVendorSkuIDsFromOpResult(opResult))
}
} else if len(storeSkuList) == 1 {
err = api.EbaiAPI.SkuPriceUpdateOne(utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList)[0])
err = api.EbaiAPI.SkuPriceUpdateOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList)[0])
}
}
return successList, err
@@ -211,12 +211,12 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (successList []*partner.StoreSkuInfo, err error) {
if globals.EnableEbaiStoreWrite {
if len(storeSkuList) > 1 {
opResult, err2 := api.EbaiAPI.SkuStockUpdateBatch(utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList), ebaiapi.SkuIDTypeSkuID)
opResult, err2 := api.EbaiAPI.SkuStockUpdateBatch(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList), ebaiapi.SkuIDTypeSkuID)
if err = err2; err != nil && opResult != nil {
successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getFailedVendorSkuIDsFromOpResult(opResult))
}
} else if len(storeSkuList) == 1 {
err = api.EbaiAPI.SkuStockUpdateOne(utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList)[0])
err = api.EbaiAPI.SkuStockUpdateOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList)[0])
}
}
return successList, err