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

This commit is contained in:
TsMask
2025-06-13 18:03:18 +08:00
parent 774f2399cf
commit 860c509586

View File

@@ -3,6 +3,7 @@ package ne_alarm_state_check_license
import (
"encoding/json"
"fmt"
"math"
"time"
"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)
if daysLeft < dayLt {
return fmt.Errorf("license will expire in %d days", daysLeft)
daysLeft := time.Until(expireTime).Hours() / 24
expireDay := int64(math.Ceil(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
}