- hack a jd bug, modifySellerDelivery return code 0 when failed.
This commit is contained in:
@@ -227,7 +227,8 @@ func genNoPageResultParser(codeKey, msgKey, resultKey, okCode string) func(data
|
||||
panic(fmt.Sprintf("genNoPageResultParser codeKey %s can not be found in result:%v", codeKey, data))
|
||||
}
|
||||
innerCode := forceInnerCode2Str(rawInnerCode)
|
||||
if innerCode == okCode {
|
||||
errMsg := formatErrorMsg(data[msgKey])
|
||||
if innerCode == okCode && errMsg != "调用订单中心修改承运商接口失败!" { // todo 京东的order/modifySellerDelivery在失败时也返回成功code,临时处理一下
|
||||
if resultKey != "" {
|
||||
if innerData, ok := data[resultKey]; ok {
|
||||
return innerData, nil
|
||||
@@ -238,17 +239,20 @@ func genNoPageResultParser(codeKey, msgKey, resultKey, okCode string) func(data
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
if msg, ok := data[msgKey]; ok {
|
||||
errMsg := utils.Format4Output(msg, true)
|
||||
if innerCode == ResponseInnerCodePartialFailed {
|
||||
errMsg += ", " + utils.Format4Output(data[resultKey], true)
|
||||
}
|
||||
return nil, utils.NewErrorCode(errMsg, innerCode, 1)
|
||||
if innerCode == ResponseInnerCodePartialFailed {
|
||||
errMsg += ", " + utils.Format4Output(data[resultKey], true)
|
||||
}
|
||||
panic(fmt.Sprintf("genNoPageResultParser msgKey %s can not be found in result:%v", msgKey, data))
|
||||
return nil, utils.NewErrorCode(errMsg, innerCode, 1)
|
||||
}
|
||||
}
|
||||
|
||||
func formatErrorMsg(msg interface{}) (strMsg string) {
|
||||
if msg != nil {
|
||||
strMsg = utils.Format4Output(msg, true)
|
||||
}
|
||||
return strMsg
|
||||
}
|
||||
|
||||
func (a *API) AccessAPINoPage(apiStr string, jdParams map[string]interface{}, keyToRemove, keyToKeep []string, resultParser func(data map[string]interface{}) (interface{}, error)) (interface{}, error) {
|
||||
if resultParser == nil {
|
||||
resultParser = genNoPageResultParser("code", "msg", "result", "0")
|
||||
|
||||
Reference in New Issue
Block a user