From 490e7b96ca653468a1e201835622da9e8bbeee6c Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 9 Dec 2019 14:43:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BE=8E=E5=9B=A2=EF=BC=8C=E9=A5=BF=E7=99=BE?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E6=B7=BB=E5=8A=A0=E7=B3=BB=E7=BB=9F=E7=BA=A7?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/ebaiapi/callback.go | 22 +++++++++++++++++----- platformapi/mtwmapi/callback.go | 11 ++++++++++- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/platformapi/ebaiapi/callback.go b/platformapi/ebaiapi/callback.go index c7be08be..39bb5e3d 100644 --- a/platformapi/ebaiapi/callback.go +++ b/platformapi/ebaiapi/callback.go @@ -34,10 +34,16 @@ type CallbackResponse struct { } type CallbackMsg struct { - Cmd string `json:"cmd"` - Timestamp int64 `json:"timestamp"` - Body map[string]interface{} `json:"body"` - Data interface{} `json:"data"` + Cmd string `json:"cmd"` + Version string `json:"version"` + Timestamp int64 `json:"timestamp"` + Ticket string `json:"ticket"` + Source string `json:"source"` + Sign string `json:"sign"` + Encrypt string `json:"encrypt"` + + Body map[string]interface{} `json:"body"` + Data interface{} `json:"data"` } type CBPartRefundInfo struct { @@ -139,7 +145,13 @@ func (a *API) GetCallbackMsg(request *http.Request) (msg *CallbackMsg, callbackR if callbackResponse = a.unmarshalData(msg.Cmd, []byte(params.Get("body")), &msg.Body); callbackResponse != nil { return nil, callbackResponse } - msg.Timestamp = utils.Str2Int64(utils.Interface2String(params.Get("timestamp"))) + msg.Timestamp = utils.Str2Int64(params.Get("timestamp")) + msg.Version = params.Get("version") + msg.Ticket = params.Get("ticket") + msg.Source = params.Get("source") + msg.Sign = params.Get("sign") + msg.Encrypt = params.Get("encrypt") + var tmpObj interface{} switch msg.Cmd { case CmdOrderPartRefund: diff --git a/platformapi/mtwmapi/callback.go b/platformapi/mtwmapi/callback.go index 9353678e..d575673d 100644 --- a/platformapi/mtwmapi/callback.go +++ b/platformapi/mtwmapi/callback.go @@ -60,7 +60,12 @@ type CallbackRefundInfo struct { } type CallbackMsg struct { - Cmd string + Cmd string + + Timestamp int64 `json:"timestamp"` + AppID string `json:"app_id"` + Sig string `json:"sig"` + FormData url.Values Data interface{} } @@ -110,6 +115,10 @@ func (a *API) GetCallbackMsg(request *http.Request) (msg *CallbackMsg, callbackR } msg.FormData.Set(k, v.(string)) } + msg.Timestamp = utils.Str2Int64(msg.FormData.Get("timestamp")) + msg.Sig = dataSign.(string) + msg.AppID = msg.FormData.Get("app_id") + if msg.Cmd == MsgTypeOrderRefund || msg.Cmd == MsgTypeOrderPartialRefund { var refundData *CallbackRefundInfo if err = utils.Map2StructByJson(data, &refundData, true); err == nil {