From ce34e426c42a5a41bfc5bfe4c3cab0cb6f99bfc4 Mon Sep 17 00:00:00 2001 From: liangzai <2440983361@qq.com> Date: Thu, 12 Feb 2026 15:42:09 +0800 Subject: [PATCH] f --- .../logic/tianyuan/vehiclecallbacklogic.go | 3 +++ .../api/internal/service/apirequestService.go | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/app/main/api/internal/logic/tianyuan/vehiclecallbacklogic.go b/app/main/api/internal/logic/tianyuan/vehiclecallbacklogic.go index f887ba9..8689099 100644 --- a/app/main/api/internal/logic/tianyuan/vehiclecallbacklogic.go +++ b/app/main/api/internal/logic/tianyuan/vehiclecallbacklogic.go @@ -64,10 +64,13 @@ func (l *VehicleCallbackLogic) Handle(r *http.Request) error { ) } + l.Infof("tianyuan vehicle callback start, api_id=%s, order_no=%s", apiID, orderNo) + bodyBytes, err := io.ReadAll(r.Body) if err != nil { return errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "读取回调 Body 失败: %v", err) } + l.Infof("tianyuan vehicle callback body received, api_id=%s, order_no=%s, body_len=%d", apiID, orderNo, len(bodyBytes)) // 1. 根据订单号找到订单 order, err := l.svcCtx.OrderModel.FindOneByOrderNo(l.ctx, orderNo) diff --git a/app/main/api/internal/service/apirequestService.go b/app/main/api/internal/service/apirequestService.go index ad25329..a4551ca 100644 --- a/app/main/api/internal/service/apirequestService.go +++ b/app/main/api/internal/service/apirequestService.go @@ -51,6 +51,16 @@ func NewApiRequestService(c config.Config, featureModel model.FeatureModel, prod } } +// keysOfMap 返回 map 的 key 列表,便于 debug 日志展示参数结构而不是完整明文 +func keysOfMap(m map[string]interface{}) []string { + keys := make([]string, 0, len(m)) + for k := range m { + keys = append(keys, k) + } + sort.Strings(keys) + return keys +} + type APIResponseData struct { ApiID string `json:"apiID"` Data json.RawMessage `json:"data"` // 这里用 RawMessage 来存储原始的 data @@ -1221,6 +1231,7 @@ func (a *ApiRequestService) processVehicleApiPassThrough(params []byte, apiID st if err := json.Unmarshal(params, &m); err != nil { return nil, fmt.Errorf("api请求, %s, 解析参数失败: %w", apiID, err) } + logx.Infof("vehicle api passthrough, api_id=%s, params_keys=%v", apiID, keysOfMap(m)) resp, err := a.tianyuanapi.CallInterface(apiID, m) if err != nil { return nil, err @@ -1271,6 +1282,7 @@ func (a *ApiRequestService) ProcessQCXG1U4URequest(params []byte) ([]byte, error if body["vin_code"] == nil || body["image_url"] == nil || orderNo == "" { return nil, errors.New("api请求, QCXG1U4U, 缺少必填参数 vin_code/image_url/order_no") } + logx.Infof("vehicle api request QCXG1U4U, order_no=%s, vin_code=%v, image_url=%v", orderNo, body["vin_code"], body["image_url"]) body["return_url"] = a.buildVehicleCallbackURL(orderNo, "QCXG1U4U") resp, err := a.tianyuanapi.CallInterface("QCXG1U4U", body) if err != nil { @@ -1284,6 +1296,7 @@ func (a *ApiRequestService) ProcessQCXGY7F2Request(params []byte) ([]byte, error if body["vin_code"] == nil || body["vehicle_location"] == nil || body["first_registrationdate"] == nil { return nil, errors.New("api请求, QCXGY7F2, 缺少必填参数 vin_code/vehicle_location/first_registrationdate") } + logx.Infof("vehicle api request QCXGY7F2, vin_code=%v, vehicle_location=%v, first_registrationdate=%v", body["vin_code"], body["vehicle_location"], body["first_registrationdate"]) resp, err := a.tianyuanapi.CallInterface("QCXGY7F2", body) if err != nil { return nil, err @@ -1321,6 +1334,7 @@ func (a *ApiRequestService) ProcessQCXG3Y6BRequest(params []byte) ([]byte, error if body["vin_code"] == nil || orderNo == "" { return nil, errors.New("api请求, QCXG3Y6B, 缺少必填参数 vin_code/order_no") } + logx.Infof("vehicle api request QCXG3Y6B, order_no=%s, vin_code=%v", orderNo, body["vin_code"]) body["return_url"] = a.buildVehicleCallbackURL(orderNo, "QCXG3Y6B") resp, err := a.tianyuanapi.CallInterface("QCXG3Y6B", body) if err != nil { @@ -1335,6 +1349,7 @@ func (a *ApiRequestService) ProcessQCXG3Z3LRequest(params []byte) ([]byte, error if body["vin_code"] == nil || orderNo == "" { return nil, errors.New("api请求, QCXG3Z3L, 缺少必填参数 vin_code/order_no") } + logx.Infof("vehicle api request QCXG3Z3L, order_no=%s, vin_code=%v", orderNo, body["vin_code"]) body["return_url"] = a.buildVehicleCallbackURL(orderNo, "QCXG3Z3L") resp, err := a.tianyuanapi.CallInterface("QCXG3Z3L", body) if err != nil { @@ -1350,6 +1365,7 @@ func (a *ApiRequestService) ProcessQCXGP00WRequest(params []byte) ([]byte, error if !vin.Exists() || vin.String() == "" || orderNo == "" || !vlphoto.Exists() || vlphoto.String() == "" { return nil, errors.New("api请求, QCXGP00W, 缺少必填参数 vin_code/order_no/vlphoto_data") } + logx.Infof("vehicle api request QCXGP00W, order_no=%s, vin_code=%s, vlphoto_data_len=%d", orderNo, vin.String(), len(vlphoto.String())) key, err := hex.DecodeString(a.config.Encrypt.SecretKey) if err != nil { return nil, fmt.Errorf("api请求, QCXGP00W, 密钥解析失败: %w", err) @@ -1395,6 +1411,7 @@ func (a *ApiRequestService) processVerifyPassThrough(params []byte, apiID string if err := json.Unmarshal(params, &m); err != nil { return nil, fmt.Errorf("api请求, %s, 解析参数失败: %w", apiID, err) } + logx.Infof("verify api passthrough, api_id=%s, params_keys=%v", apiID, keysOfMap(m)) resp, err := a.tianyuanapi.CallInterface(apiID, m) if err != nil { return nil, err