diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/service/team/TeamBillCycleUtils.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/service/team/TeamBillCycleUtils.java index 84f10b64..2adebcb4 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/service/team/TeamBillCycleUtils.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/service/team/TeamBillCycleUtils.java @@ -719,37 +719,30 @@ public final class TeamBillCycleUtils { return String.format("%d年%d月(%s)", year, month, batchDesc); } - public static LocalDateTime getBillBelongStartTime(Integer billBelong) { - int year, month; + public static LocalDateTime getBillBelongStartTime(Integer billBelong) { + // billBelong 格式:20251101 或 20251116 + int year = billBelong / 10000; // 2025 + int month = (billBelong / 100) % 100; // 11 + int day = billBelong % 100; // 01 或 16 - if (billBelong > 999999) { - // 8位格式:20251016 - year = billBelong / 10000; - month = (billBelong / 100) % 100; - } else { - // 6位格式:202510 - year = billBelong / 100; - month = billBelong % 100; - } - LocalDateTime startTime = LocalDateTime.of(year, month, 1, 0, 0, 0); - return startTime; - } - - public static LocalDateTime getBillBelongEndTime(Integer billBelong) { - int year, month; - - if (billBelong > 999999) { - // 8位格式:20251016 - year = billBelong / 10000; - month = (billBelong / 100) % 100; - } else { - // 6位格式:202510 - year = billBelong / 100; - month = billBelong % 100; - } - LocalDateTime startTime = LocalDateTime.of(year, month, 1, 0, 0, 0); - LocalDateTime endTime = startTime.plusMonths(1).minusSeconds(1); - return endTime; + return LocalDateTime.of(year, month, day, 0, 0, 0); + } + + public static LocalDateTime getBillBelongEndTime(Integer billBelong) { + // billBelong 格式:20251101 或 20251116 + int year = billBelong / 10000; // 2025 + int month = (billBelong / 100) % 100; // 11 + int day = billBelong % 100; // 01 或 16 + + LocalDateTime startTime = LocalDateTime.of(year, month, day, 0, 0, 0); + + if (day == 1) { + // 如果是1号,结束时间是当月16号0点 + return LocalDateTime.of(year, month, 16, 0, 0, 0); + } else { + // 如果是16号,结束时间是下个月1号0点 + return startTime.plusMonths(1).withDayOfMonth(1); } + } }