fix: 许可到期天数偏差,当天提示修改
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user