- 适应门店商品修复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

@@ -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
}

View File

@@ -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

View File

@@ -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)))
}