- async call some funcs in scheduleRoutine to avoid blocking

This commit is contained in:
gazebo
2018-11-10 09:32:34 +08:00
parent e664e9ea3f
commit 8cea399565

View File

@@ -198,31 +198,36 @@ func init() {
gob.Register([]*SkuPrice{})
}
func scheduleDailyRoutine() {
func scheduleDailyRoutine(isFirst bool) {
executeTime := utils.GetCurDate().Add(24*time.Hour + 5*time.Minute) // 凌晨00:05执行
duration := executeTime.Sub(time.Now())
if duration > 1*time.Hour {
if isFirst && duration > 1*time.Hour {
UpdateJdPromotionStatus()
}
// globals.SugarLogger.Debug(duration)
time.AfterFunc(duration, func() {
UpdateJdPromotionStatus()
scheduleDailyRoutine()
scheduleDailyRoutine(false)
})
}
func scheduleRoutine() {
RefreshJdLockStoreSku()
RefreshJdStoreSkuStock()
func scheduleRoutine(isFirst bool) {
if isFirst {
go func() {
RefreshJdLockStoreSku()
RefreshJdStoreSkuStock()
}()
}
time.AfterFunc(stockRefreshGap, func() {
scheduleRoutine()
RefreshJdLockStoreSku()
RefreshJdStoreSkuStock()
scheduleRoutine(false)
})
}
func Init() {
scheduleDailyRoutine()
scheduleRoutine()
scheduleDailyRoutine(true)
scheduleRoutine(true)
}
func CreateJdPromotion(ctx *jxcontext.Context, isIDJd bool, isAsync, isContinueWhenError bool, vendorPromotionID string, params *PromotionParams, mapData map[string]interface{}) (hint string, err error) {