- min timeout scattered.
- fix LoadPendingOrders bug when there is no waybill.
This commit is contained in:
@@ -140,7 +140,7 @@ func LoadPendingOrders() {
|
||||
scheduler.CurrentScheduler.OnWaybillStatusChanged(&bill2)
|
||||
}, bill.VendorOrderID)
|
||||
}
|
||||
if order.Status > model.OrderStatusNew {
|
||||
if order.Status > model.OrderStatusNew && !isNoNewSent {
|
||||
isNoNewSent = true
|
||||
order2 := *order
|
||||
routinePool.CallFunAsync(func() {
|
||||
@@ -148,5 +148,11 @@ func LoadPendingOrders() {
|
||||
}, order.VendorOrderID)
|
||||
}
|
||||
}
|
||||
if order.Status > model.OrderStatusNew && !isNoNewSent {
|
||||
order2 := *order
|
||||
routinePool.CallFunAsync(func() {
|
||||
scheduler.CurrentScheduler.OnOrderStatusChanged(model.Order2Status(&order2))
|
||||
}, order.VendorOrderID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ func (c *WaybillController) onWaybillMsg(msg *jdapi.CallbackDeliveryStatusMsg) (
|
||||
order.Status = model.WaybillStatusDelivering
|
||||
case jdapi.DeliveryStatusFinished:
|
||||
order.Status = model.WaybillStatusDelivered
|
||||
case jdapi.DeliveryStatusFailedDelivery:
|
||||
case jdapi.DeliveryStatusFailedDelivery, jdapi.DeliveryStatusFailedGetGoods:
|
||||
order.Status = model.WaybillStatusFailed
|
||||
default:
|
||||
order.Status = model.WaybillStatusUnknown
|
||||
|
||||
@@ -87,7 +87,7 @@ func GetUniversalOrderIDFromOrderStatus(status *model.OrderStatus) string {
|
||||
func GetRealTimeout(beginTime time.Time, timeout time.Duration, minTimeout time.Duration) time.Duration {
|
||||
retVal := beginTime.Add(timeout).Sub(time.Now())
|
||||
if retVal < minTimeout {
|
||||
retVal = minTimeout
|
||||
retVal = minTimeout + time.Duration(rand.Int31n(5*1000))*time.Millisecond // 随机分布在5秒内这样写的原因是避免启动时加载订单,TIMER同一瞬间启动
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ const (
|
||||
time2Schedule3rdCarrierGap4OrderStatus = 3 * time.Minute // 京东要求是运单状态为待抢单且超时5分钟,但为了防止没有运单事件,所以就拣货完成事件开始算,添加3分钟
|
||||
time2AutoPickupMin = 15 * time.Minute
|
||||
time2AutoPickupGap = 5 * time.Minute
|
||||
minTimeout = 10 * time.Second // timer的最小时间,这样写的上的是在load pending orders,让延迟的事件有机会执行
|
||||
minTimeout = 5 * time.Second // timer的最小时间,这样写的上的是在load pending orders,让延迟的事件有机会执行
|
||||
)
|
||||
|
||||
type WatchOrderInfo struct {
|
||||
@@ -147,7 +147,7 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill) (err error) {
|
||||
s.CurOrderManager.UpdateWaybillVendorID(bill)
|
||||
savedOrderInfo.order.WaybillVendorID = bill.WaybillVendorID
|
||||
}
|
||||
case model.WaybillStatusFailed: // WaybillStatusFailed理解成订单整个失败了,不需要再尝试创建运单了
|
||||
case model.WaybillStatusFailed: // todo WaybillStatusFailed理解成订单整个失败了,不需要再尝试创建运单了,注意这里应该加个zabbix日志的报警
|
||||
s.removeWaybillFromMap(savedOrderInfo, bill)
|
||||
globals.SugarLogger.Infof("OnWaybillStatusChanged WaybillStatusFailed, bill:%v", bill)
|
||||
case model.WaybillStatusCanceled:
|
||||
|
||||
Reference in New Issue
Block a user