diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 3c80e0540..bf371f104 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -81,31 +81,30 @@ func IsImportantTaskRunning(taskName string) bool { func Init() { if globals.IsProductEnv() { - ScheduleTimerFunc(doDailyWork, dailyWorkTimeList) + ScheduleTimerFunc("doDailyWork", doDailyWork, dailyWorkTimeList) ScheduleTimerFuncByInterval(func() { RefreshRealMobile(jxcontext.AdminCtx, model.VendorIDEBAI, time.Now().Add(-24*time.Hour), utils.DefaultTimeValue, false, true) }, 5*time.Second, 1*time.Hour) - ScheduleTimerFunc(func() { + ScheduleTimerFunc("auto enable remote store", func() { cms.EnableHaveRestStores(jxcontext.AdminCtx, false, true) cms.OpenRemoteStoreByJxStatus(jxcontext.AdminCtx, nil, nil, false, false, true) }, openRemoteStoreTimeList) - ScheduleTimerFunc(func() { + ScheduleTimerFunc("SaveAndSendAlarmVendorSnapshot", func() { cms.SaveAndSendAlarmVendorSnapshot(jxcontext.AdminCtx, nil, nil, false) }, cms.WatchVendorStoreTimeList) - ScheduleTimerFunc(func() { + ScheduleTimerFunc("RefreshPageActs", func() { act.RefreshPageActs(jxcontext.AdminCtx, []int{model.VendorIDEBAI}, time.Now().Add(-30*24*time.Hour), false) }, refreshPageActTimeList) - - ScheduleTimerFunc(func() { + ScheduleTimerFunc("UpdateActStatusByTime", func() { dao.UpdateActStatusByTime(dao.GetDB(), time.Now().Add(-48*time.Hour)) }, updateActStatusTimeList) InitEx() } - ScheduleTimerFunc(func() { + ScheduleTimerFunc("AutoSaleStoreSku", func() { cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil, false) }, autoSaleStoreSkuTimeList) } @@ -170,14 +169,15 @@ func RefreshRealMobile(ctx *jxcontext.Context, vendorID int, fromTime, toTime ti return hint, err } -func ScheduleTimerFunc(handler func(), timeList []string) { +func ScheduleTimerFunc(name string, handler func(), timeList []string) { now := time.Now() nextTime := jxutils.GetNextTimeFromList(now, timeList) duration := nextTime.Sub(now) + 1*time.Second - globals.SugarLogger.Debugf("ScheduleTimerFunc, duration:%v", duration) + globals.SugarLogger.Debugf("ScheduleTimerFunc, func:%s, duration:%v", name, duration) utils.AfterFuncWithRecover(duration, func() { + globals.SugarLogger.Debugf("ScheduleTimerFunc func:%s", name) handler() - ScheduleTimerFunc(handler, timeList) + ScheduleTimerFunc(name, handler, timeList) }) } diff --git a/business/jxstore/misc/misc2.go b/business/jxstore/misc/misc2.go index 1937f9468..70ee7d69a 100644 --- a/business/jxstore/misc/misc2.go +++ b/business/jxstore/misc/misc2.go @@ -165,12 +165,12 @@ func InitEx() { startTimeList = startOpStoreTimeListJXGY stopTimeList = endOpStoreTimeListJXGY } - ScheduleTimerFunc(func() { + ScheduleTimerFunc("StartOpStore", func() { if !IsImportantTaskRunning(TaskNameSyncStoreSku) { StartOrEndOpStore(true, 0, 0, false, true) } }, startTimeList) - ScheduleTimerFunc(func() { + ScheduleTimerFunc("EndOpStore", func() { if !IsImportantTaskRunning(TaskNameSyncStoreSku) { StartOrEndOpStore(false, 0, 0, false, true) } diff --git a/business/model/dao/act.go b/business/model/dao/act.go index a631b193a..bab9475de 100644 --- a/business/model/dao/act.go +++ b/business/model/dao/act.go @@ -365,11 +365,12 @@ func UpdateActStatusByTime(db *DaoDB, refTime time.Time) (num int64, err error) sql := ` UPDATE act t1 SET t1.status = ? - WHERE t1.status < ? AND t1.end_at < ?;` + WHERE t1.deleted_at = ? AND t1.status < ? AND t1.end_at < ?;` sqlParams := []interface{}{ model.ActStatusEnded, - model.ActStatusCanceled, utils.DefaultTimeValue, + model.ActStatusCanceled, + refTime, } num, err = ExecuteSQL(db, sql, sqlParams...) return num, err diff --git a/business/model/dao/act_test.go b/business/model/dao/act_test.go index 58e3f2588..20ac715bd 100644 --- a/business/model/dao/act_test.go +++ b/business/model/dao/act_test.go @@ -58,3 +58,10 @@ func TestGetEffectiveActStoreSkuInfo(t *testing.T) { } } } + +func TestUpdateActStatusByTime(t *testing.T) { + _, err := UpdateActStatusByTime(GetDB(), time.Now().Add(-48*time.Hour)) + if err != nil { + t.Fatal(err) + } +}