美团,饿百回调添加系统级参数

This commit is contained in:
gazebo
2019-12-09 14:43:09 +08:00
parent 460af4f42c
commit 490e7b96ca
2 changed files with 27 additions and 6 deletions

View File

@@ -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:

View File

@@ -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 {