diff --git a/app/Http/Controllers/Admin/MarriageManagerController.php b/app/Http/Controllers/Admin/MarriageManagerController.php index bb08932..88ee2b9 100644 --- a/app/Http/Controllers/Admin/MarriageManagerController.php +++ b/app/Http/Controllers/Admin/MarriageManagerController.php @@ -1,10 +1,249 @@ Marriage::where('status', 'married')->count(), + 'total_pending' => Marriage::where('status', 'pending')->count(), + 'total_divorced' => Marriage::where('status', 'divorced')->count(), + 'total_weddings' => WeddingCeremony::whereIn('status', ['active', 'completed'])->count(), + 'total_envelopes' => WeddingEnvelopeClaim::sum('amount'), + 'claimed_amount' => WeddingEnvelopeClaim::where('claimed', true)->sum('amount'), + ]; + + $recentMarriages = Marriage::with(['user:id,username', 'partner:id,username', 'ringItem:id,name,icon']) + ->where('status', 'married') + ->orderByDesc('married_at') + ->limit(10) + ->get(); + + $recentDivorces = Marriage::with(['user:id,username', 'partner:id,username']) + ->where('status', 'divorced') + ->orderByDesc('divorced_at') + ->limit(8) + ->get(); + + return view('admin.marriages.index', compact('stats', 'recentMarriages', 'recentDivorces')); + } + + /** + * 婚姻列表(支持按状态/用户名筛选)。 + */ + public function list(Request $request): View + { + $query = Marriage::with(['user:id,username', 'partner:id,username', 'ringItem:id,name,icon']) + ->orderByDesc('id'); + + if ($status = $request->get('status')) { + $query->where('status', $status); + } + if ($search = $request->get('search')) { + $query->where(function ($q) use ($search) { + $q->whereHas('user', fn ($u) => $u->where('username', 'like', "%{$search}%")) + ->orWhereHas('partner', fn ($u) => $u->where('username', 'like', "%{$search}%")); + }); + } + + $marriages = $query->paginate(20)->withQueryString(); + + return view('admin.marriages.list', compact('marriages')); + } + + /** + * 求婚记录列表(含 pending/expired/rejected)。 + */ + public function proposals(Request $request): View + { + $proposals = Marriage::with(['user:id,username', 'partner:id,username', 'ringItem:id,name,icon']) + ->whereIn('status', ['pending', 'expired', 'rejected']) + ->orderByDesc('proposed_at') + ->paginate(20) + ->withQueryString(); + + return view('admin.marriages.proposals', compact('proposals')); + } + + /** + * 婚礼红包记录。 + */ + public function ceremonies(Request $request): View + { + $ceremonies = WeddingCeremony::with([ + 'marriage.user:id,username', + 'marriage.partner:id,username', + 'tier:id,name,tier,icon', + ]) + ->orderByDesc('id') + ->paginate(20) + ->withQueryString(); + + return view('admin.marriages.ceremonies', compact('ceremonies')); + } + + /** + * 红包领取明细(某场婚礼)。 + */ + public function claimDetail(WeddingCeremony $ceremony): View + { + $ceremony->load(['marriage.user:id,username', 'marriage.partner:id,username', 'tier:id,name,icon']); + + $claims = WeddingEnvelopeClaim::with('user:id,username,headface') + ->where('ceremony_id', $ceremony->id) + ->orderBy('amount', 'desc') + ->paginate(30); + + return view('admin.marriages.claim-detail', compact('ceremony', 'claims')); + } + + /** + * 亲密度日志列表(支持按用户筛选)。 + */ + public function intimacyLogs(Request $request): View + { + $query = MarriageIntimacyLog::with(['marriage.user:id,username', 'marriage.partner:id,username']) + ->orderByDesc('id'); + + if ($search = $request->get('search')) { + $query->whereHas('marriage', function ($q) use ($search) { + $q->whereHas('user', fn ($u) => $u->where('username', 'like', "%{$search}%")) + ->orWhereHas('partner', fn ($u) => $u->where('username', 'like', "%{$search}%")); + }); + } + if ($source = $request->get('source')) { + $query->where('source', $source); + } + + $logs = $query->paginate(30)->withQueryString(); + + return view('admin.marriages.intimacy-logs', compact('logs')); + } + + /** + * 参数配置页面(读取所有分组配置)。 + */ + public function configs(): View + { + $groups = $this->config->allGrouped(); + + return view('admin.marriages.configs', compact('groups')); + } + + /** + * 批量保存参数配置。 + */ + public function updateConfigs(Request $request): RedirectResponse + { + $data = $request->validate([ + 'configs' => 'required|array', + 'configs.*' => 'required|integer', + ]); + + $this->config->batchSet($data['configs']); + + return redirect()->route('admin.marriages.configs')->with('success', '婚姻参数配置已保存!'); + } + + /** + * 婚礼档位配置页面。 + */ + public function tiers(): View + { + $tiers = WeddingTier::orderBy('tier')->get(); + + return view('admin.marriages.tiers', compact('tiers')); + } + + /** + * 更新婚礼档位。 + */ + public function updateTier(Request $request, WeddingTier $tier): RedirectResponse + { + $data = $request->validate([ + 'name' => 'required|string|max:30', + 'icon' => 'required|string|max:20', + 'amount' => 'required|integer|min:1', + 'description' => 'nullable|string|max:100', + 'is_active' => 'boolean', + ]); + + $data['is_active'] = $request->boolean('is_active', true); + $tier->update($data); + + return redirect()->route('admin.marriages.tiers')->with('success', "档位【{$tier->name}】已更新!"); + } + + /** + * 管理员强制离婚。 + */ + public function forceDissolve(Request $request, Marriage $marriage): RedirectResponse + { + $data = $request->validate([ + 'admin_note' => 'required|string|max:200', + ]); + + if ($marriage->status !== 'married') { + return back()->with('error', '该婚姻不是已婚状态,无法操作。'); + } + + $admin = $request->user(); + $result = $this->marriageService->forceDissolve($marriage, $admin, true); + + // 写入管理员备注 + $marriage->update(['admin_note' => $data['admin_note']]); + + $msg = $result['ok'] ? '强制离婚已完成。' : $result['message']; + $type = $result['ok'] ? 'success' : 'error'; + + return back()->with($type, $msg); + } + + /** + * 管理员取消求婚(释放戒指 → 退还状态 active)。 + */ + public function cancelProposal(Request $request, Marriage $marriage): RedirectResponse + { + if ($marriage->status !== 'pending') { + return back()->with('error', '该求婚不是进行中状态,无法取消。'); + } + + $this->marriageService->expireProposal($marriage); + $marriage->update(['admin_note' => '管理员手动取消求婚:'.($request->input('reason', ''))]); + + return back()->with('success', '求婚已取消,戒指标记遗失。'); + } } diff --git a/resources/views/admin/layouts/app.blade.php b/resources/views/admin/layouts/app.blade.php index 223b65d..51d7e49 100644 --- a/resources/views/admin/layouts/app.blade.php +++ b/resources/views/admin/layouts/app.blade.php @@ -67,6 +67,10 @@ class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.vip.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}"> {!! '👑 VIP 会员等级' . $ro !!} + + {!! '💒 婚姻管理' . $ro !!} + {!! '🏛️ 部门管理' . $ro !!} diff --git a/resources/views/admin/marriages/ceremonies.blade.php b/resources/views/admin/marriages/ceremonies.blade.php new file mode 100644 index 0000000..6b72e24 --- /dev/null +++ b/resources/views/admin/marriages/ceremonies.blade.php @@ -0,0 +1,104 @@ +{{-- + 文件功能:婚礼仪式记录页(含红包分发详情链接) + + @author ChatRoom Laravel + @version 1.0.0 +--}} + +@extends('admin.layouts.app') + +@section('title', '婚礼红包记录') + +@section('content') + +
+

🎊 婚礼红包记录

+
← 返回总览 +
+ +
+
+ + + + + + + + + + + + + + + + @forelse ($ceremonies as $c) + + + + + + + + + + + + @empty + + + + @endforelse + +
ID新人档位总金额在线人数领取进度状态时间详情
{{ $c->id }} + {{ $c->marriage?->user?->username }} + × + {{ $c->marriage?->partner?->username }} + + {{ $c->tier?->icon }} {{ $c->tier?->name ?? '—' }} + + {{ number_format($c->total_amount) }} 金 + + {{ $c->online_count ?? '—' }} + + @if ($c->total_amount > 0) +
+ {{ $c->claimed_count }} / {{ $c->online_count ?? '?' }} 人 +
+
+ {{ number_format($c->claimed_amount) }} / {{ number_format($c->total_amount) }} +
+ @else + 无红包 + @endif +
+ + {{ ['completed' => '已完成', 'active' => '进行中', 'pending' => '待触发', 'expired' => '已过期', 'cancelled' => '已取消'][$c->status] ?? $c->status }} + + + {{ $c->ceremony_at?->format('Y-m-d H:i') }} + + @if ($c->total_amount > 0) + 明细 + @else + + @endif +
暂无婚礼记录
+
+ @if ($ceremonies->hasPages()) +
{{ $ceremonies->links() }}
+ @endif +
+ +@endsection diff --git a/resources/views/admin/marriages/claim-detail.blade.php b/resources/views/admin/marriages/claim-detail.blade.php new file mode 100644 index 0000000..6e5cf30 --- /dev/null +++ b/resources/views/admin/marriages/claim-detail.blade.php @@ -0,0 +1,85 @@ +{{-- + 文件功能:婚礼红包领取明细页 + + @author ChatRoom Laravel + @version 1.0.0 +--}} + +@extends('admin.layouts.app') + +@section('title', '婚礼红包明细') + +@section('content') + +
+
+

🎁 红包领取明细

+

+ {{ $ceremony->marriage?->user?->username }} × {{ $ceremony->marriage?->partner?->username }} + — {{ $ceremony->tier?->icon }} {{ $ceremony->tier?->name ?? '婚礼' }} + · 总额 {{ number_format($ceremony->total_amount) }} 金 +

+
+ ← 返回婚礼列表 +
+ + {{-- 汇总 --}} +
+
+
{{ $ceremony->online_count ?? 0 }}
+
在线人数
+
+
+
{{ $ceremony->claimed_count }}
+
已领取人数
+
+
+
{{ number_format($ceremony->claimed_amount) }}
+
已领取金额
+
+
+ +
+
+ + + + + + + + + + + @forelse ($claims as $claim) + + + + + + + @empty + + + + @endforelse + +
用户分配金额状态领取时间
{{ $claim->user?->username }} + {{ number_format($claim->amount) }} 金 + + @if ($claim->claimed) + ✅ + 已领取 + @else + 未领取 + @endif + + {{ $claim->claimed_at?->format('H:i:s') ?? '—' }} +
暂无领取记录
+
+ @if ($claims->hasPages()) +
{{ $claims->links() }}
+ @endif +
+ +@endsection diff --git a/resources/views/admin/marriages/configs.blade.php b/resources/views/admin/marriages/configs.blade.php new file mode 100644 index 0000000..ee88ffb --- /dev/null +++ b/resources/views/admin/marriages/configs.blade.php @@ -0,0 +1,75 @@ +{{-- + 文件功能:婚姻参数配置页(所有参数按分组展示,可批量保存) + + @author ChatRoom Laravel + @version 1.0.0 +--}} + +@extends('admin.layouts.app') + +@section('title', '婚姻参数配置') + +@section('content') + +
+
+

⚙️ 婚姻参数配置

+

修改参数后点击「保存」生效,参数变更会自动清除缓存

+
+ ← 返回总览 +
+ + @if (session('success')) +
+ ✅ {{ session('success') }} +
+ @endif + +
+ @csrf + + @foreach ($groups as $groupName => $configs) +
+
+ {{ $groupName }} + ({{ $configs->count() }} 项) +
+
+ @foreach ($configs as $cfg) +
+
+
{{ $cfg->label }}
+ @if ($cfg->description) +
{{ $cfg->description }}
+ @endif +
{{ $cfg->key }}
+
+
+ @if ($cfg->min !== null) + 最小: {{ $cfg->min }} + @endif + min !== null) min="{{ $cfg->min }}" @endif + @if ($cfg->max !== null) max="{{ $cfg->max }}" @endif required + class="border rounded-lg px-3 py-1.5 text-sm w-28 text-center font-bold focus:outline-none focus:ring-2 focus:ring-indigo-300"> + @if ($cfg->max !== null) + 最大: {{ $cfg->max }} + @endif +
+
+ @endforeach +
+
+ @endforeach + +
+ 取消 + +
+
+ +@endsection diff --git a/resources/views/admin/marriages/index.blade.php b/resources/views/admin/marriages/index.blade.php new file mode 100644 index 0000000..cbd9ca3 --- /dev/null +++ b/resources/views/admin/marriages/index.blade.php @@ -0,0 +1,145 @@ +{{-- + 文件功能:后台婚姻管理总览页 + 统计卡片 + 最近结婚记录 + 最近离婚记录 + + @author ChatRoom Laravel + @version 1.0.0 +--}} + +@extends('admin.layouts.app') + +@section('title', '婚姻管理 - 总览') + +@section('content') + + {{-- 页面标题 --}} +
+
+

