日期校验问题

This commit is contained in:
2024-07-25 15:55:03 +08:00
parent e9ec9a1ca5
commit c7d4757c64
3 changed files with 12 additions and 18 deletions

View File

@@ -103,6 +103,9 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
Date startTime, endTime;
DateTime offsetMonth = cn.hutool.core.date.DateUtil.offsetMonth(new Date(), 3);
if (criteria.getCreatedAt() != null && criteria.getCreatedAt().size() == 2) {
if (criteria.getCreatedAt().get(0) < System.currentTimeMillis() - 1000 * 60 * 60 * 24 * 90L) {
throw new BadRequestException("查询时间范围不能超过三个月");
}
Long startLong = criteria.getCreatedAt().get(0);
Long endLong = criteria.getCreatedAt().get(1);
@@ -110,9 +113,9 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
endTime = new Date(endLong);
// 如果开始时间小于三个月前,不查询
if (startTime.before(offsetMonth)) {
throw new BadRequestException("查询时间范围不能超过三个月");
}
// if (startTime.before(offsetMonth)) {
// throw new BadRequestException("查询时间范围不能超过三个月");
// }
} else {
startTime = offsetMonth;
endTime = new Date();