{{-- Nội dung thống kê đối tác (/report/partners) - được nạp lại bằng AJAX mỗi lần lọc (#gridForm). Bố cục: 4 thẻ KPI -> nguồn tiền -> xu hướng theo ngày -> lưới biểu đồ top / cơ cấu. Dùng chung class .crm-stats__* và Chart.js với trang thống kê doanh thu (statistics/ajax.blade.php). --}} @php $summary = $stats['summary']; $payout = $stats['payout']; $paidOutInRange = array_sum(array_column($payout['methods'], 'value')); $sourceIcons = ['Tiền mặt' => 'fas fa-money-bill-wave', 'Thẻ' => 'far fa-credit-card', 'Chuyển khoản' => 'fas fa-university', 'Trả góp' => 'fas fa-calendar-check']; $sourceMax = max(1, max(array_column($stats['sources'], 'value') ?: [0])); $panels = [ 'topRevenue' => ['title' => 'Top 5 đối tác doanh thu cao nhất', 'icon' => 'fas fa-trophy', 'rows' => $stats['topRevenue'], 'key' => 'paid'], 'topCommission' => ['title' => 'Top 5 đối tác hoa hồng cao nhất', 'icon' => 'fas fa-percent', 'rows' => $stats['topCommission'], 'key' => 'value'], 'topAvgOrder' => ['title' => 'Top 5 đối tác trung bình đơn cao nhất', 'icon' => 'fas fa-balance-scale', 'rows' => $stats['topAvgOrder'], 'key' => 'value'], 'topVouchers' => ['title' => 'Top 5 voucher hiệu quả nhất', 'icon' => 'fas fa-ticket-alt', 'rows' => $stats['topVouchers'], 'key' => 'value'], 'byType' => ['title' => 'Thực thu theo loại đối tác', 'icon' => 'fas fa-users', 'rows' => $stats['byType'], 'key' => 'value'], 'payout' => ['title' => 'Tình hình chi trả hoa hồng (toàn thời gian)', 'icon' => 'fas fa-money-check-alt', 'rows' => $payout['status'], 'key' => 'value'], ]; @endphp
{{-- ===== KPI chính ===== --}}
Doanh số
{{ number_format($summary['sales']) }}VNĐ
  • Số đơn{{ number_format($summary['orders']) }}
  • Trung bình đơn{{ number_format($summary['avg_order']) }}
  • Khách hàng{{ number_format($summary['customers']) }}
  • Còn nợ{{ number_format($summary['debt']) }}
Thực thu
{{ number_format($summary['paid']) }}VNĐ
  • Lần thanh toán{{ number_format($summary['payment_times']) }}
  • Trung bình / lần{{ number_format($summary['payment_times'] ? round($summary['paid'] / $summary['payment_times']) : 0) }}
Hoa hồng phát sinh
{{ number_format($summary['commission']) }}VNĐ
  • Đã chi trong kỳ{{ number_format($paidOutInRange) }}
  • Đang chờ trả (hiện tại){{ number_format($payout['status'][1]['value']) }}
  • Chưa chốt sổ (hiện tại){{ number_format($payout['status'][2]['value']) }}
Lượt dùng voucher
{{ number_format($summary['orders']) }}
  • Số voucher được dùng{{ number_format($summary['vouchers']) }}
  • Đối tác phát sinh đơn{{ number_format($summary['active_partners']) }} / {{ number_format($summary['partners']) }}
{{-- ===== Nguồn tiền thanh toán ===== --}}

Nguồn tiền thanh toán

{{ number_format($summary['paid']) }} VNĐ
@foreach($stats['sources'] as $src)
{{ $src['label'] }}{{ number_format($src['value']) }}
@endforeach
Thanh toán bằng Điểm không tính vào thực thu và hoa hồng đối tác.
{{-- ===== Xu hướng ===== --}}

Doanh số, thực thu & hoa hồng theo {{ $stats['trend']['monthly'] ? 'tháng' : 'ngày' }}

{{-- ===== Top & cơ cấu ===== --}}
@foreach($panels as $key => $panel)

{{ $panel['title'] }}

@if(array_sum(array_column($panel['rows'], $panel['key'])) > 0)
@else
Chưa có dữ liệu
@endif @if($key === 'payout')
    @foreach($payout['methods'] as $method)
  • Đã chi trong kỳ - {{ $method['label'] }}{{ number_format($method['value']) }}
  • @endforeach
@endif
@endforeach