💒 婚姻管理

+

婚姻系统总览,管理求婚、结婚、婚礼及参数配置

+
+
+ + ⚙️ 参数配置 + + + 🎊 婚礼档位 + +
+
+ + {{-- 统计卡片 --}} +
+
+
💑
+
{{ $stats['total_married'] }}
+
当前已婚
+
+
+
💍
+
{{ $stats['total_pending'] }}
+
求婚中
+
+
+
💔
+
{{ $stats['total_divorced'] }}
+
已离婚
+
+
+
🎊
+
{{ $stats['total_weddings'] }}
+
婚礼场次
+
+
+
🎁
+
{{ number_format($stats['total_envelopes']) }}
+
红包总额(金)
+
+
+
+
{{ number_format($stats['claimed_amount']) }}
+
已领取(金)
+
+
+ + {{-- 快捷入口 --}} +
+ @foreach ([['route' => 'admin.marriages.list', 'icon' => '📋', 'label' => '婚姻列表', 'color' => 'blue'], ['route' => 'admin.marriages.proposals', 'icon' => '💌', 'label' => '求婚记录', 'color' => 'amber'], ['route' => 'admin.marriages.ceremonies', 'icon' => '🎊', 'label' => '婚礼红包', 'color' => 'pink'], ['route' => 'admin.marriages.intimacy-logs', 'icon' => '💞', 'label' => '亲密度日志', 'color' => 'purple']] as $item) + + {{ $item['icon'] }} + {{ $item['label'] }} + + @endforeach +
+ + {{-- 最近已婚 --}} +
+
+
+

