- 修复UpdateActStatusByTime中的BUG
This commit is contained in:
@@ -81,31 +81,30 @@ func IsImportantTaskRunning(taskName string) bool {
|
|||||||
|
|
||||||
func Init() {
|
func Init() {
|
||||||
if globals.IsProductEnv() {
|
if globals.IsProductEnv() {
|
||||||
ScheduleTimerFunc(doDailyWork, dailyWorkTimeList)
|
ScheduleTimerFunc("doDailyWork", doDailyWork, dailyWorkTimeList)
|
||||||
|
|
||||||
ScheduleTimerFuncByInterval(func() {
|
ScheduleTimerFuncByInterval(func() {
|
||||||
RefreshRealMobile(jxcontext.AdminCtx, model.VendorIDEBAI, time.Now().Add(-24*time.Hour), utils.DefaultTimeValue, false, true)
|
RefreshRealMobile(jxcontext.AdminCtx, model.VendorIDEBAI, time.Now().Add(-24*time.Hour), utils.DefaultTimeValue, false, true)
|
||||||
}, 5*time.Second, 1*time.Hour)
|
}, 5*time.Second, 1*time.Hour)
|
||||||
|
|
||||||
ScheduleTimerFunc(func() {
|
ScheduleTimerFunc("auto enable remote store", func() {
|
||||||
cms.EnableHaveRestStores(jxcontext.AdminCtx, false, true)
|
cms.EnableHaveRestStores(jxcontext.AdminCtx, false, true)
|
||||||
cms.OpenRemoteStoreByJxStatus(jxcontext.AdminCtx, nil, nil, false, false, true)
|
cms.OpenRemoteStoreByJxStatus(jxcontext.AdminCtx, nil, nil, false, false, true)
|
||||||
}, openRemoteStoreTimeList)
|
}, openRemoteStoreTimeList)
|
||||||
|
|
||||||
ScheduleTimerFunc(func() {
|
ScheduleTimerFunc("SaveAndSendAlarmVendorSnapshot", func() {
|
||||||
cms.SaveAndSendAlarmVendorSnapshot(jxcontext.AdminCtx, nil, nil, false)
|
cms.SaveAndSendAlarmVendorSnapshot(jxcontext.AdminCtx, nil, nil, false)
|
||||||
}, cms.WatchVendorStoreTimeList)
|
}, cms.WatchVendorStoreTimeList)
|
||||||
|
|
||||||
ScheduleTimerFunc(func() {
|
ScheduleTimerFunc("RefreshPageActs", func() {
|
||||||
act.RefreshPageActs(jxcontext.AdminCtx, []int{model.VendorIDEBAI}, time.Now().Add(-30*24*time.Hour), false)
|
act.RefreshPageActs(jxcontext.AdminCtx, []int{model.VendorIDEBAI}, time.Now().Add(-30*24*time.Hour), false)
|
||||||
}, refreshPageActTimeList)
|
}, refreshPageActTimeList)
|
||||||
|
ScheduleTimerFunc("UpdateActStatusByTime", func() {
|
||||||
ScheduleTimerFunc(func() {
|
|
||||||
dao.UpdateActStatusByTime(dao.GetDB(), time.Now().Add(-48*time.Hour))
|
dao.UpdateActStatusByTime(dao.GetDB(), time.Now().Add(-48*time.Hour))
|
||||||
}, updateActStatusTimeList)
|
}, updateActStatusTimeList)
|
||||||
InitEx()
|
InitEx()
|
||||||
}
|
}
|
||||||
ScheduleTimerFunc(func() {
|
ScheduleTimerFunc("AutoSaleStoreSku", func() {
|
||||||
cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil, false)
|
cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil, false)
|
||||||
}, autoSaleStoreSkuTimeList)
|
}, autoSaleStoreSkuTimeList)
|
||||||
}
|
}
|
||||||
@@ -170,14 +169,15 @@ func RefreshRealMobile(ctx *jxcontext.Context, vendorID int, fromTime, toTime ti
|
|||||||
return hint, err
|
return hint, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func ScheduleTimerFunc(handler func(), timeList []string) {
|
func ScheduleTimerFunc(name string, handler func(), timeList []string) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
nextTime := jxutils.GetNextTimeFromList(now, timeList)
|
nextTime := jxutils.GetNextTimeFromList(now, timeList)
|
||||||
duration := nextTime.Sub(now) + 1*time.Second
|
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() {
|
utils.AfterFuncWithRecover(duration, func() {
|
||||||
|
globals.SugarLogger.Debugf("ScheduleTimerFunc func:%s", name)
|
||||||
handler()
|
handler()
|
||||||
ScheduleTimerFunc(handler, timeList)
|
ScheduleTimerFunc(name, handler, timeList)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -165,12 +165,12 @@ func InitEx() {
|
|||||||
startTimeList = startOpStoreTimeListJXGY
|
startTimeList = startOpStoreTimeListJXGY
|
||||||
stopTimeList = endOpStoreTimeListJXGY
|
stopTimeList = endOpStoreTimeListJXGY
|
||||||
}
|
}
|
||||||
ScheduleTimerFunc(func() {
|
ScheduleTimerFunc("StartOpStore", func() {
|
||||||
if !IsImportantTaskRunning(TaskNameSyncStoreSku) {
|
if !IsImportantTaskRunning(TaskNameSyncStoreSku) {
|
||||||
StartOrEndOpStore(true, 0, 0, false, true)
|
StartOrEndOpStore(true, 0, 0, false, true)
|
||||||
}
|
}
|
||||||
}, startTimeList)
|
}, startTimeList)
|
||||||
ScheduleTimerFunc(func() {
|
ScheduleTimerFunc("EndOpStore", func() {
|
||||||
if !IsImportantTaskRunning(TaskNameSyncStoreSku) {
|
if !IsImportantTaskRunning(TaskNameSyncStoreSku) {
|
||||||
StartOrEndOpStore(false, 0, 0, false, true)
|
StartOrEndOpStore(false, 0, 0, false, true)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -365,11 +365,12 @@ func UpdateActStatusByTime(db *DaoDB, refTime time.Time) (num int64, err error)
|
|||||||
sql := `
|
sql := `
|
||||||
UPDATE act t1
|
UPDATE act t1
|
||||||
SET t1.status = ?
|
SET t1.status = ?
|
||||||
WHERE t1.status < ? AND t1.end_at < ?;`
|
WHERE t1.deleted_at = ? AND t1.status < ? AND t1.end_at < ?;`
|
||||||
sqlParams := []interface{}{
|
sqlParams := []interface{}{
|
||||||
model.ActStatusEnded,
|
model.ActStatusEnded,
|
||||||
model.ActStatusCanceled,
|
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
|
model.ActStatusCanceled,
|
||||||
|
refTime,
|
||||||
}
|
}
|
||||||
num, err = ExecuteSQL(db, sql, sqlParams...)
|
num, err = ExecuteSQL(db, sql, sqlParams...)
|
||||||
return num, err
|
return num, err
|
||||||
|
|||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user