From 90e74603bb4669aa1507bd112ff18710ed96c980 Mon Sep 17 00:00:00 2001 From: luqingjie <544309509@qq.com> Date: Sat, 31 Oct 2026 20:09:36 -0400 Subject: [PATCH] =?UTF-8?q?=E6=A0=B8=E9=AA=8C=E5=AE=8C=E6=88=90=E6=97=B6?= =?UTF-8?q?=E5=B7=B2=E7=BB=8F=E8=B6=85=E8=BF=8723:16:54=EF=BC=8C=E7=A7=9F?= =?UTF-8?q?=E6=9C=9F=E5=B7=B2=E7=BB=93=E6=9D=9F=EF=BC=8C=E8=BF=99=E4=B8=AA?= =?UTF-8?q?=E8=A6=81=E6=B7=BB=E5=8A=A0=E5=86=97=E4=BD=99=E6=97=B6=E9=97=B4?= =?UTF-8?q?=EF=BC=8C=E5=BA=94=E4=B8=BA=E5=AE=9E=E9=99=85=E9=93=BE=E4=B8=8A?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=98=AF=E9=9C=80=E8=A6=81=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E7=9A=84=EF=BC=8C=E9=BB=98=E8=AE=A4=E5=86=97=E4=BD=99=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=98=AF3=E5=88=86=E9=92=9F=EF=BC=8C=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-admin/src/main/resources/application-rental.yml | 2 ++ .../system/rental/RentalDeliveryDiagnostics.java | 11 ++++++++++- .../java/com/ruoyi/system/rental/RentalQueries.java | 4 +++- .../java/com/ruoyi/system/rental/RentalTasks.java | 5 ++++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ruoyi-admin/src/main/resources/application-rental.yml b/ruoyi-admin/src/main/resources/application-rental.yml index 6d14218..19fe7f1 100644 --- a/ruoyi-admin/src/main/resources/application-rental.yml +++ b/ruoyi-admin/src/main/resources/application-rental.yml @@ -13,6 +13,8 @@ rental: queue-capacity: ${RENT_DELIVERY_QUEUE_CAPACITY:200} dispatch-interval-ms: ${RENT_DELIVERY_DISPATCH_INTERVAL_MS:3000} push-interval-ms: ${RENT_DELIVERY_PUSH_INTERVAL_MS:2000} + # 链上委托确认可能晚于业务租期;仅放宽履约核验,不延长用户实际租期。 + verification-grace-seconds: ${RENT_DELIVERY_VERIFICATION_GRACE_SECONDS:180} payment: # 新增表见sql/rent_topup_init.sql;支付库先执行sql/payment_topup_upgrade.sql。 enabled: ${RENT_PAYMENT_ENABLED:false} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/rental/RentalDeliveryDiagnostics.java b/ruoyi-system/src/main/java/com/ruoyi/system/rental/RentalDeliveryDiagnostics.java index ed098a3..d4f13b3 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/rental/RentalDeliveryDiagnostics.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/rental/RentalDeliveryDiagnostics.java @@ -19,6 +19,15 @@ final class RentalDeliveryDiagnostics { } static String explain(boolean proven, Long verified, long target, Instant expires, Instant checked) { + return explain(proven, verified, target, expires, checked, 0L); + } + + /** + * 履约核验允许在业务租期结束后保留一个链上确认宽限期;宽限期只影响核验, + * 不会延长 service_expires_at,也不会延长用户实际可用租期。 + */ + static String explain(boolean proven, Long verified, long target, Instant expires, Instant checked, + long verificationGraceSeconds) { List reasons = new ArrayList<>(); if (!proven) { reasons.add("缺少完整历史履约证明,无法确认委托区块的实际资源数量"); @@ -29,7 +38,7 @@ final class RentalDeliveryDiagnostics { } if (expires == null || checked == null) { reasons.add("缺少租期或核验时间,无法确认是否在有效租期内完成核验"); - } else if (!expires.isAfter(checked)) { + } else if (!checked.isBefore(expires.plusSeconds(Math.max(0L, verificationGraceSeconds)))) { reasons.add("核验完成时租期已结束:租期截止=" + expires + ",核验时间=" + checked); } return String.join(";", reasons); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/rental/RentalQueries.java b/ruoyi-system/src/main/java/com/ruoyi/system/rental/RentalQueries.java index c9fc2da..6dffaf2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/rental/RentalQueries.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/rental/RentalQueries.java @@ -9,6 +9,8 @@ import java.util.*; /** 查询层显式沿关联关系确定用户归属,绝不对没有user_id的表直接拼用户过滤。 */ @Service public class RentalQueries { + @org.springframework.beans.factory.annotation.Value("${rental.delivery.verification-grace-seconds:180}") + private long verificationGraceSeconds = 180L; private final RentalStore store; public RentalQueries(RentalStore store) { @@ -155,7 +157,7 @@ public class RentalQueries { String reason = RentalDeliveryDiagnostics.explain(proof.path("delivery_proven").asBoolean(false), verified, number(row, "target_resource_quantity"), row.get("service_expires_at") == null ? null : time(row.get("service_expires_at")), - checked == null ? null : time(checked)); + checked == null ? null : time(checked), verificationGraceSeconds); row.put("fulfillment_reason", reason.isEmpty() ? "历史核验未通过,现有归档未记录明确失败项,请核对原任务及订单事件" : reason); return; diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/rental/RentalTasks.java b/ruoyi-system/src/main/java/com/ruoyi/system/rental/RentalTasks.java index bcdd0c6..c5978df 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/rental/RentalTasks.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/rental/RentalTasks.java @@ -13,6 +13,8 @@ import java.util.function.Supplier; @Service @lombok.extern.slf4j.Slf4j public class RentalTasks { + @org.springframework.beans.factory.annotation.Value("${rental.delivery.verification-grace-seconds:180}") + private long verificationGraceSeconds = 180L; @org.springframework.beans.factory.annotation.Autowired(required = false) private org.springframework.context.ApplicationEventPublisher deliveryEvents; private final RentalStore store; @@ -692,7 +694,8 @@ public class RentalTasks { Boolean.TRUE.equals(proof.get("delivery_proven")), proof.get("verified_resource_quantity") == null ? null : number(proof, "verified_resource_quantity"), - number(order, "target_resource_quantity"), expires, checkedAt); + number(order, "target_resource_quantity"), expires, checkedAt, + verificationGraceSeconds); String gap = RentalDeliveryDiagnostics.evidenceGap(text(proof, "delivery_evidence_gap")); if (!gap.isEmpty() && !Boolean.TRUE.equals(proof.get("delivery_proven"))) { reviewReason += ";" + gap;