💑 最近结婚

+ 查看全部 +
+
+ @forelse ($recentMarriages as $m) +
+
+ {{ $m->ringItem?->icon ?? '💍' }} +
+ {{ $m->user?->username }} + × + {{ $m->partner?->username }} +
+
+
+
{{ $m->married_at?->format('m/d') }}
+
+ {{ \App\Services\MarriageIntimacyService::levelName($m->level) }}
+
+
+ @empty +
暂无已婚记录
+ @endforelse +
+
+ + {{-- 最近离婚 --}} +
+
+

💔 最近离婚

+ 查看全部 +
+
+ @forelse ($recentDivorces as $m) +
+
+ {{ $m->user?->username }} + × + {{ $m->partner?->username }} +
+
+ + {{ match ($m->divorce_type) {'forced' => '强制','auto' => '超时','admin' => '管理员',default => '协议'} }} + +
{{ $m->divorced_at?->format('m/d') }}
+
+
+ @empty +
暂无离婚记录
+ @endforelse +
+
+
+ +@endsection diff --git a/resources/views/admin/marriages/intimacy-logs.blade.php b/resources/views/admin/marriages/intimacy-logs.blade.php new file mode 100644 index 0000000..cefeb6d --- /dev/null +++ b/resources/views/admin/marriages/intimacy-logs.blade.php @@ -0,0 +1,97 @@ +{{-- + 文件功能:亲密度变更日志审计页 + + @author ChatRoom Laravel + @version 1.0.0 +--}} + +@extends('admin.layouts.app') + +@section('title', '亲密度日志') + +@section('content') + +
+

