diff --git a/docs/evidence/rev004-accounting/late-fee-start-and-daily-recalculation-2026-06-30.md b/docs/evidence/rev004-accounting/late-fee-start-and-daily-recalculation-2026-06-30.md index ddc298b..41f244c 100644 --- a/docs/evidence/rev004-accounting/late-fee-start-and-daily-recalculation-2026-06-30.md +++ b/docs/evidence/rev004-accounting/late-fee-start-and-daily-recalculation-2026-06-30.md @@ -16,6 +16,7 @@ - `fd5154f83 feat: save late fee begin date during billing` - `f7207fe61 feat: add daily late fee recalculation job` - `af05601f1 fix: harden late fee recalculation batch` +- `3722c54fa fix: paginate late fee recalculation batches` ## Implemented Files @@ -23,6 +24,7 @@ - `sw-business/sw-business-server/src/main/java/cn/com/emsoft/sw/business/service/charge/latefee/LateFeeConfig.java` - `sw-business/sw-business-server/src/main/java/cn/com/emsoft/sw/business/service/charge/latefee/LateFeeConfigResolver.java` - `sw-business/sw-business-server/src/main/java/cn/com/emsoft/sw/business/service/charge/latefee/LateFeeBeginDateCalculator.java` +- `sw-business/sw-business-server/src/main/java/cn/com/emsoft/sw/business/service/charge/latefee/LateFeeBeginDateApplyService.java` - `sw-business/sw-business-server/src/main/java/cn/com/emsoft/sw/business/service/charge/latefee/LateFeeDailyCalculator.java` - `sw-business/sw-business-server/src/main/java/cn/com/emsoft/sw/business/service/charge/latefee/LateFeeRecalculationService.java` - `sw-business/sw-business-server/src/main/java/cn/com/emsoft/sw/business/job/charge/LateFeeRecalculationJob.java` @@ -41,6 +43,9 @@ - The daily recalculation batch now selects unpaid charges with non-null `lateFeeBeginDate`, avoiding repeated starvation behind historical rows that cannot be recalculated. - `script/xxl-job-init.sql` registers handler `lateFeeDailyRecalculation` for business-server with cron `0 30 3 * * ?`. - `LateFeeRecalculationServiceTest` includes a defensive scenario where a reversed late-fee detail is returned by the mapper and ignored by aggregation. +- The daily recalculation job now uses keyset pagination (`id > lastId`) until no eligible rows remain, so rows after the first page are recalculated in the same run instead of waiting forever behind unchanged earlier rows. +- `LateFeeBeginDateApplyService` centralizes `lateFeeBeginDate` persistence and is reused by normal billing, manual charge creation, counter add-reading formalization, and special billing formalization before `chargeMapper.insert`. +- Focused tests now cover the shared begin-date apply service, keyset pagination across batches, and direct insert path wiring for counter add-reading and special billing. ## Verification @@ -49,17 +54,20 @@ Command: ```bash -mvn -pl sw-business/sw-business-server -am -Dtest=LateFeeBeginDateCalculatorTest,LateFeeConfigResolverTest,LateFeeDailyCalculatorTest,LateFeeRecalculationServiceTest,ChargeLateFeeBeginDateWiringTest -Dsurefire.failIfNoSpecifiedTests=false test +mvn -pl sw-business/sw-business-server -am -Dtest=LateFeeBeginDateCalculatorTest,LateFeeBeginDateApplyServiceTest,LateFeeConfigResolverTest,LateFeeDailyCalculatorTest,LateFeeRecalculationServiceTest,ChargeLateFeeBeginDateWiringTest,CounterAddReadingApplicationServiceImplTest,SpecialBillingServiceImplTest -Dsurefire.failIfNoSpecifiedTests=false test ``` Result: PASS -- `LateFeeRecalculationServiceTest`: 4 tests, 0 failures, 0 errors, 0 skipped +- `LateFeeBeginDateApplyServiceTest`: 2 tests, 0 failures, 0 errors, 0 skipped +- `LateFeeRecalculationServiceTest`: 5 tests, 0 failures, 0 errors, 0 skipped - `LateFeeConfigResolverTest`: 3 tests, 0 failures, 0 errors, 0 skipped - `LateFeeBeginDateCalculatorTest`: 7 tests, 0 failures, 0 errors, 0 skipped - `LateFeeDailyCalculatorTest`: 8 tests, 0 failures, 0 errors, 0 skipped - `ChargeLateFeeBeginDateWiringTest`: 5 tests, 0 failures, 0 errors, 0 skipped -- Total: 27 tests, 0 failures, 0 errors, 0 skipped +- `CounterAddReadingApplicationServiceImplTest`: 24 tests, 0 failures, 0 errors, 0 skipped +- `SpecialBillingServiceImplTest`: 4 tests, 0 failures, 0 errors, 0 skipped +- Total: 58 tests, 0 failures, 0 errors, 0 skipped ### Existing Accounting Regression Tests