diff --git a/api/consts/status.go b/api/consts/status.go index 279b19df..1de819e3 100644 --- a/api/consts/status.go +++ b/api/consts/status.go @@ -214,3 +214,8 @@ const ( IsHeaded_No = 0 //否 IsHeaded_Yes = 1 //是 ) + +// 从未更新的时间跨度 +const ( + DaysElapsedSinceTheLastZonesUpdate_Never = -1 +) diff --git a/app/mix/service/utilservice.go b/app/mix/service/utilservice.go index 769951f4..afea5a8d 100644 --- a/app/mix/service/utilservice.go +++ b/app/mix/service/utilservice.go @@ -763,8 +763,17 @@ func (s *Service) utilGetStreamerExtMapByMids(ctx *gin.Context, mids []int64, op streamerExt.CopyZones(zonesMap[mid]) // 计算空间更新时间距离现在时间跨度 nowTime := time.Now() + lastZoneMomentCt := int64(0) for _, zone := range zonesMap[mid] { - lastZoneMomentCreateDay := util.GetDayStartTimeStamp(time.Unix(util.DerefInt64(zone.LastZoneMomentCt), 0)) + if util.DerefInt64(zone.LastZoneMomentCt) > lastZoneMomentCt { + lastZoneMomentCt = util.DerefInt64(zone.LastZoneMomentCt) + } + } + if lastZoneMomentCt == 0 { + streamerExt.SetIsActiveWithinAWeek(consts.ZoneIsActiveWithinAWeek_No) + streamerExt.SetDaysElapsedSinceTheLastZonesUpdate(consts.DaysElapsedSinceTheLastZonesUpdate_Never) + } else { + lastZoneMomentCreateDay := util.GetDayStartTimeStamp(time.Unix(lastZoneMomentCt, 0)) today := util.GetDayStartTimeStamp(nowTime) daysElapsedSinceTheLastZonesUpdate := (today - lastZoneMomentCreateDay) / int64(86400) // 24 * 60 * 60 = 86400秒 streamerExt.SetDaysElapsedSinceTheLastZonesUpdate(daysElapsedSinceTheLastZonesUpdate)