@php $itemThumbs = $order->items->map(fn ($orderItem) => $orderItem->thumbnailUrl())->filter()->values(); $pStat = $phoneStats[$order->customer_phone] ?? ['delivered'=>0,'returned'=>0,'total'=>0,'score'=>0]; $score = $pStat['score'] ?? ($pStat['total'] ? round($pStat['delivered']/$pStat['total']*100) : 0); $cStatDefaults = ['steadfast' => ['d' => 0, 'r' => 0], 'pathao' => ['d' => 0, 'r' => 0], 'redx' => ['d' => 0, 'r' => 0], 'carrybee' => ['d' => 0, 'r' => 0]]; $cStat = array_replace_recursive($cStatDefaults, $courierStats[$order->customer_phone] ?? []); $normPhone = app(\App\Services\CourierFraudCheckService::class)->normalizePhone($order->customer_phone); $fraudData = ($fraudCache ?? [])[$normPhone] ?? null; if ($fraudData) { if (empty($fraudData['steadfast']['error'] ?? null) && (int) ($fraudData['steadfast']['total'] ?? 0) > 0) { $cStat['steadfast'] = ['d' => (int) $fraudData['steadfast']['success'], 'r' => (int) $fraudData['steadfast']['cancel']]; } if (empty($fraudData['pathao']['error'] ?? null) && (int) ($fraudData['pathao']['total'] ?? 0) > 0) { $cStat['pathao'] = ['d' => (int) $fraudData['pathao']['success'], 'r' => (int) $fraudData['pathao']['cancel']]; } if (empty($fraudData['redx']['error'] ?? null) && (int) ($fraudData['redx']['total'] ?? 0) > 0) { $cStat['redx'] = ['d' => (int) $fraudData['redx']['success'], 'r' => (int) $fraudData['redx']['cancel']]; } if (empty($fraudData['carrybee']['error'] ?? null) && (int) ($fraudData['carrybee']['total'] ?? 0) > 0) { $cStat['carrybee'] = ['d' => (int) $fraudData['carrybee']['success'], 'r' => (int) $fraudData['carrybee']['cancel']]; } } $siteHost = parse_url(config('app.url'), PHP_URL_HOST) ?: request()->getHost(); $fraudAgg = $fraudData['aggregate'] ?? null; $fraudRisk = $fraudData['risk'] ?? null; $fraudScoreClass = match ($fraudRisk['level'] ?? '') { 'good' => 'oc-pill-fraud-good', 'medium' => 'oc-pill-fraud-medium', 'warning' => 'oc-pill-fraud-warn', 'bad' => 'oc-pill-fraud-bad', default => 'oc-pill-score', }; $showFraudAvg = $fraudAgg && (int) ($fraudAgg['couriers_count'] ?? 0) > 0; $activeBlock = ($blockedMap ?? [])[$order->customer_phone] ?? null; $isBlocked = (bool) $activeBlock; $customerOrderTotal = (int) ($pStat['total'] ?? 0); $customerDeliveredTotal = (int) ($pStat['delivered'] ?? 0); $isNewCustomer = $customerOrderTotal <= 1; $orderCustomer = $order->customer ?? null; $customerTier = \App\Services\CustomerInsightsSettingsService::resolveTier( (float) ($pStat['delivered_spend'] ?? 0), (int) ($pStat['total'] ?? 0), $orderCustomer, $insightsSettings ?? null ); $claimService = app(\App\Services\OrderClaimService::class); $claimReady = $claimService->isReady() && (int) $order->order_status === \App\Models\Order::STATUS_PENDING; $claim = $claimReady ? $claimService->serializeClaim($order, (int) auth()->id()) : null; $claimLocked = $claim && ($claim['claim_state'] ?? '') === 'other'; $actionsLocked = $claim && ! ($claim['can_work'] ?? true); @endphp
{{-- ══ LEFT: Order ID, badges, customer ══ --}}
@if($showFraudAvg) Avg: {{ $fraudAgg['success_ratio'] }}% @else Score: {{ $score }}% @endif D:{{ $pStat['delivered'] ?? 0 }} R:{{ $pStat['returned'] ?? 0 }} Steadfast: {{ $cStat['steadfast']['d'] }}-{{ $cStat['steadfast']['r'] }} Pathao: {{ $cStat['pathao']['d'] }}-{{ $cStat['pathao']['r'] }} RedX: {{ $cStat['redx']['d'] }}-{{ $cStat['redx']['r'] }} CarryBee: {{ $cStat['carrybee']['d'] }}-{{ $cStat['carrybee']['r'] }}
Name: {{ $order->customer_name }} @include('backEnd.customer.partials.tier-badge', ['tier' => $customerTier, 'sm' => true])
@if($order->shipping_address)
Address: {{ $order->shipping_address }}
@endif @if($order->district || $order->upazila)
Area: {{ $order->district }}@if($order->upazila) >> {{ $order->upazila }}@endif
@endif @can('staff.performance.own') @if($order->relationLoaded('moderatorCallLogs'))
Call Log Hub
@if($order->moderatorCallLogs->isNotEmpty())
@foreach($order->moderatorCallLogs as $clog)
{{ $clog->started_at?->format('d M, h:i A') ?? '—' }} {{ $clog->moderator?->name ?? 'Staff' }} {{ str_replace('_', ' ', $clog->outcome ?: 'logged') }} @if($clog->duration_seconds) {{ $clog->durationLabel() }} @endif @if($clog->note) · {{ Str::limit($clog->note, 60) }} @endif
@endforeach
@else

