错误返回
This commit is contained in:
@@ -166,7 +166,7 @@ func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
return successList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo, status int) (successList []*partner.StoreSkuInfo, err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo, status int) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
vendorSkuIDs := partner.BareStoreSkuInfoList(storeSkuList).GetVendorSkuIDIntList()
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
var opResult *ebaiapi.BatchOpResult
|
||||
@@ -175,19 +175,24 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID
|
||||
opResult, err = api.EbaiAPI.SkuOnline(ctx.GetTrackInfo(), utils.Int2Str(storeID), vendorSkuIDs, nil, nil)
|
||||
} else if len(vendorSkuIDs) == 1 {
|
||||
err = api.EbaiAPI.SkuOnlineOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), vendorSkuIDs[0], "", "")
|
||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
||||
return failedList, err
|
||||
}
|
||||
} else {
|
||||
if len(vendorSkuIDs) > 1 {
|
||||
opResult, err = api.EbaiAPI.SkuOffline(ctx.GetTrackInfo(), utils.Int2Str(storeID), vendorSkuIDs, nil, nil)
|
||||
} else if len(vendorSkuIDs) == 1 {
|
||||
err = api.EbaiAPI.SkuOfflineOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), vendorSkuIDs[0], "", "")
|
||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
||||
return failedList, err
|
||||
}
|
||||
}
|
||||
if err != nil && opResult != nil {
|
||||
successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getFailedVendorSkuIDsFromOpResult(opResult))
|
||||
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult)
|
||||
// failedList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getFailedVendorSkuIDsFromOpResult(opResult))
|
||||
}
|
||||
}
|
||||
return successList, err
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func StoreSkuInfoList2Ebai(storeSkuList []*partner.StoreSkuInfo) (outList ebaiapi.ShopSkuInfoList) {
|
||||
@@ -203,7 +208,7 @@ func StoreSkuInfoList2Ebai(storeSkuList []*partner.StoreSkuInfo) (outList ebaiap
|
||||
return outList
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*tasksch.ErrMsg, err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
if len(storeSkuList) > 1 {
|
||||
opResult, err2 := api.EbaiAPI.SkuPriceUpdateBatch(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList), ebaiapi.SkuIDTypeSkuID)
|
||||
@@ -211,24 +216,29 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
|
||||
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult)
|
||||
}
|
||||
} else if len(storeSkuList) == 1 {
|
||||
_, err = api.EbaiAPI.SkuPriceUpdateOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList)[0])
|
||||
opResult2, err := api.EbaiAPI.SkuPriceUpdateOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList)[0])
|
||||
if err != nil && opResult2 != nil {
|
||||
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult2)
|
||||
}
|
||||
}
|
||||
}
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (successList []*partner.StoreSkuInfo, err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
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 {
|
||||
successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getFailedVendorSkuIDsFromOpResult(opResult))
|
||||
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult)
|
||||
// successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getFailedVendorSkuIDsFromOpResult(opResult))
|
||||
}
|
||||
} else if len(storeSkuList) == 1 {
|
||||
err = api.EbaiAPI.SkuStockUpdateOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList)[0])
|
||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
||||
}
|
||||
}
|
||||
return successList, err
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func genSkuParamsFromStoreSkuInfo2(storeSku *dao.StoreSkuSyncInfo, isCreate bool) (params map[string]interface{}) {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package jd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
@@ -112,7 +110,7 @@ func getStrOutSkuIDs(l []*jdapi.StoreSkuBatchUpdateResponse, isSuccess bool) (ou
|
||||
return outSkuIDs
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo, status int) (successList []*partner.StoreSkuInfo, err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo, status int) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
var skuVendibilityList []*jdapi.StockVendibility
|
||||
jdStatus := jxStoreSkuStatus2Jd(status)
|
||||
for _, v := range storeSkuList {
|
||||
@@ -124,16 +122,18 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID
|
||||
if globals.EnableJdStoreWrite {
|
||||
responseList, err2 := getAPI("").BatchUpdateVendibility(ctx.GetTrackInfo(), "", vendorStoreID, skuVendibilityList, ctx.GetUserName())
|
||||
if err = err2; isErrPartialFailed(err) {
|
||||
successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
|
||||
failedList = putils.SelectStoreSkuListByResponseList(storeSkuList, responseList)
|
||||
// successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
|
||||
}
|
||||
}
|
||||
return successList, err
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*tasksch.ErrMsg, err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
if len(storeSkuList) == 1 {
|
||||
if globals.EnableJdStoreWrite {
|
||||
_, err = getAPI("").UpdateStationPrice(ctx.GetTrackInfo(), utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), vendorStoreID, int(storeSkuList[0].VendorPrice))
|
||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
||||
}
|
||||
} else {
|
||||
var skuPriceInfoList []*jdapi.SkuPriceInfo
|
||||
@@ -146,18 +146,18 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
|
||||
if globals.EnableJdStoreWrite {
|
||||
responseList, err2 := getAPI("").UpdateVendorStationPrice(ctx.GetTrackInfo(), "", vendorStoreID, skuPriceInfoList)
|
||||
if err = err2; isErrPartialFailed(err) {
|
||||
successList := putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
|
||||
fmt.Println(successList)
|
||||
failedList = putils.SelectStoreSkuListByResponseList(storeSkuList, responseList)
|
||||
}
|
||||
}
|
||||
}
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (successList []*partner.StoreSkuInfo, err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
if len(storeSkuList) == 1 {
|
||||
if globals.EnableJdStoreWrite {
|
||||
err = getAPI("").UpdateCurrentQty(ctx.GetTrackInfo(), vendorStoreID, utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), storeSkuList[0].Stock)
|
||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
||||
}
|
||||
} else {
|
||||
var skuStockList []*jdapi.SkuStock
|
||||
@@ -170,11 +170,12 @@ func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID i
|
||||
if globals.EnableJdStoreWrite {
|
||||
responseList, err2 := getAPI("").BatchUpdateCurrentQtys(ctx.GetTrackInfo(), "", vendorStoreID, skuStockList, ctx.GetUserName())
|
||||
if err = err2; isErrPartialFailed(err) {
|
||||
successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
|
||||
failedList = putils.SelectStoreSkuListByResponseList(storeSkuList, responseList)
|
||||
// successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
|
||||
}
|
||||
}
|
||||
}
|
||||
return successList, err
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) SyncStoreProducts(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
|
||||
@@ -322,45 +322,48 @@ func storeSku2Mtwm(storeSkuList []*partner.StoreSkuInfo, updateType int) (skuLis
|
||||
return skuList
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo, status int) (successList []*partner.StoreSkuInfo, err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo, status int) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
skuList := storeSku2Mtwm(storeSkuList, updateTypeStatus)
|
||||
mtwmStatus := skuStatusJX2Mtwm(status)
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
failedFoodList, err2 := api.MtwmAPI.RetailSellStatus(ctx.GetTrackInfo(), vendorStoreID, skuList, mtwmStatus)
|
||||
if err = err2; err == nil {
|
||||
if len(failedFoodList) > 0 {
|
||||
successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
||||
}
|
||||
}
|
||||
}
|
||||
return successList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*tasksch.ErrMsg, err error) {
|
||||
priceList := storeSku2Mtwm(storeSkuList, updateTypePrice)
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
failedFoodList, err2 := api.MtwmAPI.RetailSkuPrice(ctx.GetTrackInfo(), vendorStoreID, priceList)
|
||||
if err = err2; err == nil {
|
||||
if len(failedFoodList) > 0 {
|
||||
failedList = putils.SelectStoreSkuListByFoodList(storeID, storeSkuList, failedFoodList)
|
||||
err = putils.GenPartialFailedErr(failedList, len(failedList))
|
||||
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, failedFoodList)
|
||||
// successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
||||
}
|
||||
}
|
||||
}
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (successList []*partner.StoreSkuInfo, err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
priceList := storeSku2Mtwm(storeSkuList, updateTypePrice)
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
failedFoodList, err2 := api.MtwmAPI.RetailSkuPrice(ctx.GetTrackInfo(), vendorStoreID, priceList)
|
||||
if err = err2; err == nil {
|
||||
if len(failedFoodList) > 0 {
|
||||
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, failedFoodList)
|
||||
}
|
||||
}
|
||||
}
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
stockList := storeSku2Mtwm(storeSkuList, updateTypeStock)
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
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))
|
||||
if len(failedFoodList) > 0 {
|
||||
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, failedFoodList)
|
||||
}
|
||||
// if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil {
|
||||
// successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
||||
// }
|
||||
}
|
||||
}
|
||||
return successList, err
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func mtwmSkuStatus2Jx(mtwmSkuStatus int) (jxSkuStatus int) {
|
||||
|
||||
Reference in New Issue
Block a user