diff --git a/business/jxstore/promotion/jd_promotion.go b/business/jxstore/promotion/jd_promotion.go index 398acd1e3..55ab42fec 100644 --- a/business/jxstore/promotion/jd_promotion.go +++ b/business/jxstore/promotion/jd_promotion.go @@ -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) {