Hub → Call চাপলে log হবে (timer + outcome)।

@endif
@endif @endcan
{{-- ══ MIDDLE: date, pricing, note only ══ --}}
{{ $order->created_at->format('F j, Y g:i A') }}
@php $src = $order->order_source ?? 'website'; @endphp {{ \App\Models\Order::sourceLabel($src) }} @if($order->ip_address ?? null)
Ip: {{ $order->ip_address }}
@endif
@if($order->customer_phone) @if($isNewCustomer) New Customer @else Total Orders: {{ $customerOrderTotal }} Delivered: {{ $customerDeliveredTotal }} @endif @endif @can('customers.block') @if($isBlocked) Blocked
@csrf @method('DELETE')
@endif @endcan @if($claim) @can('support.view') @if($claim['claim_state'] === 'unclaimed') @elseif($claim['claim_state'] === 'mine') @else {{ $claim['claimed_by_name'] }} @endif @endcan @endif
@can('orders.manage') @if($claim && (int) $order->order_status === \App\Models\Order::STATUS_PENDING) @endif @endcan
৳{{ number_format($order->subtotal) }} | Shipping: ৳{{ number_format($order->shipping_charge) }}
{{ $order->payment_method === 'cod' ? 'Cash on Delivery' : ucfirst($order->payment_method) }} ৳{{ number_format($order->amount) }}
@include('backEnd.order.partials.order-note-list', [ 'order' => $order, 'boxId' => 'note-box-' . $order->id, ]) @if($order->consignment_id && ($tab ?? '') !== 'tracking')
Courier: {{ \App\Models\CourierApi::displayName($order->courier_type) }} | Consignment: {{ $order->consignment_id }} @if(in_array($order->fulfillment_stage, [\App\Models\Order::STAGE_BOOKED, \App\Models\Order::STAGE_PACKED, \App\Models\Order::STAGE_COMPLETED], true)) @endif
@endif
{{-- ══ RIGHT: product + actions ══ --}}
@if($itemThumbs->isNotEmpty())
@foreach($itemThumbs as $thumbUrl)
@endforeach
@else
@endif
@forelse($order->items as $orderItem) @php $lineLabel = $orderItem->variant_label ?: $orderItem->product_name; @endphp
{{ Str::limit($lineLabel, 16) }} | Q:{{ $orderItem->qty }}
@empty
Product | Q:0
@endforelse
@if(!in_array($order->order_status, [4,5,6])) @endif @can('customers.block') @if(!$isBlocked) @endif @endcan @if(!in_array($order->order_status, [5,6])) @endif
@if(($tab ?? '') === 'tracking') @include('backEnd.order.partials.tracking-update-panel', [ 'order' => $order, 'manualCouriers' => $manualCouriers ?? collect(), 'steadfastOn' => $steadfastOn ?? false, 'pathaoOn' => $pathaoOn ?? false, 'carrybeeOn' => $carrybeeOn ?? false, ]) @endif