- 当收到三方运单的接单消息时,只有自配送门店才会马上发信息消息,非自配送门店要到转自送成功后才发

- 收到运单取消后重建的条件从order.Status >= model.OrderStatusDelivering改为order.Status >= model.OrderStatusFinishedPickup
This commit is contained in:
gazebo
2019-05-01 10:46:36 +08:00
parent fa97e0b038
commit 3591e00636
2 changed files with 16 additions and 16 deletions

View File

@@ -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 {

View File

@@ -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 {