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} 解除了婚姻关系。`); } });