- 修复转自配送后收到运单接受消息处理错误问题
This commit is contained in:
@@ -115,11 +115,6 @@ func (s *WatchOrderInfo) updateOrderStoreFeature(order *model.GoodsOrder) (err e
|
||||
s.autoPickupTimeoutMinute = int(storeMap.AutoPickup)
|
||||
s.storeDeliveryType = FixedScheduler.GetStoreDeliveryType(order, storeMap)
|
||||
globals.SugarLogger.Debugf("updateOrderStoreFeature orderID:%s, s.storeDeliveryType:%d", order.VendorOrderID, s.storeDeliveryType)
|
||||
// if s.storeDeliveryType == scheduler.StoreDeliveryTypeByStore && (order.DeliveryFlag&model.OrderDeliveryFlagMaskPurcahseDisabled) == 0 {
|
||||
// order.DeliveryFlag |= model.OrderDeliveryFlagMaskPurcahseDisabled
|
||||
// err = partner.CurOrderManager.UpdateOrderStatusAndFlag(order)
|
||||
// }
|
||||
// globals.SugarLogger.Debugf("updateOrderStoreFeature orderID:%s, s.storeDeliveryType:%d, order.DeliveryFlag:%d", order.VendorOrderID, s.storeDeliveryType, order.DeliveryFlag)
|
||||
}
|
||||
return err
|
||||
}
|
||||
@@ -570,39 +565,37 @@ func (s *DefScheduler) cancelOtherWaybills(savedOrderInfo *WatchOrderInfo, bill2
|
||||
func (s *DefScheduler) swtich2SelfDeliverWithRetry(savedOrderInfo *WatchOrderInfo, bill *model.Waybill, retryCount int, duration time.Duration) {
|
||||
order := savedOrderInfo.order
|
||||
globals.SugarLogger.Debugf("swtich2SelfDeliverWithRetry orderID:%s", order.VendorOrderID)
|
||||
if (order.DeliveryFlag & model.OrderDeliveryFlagMaskPurcahseDisabled) == 0 {
|
||||
if order.WaybillVendorID != order.VendorID {
|
||||
if err := s.Swtich2SelfDeliver(order, ""); err != nil && err != scheduler.ErrOrderStatusAlreadySatisfyCurOperation {
|
||||
globals.SugarLogger.Infof("swtich2SelfDeliverWithRetry failed, bill:%v, err:%v", bill, err)
|
||||
if retryCount > 0 {
|
||||
utils.AfterFuncWithRecover(duration, func() {
|
||||
jxutils.CallMsgHandlerAsync(func() {
|
||||
s.swtich2SelfDeliverWithRetry(savedOrderInfo, bill, retryCount-1, duration)
|
||||
}, order.VendorOrderID)
|
||||
})
|
||||
} else {
|
||||
errStr := fmt.Sprintf("订单:%s转自配送失败, 错误信息:%v", order.VendorOrderID, err)
|
||||
globals.SugarLogger.Info(errStr)
|
||||
if s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonSwitch2SelfFailed, partner.CancelWaybillReasonStrSwitch2SelfFailed) == nil {
|
||||
// 转自送失败的取消,要将订单中的运单状态更新
|
||||
if s.isBillCandidate(order, bill) {
|
||||
bill.WaybillVendorID = model.VendorIDUnknown
|
||||
s.updateOrderByBill(order, bill, false)
|
||||
}
|
||||
}
|
||||
partner.CurOrderManager.OnOrderMsg(order, "转商家自配送", errStr)
|
||||
}
|
||||
} else {
|
||||
utils.CallFuncAsync(func() {
|
||||
weixinmsg.NotifyWaybillStatus(bill, order, false)
|
||||
if order.WaybillVendorID != order.VendorID {
|
||||
if err := s.Swtich2SelfDeliver(order, ""); err != nil && err != scheduler.ErrOrderStatusAlreadySatisfyCurOperation {
|
||||
globals.SugarLogger.Infof("swtich2SelfDeliverWithRetry failed, bill:%v, err:%v", bill, err)
|
||||
if retryCount > 0 {
|
||||
utils.AfterFuncWithRecover(duration, func() {
|
||||
jxutils.CallMsgHandlerAsync(func() {
|
||||
s.swtich2SelfDeliverWithRetry(savedOrderInfo, bill, retryCount-1, duration)
|
||||
}, order.VendorOrderID)
|
||||
})
|
||||
s.removeWaybillFromMap(savedOrderInfo, order.VendorID)
|
||||
} else {
|
||||
errStr := fmt.Sprintf("订单:%s转自配送失败, 错误信息:%v", order.VendorOrderID, err)
|
||||
globals.SugarLogger.Info(errStr)
|
||||
if s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonSwitch2SelfFailed, partner.CancelWaybillReasonStrSwitch2SelfFailed) == nil {
|
||||
// 转自送失败的取消,要将订单中的运单状态更新
|
||||
if s.isBillCandidate(order, bill) {
|
||||
bill.WaybillVendorID = model.VendorIDUnknown
|
||||
s.updateOrderByBill(order, bill, false)
|
||||
}
|
||||
}
|
||||
partner.CurOrderManager.OnOrderMsg(order, "转商家自配送", errStr)
|
||||
}
|
||||
} else {
|
||||
// 进到这里的原因是,在这个时间点,购物平台物流已经抢单(但抢单消息还没有被收到),所以转自送会失败 (比如:818810379000941),更好的做法应该是判断Swtich2SelfDeliver的返回值,这种情况下就不得试了
|
||||
globals.SugarLogger.Infof("swtich2SelfDeliverWithRetry orderID:%s status is wrong(maybe purchase platform accepted waybill)", order.VendorOrderID)
|
||||
// globals.SugarLogger.Warnf("swtich2SelfDeliverWithRetry orderID:%s status is wrong, order details:%v", order.VendorOrderID, order)
|
||||
utils.CallFuncAsync(func() {
|
||||
weixinmsg.NotifyWaybillStatus(bill, order, false)
|
||||
})
|
||||
s.removeWaybillFromMap(savedOrderInfo, order.VendorID)
|
||||
}
|
||||
} else {
|
||||
// 进到这里的原因是,在这个时间点,购物平台物流已经抢单(但抢单消息还没有被收到),所以转自送会失败 (比如:818810379000941),更好的做法应该是判断Swtich2SelfDeliver的返回值,这种情况下就不得试了
|
||||
globals.SugarLogger.Infof("swtich2SelfDeliverWithRetry orderID:%s status is wrong(maybe purchase platform accepted waybill)", order.VendorOrderID)
|
||||
// globals.SugarLogger.Warnf("swtich2SelfDeliverWithRetry orderID:%s status is wrong, order details:%v", order.VendorOrderID, order)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user