83 lines
2.5 KiB
Go
83 lines
2.5 KiB
Go
package mtpsapi
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
)
|
|
|
|
type MtpsCallbackResponse struct {
|
|
Code string `json:"code"`
|
|
}
|
|
|
|
type MtpsCallbackCommon struct {
|
|
AppKey string
|
|
Timestamp int64
|
|
Sign string
|
|
}
|
|
|
|
type MtpsCallbackOrderMsg struct {
|
|
MtpsOrderInfoCommon
|
|
MtpsCallbackCommon
|
|
Status int
|
|
CancelReasonId int
|
|
CancelReason string
|
|
}
|
|
|
|
type MtpsCallbackOrderExceptionMsg struct {
|
|
MtpsOrderInfoCommon
|
|
MtpsCallbackCommon
|
|
ExceptionId int64
|
|
ExceptionCode int
|
|
ExceptionDescr string
|
|
ExceptionTime int64
|
|
}
|
|
|
|
var (
|
|
SuccessResponse = &MtpsCallbackResponse{Code: "0"}
|
|
)
|
|
|
|
func (m *MTPSAPI) GetOrderCallbackMsg(request *http.Request) (orderMsg *MtpsCallbackOrderMsg, callbackResponse *MtpsCallbackResponse) {
|
|
orderMsg = &MtpsCallbackOrderMsg{
|
|
MtpsOrderInfoCommon: MtpsOrderInfoCommon{
|
|
DeliveryId: utils.Str2Int64(request.FormValue("delivery_id")),
|
|
MtPeisongId: request.FormValue("mt_peisong_id"),
|
|
OrderId: request.FormValue("order_id"),
|
|
CourierName: request.FormValue("courier_name"),
|
|
CourierPhone: request.FormValue("courier_phone"),
|
|
},
|
|
MtpsCallbackCommon: MtpsCallbackCommon{
|
|
AppKey: request.FormValue("appkey"),
|
|
Timestamp: utils.Str2Int64(request.FormValue("timestamp")),
|
|
Sign: request.FormValue("sign"),
|
|
},
|
|
Status: int(utils.Str2Int64(request.FormValue("status"))),
|
|
CancelReasonId: int(utils.Str2Int64(request.FormValue("cancel_reason_id"))),
|
|
CancelReason: request.FormValue("cancel_reason"),
|
|
}
|
|
return orderMsg, nil
|
|
}
|
|
|
|
func (m *MTPSAPI) GetOrderExceptionCallbackMsg(request *http.Request) (orderMsg *MtpsCallbackOrderExceptionMsg, callbackResponse *MtpsCallbackResponse) {
|
|
orderMsg = &MtpsCallbackOrderExceptionMsg{
|
|
MtpsOrderInfoCommon: MtpsOrderInfoCommon{
|
|
DeliveryId: utils.Str2Int64(request.FormValue("delivery_id")),
|
|
MtPeisongId: request.FormValue("mt_peisong_id"),
|
|
OrderId: request.FormValue("order_id"),
|
|
CourierName: request.FormValue("courier_name"),
|
|
CourierPhone: request.FormValue("courier_phone"),
|
|
},
|
|
MtpsCallbackCommon: MtpsCallbackCommon{
|
|
AppKey: request.FormValue("appkey"),
|
|
Timestamp: utils.Str2Int64(request.FormValue("timestamp")),
|
|
Sign: request.FormValue("sign"),
|
|
},
|
|
ExceptionId: utils.Str2Int64(request.FormValue("exception_id")),
|
|
ExceptionCode: int(utils.Str2Int64(request.FormValue("exception_code"))),
|
|
ExceptionDescr: request.FormValue("exception_descr"),
|
|
ExceptionTime: utils.Str2Int64(request.FormValue("exception_time")),
|
|
}
|
|
|
|
return orderMsg, nil
|
|
}
|