From edfbf7565acbb3b892ca87924311382d5c1c90d5 Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 17 Oct 2019 16:05:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=AC=E4=B8=9C=E9=97=A8=E5=BA=97=E5=95=86?= =?UTF-8?q?=E5=93=81=E6=93=8D=E4=BD=9C=E9=83=A8=E5=88=86=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=B7=BB=E5=8A=A0=E9=97=A8=E5=BA=97=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/jdapi/store_sku.go | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/platformapi/jdapi/store_sku.go b/platformapi/jdapi/store_sku.go index cee2f4cf..2784e4a2 100644 --- a/platformapi/jdapi/store_sku.go +++ b/platformapi/jdapi/store_sku.go @@ -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 } }