- use Request.Body directly when handling jd msg.

This commit is contained in:
gazebo
2018-06-27 15:42:44 +08:00
parent e96e04ae0e
commit c00d00630e
3 changed files with 13 additions and 27 deletions

View File

@@ -2,7 +2,6 @@ package jdapi
import (
"fmt"
"net/http"
"net/url"
"git.rosy.net.cn/baseapi"
@@ -78,8 +77,8 @@ func (a *API) CheckCallbackValidation(values url.Values) (callbackResponse *Call
return nil
}
func (a *API) getCommonOrderCallbackMsg(request *http.Request, msg interface{}, needDecode bool) (callbackResponse *CallbackResponse) {
result, err := utils.HTTPRequest2Values(request, needDecode)
func (a *API) getCommonOrderCallbackMsg(data []byte, msg interface{}, needDecode bool) (callbackResponse *CallbackResponse) {
result, err := utils.HTTPBody2Values(data, needDecode)
if err != nil {
return FormatErrorResponse
}
@@ -95,20 +94,20 @@ func (a *API) getCommonOrderCallbackMsg(request *http.Request, msg interface{},
return nil
}
func (a *API) GetOrderCallbackMsg(request *http.Request) (msg *CallbackOrderMsg, callbackResponse *CallbackResponse) {
func (a *API) GetOrderCallbackMsg(data []byte) (msg *CallbackOrderMsg, callbackResponse *CallbackResponse) {
msg = new(CallbackOrderMsg)
callbackResponse = a.getCommonOrderCallbackMsg(request, msg, false)
callbackResponse = a.getCommonOrderCallbackMsg(data, msg, false)
return msg, callbackResponse
}
func (a *API) GetOrderApplyCancelCallbackMsg(request *http.Request) (msg *CallbackOrderMsg, callbackResponse *CallbackResponse) {
func (a *API) GetOrderApplyCancelCallbackMsg(data []byte) (msg *CallbackOrderMsg, callbackResponse *CallbackResponse) {
msg = new(CallbackOrderMsg)
callbackResponse = a.getCommonOrderCallbackMsg(request, msg, true)
callbackResponse = a.getCommonOrderCallbackMsg(data, msg, true)
return msg, callbackResponse
}
func (a *API) GetOrderDeliveryCallbackMsg(request *http.Request) (msg *CallbackDeliveryStatusMsg, callbackResponse *CallbackResponse) {
func (a *API) GetOrderDeliveryCallbackMsg(data []byte) (msg *CallbackDeliveryStatusMsg, callbackResponse *CallbackResponse) {
msg = new(CallbackDeliveryStatusMsg)
callbackResponse = a.getCommonOrderCallbackMsg(request, msg, true)
callbackResponse = a.getCommonOrderCallbackMsg(data, msg, true)
return msg, callbackResponse
}