- mtwm callback
This commit is contained in:
47
business/partner/purchase/mtwm/waybill.go
Normal file
47
business/partner/purchase/mtwm/waybill.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package mtwm
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
)
|
||||
|
||||
var (
|
||||
VendorWaybillStatus2StatusMap = map[string]int{
|
||||
mtwmapi.WaybillStatusWait4Delivery: model.WaybillStatusNew,
|
||||
mtwmapi.WaybillStatusAccepted: model.WaybillStatusAccepted,
|
||||
mtwmapi.WaybillStatusCourierArrived: model.WaybillStatusCourierArrived,
|
||||
mtwmapi.WaybillStatusPickedup: model.WaybillStatusDelivering,
|
||||
mtwmapi.WaybillStatusDelivered: model.WaybillStatusDelivered,
|
||||
mtwmapi.WaybillStatusCanceled: model.WaybillStatusCanceled,
|
||||
}
|
||||
)
|
||||
|
||||
func (p *PurchaseHandler) GetWaybillStatusFromVendorStatus(vendorStatus string) int {
|
||||
if status, ok := VendorWaybillStatus2StatusMap[vendorStatus]; ok {
|
||||
return status
|
||||
}
|
||||
return model.WaybillStatusUnknown
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) onWaybillMsg(msg *mtwmapi.CallbackMsg) (response *mtwmapi.CallbackResponse) {
|
||||
waybill := c.callbackMsg2Waybill(msg)
|
||||
return mtwmapi.Err2CallbackResponse(partner.CurOrderManager.OnWaybillStatusChanged(waybill), "")
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) callbackMsg2Waybill(msg *mtwmapi.CallbackMsg) (retVal *model.Waybill) {
|
||||
orderID := GetOrderIDFromMsg(msg)
|
||||
retVal = &model.Waybill{
|
||||
VendorOrderID: orderID,
|
||||
OrderVendorID: model.VendorIDMTWM,
|
||||
VendorWaybillID: orderID,
|
||||
WaybillVendorID: model.VendorIDMTWM,
|
||||
CourierName: msg.Data.Get("dispatcher_name"),
|
||||
CourierMobile: msg.Data.Get("dispatcher_mobile"),
|
||||
VendorStatus: msg.Data.Get("logistics_status"),
|
||||
StatusTime: getTimeFromTimestamp(utils.Str2Int64(msg.Data.Get("time"))),
|
||||
Remark: "",
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
Reference in New Issue
Block a user