{{-- 側滑面板標題 --}}

{{ __('Order Details') }}

{{ $order->order_no }}
{{-- 基本狀態卡片 --}}

{{ __('Payment Status') }}

@php $statusMap = [ 'pending' => 'pending', 'paid' => 'active', 'completed' => 'active', 'failed' => 'error', 'abandoned' => 'disabled', 'cancelled' => 'disabled', 'refunded' => 'error', ]; $labelMap = [ 'pending' => __('Pending'), 'paid' => __('Paid'), 'completed' => __('Completed'), 'failed' => __('Failed'), 'abandoned' => __('Unpaid'), 'cancelled' => __('Cancelled'), 'refunded' => __('Refunded'), ]; $status = $statusMap[$order->status] ?? 'slate'; $label = $labelMap[$order->status] ?? $order->status; @endphp

{{ __('Payment Type') }}

{{ $order->payment_type_label }}

{{ __('Dispense Status') }}

{{-- 非付款成功(未完成/支付失敗/未支付)的單從未出貨,出貨狀態無意義 → 顯示 '--' --}} @if(! $order->hasDeliveryOutcome()) -- @else @php $deliveryStatusMap = [ 0 => ['label' => __('Dispense Failed'), 'color' => 'rose'], 1 => ['label' => __('Dispense Success'), 'color' => 'emerald'], 2 => ['label' => __('Partial Dispense Success'), 'color' => 'amber'], ]; $ds = $deliveryStatusMap[$order->delivery_status] ?? ['label' => __('Unknown'), 'color' => 'slate']; @endphp @endif
{{-- 交易資訊 --}}

{{ __('Transaction Info') }}

{{ __('Transaction Time') }}

{{ $order->created_at->format('Y-m-d H:i:s') }}

{{ __('Machine Name') }}

{{ $order->machine->name ?? __('Unknown') }}

{{ __('Machine Serial') }}

{{ $order->machine->serial_no ?? '---' }}

{{ __('Machine Flow ID') }}

{{-- 顯示去前綴序號的乾淨流水號(DB 仍存完整 serial+flow_id 唯一值供後台判斷) --}}

{{ $order->display_flow_id }}

{{-- 管理者備註(訂單內部註記) --}}

{{ __('Remark') }}

{{-- 員工卡資訊 --}} @if($order->payment_type == 41 && $order->staffCardLog && $order->staffCardLog->staffCard)

{{ __('Staff Card Info') }}

{{ __('Staff Name') }}

{{ $order->staffCardLog->staffCard->name }}

{{ __('Employee ID') }}

{{ $order->staffCardLog->staffCard->employee_id }}

{{ __('Card UID') }}

{{ $order->staffCardLog->staffCard->card_uid }}

@if($order->staffCardLog->staffCard->notes)

{{ __('Notes') }}

{{ $order->staffCardLog->staffCard->notes }}

@endif
@endif @if($order->payment_type == 42 && !empty($order->member_barcode))

{{ __('Pickup Recipient Info') }}

{{ __('Pickup Recipient (Prescription Slip)') }}

{{ $order->masked_pickup_recipient }}

@endif {{-- 商品明細 --}}

{{ __('Product Details') }}

{{ $order->items->count() }} {{ __('Items') }}
@foreach($order->items as $item)
@if(isset($item->product->image_url) && $item->product->image_url) @endif

{{ $item->product_name }}

${{ number_format($item->price, 0) }} × {{ $item->quantity }} @if(!empty($item->slot_no)) {{-- 消費者選擇的貨道/格子(不管出貨成功失敗都會記錄) --}} {{ __('Slot') }}: {{ $item->slot_no }} @endif

${{ number_format($item->subtotal, 0) }}

@endforeach
{{-- 金額彙總 --}}
{{ __('Subtotal') }} ${{ number_format($order->total_amount + $order->discount_amount, 0) }}
{{ __('Discount') }} -${{ number_format($order->discount_amount, 0) }}
{{ __('Total') }}
${{ number_format($order->total_amount, 0) }}
{{-- 出貨紀錄 --}} @if($order->dispenseRecords->count() > 0)

{{ __('Dispense Status') }}

@foreach($order->dispenseRecords as $dispense) @endforeach
{{ __('Slot') }} {{ __('Product') }} {{ __('Status') }}
#{{ str_pad($dispense->slot_no, 2, '0', STR_PAD_LEFT) }}

{{ $dispense->product->localized_name ?? __('Unknown Product') }}

@php $dStatusMap = [ 'success' => 'active', 'failed' => 'error', 'pending' => 'pending', '1' => 'active', '0' => 'error', ]; $dLabelMap = [ 'success' => __('Success'), 'failed' => __('Failed'), 'pending' => __('Pending'), '1' => __('Success'), '0' => __('Failed'), ]; $statusValue = (string)($dispense->dispense_status ?? 'pending'); $ds = $dStatusMap[$statusValue] ?? 'slate'; $dl = $dLabelMap[$statusValue] ?? $statusValue; @endphp
@endif {{-- 發票資訊 --}} @if($order->invoice)

{{ __('Invoice Information') }}

@php // 以發票狀態機顯示(pending/issued/failed/void);舊資料無 status 時以發票號回推 $invStatus = $order->invoice->status ?: (empty($order->invoice->invoice_no) ? 'failed' : 'issued'); $invStatusMap = [ 'pending' => ['label' => __('Pending'), 'color' => 'amber'], 'issued' => ['label' => __('Issued'), 'color' => 'emerald'], 'failed' => ['label' => __('Failed'), 'color' => 'rose'], 'void' => ['label' => __('Void'), 'color' => 'slate'], ]; $invBadge = $invStatusMap[$invStatus] ?? ['label' => $invStatus, 'color' => 'slate']; // 僅「統編發票」可列印:本系統開立時 Print=1 僅給帶統編者; // 捐贈、載具、一般無統編 B2C 皆為 Print=0,綠界 InvoicePrint 會回查無資料而失敗。 $invPrintable = !empty($order->invoice->metadata['business_tax_id'] ?? ''); @endphp

{{ $order->invoice->invoice_no ?: '---' }}

{{ __('Issued At') }}

{{ optional($order->invoice->invoice_date)->format('Y-m-d') ?: '---' }}

@if($invStatus === 'issued')
{{-- 列印:僅統編發票可列印(載具/捐贈/一般無統編 B2C 為 Print=0,綠界查無資料) --}} @if($invPrintable)
@csrf
@else {{ __('This invoice has no printable copy') }} @endif {{-- 作廢:僅平台系統管理員可見可用(後端亦有 403 守衛)。使用自製確認框 UI --}} @if(auth()->user()->isSystemAdmin()) @endif
@endif
{{-- 發票備註(管理者內部註記;作廢視窗輸入的備註也會顯示於此) --}}

{{ __('Remark') }}

@endif