💞 亲密度变更日志

+ ← 返回总览 +
+ + {{-- 筛选 --}} +
+
+ + +
+
+ + +
+ + 重置 +
+ +
+
+ + + + + + + + + + + + + + @forelse ($logs as $log) + + + + + + + + + + @empty + + + + @endforelse + +
ID婚姻双方变动量变后余额来源备注时间
{{ $log->id }} + {{ $log->marriage?->user?->username }} + × + {{ $log->marriage?->partner?->username }} + + {{ $log->amount >= 0 ? '+' : '' }}{{ $log->amount }} + + {{ number_format($log->balance_after) }} + + + {{ \App\Enums\IntimacySource::tryFrom($log->source)?->label() ?? $log->source }} + + {{ $log->remark ?? '—' }} + {{ $log->created_at?->format('m-d H:i') }} +
暂无记录
+
+ @if ($logs->hasPages()) +
{{ $logs->links() }}
+ @endif +
+ +@endsection diff --git a/resources/views/admin/marriages/list.blade.php b/resources/views/admin/marriages/list.blade.php new file mode 100644 index 0000000..d0407bb --- /dev/null +++ b/resources/views/admin/marriages/list.blade.php @@ -0,0 +1,162 @@ +{{-- + 文件功能:后台婚姻列表页(支持状态筛选/用户名搜索) + + @author ChatRoom Laravel + @version 1.0.0 +--}} + +@extends('admin.layouts.app') + +@section('title', '婚姻列表') + +@section('content') + +
+

📋 婚姻列表

