- mtwm callback

This commit is contained in:
gazebo
2018-11-29 09:59:08 +08:00
parent de110daf0b
commit 9e276a01c9
3 changed files with 35 additions and 12 deletions

View File

@@ -7,15 +7,19 @@ import (
)
func OnOrderCallbackMsg(msg *mtwmapi.CallbackMsg) (response *mtwmapi.CallbackResponse) {
orderID := GetOrderIDFromMsg(msg)
jxutils.CallMsgHandler(func() {
switch msg.Cmd {
case mtwmapi.MsgTypeWaybillStatus:
response = curPurchaseHandler.onWaybillMsg(msg)
default:
response = curPurchaseHandler.onOrderMsg(msg)
}
}, jxutils.ComposeUniversalOrderID(orderID, model.VendorIDMTWM))
if msg.Cmd == mtwmapi.MsgTypePrivateNumberDowngrade {
response = mtwmapi.SuccessResponse
} else {
orderID := GetOrderIDFromMsg(msg)
jxutils.CallMsgHandler(func() {
switch msg.Cmd {
case mtwmapi.MsgTypeWaybillStatus:
response = curPurchaseHandler.onWaybillMsg(msg)
default:
response = curPurchaseHandler.onOrderMsg(msg)
}
}, jxutils.ComposeUniversalOrderID(orderID, model.VendorIDMTWM))
}
return response
}

View File

@@ -11,6 +11,12 @@ import (
"git.rosy.net.cn/jx-callback/globals/api"
)
const (
FakeOrderStatusModified = "10001"
FakeOrderStatusUserUrgeOrder = "10002"
FakeOrderStatusFinancial = "10003"
)
var (
VendorStatus2StatusMap = map[string]int{
mtwmapi.OrderStatusUserCommitted: model.OrderStatusUnknown,
@@ -21,6 +27,7 @@ var (
mtwmapi.OrderStatusDelivered: model.OrderStatusDelivered,
mtwmapi.OrderStatusFinished: model.OrderStatusFinished,
mtwmapi.OrderStatusCanceled: model.OrderStatusCanceled,
FakeOrderStatusModified: model.OrderStatusAdjust,
}
)
@@ -127,7 +134,19 @@ func (c *PurchaseHandler) onOrderMsg(msg *mtwmapi.CallbackMsg) (response *mtwmap
func (c *PurchaseHandler) callbackMsg2Status(msg *mtwmapi.CallbackMsg) *model.OrderStatus {
orderID := GetOrderIDFromMsg(msg)
vendorStatus := msg.Data.Get("status")
vendorStatus := ""
statusTime := time.Now().Unix()
switch msg.Cmd {
case mtwmapi.MsgTypeUserUrgeOrder:
vendorStatus = FakeOrderStatusUserUrgeOrder
case mtwmapi.MsgTypeOrderModified:
vendorStatus = FakeOrderStatusModified
case mtwmapi.MsgTypeOrderFinancial:
vendorStatus = FakeOrderStatusFinancial
default:
vendorStatus = msg.Data.Get("status")
statusTime = utils.Str2Int64(msg.Data.Get("utime"))
}
orderStatus := &model.OrderStatus{
VendorOrderID: orderID,
VendorID: model.VendorIDMTWM,
@@ -136,7 +155,7 @@ func (c *PurchaseHandler) callbackMsg2Status(msg *mtwmapi.CallbackMsg) *model.Or
RefVendorID: model.VendorIDMTWM,
VendorStatus: vendorStatus,
Status: c.GetStatusFromVendorStatus(vendorStatus),
StatusTime: getTimeFromTimestamp(utils.Str2Int64(msg.Data.Get("utime"))),
StatusTime: getTimeFromTimestamp(statusTime),
Remark: "",
}
return orderStatus

View File

@@ -29,7 +29,7 @@ func (c *MtwmController) NewOrder() {
c.onCallbackMsg(mtwmapi.MsgTypeNewOrder)
}
func (c *MtwmController) OrderAccpted() {
func (c *MtwmController) OrderAccepted() {
c.onCallbackMsg(mtwmapi.MsgTypeOrderAccepted)
}