- mtwm WaybillStatusDelivered
This commit is contained in:
@@ -1,5 +1,13 @@
|
|||||||
package mtwmapi
|
package mtwmapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
MsgTypeWaybillStatus = "waybillStatus"
|
MsgTypeWaybillStatus = "waybillStatus"
|
||||||
MsgTypeNewOrder = "newOrder"
|
MsgTypeNewOrder = "newOrder"
|
||||||
@@ -15,15 +23,40 @@ type CallbackResponse struct {
|
|||||||
Data string `json:"data"`
|
Data string `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// !!!特别注意,Data中的数据
|
||||||
|
type CallbackMsg struct {
|
||||||
|
Data url.Values
|
||||||
|
Cmd string
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
SuccessResponse = &CallbackResponse{Data: "ok"}
|
SuccessResponse = &CallbackResponse{Data: "ok"}
|
||||||
|
SignatureIsNotOk = &CallbackResponse{Data: "sign failed"}
|
||||||
)
|
)
|
||||||
|
|
||||||
func Err2CallbackResponse(err error, data string) *CallbackResponse {
|
func Err2CallbackResponse(err error, data string) *CallbackResponse {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return SuccessResponse
|
return SuccessResponse
|
||||||
}
|
}
|
||||||
|
if data == "" {
|
||||||
|
data = err.Error()
|
||||||
|
}
|
||||||
return &CallbackResponse{
|
return &CallbackResponse{
|
||||||
Data: data,
|
Data: data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *API) GetCallbackMsg(request *http.Request) (msg *CallbackMsg, callbackResponse *CallbackResponse) {
|
||||||
|
data := utils.URLValues2Map(request.PostForm)
|
||||||
|
fullURL := strings.TrimRight(request.URL.String(), "/")
|
||||||
|
sign := a.signParams(fullURL+"?", data)
|
||||||
|
if sign != data[signKey] {
|
||||||
|
return nil, SignatureIsNotOk
|
||||||
|
}
|
||||||
|
cmd := strings.Trim(request.URL.EscapedPath(), "/")
|
||||||
|
msg = &CallbackMsg{
|
||||||
|
Cmd: cmd,
|
||||||
|
Data: request.PostForm,
|
||||||
|
}
|
||||||
|
return msg, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ const (
|
|||||||
WaybillStatusAccepted = "10"
|
WaybillStatusAccepted = "10"
|
||||||
WaybillStatusCourierArrived = "15"
|
WaybillStatusCourierArrived = "15"
|
||||||
WaybillStatusPickedup = "20"
|
WaybillStatusPickedup = "20"
|
||||||
|
WaybillStatusDelivered = "40"
|
||||||
WaybillStatusCanceled = "100"
|
WaybillStatusCanceled = "100"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user