+ ← 返回总览 +
+ + {{-- 筛选栏 --}} +
+
+ + +
+
+ + +
+ + 重置 +
+ + {{-- 婚姻列表 --}} +
+
+ + + + + + + + + + + + + + + @forelse ($marriages as $m) + + + + + + + + + + + @empty + + + + @endforelse + +
ID双方戒指状态亲密度/等级结婚天数时间操作
{{ $m->id }} +
{{ $m->user?->username }}
+
× {{ $m->partner?->username }}
+
+ {{ $m->ringItem?->icon }} {{ $m->ringItem?->name ?? '—' }} + + + {{ ['married' => '💑 已婚', 'pending' => '💍 求婚中', 'divorced' => '💔 已离婚', 'rejected' => '❌ 被拒', 'expired' => '⏰ 已过期'][$m->status] ?? $m->status }} + + +
{{ number_format($m->intimacy) }}
+
+ {{ \App\Services\MarriageIntimacyService::levelIcon($m->level) }} + Lv{{ $m->level }}
+
+ {{ $m->married_at ? $m->married_at->diffInDays(now()) . ' 天' : '—' }} + + @if ($m->married_at) + 结婚:{{ $m->married_at->format('Y-m-d') }} + @elseif ($m->proposed_at) + 求婚:{{ $m->proposed_at->format('Y-m-d') }} + @endif + @if ($m->divorced_at) +
离婚:{{ $m->divorced_at->format('Y-m-d') }}
+ @endif +
+ @if ($m->status === 'married') + + {{-- 强制离婚确认弹窗 --}} + + @elseif ($m->status === 'pending') +
+ @csrf + +
+ @else + + @endif +
暂无记录
+
+ + {{-- 分页 --}} + @if ($marriages->hasPages()) +
{{ $marriages->links() }}
+ @endif +
+ +@endsection diff --git a/resources/views/admin/marriages/proposals.blade.php b/resources/views/admin/marriages/proposals.blade.php new file mode 100644 index 0000000..b73e649 --- /dev/null +++ b/resources/views/admin/marriages/proposals.blade.php @@ -0,0 +1,89 @@ +{{-- + 文件功能:求婚记录页(含取消操作) + + @author ChatRoom Laravel + @version 1.0.0 +--}} + +@extends('admin.layouts.app') + +@section('title', '求婚记录') + +@section('content') + +
+

💌 求婚记录

+ ← 返回总览 +
+ +
+
+ + + + + + + + + + + + + + + @forelse ($proposals as $p) + + + + + + + + + + + @empty + + + + @endforelse + +
ID发起方目标戒指状态求婚时间过期时间操作
{{ $p->id }}{{ $p->user?->username }}{{ $p->partner?->username }}{{ $p->ringItem?->icon }} {{ $p->ringItem?->name ?? '—' }} + + {{ ['pending' => '⏳ 等待中', 'rejected' => '❌ 已拒绝', 'expired' => '⏰ 已过期'][$p->status] ?? $p->status }} + + {{ $p->proposed_at?->format('Y-m-d H:i') }} + {{ $p->expires_at?->format('Y-m-d H:i') }} + @if ($p->status === 'pending' && $p->expires_at?->isPast()) + (已超时) + @endif + + @if ($p->status === 'pending') +
+ @csrf + +
+ @else + + @endif +
暂无求婚记录
+
+ @if ($proposals->hasPages()) +
{{ $proposals->links() }}
+ @endif +
+ +@endsection diff --git a/resources/views/admin/marriages/tiers.blade.php b/resources/views/admin/marriages/tiers.blade.php new file mode 100644 index 0000000..85c1eb3 --- /dev/null +++ b/resources/views/admin/marriages/tiers.blade.php @@ -0,0 +1,107 @@ +{{-- + 文件功能:婚礼档位配置页(5档固定,可修改名称/图标/金额/描述/启用状态) + + @author ChatRoom Laravel + @version 1.0.0 +--}} + +@extends('admin.layouts.app') + +@section('title', '婚礼档位配置') + +@section('content') + +
+
+

🎊 婚礼档位配置

+

5个固定档位,可修改名称、金额及启用状态(不可增删)

+
+ ← 返回总览 +
+ + @if (session('success')) +
+ ✅ {{ session('success') }} +
+ @endif + +
+ @foreach ($tiers as $tier) +
+ {{-- 档位头部 --}} +
+
+ {{ $tier->icon }} +
+
{{ $tier->name }}
+
第 {{ $tier->tier }} 档
+
+
+
+ @if (!$tier->is_active) + 已禁用 + @endif + +
+
+ + {{-- 当前值展示 --}} +
+
+ 金币总额 + {{ number_format($tier->amount) }} 金 +
+ @if ($tier->description) +

{{ $tier->description }}

+ @endif +
+ + {{-- 编辑表单 --}} + +
+ @endforeach +
+ +@endsection