From d0a76d1ac1f1751b6b5985e575dc78d62bbad547 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Tue, 16 Dec 2025 15:11:00 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=85=85=E5=80=BC=20?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/team/TeamBillCycleUtils.java | 53 ++++++++----------- 1 file changed, 23 insertions(+), 30 deletions(-) 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); } + } }