fix: 许可到期天数偏差,当天提示修改

This commit is contained in:
TsMask
2025-06-13 18:03:08 +08:00
parent a946b9db60
commit fef7415968

View File

@@ -3,6 +3,7 @@ package ne_alarm_state_check_license
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"math"
"time" "time"
"be.ems/src/framework/constants" "be.ems/src/framework/constants"
@@ -157,9 +158,13 @@ func (s NeAlarmStateCheckLicenseProcessor) serverState(state map[string]any, day
} }
// 计算距离天数 // 计算距离天数
daysLeft := int64(time.Until(expireTime).Hours() / 24) daysLeft := time.Until(expireTime).Hours() / 24
if daysLeft < dayLt { expireDay := int64(math.Ceil(daysLeft))
return fmt.Errorf("license will expire in %d days", daysLeft) if expireDay <= dayLt {
if expireDay <= 0 {
return fmt.Errorf("license will expire after today")
}
return fmt.Errorf("license will expire in %d days", expireDay)
} }
return nil return nil
} }