|
@@ -6,16 +6,13 @@ import (
|
|
|
"fmt"
|
|
|
"gd_vehicle/apis"
|
|
|
"gd_vehicle/errors"
|
|
|
- "gd_vehicle/thirdparty"
|
|
|
+ "gd_vehicle/rpc_apis"
|
|
|
+ dutils "gd_vehicle/utils"
|
|
|
"strconv"
|
|
|
"time"
|
|
|
|
|
|
"gd_vehicle/common.in/jsonrpc2"
|
|
|
-
|
|
|
- dutils "gd_vehicle/utils"
|
|
|
-
|
|
|
- jsoniter "github.com/json-iterator/go"
|
|
|
- "github.com/tidwall/gjson"
|
|
|
+ "gd_vehicle/common.in/utils"
|
|
|
"go.uber.org/zap"
|
|
|
)
|
|
|
|
|
@@ -55,44 +52,43 @@ func (a *Adm) Request() (reply string, err error) {
|
|
|
}
|
|
|
}()
|
|
|
|
|
|
+ req := apis.QueryRequest{}
|
|
|
+ req.Code = a.Code
|
|
|
+ params, _ := json.Marshal(a.Params)
|
|
|
+ req.Params = string(params)
|
|
|
lReq := &apis.ThirdpartLogWrite{ProviderApiId: a.Provider.ProviderApiId, ProviderCode: a.Provider.ProviderApiCode}
|
|
|
startTime := uint64(time.Now().UnixNano())
|
|
|
defer dutils.AppendLog(a.LReqs, lReq, startTime)
|
|
|
-
|
|
|
- lReq.RequestParams, _ = jsoniter.MarshalToString(a.Params)
|
|
|
-
|
|
|
- result, err := thirdparty.Adm(a.Ctx, a.Code, a.Params, a.Provider)
|
|
|
+ lReq.RequestParams = req.Params
|
|
|
+ ret, err := rpc_apis.AdmData.Query(context.Background(), &req)
|
|
|
if err != nil {
|
|
|
- l.Error("thridPart",
|
|
|
- zap.String("call", a.Provider.ThirdpartHost+"/"+a.Provider.ThirdpartApiRouter),
|
|
|
- zap.String("args", a.Code),
|
|
|
- zap.String("error", err.Error()))
|
|
|
- lReq.ResponseParams = err.Error()
|
|
|
- dutils.SetAccessLogReqCodeMsgState(lReq, 20002, "gd_20002", "三方错误,请求失败", false)
|
|
|
- return reply, errors.VendorError
|
|
|
- }
|
|
|
-
|
|
|
- lReq.ResponseParams = string(result)
|
|
|
+ var e jsonrpc2.Error
|
|
|
+ merr := json.Unmarshal([]byte(err.Error()), &e)
|
|
|
+ if merr != nil {
|
|
|
+ l.Error("func",
|
|
|
+ zap.String("call", "Query"),
|
|
|
+ zap.String("args", utils.MarshalJsonString(req)),
|
|
|
+ zap.String("error", err.Error()))
|
|
|
+ lReq.ResponseParams = err.Error()
|
|
|
+ dutils.SetAccessLogReqCodeMsgState(lReq, 1101, "gd_1101", "三方错误,请求失败", false)
|
|
|
+ } else {
|
|
|
+
|
|
|
+ lReq.ResponseParams = err.Error()
|
|
|
+ if e.Code == 11004 {
|
|
|
+ dutils.SetAccessLogReqCodeMsgState(lReq, 1100, "gd_1100", "无数据", false)
|
|
|
+ } else {
|
|
|
+ l.Error("func",
|
|
|
+ zap.String("call", "Query"),
|
|
|
+ zap.String("args", utils.MarshalJsonString(req)),
|
|
|
+ zap.String("error", err.Error()))
|
|
|
+ dutils.SetAccessLogReqCodeMsgState(lReq, e.Code, "gd_1101", "三方错误,请求失败", false)
|
|
|
+ }
|
|
|
|
|
|
- code := gjson.Get(string(result), "code").Int()
|
|
|
- if code != 0 {
|
|
|
- c := int(code)
|
|
|
- if code == 11004 {
|
|
|
- c = 1100
|
|
|
}
|
|
|
-
|
|
|
- dutils.SetAccessLogReqCodeMsgState(
|
|
|
- lReq,
|
|
|
- c,
|
|
|
- strconv.Itoa(int(code)),
|
|
|
- gjson.Get(string(result), "message").String(),
|
|
|
- false,
|
|
|
- )
|
|
|
- return reply, errors.NoRecord
|
|
|
+ return "", errors.VendorError
|
|
|
}
|
|
|
-
|
|
|
+ reply = ret.Data
|
|
|
+ lReq.ResponseParams = ret.Data
|
|
|
dutils.SetAccessLogReqCodeMsgState(lReq, 0, "0", "成功", true)
|
|
|
- reply = gjson.Get(string(result), "data").String()
|
|
|
-
|
|
|
return
|
|
|
}
|