+mtwmapi.ErrCodeSuccess
This commit is contained in:
@@ -41,6 +41,7 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
ErrCodeSuccess = 0
|
||||
ErrCodeSysErr = 700 // 系统错误,按美团外卖技术支持的说法,可当成需重试的错误
|
||||
ErrCodeParameterFormatWrong = 705 // 参数格式错误
|
||||
ErrCodeAccessLimited = 711 // 接口调用过于频繁,触发流控,请降低调用频率
|
||||
@@ -176,16 +177,18 @@ func (a *API) AccessAPI2(cmd string, isGet bool, bizParams map[string]interface{
|
||||
retVal = jsonResult1
|
||||
}
|
||||
if errObj, ok := jsonResult1["error"]; ok {
|
||||
baseapi.SugarLogger.Debugf("mtwm AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
||||
errorInfo := errObj.(map[string]interface{})
|
||||
errCode := int(utils.MustInterface2Int64(errorInfo["code"]))
|
||||
newErr := utils.NewErrorIntCode(errorInfo["msg"].(string), errCode)
|
||||
if canRetryCodes[errCode] == 1 {
|
||||
return platformapi.ErrLevelExceedLimit, newErr
|
||||
} else if canRecoverCodes[errCode] == 1 {
|
||||
return platformapi.ErrLevelRecoverableErr, newErr
|
||||
} else if errCode != 0 {
|
||||
return platformapi.ErrLevelCodeIsNotOK, newErr
|
||||
if errCode != ErrCodeSuccess {
|
||||
baseapi.SugarLogger.Debugf("mtwm AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
||||
newErr := utils.NewErrorIntCode(errorInfo["msg"].(string), errCode)
|
||||
if canRetryCodes[errCode] == 1 {
|
||||
return platformapi.ErrLevelExceedLimit, newErr
|
||||
} else if canRecoverCodes[errCode] == 1 {
|
||||
return platformapi.ErrLevelRecoverableErr, newErr
|
||||
} else {
|
||||
return platformapi.ErrLevelCodeIsNotOK, newErr
|
||||
}
|
||||
}
|
||||
}
|
||||
return platformapi.ErrLevelSuccess, nil
|
||||
|
||||
@@ -612,7 +612,8 @@ func (a *API) GetOrderIdByDaySeqSingle(poiCode string, dateTime time.Time, daySe
|
||||
|
||||
// 订单流水号的开始序号,门店内每日的订单流水号都是从1开始。
|
||||
// 订单流水号的结束序号,注意开始流水号与结束流水号的跨度需小于100,即差值最大为99
|
||||
// 这个函数在给定的区间范围全部没有订单时,返回错误808,但如果有部分订单,返回的错误是0
|
||||
// 这个函数在给定的区间范围全部没有订单时,返回错误808,
|
||||
// 但如果有部分订单,底层返回的错误是0(然后被忽略),vendorOrderIDs只包含有效的订单号(数量少于seqEnd-seqStart+1)
|
||||
// 此API速度与查询的区间范围直接相关,越大越慢(即使订单不存在),最大可到4,5秒级别
|
||||
func (a *API) GetOrderIdByDaySeq(poiCode string, dateTime time.Time, seqStart, seqEnd int) (vendorOrderIDs []int64, err error) {
|
||||
params := map[string]interface{}{
|
||||
@@ -622,10 +623,12 @@ func (a *API) GetOrderIdByDaySeq(poiCode string, dateTime time.Time, seqStart, s
|
||||
"day_seq_end": seqEnd,
|
||||
}
|
||||
result, err := a.AccessAPI("ecommerce/order/getOrderIdByDaySeq", true, params)
|
||||
// 当前底层已经处理了错误0的情况了,不会返回错误0了
|
||||
if extErr, ok := err.(*utils.ErrorWithCode); err == nil || (ok && extErr.IntCode() == 0) {
|
||||
var data GetOrderIdByDaySeqResult
|
||||
if err2 := utils.UnmarshalUseNumber([]byte(utils.Interface2String(result)), &data); err2 == nil {
|
||||
vendorOrderIDs = data.OrderIDs
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
return vendorOrderIDs, err
|
||||
|
||||
Reference in New Issue
Block a user