- 适应门店商品修复API,添加trackInfo参数
This commit is contained in:
@@ -37,11 +37,6 @@ func (ctx *Context) GetTrackInfo() string {
|
||||
return ctx.accessUUID
|
||||
}
|
||||
|
||||
// 待删除
|
||||
func (ctx *Context) GetAccessUUID() string {
|
||||
return ctx.accessUUID
|
||||
}
|
||||
|
||||
func (ctx *Context) GetRealRemoteIP() (ip string) {
|
||||
r := ctx.r
|
||||
if r != nil {
|
||||
|
||||
@@ -457,7 +457,7 @@ func CreateJdPromotion(ctx *jxcontext.Context, vendorID int, isIDJd bool, isAsyn
|
||||
modifyPrices2[k] = v.(*jdapi.SkuPriceInfo)
|
||||
}
|
||||
if globals.EnableJdStoreWrite {
|
||||
if _, err = api.JdAPI.UpdateVendorStationPrice(utils.Int2Str(storeID), "", modifyPrices2); err != nil {
|
||||
if _, err = api.JdAPI.UpdateVendorStationPrice(ctx.GetTrackInfo(), utils.Int2Str(storeID), "", modifyPrices2); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -783,7 +783,7 @@ func RefreshJdStoreSkuStock(promotionID int, skuIDs []int) (err error) {
|
||||
promotionItem := v.(*tPromotionItemInfo)
|
||||
if promotionItem.JdStoreID != stationNo {
|
||||
// globals.SugarLogger.Debugf("RefreshJdStoreSkuStock BatchUpdateCurrentQtys stationNo:%s, stockList:%s", stationNo, utils.Format4Output(stockList, false))
|
||||
_, err = api.JdAPI.BatchUpdateCurrentQtys("", stationNo, stockList, userName)
|
||||
_, err = api.JdAPI.BatchUpdateCurrentQtys("", "", stationNo, stockList, userName)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Warnf("RefreshJdStoreSkuStock BatchUpdateCurrentQtys failed with error:%v", err)
|
||||
}
|
||||
@@ -796,7 +796,7 @@ func RefreshJdStoreSkuStock(promotionID int, skuIDs []int) (err error) {
|
||||
})
|
||||
}
|
||||
// globals.SugarLogger.Debugf("RefreshJdStoreSkuStock BatchUpdateCurrentQtys stationNo:%s, stockList:%s", stationNo, utils.Format4Output(stockList, false))
|
||||
_, err = api.JdAPI.BatchUpdateCurrentQtys("", stationNo, stockList, userName)
|
||||
_, err = api.JdAPI.BatchUpdateCurrentQtys("", "", stationNo, stockList, userName)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Warnf("RefreshJdStoreSkuStock BatchUpdateCurrentQtys failed with error:%v", err)
|
||||
}
|
||||
@@ -952,7 +952,7 @@ func OnStoreStockMsg(msg *jdapi.CallbackStoreStockMsg) (retVal *jdapi.CallbackRe
|
||||
OutSkuId: utils.Int2Str(sku.ID),
|
||||
DoSale: true,
|
||||
}
|
||||
_, err = api.JdAPI.BatchUpdateVendibility("", msg.StationNo, []*jdapi.StockVendibility{
|
||||
_, err = api.JdAPI.BatchUpdateVendibility("", "", msg.StationNo, []*jdapi.StockVendibility{
|
||||
vendibility,
|
||||
}, userName)
|
||||
}
|
||||
@@ -961,7 +961,7 @@ func OnStoreStockMsg(msg *jdapi.CallbackStoreStockMsg) (retVal *jdapi.CallbackRe
|
||||
OutSkuId: utils.Int2Str(sku.ID),
|
||||
StockQty: model.MaxStoreSkuStockQty,
|
||||
}
|
||||
_, err = api.JdAPI.BatchUpdateCurrentQtys("", msg.StationNo, []*jdapi.SkuStock{
|
||||
_, err = api.JdAPI.BatchUpdateCurrentQtys("", "", msg.StationNo, []*jdapi.SkuStock{
|
||||
stock,
|
||||
}, userName)
|
||||
}
|
||||
|
||||
@@ -126,3 +126,7 @@ func (ctx *Context) GetV2AuthInfo() (authInfo *auth2.AuthInfo, err error) {
|
||||
}
|
||||
return nil, auth2.ErrNeedV2Token
|
||||
}
|
||||
|
||||
func (ctx *Context) GetTrackInfo() string {
|
||||
return ctx.Context.GetTrackInfo() + "," + ctx.GetUserName()
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -180,17 +180,17 @@ func storeSku2Jd(actStoreSku []*model.ActStoreSku2, handler func(syncStatus int8
|
||||
}
|
||||
|
||||
func createSkuAct(ctx *jxcontext.Context, act *model.Act2, actStoreSku []*model.ActStoreSku2) (vendorActID string, err error) {
|
||||
traceID := ctx.GetAccessUUID()
|
||||
traceInfo := ctx.GetTrackInfo()
|
||||
outInfoID := ""
|
||||
if act.VendorActID == "" {
|
||||
outInfoID = utils.Int2Str(act.ID)
|
||||
}
|
||||
infoID, err2 := CreatePromotionInfos(act.Type, act.GetRealActName(), act.BeginAt, act.EndAt, outInfoID, act.Advertising, traceID)
|
||||
infoID, err2 := CreatePromotionInfos(act.Type, act.GetRealActName(), act.BeginAt, act.EndAt, outInfoID, act.Advertising, traceInfo)
|
||||
if err = err2; err == nil {
|
||||
vendorActID = utils.Int64ToStr(infoID)
|
||||
if err = CreatePromotionRules(act.Type, infoID, "", act.LimitUser, act.LimitUser, act.LimitCount, 1, traceID); err == nil {
|
||||
if _, err = CreatePromotionSku(act.Type, infoID, "", storeSku2Jd(actStoreSku, model.IsSyncStatusNeedCreate), traceID); err == nil {
|
||||
if err = ConfirmPromotion(act.Type, infoID, "", traceID); err == nil {
|
||||
if err = CreatePromotionRules(act.Type, infoID, "", act.LimitUser, act.LimitUser, act.LimitCount, 1, traceInfo); err == nil {
|
||||
if _, err = CreatePromotionSku(act.Type, infoID, "", storeSku2Jd(actStoreSku, model.IsSyncStatusNeedCreate), traceInfo); err == nil {
|
||||
if err = ConfirmPromotion(act.Type, infoID, "", traceInfo); err == nil {
|
||||
for _, v := range actStoreSku {
|
||||
v.VendorActID = vendorActID
|
||||
}
|
||||
@@ -198,7 +198,7 @@ func createSkuAct(ctx *jxcontext.Context, act *model.Act2, actStoreSku []*model.
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
CancelPromotion(act.Type, infoID, "", traceID)
|
||||
CancelPromotion(act.Type, infoID, "", traceInfo)
|
||||
}
|
||||
}
|
||||
return vendorActID, err
|
||||
@@ -207,7 +207,7 @@ func createSkuAct(ctx *jxcontext.Context, act *model.Act2, actStoreSku []*model.
|
||||
func cancelSkuActSkus(ctx *jxcontext.Context, actType int, vendorActID string, actStoreSku []*model.ActStoreSku2) (err error) {
|
||||
if vendorActID != "" {
|
||||
if skuList := storeSku2Jd(actStoreSku, model.IsSyncStatusNeedDelete); len(skuList) > 0 {
|
||||
err = CancelPromotionSku(actType, utils.Str2Int64(vendorActID), "", skuList, ctx.GetAccessUUID())
|
||||
err = CancelPromotionSku(actType, utils.Str2Int64(vendorActID), "", skuList, ctx.GetTrackInfo())
|
||||
}
|
||||
}
|
||||
return err
|
||||
@@ -215,7 +215,7 @@ func cancelSkuActSkus(ctx *jxcontext.Context, actType int, vendorActID string, a
|
||||
|
||||
func cancelSkuAct(ctx *jxcontext.Context, actType int, vendorActID string) (err error) {
|
||||
if vendorActID != "" {
|
||||
err = CancelPromotion(actType, utils.Str2Int64(vendorActID), "", ctx.GetAccessUUID())
|
||||
err = CancelPromotion(actType, utils.Str2Int64(vendorActID), "", ctx.GetTrackInfo())
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks
|
||||
// todo 以下可以优化为并行操作
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(skuVendibilityList, false), utils.Format4Output(skuPriceInfoList, false), utils.Format4Output(skuStockList, false))
|
||||
if len(skuVendibilityList) > 0 {
|
||||
if _, err = api.JdAPI.BatchUpdateVendibility("", stationNo, skuVendibilityList, ctx.GetUserName()); err == nil {
|
||||
if _, err = api.JdAPI.BatchUpdateVendibility(ctx.GetTrackInfo(), "", stationNo, skuVendibilityList, ctx.GetUserName()); err == nil {
|
||||
syncMask |= model.SyncFlagSaleMask
|
||||
} else {
|
||||
if !isPartialFailed {
|
||||
@@ -109,9 +109,9 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks
|
||||
}
|
||||
if (err == nil || isContinueWhenError) && len(skuStockList) > 0 {
|
||||
if len(skuStockList) == 1 {
|
||||
err = api.JdAPI.UpdateCurrentQty(stationNo, utils.Str2Int64WithDefault(vendorSkuID4Qty, 0), skuStockList[0].StockQty)
|
||||
err = api.JdAPI.UpdateCurrentQty(ctx.GetTrackInfo(), stationNo, utils.Str2Int64WithDefault(vendorSkuID4Qty, 0), skuStockList[0].StockQty)
|
||||
} else {
|
||||
_, err = api.JdAPI.BatchUpdateCurrentQtys("", stationNo, skuStockList, ctx.GetUserName())
|
||||
_, err = api.JdAPI.BatchUpdateCurrentQtys(ctx.GetTrackInfo(), "", stationNo, skuStockList, ctx.GetUserName())
|
||||
}
|
||||
if err == nil {
|
||||
syncMask |= model.SyncFlagNewMask | model.SyncFlagDeletedMask
|
||||
@@ -124,9 +124,9 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks
|
||||
}
|
||||
if (err == nil || isContinueWhenError) && len(skuPriceInfoList) > 0 {
|
||||
if len(skuPriceInfoList) == 1 {
|
||||
_, err = api.JdAPI.UpdateStationPrice(utils.Str2Int64WithDefault(vendorSkuID4Price, 0), stationNo, skuPriceInfoList[0].Price)
|
||||
_, err = api.JdAPI.UpdateStationPrice(ctx.GetTrackInfo(), utils.Str2Int64WithDefault(vendorSkuID4Price, 0), stationNo, skuPriceInfoList[0].Price)
|
||||
} else {
|
||||
_, err = api.JdAPI.UpdateVendorStationPrice("", stationNo, skuPriceInfoList)
|
||||
_, err = api.JdAPI.UpdateVendorStationPrice(ctx.GetTrackInfo(), "", stationNo, skuPriceInfoList)
|
||||
}
|
||||
if err == nil {
|
||||
syncMask |= model.SyncFlagPriceMask
|
||||
|
||||
@@ -119,7 +119,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID
|
||||
})
|
||||
}
|
||||
if globals.EnableJdStoreWrite {
|
||||
responseList, err2 := api.JdAPI.BatchUpdateVendibility("", vendorStoreID, skuVendibilityList, ctx.GetUserName())
|
||||
responseList, err2 := api.JdAPI.BatchUpdateVendibility(ctx.GetTrackInfo(), "", vendorStoreID, skuVendibilityList, ctx.GetUserName())
|
||||
if err = err2; isErrPartialFailed(err) {
|
||||
successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
|
||||
}
|
||||
@@ -130,7 +130,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID
|
||||
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (successList []*partner.StoreSkuInfo, err error) {
|
||||
if len(storeSkuList) == 1 {
|
||||
if globals.EnableJdStoreWrite {
|
||||
_, err = api.JdAPI.UpdateStationPrice(utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), vendorStoreID, int(storeSkuList[0].VendorPrice))
|
||||
_, err = api.JdAPI.UpdateStationPrice(ctx.GetTrackInfo(), utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), vendorStoreID, int(storeSkuList[0].VendorPrice))
|
||||
}
|
||||
} else {
|
||||
var skuPriceInfoList []*jdapi.SkuPriceInfo
|
||||
@@ -141,7 +141,7 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
|
||||
})
|
||||
}
|
||||
if globals.EnableJdStoreWrite {
|
||||
responseList, err2 := api.JdAPI.UpdateVendorStationPrice("", vendorStoreID, skuPriceInfoList)
|
||||
responseList, err2 := api.JdAPI.UpdateVendorStationPrice(ctx.GetTrackInfo(), "", vendorStoreID, skuPriceInfoList)
|
||||
if err = err2; isErrPartialFailed(err) {
|
||||
successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
|
||||
}
|
||||
@@ -153,7 +153,7 @@ 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 len(storeSkuList) == 1 {
|
||||
if globals.EnableJdStoreWrite {
|
||||
err = api.JdAPI.UpdateCurrentQty(vendorStoreID, utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), storeSkuList[0].Stock)
|
||||
err = api.JdAPI.UpdateCurrentQty(ctx.GetTrackInfo(), vendorStoreID, utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), storeSkuList[0].Stock)
|
||||
}
|
||||
} else {
|
||||
var skuStockList []*jdapi.SkuStock
|
||||
@@ -164,7 +164,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID i
|
||||
})
|
||||
}
|
||||
if globals.EnableJdStoreWrite {
|
||||
responseList, err2 := api.JdAPI.BatchUpdateCurrentQtys("", vendorStoreID, skuStockList, ctx.GetUserName())
|
||||
responseList, err2 := api.JdAPI.BatchUpdateCurrentQtys(ctx.GetTrackInfo(), "", vendorStoreID, skuStockList, ctx.GetUserName())
|
||||
if err = err2; isErrPartialFailed(err) {
|
||||
successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks
|
||||
if skuItem.NameID == 0 || skuItem.StoreSkuSyncStatus&model.SyncFlagDeletedMask != 0 {
|
||||
if skuItem.StoreSkuSyncStatus&model.SyncFlagNewMask == 0 && !dao.IsVendorThingIDEmpty(skuItem.VendorSkuID) {
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
if err = api.MtwmAPI.RetailDelete(vendorStoreID, skuItem.VendorSkuID); mtwmapi.IsErrSkuNotExist(err) {
|
||||
if err = api.MtwmAPI.RetailDelete(ctx.GetTrackInfo(), vendorStoreID, skuItem.VendorSkuID); mtwmapi.IsErrSkuNotExist(err) {
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
@@ -338,10 +338,10 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks
|
||||
skus[0]["weight"] = skuItem.Weight // weight字段仅限服饰鞋帽、美妆、日用品、母婴、生鲜果蔬、生活超市下的便利店/超市门店品类的商家使用
|
||||
}
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
// err = api.MtwmAPI.RetailBatchInitData(vendorStoreID, foodDataList)
|
||||
// err = api.MtwmAPI.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList)
|
||||
|
||||
foodData["skus"] = string(utils.MustMarshal(skus))
|
||||
err = api.MtwmAPI.RetailInitData(vendorStoreID, utils.Int2Str(skuItem.SkuID), foodData)
|
||||
err = api.MtwmAPI.RetailInitData(ctx.GetTrackInfo(), vendorStoreID, utils.Int2Str(skuItem.SkuID), foodData)
|
||||
}
|
||||
if err == nil {
|
||||
storeSkuBind.MtwmID = int64(skuItem.SkuID)
|
||||
@@ -363,7 +363,7 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks
|
||||
globals.SugarLogger.Debugf("mtwm SyncStoreSkus4 skuID:%d, SkuSyncStatus:%d", skuItem.SkuID, skuItem.StoreSkuSyncStatus)
|
||||
sellStatus := skuStatusJX2Mtwm(jxutils.MergeSkuStatus(skuItem.Status, skuItem.StoreSkuStatus))
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
if _, err2 := api.MtwmAPI.RetailSkuSellStatus(vendorStoreID, []*mtwmapi.BareStoreFoodInfo{
|
||||
if _, err2 := api.MtwmAPI.RetailSkuSellStatus(ctx.GetTrackInfo(), vendorStoreID, []*mtwmapi.BareStoreFoodInfo{
|
||||
&mtwmapi.BareStoreFoodInfo{
|
||||
AppFoodCode: utils.Int2Str(skuItem.SkuID),
|
||||
Skus: []*mtwmapi.BareStoreSkuInfo{
|
||||
|
||||
@@ -173,9 +173,9 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
if len(foodDataList) == 1 {
|
||||
foodDataList[0]["skus"] = string(utils.MustMarshal(foodDataList[0]["skus"]))
|
||||
err = api.MtwmAPI.RetailInitData(vendorStoreID, utils.Int2Str(storeSkuList[0].SkuID), foodDataList[0])
|
||||
err = api.MtwmAPI.RetailInitData(ctx.GetTrackInfo(), vendorStoreID, utils.Int2Str(storeSkuList[0].SkuID), foodDataList[0])
|
||||
} else if len(foodDataList) > 0 {
|
||||
failedFoodList, err2 := api.MtwmAPI.RetailBatchInitData(vendorStoreID, foodDataList)
|
||||
failedFoodList, err2 := api.MtwmAPI.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList)
|
||||
if err = err2; err == nil {
|
||||
if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil {
|
||||
successList = putils.UnselectStoreSkuSyncListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
||||
@@ -196,10 +196,10 @@ func getAppFoodCodeList(l []*mtwmapi.AppFoodResult) (vendorSkuIDs []string) {
|
||||
func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (successList []*partner.StoreSkuInfo, err error) {
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
if len(storeSkuList) == 1 {
|
||||
err = api.MtwmAPI.RetailDelete(vendorStoreID, storeSkuList[0].VendorSkuID)
|
||||
err = api.MtwmAPI.RetailDelete(ctx.GetTrackInfo(), vendorStoreID, storeSkuList[0].VendorSkuID)
|
||||
} else {
|
||||
// todo 部分失败
|
||||
err = api.MtwmAPI.RetailCatSkuBatchDelete(vendorStoreID, nil, nil, partner.BareStoreSkuInfoList(storeSkuList).GetVendorSkuIDList())
|
||||
err = api.MtwmAPI.RetailCatSkuBatchDelete(ctx.GetTrackInfo(), vendorStoreID, nil, nil, partner.BareStoreSkuInfoList(storeSkuList).GetVendorSkuIDList())
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
@@ -233,7 +233,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID
|
||||
skuList := storeSku2Mtwm(storeSkuList, updateTypeStatus)
|
||||
mtwmStatus := skuStatusJX2Mtwm(status)
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
failedFoodList, err2 := api.MtwmAPI.RetailSkuSellStatus(vendorStoreID, skuList, mtwmStatus)
|
||||
failedFoodList, err2 := api.MtwmAPI.RetailSkuSellStatus(ctx.GetTrackInfo(), vendorStoreID, skuList, mtwmStatus)
|
||||
if err = err2; err == nil {
|
||||
if len(failedFoodList) > 0 {
|
||||
successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
||||
@@ -246,7 +246,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID
|
||||
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (successList []*partner.StoreSkuInfo, err error) {
|
||||
priceList := storeSku2Mtwm(storeSkuList, updateTypePrice)
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
failedFoodList, err2 := api.MtwmAPI.RetailSkuPrice(vendorStoreID, priceList)
|
||||
failedFoodList, err2 := api.MtwmAPI.RetailSkuPrice(ctx.GetTrackInfo(), vendorStoreID, priceList)
|
||||
if err = err2; err == nil {
|
||||
if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil {
|
||||
successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
||||
@@ -259,7 +259,7 @@ 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) {
|
||||
stockList := storeSku2Mtwm(storeSkuList, updateTypeStock)
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
failedFoodList, err2 := api.MtwmAPI.RetailSkuStock(vendorStoreID, stockList)
|
||||
failedFoodList, err2 := api.MtwmAPI.RetailSkuStock(ctx.GetTrackInfo(), vendorStoreID, stockList)
|
||||
if err = err2; err == nil {
|
||||
if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil {
|
||||
successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
||||
|
||||
Reference in New Issue
Block a user