diff --git a/app/Http/Controllers/Admin/CurrencyLogController.php b/app/Http/Controllers/Admin/CurrencyLogController.php new file mode 100644 index 0000000..68f3422 --- /dev/null +++ b/app/Http/Controllers/Admin/CurrencyLogController.php @@ -0,0 +1,70 @@ +with('user'); + + // 查询条件过滤 + if ($request->filled('username')) { + $query->where('username', 'like', '%'.$request->input('username').'%'); + } + + if ($request->filled('currency')) { + $query->where('currency', $request->input('currency')); + } + + if ($request->filled('source')) { + $query->where('source', $request->input('source')); + } + + if ($request->filled('remark')) { + $query->where('remark', 'like', '%'.$request->input('remark').'%'); + } + + if ($request->filled('direction')) { + if ($request->input('direction') === 'in') { + $query->where('amount', '>', 0); + } elseif ($request->input('direction') === 'out') { + $query->where('amount', '<', 0); + } + } + + if ($request->filled('date_start')) { + $query->whereDate('created_at', '>=', $request->input('date_start')); + } + + if ($request->filled('date_end')) { + $query->whereDate('created_at', '<=', $request->input('date_end')); + } + + // 默认按时间倒序 + $logs = $query->latest('id')->paginate(50)->withQueryString(); + + $allSources = CurrencySource::cases(); + + return view('admin.currency-logs.index', compact('logs', 'allSources')); + } +} diff --git a/resources/views/admin/currency-logs/index.blade.php b/resources/views/admin/currency-logs/index.blade.php new file mode 100644 index 0000000..a3f2030 --- /dev/null +++ b/resources/views/admin/currency-logs/index.blade.php @@ -0,0 +1,181 @@ +@extends('admin.layouts.app') + +@section('title', '金币/积分流水查询') + +@section('content') + +
| 记录ID | +用户 | +类型 | +变动数额 | +变后余额 | +来源 | +备注信息 | +发生时间 | +
|---|---|---|---|---|---|---|---|
| + #{{ $log->id }} + | +
+
+ {{ $log->username }}
+ ID: {{ $log->user_id }}
+
+ |
+ + @if($log->currency === 'gold') + + 💰 金币 + + @elseif($log->currency === 'exp') + + ⭐ 经验 + + @elseif($log->currency === 'charm') + + 💖 魅力 + + @else + {{ $log->currency }} + @endif + | ++ @if ($log->amount > 0) + +{{ $log->amount }} + @elseif ($log->amount === 0) + 0 + @else + {{ $log->amount }} + @endif + | ++ {{ $log->balance_after }} + | ++ @php + $sourceLabel = \App\Enums\CurrencySource::tryFrom($log->source)?->label() ?? $log->source; + @endphp + + {{ $sourceLabel }} + + | +
+ {{ $log->remark }}
+ @if($log->room_id)
+ 房间ID: {{ $log->room_id }}
+ @endif
+ |
+ + {{ $log->created_at->format('Y-m-d H:i:s') }} + | +
| + 📭 暂无相关流水记录 + | +|||||||