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.WaybillStatusPending: model.WaybillStatusPending, 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) err := partner.CurOrderManager.OnWaybillStatusChanged(waybill) if err == nil && waybill.Status == model.WaybillStatusDelivering { c.postFakeMsg(waybill.VendorOrderID, FakeMsgType, mtwmapi.OrderStatusDelivering) } return mtwmapi.Err2CallbackResponse(err, "") } func (c *PurchaseHandler) callbackMsg2Waybill(msg *mtwmapi.CallbackMsg) (retVal *model.Waybill) { orderID := GetOrderIDFromMsg(msg) vendorStatus := msg.FormData.Get("logistics_status") retVal = &model.Waybill{ VendorOrderID: orderID, OrderVendorID: model.VendorIDMTWM, VendorWaybillID: orderID, WaybillVendorID: model.VendorIDMTWM, CourierName: msg.FormData.Get("dispatcher_name"), CourierMobile: msg.FormData.Get("dispatcher_mobile"), VendorStatus: vendorStatus, Status: c.GetWaybillStatusFromVendorStatus(vendorStatus), StatusTime: getTimeFromTimestamp(utils.Str2Int64(msg.FormData.Get("time"))), Remark: "", VendorOrgCode: msg.AppID, } if retVal.StatusTime == utils.DefaultTimeValue { retVal.StatusTime = getTimeFromTimestamp(utils.Str2Int64(msg.FormData.Get("timestamp"))) } return retVal }