- 修复转自配送后收到运单接受消息处理错误问题
This commit is contained in:
@@ -55,17 +55,16 @@ func (c *BaseScheduler) PickupGoods(order *model.GoodsOrder, isSelfDelivery bool
|
|||||||
|
|
||||||
func (c *BaseScheduler) Swtich2SelfDeliver(order *model.GoodsOrder, userName string) (err error) {
|
func (c *BaseScheduler) Swtich2SelfDeliver(order *model.GoodsOrder, userName string) (err error) {
|
||||||
globals.SugarLogger.Infof("Swtich2SelfDeliver orderID:%s", order.VendorOrderID)
|
globals.SugarLogger.Infof("Swtich2SelfDeliver orderID:%s", order.VendorOrderID)
|
||||||
if /*order.LockStatus == model.OrderStatusUnknown && */ (order.Status == model.OrderStatusFinishedPickup || order.Status == model.OrderStatusDelivering) &&
|
if /*order.LockStatus == model.OrderStatusUnknown && */ order.Status == model.OrderStatusFinishedPickup || order.Status == model.OrderStatusDelivering {
|
||||||
order.DeliveryFlag&model.OrderDeliveryFlagMaskPurcahseDisabled == 0 {
|
if order.DeliveryFlag&model.OrderDeliveryFlagMaskPurcahseDisabled == 0 && c.IsReallyCallPlatformAPI {
|
||||||
if c.IsReallyCallPlatformAPI {
|
|
||||||
err = utils.CallFuncLogErrorWithInfo(func() error {
|
err = utils.CallFuncLogErrorWithInfo(func() error {
|
||||||
return partner.GetPurchasePlatformFromVendorID(order.VendorID).Swtich2SelfDeliver(order, userName)
|
return partner.GetPurchasePlatformFromVendorID(order.VendorID).Swtich2SelfDeliver(order, userName)
|
||||||
}, "Swtich2SelfDeliver orderID:%s", order.VendorOrderID)
|
}, "Swtich2SelfDeliver orderID:%s", order.VendorOrderID)
|
||||||
if err == nil { // 因为有些平台转自送后,不会再发送订单在配送中消息过来,所以成功后就强制设置状态为配送中
|
}
|
||||||
order.Status = model.OrderStatusDelivering
|
if err == nil { // 因为有些平台转自送后,不会再发送订单在配送中消息过来,所以成功后就强制设置状态为配送中
|
||||||
order.DeliveryFlag |= model.OrderDeliveryFlagMaskPurcahseDisabled
|
order.Status = model.OrderStatusDelivering
|
||||||
err = partner.CurOrderManager.UpdateOrderStatusAndFlag(order)
|
order.DeliveryFlag |= model.OrderDeliveryFlagMaskPurcahseDisabled
|
||||||
}
|
err = partner.CurOrderManager.UpdateOrderStatusAndFlag(order)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if order.LockStatus != model.OrderStatusUnknown || order.Status < model.OrderStatusFinishedPickup || order.VendorID == order.WaybillVendorID {
|
if order.LockStatus != model.OrderStatusUnknown || order.Status < model.OrderStatusFinishedPickup || order.VendorID == order.WaybillVendorID {
|
||||||
|
|||||||
@@ -115,11 +115,6 @@ func (s *WatchOrderInfo) updateOrderStoreFeature(order *model.GoodsOrder) (err e
|
|||||||
s.autoPickupTimeoutMinute = int(storeMap.AutoPickup)
|
s.autoPickupTimeoutMinute = int(storeMap.AutoPickup)
|
||||||
s.storeDeliveryType = FixedScheduler.GetStoreDeliveryType(order, storeMap)
|
s.storeDeliveryType = FixedScheduler.GetStoreDeliveryType(order, storeMap)
|
||||||
globals.SugarLogger.Debugf("updateOrderStoreFeature orderID:%s, s.storeDeliveryType:%d", order.VendorOrderID, s.storeDeliveryType)
|
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
|
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) {
|
func (s *DefScheduler) swtich2SelfDeliverWithRetry(savedOrderInfo *WatchOrderInfo, bill *model.Waybill, retryCount int, duration time.Duration) {
|
||||||
order := savedOrderInfo.order
|
order := savedOrderInfo.order
|
||||||
globals.SugarLogger.Debugf("swtich2SelfDeliverWithRetry orderID:%s", order.VendorOrderID)
|
globals.SugarLogger.Debugf("swtich2SelfDeliverWithRetry orderID:%s", order.VendorOrderID)
|
||||||
if (order.DeliveryFlag & model.OrderDeliveryFlagMaskPurcahseDisabled) == 0 {
|
if order.WaybillVendorID != order.VendorID {
|
||||||
if order.WaybillVendorID != order.VendorID {
|
if err := s.Swtich2SelfDeliver(order, ""); err != nil && err != scheduler.ErrOrderStatusAlreadySatisfyCurOperation {
|
||||||
if err := s.Swtich2SelfDeliver(order, ""); err != nil && err != scheduler.ErrOrderStatusAlreadySatisfyCurOperation {
|
globals.SugarLogger.Infof("swtich2SelfDeliverWithRetry failed, bill:%v, err:%v", bill, err)
|
||||||
globals.SugarLogger.Infof("swtich2SelfDeliverWithRetry failed, bill:%v, err:%v", bill, err)
|
if retryCount > 0 {
|
||||||
if retryCount > 0 {
|
utils.AfterFuncWithRecover(duration, func() {
|
||||||
utils.AfterFuncWithRecover(duration, func() {
|
jxutils.CallMsgHandlerAsync(func() {
|
||||||
jxutils.CallMsgHandlerAsync(func() {
|
s.swtich2SelfDeliverWithRetry(savedOrderInfo, bill, retryCount-1, duration)
|
||||||
s.swtich2SelfDeliverWithRetry(savedOrderInfo, bill, retryCount-1, duration)
|
}, order.VendorOrderID)
|
||||||
}, 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)
|
|
||||||
})
|
})
|
||||||
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 {
|
} else {
|
||||||
// 进到这里的原因是,在这个时间点,购物平台物流已经抢单(但抢单消息还没有被收到),所以转自送会失败 (比如:818810379000941),更好的做法应该是判断Swtich2SelfDeliver的返回值,这种情况下就不得试了
|
utils.CallFuncAsync(func() {
|
||||||
globals.SugarLogger.Infof("swtich2SelfDeliverWithRetry orderID:%s status is wrong(maybe purchase platform accepted waybill)", order.VendorOrderID)
|
weixinmsg.NotifyWaybillStatus(bill, order, false)
|
||||||
// globals.SugarLogger.Warnf("swtich2SelfDeliverWithRetry orderID:%s status is wrong, order details:%v", order.VendorOrderID, order)
|
})
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,23 +32,20 @@ func (s *DefScheduler) SelfDeliveringAndUpdateStatus(ctx *jxcontext.Context, ven
|
|||||||
if err = s.isPossibleSwitch2SelfDelivery(order); err == nil {
|
if err = s.isPossibleSwitch2SelfDelivery(order); err == nil {
|
||||||
err = s.cancelOtherWaybillsCheckOrderDeliveryFlag(savedOrderInfo, nil, partner.CancelWaybillReasonOther, partner.CancelWaybillReasonStrActive)
|
err = s.cancelOtherWaybillsCheckOrderDeliveryFlag(savedOrderInfo, nil, partner.CancelWaybillReasonOther, partner.CancelWaybillReasonStrActive)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// todo
|
if savedOrderInfo.storeDeliveryType == scheduler.StoreDeliveryTypeByStore {
|
||||||
if true { //order.DeliveryFlag&model.OrderDeliveryFlagMaskPurcahseDisabled == 0 {
|
if order.Status <= model.OrderStatusFinishedPickup {
|
||||||
if savedOrderInfo.storeDeliveryType == scheduler.StoreDeliveryTypeByStore {
|
storeDetail, err2 := dao.GetStoreDetail(dao.GetDB(), order.StoreID, order.VendorID)
|
||||||
if order.Status <= model.OrderStatusFinishedPickup {
|
phone := userName
|
||||||
storeDetail, err2 := dao.GetStoreDetail(dao.GetDB(), order.StoreID, order.VendorID)
|
if err = err2; err == nil {
|
||||||
phone := userName
|
phone = storeDetail.Tel1
|
||||||
if err = err2; err == nil {
|
|
||||||
phone = storeDetail.Tel1
|
|
||||||
}
|
|
||||||
err = s.SelfDeliverDelivering(order, phone)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if order.Status <= model.OrderStatusFinishedPickup {
|
|
||||||
err = s.Swtich2SelfDeliver(order, userName)
|
|
||||||
} else if order.VendorID == order.WaybillVendorID { // 状态为配送中,且是购物平台运单,不能转自送了
|
|
||||||
err = scheduler.ErrOrderStatusIsNotSuitable4CurOperation
|
|
||||||
}
|
}
|
||||||
|
err = s.SelfDeliverDelivering(order, phone)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if order.Status <= model.OrderStatusFinishedPickup {
|
||||||
|
err = s.Swtich2SelfDeliver(order, userName)
|
||||||
|
} else if order.VendorID == order.WaybillVendorID { // 状态为配送中,且是购物平台运单,不能转自送了
|
||||||
|
err = scheduler.ErrOrderStatusIsNotSuitable4CurOperation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user