Explorar el Código

fix:“优化第三方接口订单查询逻辑"

soobin hace 7 meses
padre
commit
14fb0d8b5d
Se han modificado 1 ficheros con 4 adiciones y 16 borrados
  1. 4 16
      src/main/java/com/szwl/controller/ApiInterContriller.java

+ 4 - 16
src/main/java/com/szwl/controller/ApiInterContriller.java

@@ -24,8 +24,8 @@ import org.springframework.web.bind.annotation.*;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
-import java.time.Period;
 import java.time.ZoneId;
+import java.time.temporal.ChronoUnit;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -144,20 +144,8 @@ public class ApiInterContriller {
         // 将 Date 转换为 LocalDate
         LocalDate startLocalDate = startDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
         LocalDate endLocalDate = endDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
-
-        // 使用 Period 类来计算日期差异
-        Period period = Period.between(startLocalDate, endLocalDate);
-
-        // 如果年差异大于 0 或月差异大于 1,则认为超过一个月
-        if (period.getYears() > 0 || period.getMonths() > 1) {
-            return true;
-        }
-
-        // 如果月差异是 1,检查天数是否足够达到一个月
-        if (period.getMonths() == 1 && period.getDays() >= 0) {
-            return true;
-        }
-
-        return false;
+        // 计算两个日期之间的天数差
+        long daysBetween = ChronoUnit.DAYS.between(startLocalDate, endLocalDate);
+        return daysBetween > 31;
     }
 }