- fix early miscommit pendingOrderGapMax.

- don't update order status when it's already finished.
This commit is contained in:
gazebo
2018-07-28 22:20:24 +08:00
parent ecdf2af63c
commit cbf72ac85d
2 changed files with 7 additions and 4 deletions

View File

@@ -14,7 +14,7 @@ import (
)
const (
pendingOrderGapMax = 200 * 24 * time.Hour // 每次重启机子时,要检查几天内的订单状态
pendingOrderGapMax = 2 * 24 * time.Hour // 每次重启机子时,要检查几天内的订单状态
maxTimeHandlePendingOrder = 2 * time.Second //处理pending order的最长时间
maxSleepGapHandlePendingOrder = 5 * time.Millisecond // 每个pending order的最长时间间隙
)

View File

@@ -282,7 +282,7 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
if !isPending {
globals.SugarLogger.Infof("OnWaybillStatusChanged WaybillStatusFailed, bill:%v", bill)
bill.WaybillVendorID = model.VendorIDUnknown
s.updateOrderByBill(order, bill, true)
s.updateOrderByBill(order, bill, false)
}
} else {
globals.SugarLogger.Warnf("OnWaybillStatusChanged Failed bill:%v shouldn't got here, order details:%v", bill, order)
@@ -293,7 +293,7 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
s.resetTimer(savedOrderInfo, scheduler.TimerStatusTypeWaybill, bill.Status, false)
if !isPending {
bill.WaybillVendorID = model.VendorIDUnknown
s.updateOrderByBill(order, bill, true)
s.updateOrderByBill(order, bill, false)
if bill.WaybillVendorID != order.VendorID { // 3方的运单取消才会重新发起创建3方订单购物平台的运单取消后它本身还会再创建新运单(NewWabill事件有相应TIMER)),至少京东是这样的,暂时按京东的行为来
s.createWaybillOn3rdProviders(savedOrderInfo, nil)
}
@@ -557,13 +557,16 @@ func (s *DefScheduler) updateOrderByStatus(order *model.GoodsOrder, status *mode
}
func (s *DefScheduler) updateOrderByBill(order *model.GoodsOrder, bill *model.Waybill, revertStatus bool) {
if order.Status > model.OrderStatusEndBegin {
return
}
if bill.WaybillVendorID == model.VendorIDUnknown {
bill.VendorWaybillID = ""
}
s.CurOrderManager.UpdateWaybillVendorID(bill, revertStatus)
order.WaybillVendorID = bill.WaybillVendorID
order.VendorWaybillID = bill.VendorWaybillID
if revertStatus && order.Status < model.OrderStatusEndBegin {
if revertStatus {
order.Status = model.OrderStatusFinishedPickup
}
}