- 清理三个平台的门店商品批处理操作,部分失败返回失败条目
This commit is contained in:
@@ -207,28 +207,23 @@ func (a *API) AccessAPI(apiStr string, jdParams map[string]interface{}) (retVal
|
||||
}
|
||||
|
||||
func genNoPageResultParser(codeKey, msgKey, resultKey, okCode string) func(data map[string]interface{}) (interface{}, error) {
|
||||
return func(data map[string]interface{}) (interface{}, error) {
|
||||
return func(data map[string]interface{}) (innerData interface{}, err error) {
|
||||
rawInnerCode, ok := data[codeKey]
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("genNoPageResultParser codeKey %s can not be found in result:%v", codeKey, data))
|
||||
}
|
||||
innerCode := forceInnerCode2Str(rawInnerCode)
|
||||
errMsg := formatErrorMsg(data[msgKey])
|
||||
if innerCode == okCode && errMsg != "调用订单中心修改承运商接口失败!" { // todo 京东的order/modifySellerDelivery在失败时也返回成功code,临时处理一下
|
||||
if resultKey != "" {
|
||||
if innerData, ok := data[resultKey]; ok {
|
||||
return innerData, nil
|
||||
}
|
||||
baseapi.SugarLogger.Warnf("genNoPageResultParser resultKey %s can not be found in result:%v", resultKey, utils.Format4Output(data, false))
|
||||
return nil, nil // 容错
|
||||
// panic(fmt.Sprintf("genNoPageResultParser resultKey %s can not be found in result:%v", resultKey, data))
|
||||
if resultKey != "" {
|
||||
innerData, _ = data[resultKey]
|
||||
}
|
||||
if innerCode != okCode {
|
||||
errMsg := formatErrorMsg(data[msgKey])
|
||||
if innerCode == ResponseInnerCodePartialFailed {
|
||||
errMsg += ", " + utils.Format4Output(innerData, true)
|
||||
}
|
||||
return nil, nil
|
||||
err = utils.NewErrorCode(errMsg, innerCode, 1)
|
||||
}
|
||||
if innerCode == ResponseInnerCodePartialFailed {
|
||||
errMsg += ", " + utils.Format4Output(data[resultKey], true)
|
||||
}
|
||||
return nil, utils.NewErrorCode(errMsg, innerCode, 1)
|
||||
return innerData, err
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user