- fix resetTimer error.
This commit is contained in:
@@ -352,7 +352,7 @@ func (s *DefScheduler) resetTimer(savedOrderInfo *WatchOrderInfo, statusType, st
|
|||||||
if config == nil || config.TimerType != scheduler.TimerTypeByPass {
|
if config == nil || config.TimerType != scheduler.TimerTypeByPass {
|
||||||
s.stopTimer(savedOrderInfo)
|
s.stopTimer(savedOrderInfo)
|
||||||
}
|
}
|
||||||
if config != nil && config.TimeoutAction != nil && config.TimerType != scheduler.TimerTypeNoTimer && config.TimerType != scheduler.TimerTypeByPass {
|
if config != nil && config.TimeoutAction != nil && config.TimerType != scheduler.TimerTypeByPass {
|
||||||
var timeout time.Duration
|
var timeout time.Duration
|
||||||
switch config.TimerType {
|
switch config.TimerType {
|
||||||
case scheduler.TimerTypeBaseNow:
|
case scheduler.TimerTypeBaseNow:
|
||||||
@@ -389,7 +389,7 @@ func (s *DefScheduler) resetTimer(savedOrderInfo *WatchOrderInfo, statusType, st
|
|||||||
}, order.VendorOrderID)
|
}, order.VendorOrderID)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debugf("resetTimer orderID:%s, status:%d, timeout:%v", order.VendorOrderID, status, timeout)
|
globals.SugarLogger.Debugf("resetTimer, orderID:%s, status:%d, timeout:%v", order.VendorOrderID, status, timeout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -433,13 +433,18 @@ func (s *DefScheduler) mergeOrderStatusConfig(statusType, status int, config *sc
|
|||||||
}
|
}
|
||||||
retVal = &scheduler.StatusActionConfig{}
|
retVal = &scheduler.StatusActionConfig{}
|
||||||
if defConfig != nil {
|
if defConfig != nil {
|
||||||
retVal.Timeout = defConfig.Timeout
|
*retVal = *defConfig
|
||||||
retVal.TimeoutAction = defConfig.TimeoutAction
|
|
||||||
}
|
}
|
||||||
if config != nil {
|
if config != nil {
|
||||||
if config.Timeout >= 0 {
|
if config.Timeout != 0 {
|
||||||
retVal.Timeout = config.Timeout
|
retVal.Timeout = config.Timeout
|
||||||
}
|
}
|
||||||
|
if config.TimerType != scheduler.TimerTypeNoOverride {
|
||||||
|
retVal.TimerType = config.TimerType
|
||||||
|
}
|
||||||
|
if config.TimeoutGap != 0 {
|
||||||
|
retVal.TimeoutGap = config.TimeoutGap
|
||||||
|
}
|
||||||
if config.TimeoutAction != nil {
|
if config.TimeoutAction != nil {
|
||||||
retVal.TimeoutAction = config.TimeoutAction
|
retVal.TimeoutAction = config.TimeoutAction
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TimerTypeNoTimer = 0 // 即此状态没有TIMER(但为停掉之前的TIMER,如果要保持TIMER应该用TimerTypeByPass),状态没有配置缺省就是没有TIMER
|
TimerTypeNoOverride = 0 // GetStatusActionConfig 返回表示不修改缺省配置
|
||||||
TimerTypeByPass = 1
|
TimerTypeByPass = 1
|
||||||
TimerTypeBaseNow = 2
|
TimerTypeBaseNow = 2
|
||||||
TimerTypeBaseStatusTime = 3
|
TimerTypeBaseStatusTime = 3
|
||||||
@@ -38,9 +38,9 @@ var (
|
|||||||
|
|
||||||
type StatusActionConfig struct {
|
type StatusActionConfig struct {
|
||||||
TimerType int // 参见上面的相关常量定义
|
TimerType int // 参见上面的相关常量定义
|
||||||
Timeout time.Duration // 超时时间,为0表示立即执行(其实也不能立即执行,因为有最小时间限制)
|
Timeout time.Duration // 超时时间,0在GetStatusActionConfig返回时表示不修改缺省
|
||||||
TimeoutGap int // 以秒为单位的随机时间,0表示不随机
|
TimeoutGap int // 以秒为单位的随机时间,0在GetStatusActionConfig返回时表示不修改缺省
|
||||||
TimeoutAction func(order *model.GoodsOrder) (err error) // 超时后需要执行的动作,为nil表示此状态不需要执行监控
|
TimeoutAction func(order *model.GoodsOrder) (err error) // 超时后需要执行的动作,为nil表示此状态不需要执行监控, nil在GetStatusActionConfig返回时表示不修改缺省
|
||||||
}
|
}
|
||||||
|
|
||||||
type PurchasePlatformHandler interface {
|
type PurchasePlatformHandler interface {
|
||||||
|
|||||||
Reference in New Issue
Block a user