京东门店商品操作部分失败时,添加门店信息提示
This commit is contained in:
@@ -2,6 +2,7 @@ package jdapi
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
@@ -111,7 +112,7 @@ func (a *API) UpdateVendorStationPrice(trackInfo string, outStationNo, stationNo
|
||||
result, err := a.AccessAPINoPage2("venderprice/updateStationPrice", jdParams, nil, nil, genNoPageResultParser("code", "msg", "result", "0"), trackInfo)
|
||||
if result != nil {
|
||||
var err2 error
|
||||
if responseList, err2 = a.handleBatchOpResult(len(skuPriceInfoList), err, result, "json2"); err2 != nil && err == nil {
|
||||
if responseList, err2 = a.handleBatchOpResult(outStationNo, stationNo, len(skuPriceInfoList), err, result, "json2"); err2 != nil && err == nil {
|
||||
err = err2
|
||||
}
|
||||
}
|
||||
@@ -148,7 +149,7 @@ func (a *API) GetStationInfoList(stationNo string, skuIds []int64) (priceInfo []
|
||||
return priceInfo, err
|
||||
}
|
||||
|
||||
func (a *API) handleBatchOpResult(batchCount int, inErr error, result interface{}, tagName string) (responseList []*StoreSkuBatchUpdateResponse, err error) {
|
||||
func (a *API) handleBatchOpResult(outStationNo, stationNo string, batchCount int, inErr error, result interface{}, tagName string) (responseList []*StoreSkuBatchUpdateResponse, err error) {
|
||||
if result != nil {
|
||||
if err = utils.Map2Struct(result, &responseList, true, tagName); err == nil {
|
||||
var failedList []*StoreSkuBatchUpdateResponse
|
||||
@@ -157,10 +158,19 @@ func (a *API) handleBatchOpResult(batchCount int, inErr error, result interface{
|
||||
failedList = append(failedList, v)
|
||||
}
|
||||
}
|
||||
var err2 *utils.ErrorWithCode
|
||||
if len(failedList) >= batchCount {
|
||||
err = utils.NewErrorCode(string(utils.MustMarshal(failedList)), ResponseCodeAccessFailed, 1) // 此错误基本用不到
|
||||
err2 = utils.NewErrorCode(string(utils.MustMarshal(failedList)), ResponseCodeAccessFailed, 1) // 此错误基本用不到
|
||||
} else if len(failedList) > 0 { // 部分失败
|
||||
err = utils.NewErrorCode(string(utils.MustMarshal(failedList)), ResponseInnerCodePartialFailed, 1)
|
||||
err2 = utils.NewErrorCode(string(utils.MustMarshal(failedList)), ResponseInnerCodePartialFailed, 1)
|
||||
}
|
||||
if err2 != nil {
|
||||
if stationNo != "" {
|
||||
err2.AddPrefixMsg(fmt.Sprintf("stationNo:%s", stationNo))
|
||||
} else if outStationNo != "" {
|
||||
err2.AddPrefixMsg(fmt.Sprintf("outStationNo:%s", outStationNo))
|
||||
}
|
||||
err = err2
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,7 +195,7 @@ func (a *API) BatchUpdateCurrentQtys(trackInfo, outStationNo, stationNo string,
|
||||
result, err := a.AccessAPINoPage2("stock/batchUpdateCurrentQtys", jdParams, nil, nil, genNoPageResultParser("retCode", "retMsg", "data", "0"), trackInfo)
|
||||
if result != nil {
|
||||
var err2 error
|
||||
if responseList, err2 = a.handleBatchOpResult(len(skuStockList), err, result, ""); err2 != nil && err == nil {
|
||||
if responseList, err2 = a.handleBatchOpResult(outStationNo, stationNo, len(skuStockList), err, result, ""); err2 != nil && err == nil {
|
||||
err = err2
|
||||
}
|
||||
}
|
||||
@@ -235,7 +245,7 @@ func (a *API) UpdateVendibility(trackInfo string, listBaseStockCenterRequest []*
|
||||
result, err := a.AccessAPINoPage2("stock/updateVendibility", jdParams, nil, nil, genNoPageResultParser("retCode", "retMsg", "data", "0"), trackInfo)
|
||||
if result != nil {
|
||||
var err2 error
|
||||
if responseList, err2 = a.handleBatchOpResult(len(listBaseStockCenterRequest), err, result, ""); err2 != nil && err == nil {
|
||||
if responseList, err2 = a.handleBatchOpResult("", listBaseStockCenterRequest[0].StationNo, len(listBaseStockCenterRequest), err, result, ""); err2 != nil && err == nil {
|
||||
err = err2
|
||||
}
|
||||
}
|
||||
@@ -261,7 +271,7 @@ func (a *API) BatchUpdateVendibility(trackInfo, outStationNo, stationNo string,
|
||||
result, err := a.AccessAPINoPage2("stock/batchUpdateVendibility", jdParams, nil, nil, genNoPageResultParser("retCode", "retMsg", "data", "0"), trackInfo)
|
||||
if result != nil {
|
||||
var err2 error
|
||||
if responseList, err2 = a.handleBatchOpResult(len(stockVendibilityList), err, result, ""); err2 != nil && err == nil {
|
||||
if responseList, err2 = a.handleBatchOpResult(outStationNo, stationNo, len(stockVendibilityList), err, result, ""); err2 != nil && err == nil {
|
||||
err = err2
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user