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