<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ __('kylin-payment::payment.statistics.payment_records') }}</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f8f9fa;
        }
        .dashboard-card {
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            margin-bottom: 20px;
        }
        .dashboard-card .card-header {
            background-color: #007bff;
            color: white;
            border-radius: 8px 8px 0 0;
        }
        .table-container {
            max-height: 600px;
            overflow-y: auto;
        }
        .nav-link {
            cursor: pointer;
        }
        .nav-link.active {
            font-weight: bold;
        }
        .badge {
            padding: 0.5em 0.75em;
            font-size: 0.75rem;
            font-weight: 600;
            border-radius: 1rem;
        }
    </style>
</head>
<body>
    <div class="container-fluid">
        <div class="row">
            <div class="col-12">
                <h1 class="mt-4 mb-4">{{ __('kylin-payment::payment.statistics.payment_records') }}</h1>
                
                <!-- 搜索和筛选 -->
                <div class="dashboard-card mb-4">
                    <div class="card-body">
                        <form action="{{ route('kylin-payment.dashboard.payments') }}" method="GET">
                            <div class="row">
                                <div class="col-md-3">
                                    <div class="form-group">
                                        <label for="out_trade_no">{{ __('kylin-payment::payment.payment_types.order_no') }}</label>
                                        <input type="text" class="form-control" id="out_trade_no" name="out_trade_no" value="{{ $params['out_trade_no'] ?? '' }}">
                                    </div>
                                </div>
                                <div class="col-md-3">
                                    <div class="form-group">
                                        <label for="gateway">{{ __('kylin-payment::payment.payment_types.gateway') }}</label>
                                        <select class="form-control" id="gateway" name="gateway">
                                            <option value="">{{ __('kylin-payment::payment.messages.all') }}</option>
                                            <option value="wechat" {{ isset($params['gateway']) && $params['gateway'] == 'wechat' ? 'selected' : '' }}>{{ __('kylin-payment::payment.payment_types.wechat') }}</option>
                                            <option value="alipay" {{ isset($params['gateway']) && $params['gateway'] == 'alipay' ? 'selected' : '' }}>{{ __('kylin-payment::payment.payment_types.alipay') }}</option>
                                            <option value="unionpay" {{ isset($params['gateway']) && $params['gateway'] == 'unionpay' ? 'selected' : '' }}>{{ __('kylin-payment::payment.payment_types.unionpay') }}</option>
                                            <option value="douyin" {{ isset($params['gateway']) && $params['gateway'] == 'douyin' ? 'selected' : '' }}>{{ __('kylin-payment::payment.payment_types.douyin') }}</option>
                                            <option value="jsbank" {{ isset($params['gateway']) && $params['gateway'] == 'jsbank' ? 'selected' : '' }}>{{ __('kylin-payment::payment.payment_types.jsbank') }}</option>
                                            <option value="alipay_global" {{ isset($params['gateway']) && $params['gateway'] == 'alipay_global' ? 'selected' : '' }}>{{ __('kylin-payment::payment.payment_types.alipay_global') }}</option>
                                            <option value="paypal" {{ isset($params['gateway']) && $params['gateway'] == 'paypal' ? 'selected' : '' }}>{{ __('kylin-payment::payment.payment_types.paypal') }}</option>
                                            <option value="stripe" {{ isset($params['gateway']) && $params['gateway'] == 'stripe' ? 'selected' : '' }}>{{ __('kylin-payment::payment.payment_types.stripe') }}</option>
                                            <option value="google_pay" {{ isset($params['gateway']) && $params['gateway'] == 'google_pay' ? 'selected' : '' }}>{{ __('kylin-payment::payment.payment_types.google_pay') }}</option>
                                            <option value="apple_pay" {{ isset($params['gateway']) && $params['gateway'] == 'apple_pay' ? 'selected' : '' }}>{{ __('kylin-payment::payment.payment_types.apple_pay') }}</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="col-md-3">
                                    <div class="form-group">
                                        <label for="status">{{ __('kylin-payment::payment.payment_statuses.status') }}</label>
                                        <select class="form-control" id="status" name="status">
                                            <option value="">{{ __('kylin-payment::payment.messages.all') }}</option>
                                            <option value="pending" {{ isset($params['status']) && $params['status'] == 'pending' ? 'selected' : '' }}>{{ __('kylin-payment::payment.payment_statuses.pending') }}</option>
                                            <option value="success" {{ isset($params['status']) && $params['status'] == 'success' ? 'selected' : '' }}>{{ __('kylin-payment::payment.payment_statuses.success') }}</option>
                                            <option value="failed" {{ isset($params['status']) && $params['status'] == 'failed' ? 'selected' : '' }}>{{ __('kylin-payment::payment.payment_statuses.failed') }}</option>
                                            <option value="refunded" {{ isset($params['status']) && $params['status'] == 'refunded' ? 'selected' : '' }}>{{ __('kylin-payment::payment.payment_statuses.refunded') }}</option>
                                            <option value="closed" {{ isset($params['status']) && $params['status'] == 'closed' ? 'selected' : '' }}>{{ __('kylin-payment::payment.payment_statuses.closed') }}</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="col-md-3">
                                    <div class="form-group">
                                        <label for="date">{{ __('kylin-payment::payment.statistics.date') }}</label>
                                        <input type="date" class="form-control" id="date" name="date" value="{{ $params['date'] ?? '' }}">
                                    </div>
                                </div>
                            </div>
                            <div class="row mt-3">
                                <div class="col-md-12 text-right">
                                    <button type="submit" class="btn btn-primary">{{ __('kylin-payment::payment.messages.search') }}</button>
                                    <a href="{{ route('kylin-payment.dashboard.payments') }}" class="btn btn-secondary ml-2">{{ __('kylin-payment::payment.messages.reset') }}</a>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
                
                <!-- 支付记录表格 -->
                <div class="dashboard-card">
                    <div class="card-header">
                        {{ __('kylin-payment::payment.statistics.payment_records') }}
                    </div>
                    <div class="card-body">
                        <div class="table-container">
                            <table class="table table-striped">
                                <thead>
                                    <tr>
                                        <th>{{ __('kylin-payment::payment.payment_types.order_no') }}</th>
                                        <th>{{ __('kylin-payment::payment.payment_types.gateway') }}</th>
                                        <th>{{ __('kylin-payment::payment.statistics.amount') }}</th>
                                        <th>{{ __('kylin-payment::payment.payment_statuses.status') }}</th>
                                        <th>{{ __('kylin-payment::payment.payment_types.gateway_trade_no') }}</th>
                                        <th>{{ __('kylin-payment::payment.statistics.client_ip') }}</th>
                                        <th>{{ __('kylin-payment::payment.statistics.created_at') }}</th>
                                        <th>{{ __('kylin-payment::payment.statistics.updated_at') }}</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach($payments as $payment)
                                        <tr>
                                            <td>{{ $payment->out_trade_no }}</td>
                                            <td>{{ $payment->gateway }}</td>
                                            <td>{{ number_format($payment->amount, 2) }} {{ $payment->currency }}</td>
                                            <td>
                                                @if($payment->status == 'success')
                                                    <span class="badge bg-success">{{ __('kylin-payment::payment.payment_statuses.success') }}</span>
                                                @elseif($payment->status == 'failed')
                                                    <span class="badge bg-danger">{{ __('kylin-payment::payment.payment_statuses.failed') }}</span>
                                                @elseif($payment->status == 'pending')
                                                    <span class="badge bg-warning">{{ __('kylin-payment::payment.payment_statuses.pending') }}</span>
                                                @elseif($payment->status == 'refunded')
                                                    <span class="badge bg-info">{{ __('kylin-payment::payment.payment_statuses.refunded') }}</span>
                                                @elseif($payment->status == 'closed')
                                                    <span class="badge bg-secondary">{{ __('kylin-payment::payment.payment_statuses.closed') }}</span>
                                                @else
                                                    <span class="badge bg-light text-dark">{{ $payment->status }}</span>
                                                @endif
                                            </td>
                                            <td>{{ $payment->gateway_trade_no ?? '-' }}</td>
                                            <td>{{ $payment->client_ip ?? '-' }}</td>
                                            <td>{{ $payment->created_at }}</td>
                                            <td>{{ $payment->updated_at }}</td>
                                        </tr>
                                    @endforeach
                                </tbody>
                            </table>
                        </div>
                        
                        <!-- 分页 -->
                        <div class="mt-4">
                            {{ $payments->appends($params)->links() }}
                        </div>
                    </div>
                </div>
                
                <!-- 导航链接 -->
                <div class="row mt-4">
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-body">
                                <div class="nav nav-tabs">
                                    <a class="nav-link" href="{{ route('kylin-payment.dashboard.index') }}">{{ __('kylin-payment::payment.statistics.dashboard') }}</a>
                                    <a class="nav-link active" data-toggle="tab" href="#payments">{{ __('kylin-payment::payment.statistics.payment_records') }}</a>
                                    <a class="nav-link" href="{{ route('kylin-payment.dashboard.callbacks') }}">{{ __('kylin-payment::payment.statistics.callback_logs') }}</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
