Files
tyc-server-v2/app/main/api/internal/handler/tianyuan/vehiclecallbackhandler.go
2026-02-12 15:16:54 +08:00

34 lines
1022 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package tianyuan
import (
"net/http"
tianyuanlogic "tyc-server/app/main/api/internal/logic/tianyuan"
"tyc-server/app/main/api/internal/svc"
"tyc-server/common/result"
"github.com/zeromicro/go-zero/rest/httpx"
)
// VehicleCallbackHandler 天远车辆类接口异步回调入口
// 约定:第三方在回调 URL 上携带 order_no / api_id 等标识,例如:/api/v1/tianyuan/vehicle/callback?order_no=Q_xxx&api_id=QCXG1U4U
// 回调 Body 为该接口最终的 JSON 结果。
func VehicleCallbackHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
l := tianyuanlogic.NewVehicleCallbackLogic(r.Context(), svcCtx)
if err := l.Handle(r); err != nil {
// 对第三方尽量返回 200避免无限重试这里使用统一 result 封装错误
result.HttpResult(r, w, map[string]interface{}{
"code": 500,
"msg": "fail",
}, err)
return
}
httpx.OkJson(w, map[string]interface{}{
"code": 200,
"msg": "success",
})
}
}