- ebai waybill

This commit is contained in:
gazebo
2018-11-15 17:44:27 +08:00
parent 1f4e9f3813
commit 74d1a44306

View File

@@ -5,6 +5,7 @@ import (
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/partner"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
)
@@ -33,30 +34,30 @@ func (p *PurchaseHandler) GetWaybillStatusFromVendorStatus(vendorStatus string)
func (c *PurchaseHandler) onWaybillMsg(msg *ebaiapi.CallbackMsg) (retVal *ebaiapi.CallbackResponse) {
order := c.callbackMsg2Waybill(msg)
globals.SugarLogger.Debugf("ebai onWaybillMsg orderID:%s", order.VendorOrderID)
if order.Status == model.WaybillStatusAccepted {
if result, err := api.EbaiAPI.OrderGet(order.VendorOrderID); err != nil {
if result, err := api.EbaiAPI.OrderDeliveryGet(order.VendorOrderID); err != nil {
globals.SugarLogger.Warnf("ebai onWaybillMsg orderID:%s TestOrderDeliveryGet failed with error:%v", order.VendorOrderID, err)
return api.EbaiAPI.Err2CallbackResponse(msg.Cmd, err, order.VendorOrderID)
} else {
order.CourierMobile = utils.Interface2String(result["order"].(map[string]interface{})["delivery_phone"])
order.CourierName = utils.Interface2String(result["name"])
order.CourierMobile = utils.Interface2String(result["phone"])
}
}
return api.EbaiAPI.Err2CallbackResponse(msg.Cmd, partner.CurOrderManager.OnWaybillStatusChanged(order), order.VendorStatus)
}
func (c *PurchaseHandler) callbackMsg2Waybill(msg *ebaiapi.CallbackMsg) (retVal *model.Waybill) {
body := msg.Body
vendorStatus := utils.Int64ToStr(utils.MustInterface2Int64(body["status"]))
orderID := utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["order_id"]))
vendorStatus := utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["status"]))
orderID := GetOrderIDFromMsg(msg)
retVal = &model.Waybill{
VendorOrderID: orderID,
OrderVendorID: model.VendorIDEBAI,
VendorWaybillID: orderID,
WaybillVendorID: model.VendorIDEBAI,
Status: c.GetWaybillStatusFromVendorStatus(vendorStatus),
CourierName: "", // 饿百取不到骑手的名字
// CourierMobile: msg.Phone,
VendorStatus: vendorStatus,
StatusTime: utils.Timestamp2Time(msg.Timestamp),
VendorStatus: vendorStatus,
StatusTime: utils.Timestamp2Time(msg.Timestamp),
}
return retVal
}