From 73c78ee6d7e84ab3c2f8ae573829f78f0f182759 Mon Sep 17 00:00:00 2001 From: lkddi Date: Sun, 1 Mar 2026 18:15:37 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=B9=E6=80=A7=EF=BC=9A=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=9C=A8=E5=90=8E=E5=8F=B0=E9=85=8D=E7=BD=AE=E7=BB=93=E5=A9=9A?= =?UTF-8?q?=E7=A6=BB=E5=A9=9A=E5=86=B7=E9=9D=99=E6=9C=9F=E8=A7=84=E5=88=99?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E4=BC=98=E5=8C=96=E5=86=B7=E5=8D=B4=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=96=87=E6=9C=AC=E6=8F=90=E7=A4=BA=EF=BC=9B=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=85=A8=E5=B1=80=E7=9A=84=E7=A6=BB=E5=A9=9A=E5=85=AC?= =?UTF-8?q?=E5=91=8A=E4=BA=8B=E4=BB=B6=E5=AF=B9=E8=B1=A1=E6=8E=A5=E6=94=B6?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E4=B8=8D=E5=8C=B9=E9=85=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/MarriageService.php | 4 +- ...81247_add_divorce_cooldown_to_sysparam.php | 40 +++++++++++++++++++ .../chat/partials/marriage-modals.blade.php | 17 ++++---- 3 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 database/migrations/2026_03_01_181247_add_divorce_cooldown_to_sysparam.php diff --git a/app/Services/MarriageService.php b/app/Services/MarriageService.php index a518296..26bd9ef 100644 --- a/app/Services/MarriageService.php +++ b/app/Services/MarriageService.php @@ -442,7 +442,9 @@ class MarriageService $cooldownEnds = $lastDivorce->divorced_at?->addDays($cooldownDays); if ($cooldownEnds && $cooldownEnds->isFuture()) { - $remaining = now()->diffInDays($cooldownEnds, false); + // 取两者的完全相差天数,如果有部分不够一天的则向上取整为 1 天(例:还剩 2小时 = 1天) + $diffInHours = now()->diffInHours($cooldownEnds); + $remaining = max(1, (int) ceil($diffInHours / 24)); return "您还在离婚冷静期,还需 {$remaining} 天后才能再次结婚。"; } diff --git a/database/migrations/2026_03_01_181247_add_divorce_cooldown_to_sysparam.php b/database/migrations/2026_03_01_181247_add_divorce_cooldown_to_sysparam.php new file mode 100644 index 0000000..9088ed2 --- /dev/null +++ b/database/migrations/2026_03_01_181247_add_divorce_cooldown_to_sysparam.php @@ -0,0 +1,40 @@ +insertOrIgnore([ + [ + 'alias' => 'divorce_mutual_cooldown', + 'guidetxt' => '协议离婚冷静期(天)', + 'body' => '70' + ], + [ + 'alias' => 'divorce_forced_cooldown', + 'guidetxt' => '强制离婚冷静期(天)', + 'body' => '70' + ], + [ + 'alias' => 'divorce_auto_cooldown', + 'guidetxt' => '系统强制离婚冷静期(天)', + 'body' => '70' + ], + ]); + } + + public function down(): void + { + DB::table('sysparam')->whereIn('alias', [ + 'divorce_mutual_cooldown', + 'divorce_forced_cooldown', + 'divorce_auto_cooldown' + ])->delete(); + } +}; diff --git a/resources/views/chat/partials/marriage-modals.blade.php b/resources/views/chat/partials/marriage-modals.blade.php index cca649b..3630a94 100644 --- a/resources/views/chat/partials/marriage-modals.blade.php +++ b/resources/views/chat/partials/marriage-modals.blade.php @@ -167,10 +167,13 @@ @@ -982,11 +985,11 @@ }); window.addEventListener('chat:marriage-divorced', (e) => { const { - user_name, - partner_name + user_username, + partner_username } = e.detail; if (typeof appendSystemMessage === 'function') { - appendSystemMessage(`💔 ${user_name} 与 ${partner_name} 解除了婚姻关系。`); + appendSystemMessage(`💔 ${user_username} 与 ${partner_username} 解除了婚姻关系。`); } });