diff --git a/business/jxcallback/scheduler/defsch/defsch.go b/business/jxcallback/scheduler/defsch/defsch.go index a4e326968..84cba0d80 100644 --- a/business/jxcallback/scheduler/defsch/defsch.go +++ b/business/jxcallback/scheduler/defsch/defsch.go @@ -356,34 +356,31 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo if (isBillExist || bill.WaybillVendorID != model.VendorIDDada) && !isPending { // todo 达达运单有错序的情况,临时看看 isBillAlreadyCandidate := s.isBillCandidate(order, bill) // todo 购买平台的运单,优先级最高,但这样写也可能带来问题,即在这个时间,因为之前3方已经接单,已经发出了转自送请求(而且可能成功了),所以加个状态判断 - if order.WaybillVendorID == model.VendorIDUnknown || + if !s.IsOrderHasWaybill(order) || (s.IsOrderPlatformWaybill(bill) && order.VendorID != order.WaybillVendorID && (order.DeliveryFlag&model.OrderDeliveryFlagMaskPurcahseDisabled) == 0) { if s.IsOrderHasWaybill(order) { // 进到这里的原因是,在这个时间点,购物平台物流已经抢单(但抢单消息还没有被收到)(比如:818810379000941) - globals.SugarLogger.Infof("OnWaybillStatusChanged orderID:%s purchase platform waybill arrvied later, may case problem", order.VendorOrderID) + globals.SugarLogger.Infof("OnWaybillStatusChanged orderID:%s purchase platform waybill arrvied later, may cause problem", order.VendorOrderID) } s.updateOrderByBill(order, bill, false) s.cancelOtherWaybills(savedOrderInfo, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime) - if !s.IsOrderPlatformWaybill(bill) { - if savedOrderInfo.storeDeliveryType == scheduler.StoreDeliveryTypeByStore { - s.SelfDeliverDelivering(savedOrderInfo.order, bill.CourierMobile) - } else { - s.swtich2SelfDeliverWithRetry(savedOrderInfo, bill, 2, 10*time.Second) - } + if !s.IsOrderPlatformWaybill(bill) && savedOrderInfo.storeDeliveryType != scheduler.StoreDeliveryTypeByStore { + s.swtich2SelfDeliverWithRetry(savedOrderInfo, bill, 2, 10*time.Second) } else if s.IsSpecialOrderPlatformWaybill(bill) { s.SelfDeliverDelivering(savedOrderInfo.order, bill.CourierMobile) + utils.CallFuncAsync(func() { + weixinmsg.NotifyWaybillStatus(bill, order, isBillAlreadyCandidate) + }) } } else if !s.isBillCandidate(order, bill) && bill.WaybillVendorID != order.VendorID { // 发生这种情况的原因就是两个接单事件几乎同时到达(来不及取消),也算正常 s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime) globals.SugarLogger.Infof("OnWaybillStatusChanged Accepted orderID:%s got multiple bill:%v", order.VendorOrderID, bill) } - if s.isBillCandidate(order, bill) && order.WaybillVendorID != order.VendorID { - if !isBillAlreadyCandidate || !s.isWaybillCourierSame(savedOrderInfo, bill) { - utils.CallFuncAsync(func() { - weixinmsg.NotifyWaybillStatus(bill, order, isBillAlreadyCandidate) - }) - } + if isBillAlreadyCandidate && !s.isWaybillCourierSame(savedOrderInfo, bill) && !s.IsOrderPlatformWaybill(bill) { + utils.CallFuncAsync(func() { + weixinmsg.NotifyWaybillStatus(bill, order, isBillAlreadyCandidate) + }) } } case model.WaybillStatusAcceptCanceled: @@ -422,7 +419,7 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo // 现在发现饿百取消订单后不会再创建运单了,所以饿百运单取消也允许直接创建三方运单 // 之前的条件是order.Status < model.OrderStatusDelivering,但像订单902322817000122确实有在配送中取消状态,改成非订单结束状态都可以 // OrderStatusFinishedPickup状态的订单依赖于TIMER重新建运单 - if order.Status >= model.OrderStatusDelivering && order.Status < model.OrderStatusEndBegin && (bill.WaybillVendorID != order.VendorID || order.VendorID == model.VendorIDEBAI) { + if order.Status >= model.OrderStatusFinishedPickup && order.Status < model.OrderStatusEndBegin && (bill.WaybillVendorID != order.VendorID || order.VendorID == model.VendorIDEBAI) { s.createWaybillOn3rdProviders(savedOrderInfo, nil) } } @@ -582,6 +579,9 @@ func (s *DefScheduler) swtich2SelfDeliverWithRetry(savedOrderInfo *WatchOrderInf partner.CurOrderManager.OnOrderMsg(order, "转商家自配送", errStr) } } else { + utils.CallFuncAsync(func() { + weixinmsg.NotifyWaybillStatus(bill, order, false) + }) s.removeWaybillFromMap(savedOrderInfo, order.VendorID) } } else { diff --git a/business/partner/purchase/ebai/order_test.go b/business/partner/purchase/ebai/order_test.go index b6a00d014..d39be9df4 100644 --- a/business/partner/purchase/ebai/order_test.go +++ b/business/partner/purchase/ebai/order_test.go @@ -7,7 +7,7 @@ import ( ) func TestGetOrder4PartRefund(t *testing.T) { - order, err := new(PurchaseHandler).GetOrder4PartRefund("1556530656022029520") + order, err := new(PurchaseHandler).GetOrder4PartRefund("1556529608021993938") if err != nil { t.Fatal(err.Error()) } else {