@extends('admin.layout') @section('title', 'API Müşteri Detayı') @section('page-title', 'API Müşteri Detayı') @section('content') {{-- ═══ Profil ═══ --}}

{{ $customer->name }} @if ($customer->google_id) Google @endif @if ($customer->email_verified_at) E-posta doğrulandı @else E-posta doğrulanmadı @endif

{{ $customer->email }} · #{{ $customer->id }}
Listeye dön
Kredi Bakiyesi

{{ number_format((int) $customer->api_credit_balance, 0, ',', '.') }}

Son {{ $windowDays }} gün istek

{{ number_format($windowRequests, 0, ',', '.') }}

{{ number_format($windowCredits, 0, ',', '.') }} kredi düşüldü
Toplam istek (tüm zaman)

{{ number_format($lifetimeRequests, 0, ',', '.') }}

Son: {{ $lastRequestAt ? \Illuminate\Support\Carbon::parse($lastRequestAt)->format('d.m.Y H:i') : '—' }}
Toplam Harcama

{{ number_format($orderStats['paid_total'], 2, ',', '.') }} ₺

{{ $orderStats['paid_count'] }} ödenmiş / {{ $orderStats['total_count'] }} sipariş
Telefon
{{ $customer->phone ?: '—' }}
Fatura Adı
{{ $customer->billing_name ?: '—' }}
Vergi No
{{ $customer->billing_tax_no ?: '—' }}
Kayıt Tarihi
{{ $customer->created_at?->format('d.m.Y H:i') ?? '—' }}
Fatura Adresi
{{ $customer->billing_address ?: '—' }}
{{-- ═══ (a) API Key'leri ═══ --}}
API Key'leri ({{ $keys->count() }})
@if ($keys->count() > 0)
@foreach ($keys as $key) @endforeach
Ad Prefix Ortam Durum Son Kullanım Son {{ $windowDays }} Gün İşlemler
{{ $key->name }} {{ $key->key_prefix }} {{ $key->environment }} @if ($key->status === \App\Models\ApiKey::STATUS_ACTIVE) Aktif @else Askıya alınmış @endif {{ $key->last_used_at?->format('d.m.Y H:i') ?? '—' }} {{ number_format((int) $key->recent_requests_count, 0, ',', '.') }}
@if ($key->status === \App\Models\ApiKey::STATUS_ACTIVE)
@csrf @method('PATCH')
@else
@csrf @method('PATCH')
@endif
@else

Bu müşterinin henüz API key'i yok.

@endif
{{-- ═══ (b) Plan abonelikleri ═══ --}}
Plan Abonelikleri @if ($activePlanSubscription && $activePlanSubscription->plan) Aktif: {{ $activePlanSubscription->plan->code }} @else Aktif plan yok @endif
@if ($planSubscriptions->count() > 0)
@foreach ($planSubscriptions as $sub) @endforeach
Plan Başlangıç Bitiş Durum Dönem Başı Dönem Kullanımı
{{ $sub->plan?->code ?? '—' }} {{ $sub->plan?->name_key }} {{ $sub->starts_at?->format('d.m.Y') ?? '—' }} {{ $sub->ends_at?->format('d.m.Y') ?? 'süresiz' }} @if ($sub->isActive()) aktif @else {{ $sub->status }} @endif {{ $sub->period_started_at?->format('d.m.Y') ?? '—' }} {{ number_format((int) $sub->period_requests_used, 0, ',', '.') }} @if ($sub->plan?->monthly_request_quota) / {{ number_format((int) $sub->plan->monthly_request_quota, 0, ',', '.') }} @else / sınırsız @endif
@else

Bu müşterinin plan aboneliği yok.

@endif
{{-- ═══ (c) SKU bakiyeleri + endpoint abonelikleri ═══ --}}
SKU Bakiyeleri (tek seferlik paketler)
@if ($skuBalances->count() > 0)
@foreach ($skuBalances as $balance) @endforeach
SKU Kalan İstek Güncelleme
{{ $balance->sku }} {{ number_format((int) $balance->requests_remaining, 0, ',', '.') }} {{ $balance->updated_at?->format('d.m.Y H:i') ?? '—' }}
@else

Tek seferlik paket bakiyesi yok.

@endif
Endpoint Abonelikleri (aylık)
@if ($endpointSubscriptions->count() > 0)
@foreach ($endpointSubscriptions as $sub) @endforeach
SKU Kota Dönem Kullanımı Bitiş Durum
{{ $sub->sku }} @if ($sub->offer) paket#{{ $sub->offer->id }} · {{ number_format((float) $sub->offer->price, 2, ',', '.') }} ₺ @endif {{ number_format((int) $sub->monthly_request_quota, 0, ',', '.') }} {{ number_format((int) $sub->period_requests_used, 0, ',', '.') }} kalan: {{ number_format(max(0, (int) $sub->monthly_request_quota - (int) $sub->period_requests_used), 0, ',', '.') }} {{ $sub->ends_at?->format('d.m.Y') ?? 'süresiz' }} @if ($sub->isActive()) aktif @else {{ $sub->status }} @endif
@else

Aylık endpoint aboneliği yok.

@endif
{{-- ═══ (d) Siparişler ═══ --}}
Siparişler (son {{ $orders->count() }})
@if ($orders->count() > 0)
@foreach ($orders as $order) @endforeach
Tarih Sipariş No Ürün Adet Tutar Durum Ödeme
{{ $order->created_at?->format('d.m.Y H:i') ?? '—' }} {{ $order->merchant_oid }} {{ $order->item_type }} {{ $orderItemLabels[$order->item_type . ':' . $order->item_id] ?? '#' . $order->item_id }} {{ (int) $order->quantity }} {{ number_format((float) $order->total, 2, ',', '.') }} ₺ @if ($order->status === \App\Models\ApiOrder::STATUS_PAID) ödendi @elseif ($order->status === \App\Models\ApiOrder::STATUS_FAILED) başarısız @else bekliyor @endif {{ $order->paid_at?->format('d.m.Y H:i') ?? '—' }}
@else

Bu müşterinin siparişi yok.

@endif
{{-- ═══ Manuel kredi düzeltme ═══ --}}
Manuel Kredi Düzeltme

Pozitif miktar kredi ekler, negatif miktar düşer. Her işlem için defter (ledger) satırı yazılır ve açıklama zorunludur.

@csrf
@error('amount')
{{ $message }}
@enderror @error('note')
{{ $message }}
@enderror
{{-- ═══ (e) Kredi defteri ═══ --}}
Kredi Defteri (son {{ $creditTransactions->count() }})
@if ($creditTransactions->count() > 0)
@foreach ($creditTransactions as $tx) @endforeach
Tarih Tip Miktar Sonraki Bakiye Referans Not
{{ $tx->created_at?->format('d.m.Y H:i') ?? '—' }} {{ $tx->type }} {{ $tx->amount > 0 ? '+' : '' }}{{ number_format((int) $tx->amount, 0, ',', '.') }} {{ number_format((int) $tx->balance_after, 0, ',', '.') }} {{ $tx->reference ?? '—' }} {{ $tx->meta['note'] ?? '—' }}
@else

Kredi hareketi yok.

@endif
{{-- ═══ (f) Kullanım ═══ --}}
Son {{ $windowDays }} Gün Kullanımı
Kaynak Kırılımı
@forelse ($sourceBreakdown as $source => $total)
{{ $source }} {{ number_format((int) $total, 0, ',', '.') }}
@empty Kayıt yok. @endforelse
Durum Kırılımı
@forelse ($statusBreakdown as $status => $total)
{{ $status }} {{ number_format((int) $total, 0, ',', '.') }}
@empty Kayıt yok. @endforelse
Ücretlendirme Kaynağı (meta.charge_source)
@forelse ($chargeSourceBreakdown as $chargeSource => $total)
{{ $chargeSource }} {{ number_format((int) $total, 0, ',', '.') }}
@empty Kayıt yok. @endforelse
SKU Kırılımı (son {{ $windowDays }} gün)
@if ($skuBreakdown->count() > 0)
@foreach ($skuBreakdown as $row) @endforeach
SKU İstek Düşülen Kredi
{{ $row->sku }} {{ number_format((int) $row->total, 0, ',', '.') }} {{ number_format((int) $row->credits, 0, ',', '.') }}
@else

Bu aralıkta kullanım kaydı yok.

@endif
@endsection @push('scripts') @endpush