fix
This commit is contained in:
parent
b9ca357448
commit
32fcdd7ad1
@ -112,7 +112,7 @@ func (l *PaySuccessNotifyUserHandler) ProcessTask(ctx context.Context, t *asynq.
|
|||||||
func (l *PaySuccessNotifyUserHandler) handleError(ctx context.Context, err error, order *model.Order, query *model.Query) error {
|
func (l *PaySuccessNotifyUserHandler) handleError(ctx context.Context, err error, order *model.Order, query *model.Query) error {
|
||||||
logx.Errorf("处理任务失败,原因: %v", err)
|
logx.Errorf("处理任务失败,原因: %v", err)
|
||||||
|
|
||||||
if order.Status == "paid" && query.QueryState == model.QueryStatePending {
|
if order.Status == "paid" && query.QueryState == model.QueryStateProcessing {
|
||||||
// 更新查询状态为失败
|
// 更新查询状态为失败
|
||||||
query.QueryState = model.QueryStateFailed
|
query.QueryState = model.QueryStateFailed
|
||||||
updateQueryErr := l.svcCtx.QueryModel.UpdateWithVersion(ctx, nil, query)
|
updateQueryErr := l.svcCtx.QueryModel.UpdateWithVersion(ctx, nil, query)
|
||||||
|
@ -894,14 +894,14 @@ func (a *ApiRequestService) ProcessCAR059Request(ctx context.Context, params []b
|
|||||||
logx.Infof("车辆维保记录查询任务,订单号: %s, 未查询到结果,需要重试", orderID.String())
|
logx.Infof("车辆维保记录查询任务,订单号: %s, 未查询到结果,需要重试", orderID.String())
|
||||||
|
|
||||||
// 检查重试次数
|
// 检查重试次数
|
||||||
maxRetries := 10
|
maxRetries := 56
|
||||||
if retryCount >= maxRetries {
|
if retryCount >= maxRetries {
|
||||||
return nil, fmt.Errorf("车辆维保记录查询任务已达最大重试次数 %d,停止重试,订单号: %s",
|
return nil, fmt.Errorf("车辆维保记录查询任务已达最大重试次数 %d,停止重试,订单号: %s",
|
||||||
maxRetries, orderID.String())
|
maxRetries, orderID.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
// 固定延迟时间为15秒
|
// 固定延迟时间为15秒
|
||||||
fixedDelay := 15 * time.Second
|
fixedDelay := 30 * time.Second
|
||||||
|
|
||||||
// 检查ctx是否已经有超时
|
// 检查ctx是否已经有超时
|
||||||
deadline, hasDeadline := ctx.Deadline()
|
deadline, hasDeadline := ctx.Deadline()
|
||||||
@ -946,8 +946,8 @@ func (a *ApiRequestService) ProcessCAR059Request(ctx context.Context, params []b
|
|||||||
}
|
}
|
||||||
return nil, fmt.Errorf("车辆维保记录结果查询失败: %+v", err)
|
return nil, fmt.Errorf("车辆维保记录结果查询失败: %+v", err)
|
||||||
}
|
}
|
||||||
logx.Infof("车辆维保记录查询任务完成,订单号: %s, 结果数据长度: %d",
|
logx.Infof("车辆维保记录查询任务完成,订单号: %s",
|
||||||
orderID.String(), len(resp))
|
orderID.String())
|
||||||
return &APIInternalResult{
|
return &APIInternalResult{
|
||||||
Data: resp,
|
Data: resp,
|
||||||
}, nil
|
}, nil
|
||||||
@ -1415,7 +1415,7 @@ func (a *ApiRequestService) ProcessCOM187Request(ctx context.Context, params []b
|
|||||||
"keyword": name.String(),
|
"keyword": name.String(),
|
||||||
}
|
}
|
||||||
resp, err := a.yushanService.request("COM187", request)
|
resp, err := a.yushanService.request("COM187", request)
|
||||||
if err != nil {
|
if err != nil && err != ErrEmptyResult {
|
||||||
return nil, fmt.Errorf("出境限制查询失败: %+v", err)
|
return nil, fmt.Errorf("出境限制查询失败: %+v", err)
|
||||||
}
|
}
|
||||||
return &APIInternalResult{
|
return &APIInternalResult{
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -12,6 +11,8 @@ import (
|
|||||||
"qnc-server/pkg/lzkit/crypto"
|
"qnc-server/pkg/lzkit/crypto"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type WestResp struct {
|
type WestResp struct {
|
||||||
@ -99,7 +100,6 @@ func (w *WestDexService) CallAPI(code string, reqData map[string]interface{}) (r
|
|||||||
return nil, DecryptErr
|
return nil, DecryptErr
|
||||||
}
|
}
|
||||||
return decryptedData, errors.New(westDexResp.Message)
|
return decryptedData, errors.New(westDexResp.Message)
|
||||||
log.Println(string(decryptedData))
|
|
||||||
}
|
}
|
||||||
if westDexResp.Data == "" {
|
if westDexResp.Data == "" {
|
||||||
return nil, errors.New(westDexResp.Message)
|
return nil, errors.New(westDexResp.Message)
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -28,6 +29,11 @@ func NewYushanService(c config.Config) *YushanService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// ErrEmptyResult 表示查询结果为空
|
||||||
|
ErrEmptyResult = errors.New("查询结果为空")
|
||||||
|
)
|
||||||
|
|
||||||
func (y *YushanService) request(prodID string, params map[string]interface{}) ([]byte, error) {
|
func (y *YushanService) request(prodID string, params map[string]interface{}) ([]byte, error) {
|
||||||
// 获取当前时间戳
|
// 获取当前时间戳
|
||||||
unixMilliseconds := time.Now().UnixNano() / int64(time.Millisecond)
|
unixMilliseconds := time.Now().UnixNano() / int64(time.Millisecond)
|
||||||
@ -98,7 +104,7 @@ func (y *YushanService) request(prodID string, params map[string]interface{}) ([
|
|||||||
|
|
||||||
if retCode == "100000" {
|
if retCode == "100000" {
|
||||||
// retcode 为 100000,表示查询为空
|
// retcode 为 100000,表示查询为空
|
||||||
return respData, fmt.Errorf("羽山请求查空: %s", string(respData))
|
return json.RawMessage("{}"), ErrEmptyResult
|
||||||
} else if retCode == "000000" || retCode == "000001" || retCode == "000002" || retCode == "000003" {
|
} else if retCode == "000000" || retCode == "000001" || retCode == "000002" || retCode == "000003" {
|
||||||
// retcode 为 000000,表示有数据,返回 retdata
|
// retcode 为 000000,表示有数据,返回 retdata
|
||||||
retData := gjson.GetBytes(respData, "retdata")
|
retData := gjson.GetBytes(respData, "retdata")
|
||||||
|
Loading…
Reference in New Issue
Block a user