ensure_cap(); $this->render_header(__('订单明细', 'aksrt')); if (!class_exists('\AKSRT\Payment\OrderRepository')) { echo '
' . esc_html__('订单服务不可用。', 'aksrt') . '
'; echo '
'; echo ''; echo '| ' . esc_html__('订单号', 'aksrt') . ' | '; echo '' . esc_html__('用户', 'aksrt') . ' | '; echo '' . esc_html__('商品信息', 'aksrt') . ' | '; echo '' . esc_html__('金额 / 支付方式', 'aksrt') . ' | '; echo '' . esc_html__('状态', 'aksrt') . ' | '; echo '' . esc_html__('创建 / 支付时间', 'aksrt') . ' | '; echo '' . esc_html__('操作', 'aksrt') . ' | '; echo '
|---|---|---|---|---|---|---|
| ' . esc_html__('暂无订单', 'aksrt') . ' | ||||||
' . esc_html($order_number) . ' | ';
echo '' . ($user ? esc_html($user->display_name . ' (#' . $user_id . ')') : esc_html((string) $user_id)) . ' | '; echo '' . esc_html($product_title !== '' ? $product_title : ($type_labels[$product_type] ?? $product_type)) . ' ' . esc_html($type_labels[$product_type] ?? $product_type) . ($product_id > 0 ? ' #' . esc_html((string) $product_id) : '') . ' | ';
echo '' . esc_html($this->order_amount($row)) . ' ' . esc_html((string) ($row['payment_method'] ?? '')) . ' | ';
echo '' . esc_html($status_label) . ' | '; echo '' . esc_html((string) ($row['created_at'] ?? '')) . ' ' . esc_html((string) ($row['paid_at'] ?? '') ?: '—') . ' | ';
echo ''; echo '' . esc_html__('详情', 'aksrt') . ''; // 已支付是已退款的唯一前置状态;退款仍需落到一条进行中的售后工单上。 if ($status_key === \AKSRT\Core\DomainModel::ORDER_STATUS_PAID) { echo ''; } $this->render_order_quick_status_buttons($order_number, $status_key); if ($status_key === 'closed') { echo ''; } echo ' | '; echo '
' . esc_html__('售后服务不可用。', 'aksrt') . '
' . esc_html(implode(' ', $policy_bits)) . '
'; $this->render_after_sales_page(); $this->render_footer(); } private function render_order_detail_page(string $order_number): void { $repo = \AKSRT\Payment\OrderRepository::get_instance(); $order = $repo->get($order_number); if (!$order) { echo '' . esc_html__('订单不存在。', 'aksrt') . '
' . esc_html__('返回订单列表', 'aksrt') . '
'; return; } $labels = class_exists('\AKSRT\Core\DomainModel') ? \AKSRT\Core\DomainModel::order_status_labels() : []; $context = $repo->get_admin_order_context($order_number); $user_id = (int) ($order['user_id'] ?? 0); $user = $user_id > 0 ? get_userdata($user_id) : null; $status = (string) ($order['status'] ?? ''); $meta = is_array($order['meta_payload'] ?? null) ? $order['meta_payload'] : []; $customer_note = (string) ($context['customer_note'] ?? $order['note_text'] ?? ''); $admin_note = is_array($meta) ? (string) ($meta['admin_note'] ?? '') : ''; if ($admin_note === '' && $customer_note === '' && !empty($order['note']) && !is_array(json_decode((string) $order['note'], true))) { $admin_note = (string) $order['note']; } echo '← ' . esc_html__('返回订单列表', 'aksrt') . '
'; // 售后记录区块:工单卡片 + 处理记录列表(与售后面板共用 .aksrt-as-log 样式)。 echo ''; echo '| ' . esc_html($label) . ' | ' . esc_html((string) $value) . ' |
|---|---|
| ' . esc_html__('售后记录', 'aksrt') . ' | ';
$status_labels = $this->after_sale_status_labels();
foreach ($after_sales as $application) {
$as_status = (string) ($application['status'] ?? '');
echo ' ';
echo ' ';
}
echo '' . esc_html($status_labels[$as_status] ?? $as_status) . '' . ' ' . esc_html((string) ($application['refund_amount'] ?? '')) . '' . ' ' . esc_html((string) ($application['created_at'] ?? '')) . ' '; echo '' . nl2br(esc_html((string) ($application['reason'] ?? ''))) . ' '; // 处理记录:后台每一次提交都留一条(状态 + 备注 + 时间),与售后面板同款标记。 echo $this->render_after_sale_log((array) ($application['handling_log'] ?? []), $status_labels); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo ' |
| ' . esc_html__('附加上下文', 'aksrt') . ' | ' . esc_html(wp_json_encode($context, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)) . ' |
| ID | 订单号 | 用户 | 原因 | 申请资料 | 申请说明 | 退款金额 | 状态 | 操作 / 处理记录 |
|---|---|---|---|---|---|---|---|---|
| ' . esc_html__('暂无售后申请', 'aksrt') . ' | ||||||||
| ' . esc_html((string) $id) . ' ' . esc_html((string) ($item['created_at'] ?? '')) . ' | ';
echo '' . esc_html($number) . '' . esc_html($type_label) . ($product_name !== '' ? ' · ' . esc_html($product_name) : '') . ' | ';
echo '' . esc_html($user ? $user->display_name . ' (#' . $uid . ')' : '#' . $uid) . ' | '; echo '' . $reason_cell . ' | '; echo '' . $materials_cell . ' | '; echo '' . $desc_cell . ' | '; echo '' . esc_html($refund_amount) . ' | '; echo '' . esc_html($status_label) . ' | '; echo '' . esc_html__('操作', 'aksrt') . ' | '; echo '
';
$detail_fields = [
__('订单号', 'aksrt') => '' . esc_html($number) . '',
__('商品', 'aksrt') => esc_html($type_label . ($product_name !== '' ? ' · ' . $product_name : '')),
__('用户', 'aksrt') => esc_html($user ? $user->display_name . ' (#' . $uid . ')' : '#' . $uid),
__('申请时间', 'aksrt') => esc_html((string) ($item['created_at'] ?? '')),
__('退款金额', 'aksrt') => esc_html($refund_amount),
__('当前状态', 'aksrt') => esc_html($status_label),
__('售后原因', 'aksrt') => $reason_cell,
__('申请资料', 'aksrt') => $materials_cell,
];
echo '';
foreach ($detail_fields as $field_label => $field_value) {
echo '' . esc_html($field_label) . '' . $field_value . '';
}
// 处理备注:单独占整行,放在申请说明上方;每次提交一条,含状态与时间。
echo '' . esc_html__('处理备注', 'aksrt') . ''
. $this->render_after_sale_log((array) ($item['handling_log'] ?? []), $status_labels) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
. '';
// 举证图片并入申请说明,单独占整行展示。
echo '' . esc_html__('申请说明', 'aksrt') . '' . $desc_cell . '';
echo ' ';
$status_options = '';
$current_status = (string) $item['status'];
foreach ($status_labels as $key => $label) {
$status_options .= '';
}
if (!isset($status_labels[$current_status])) {
// 历史状态(如已删除的 approved)不在可选项内:如实呈现且禁用,防止误提交。
$status_options .= '';
}
echo '';
echo ' ';
echo '' . esc_html__('售后状态', 'aksrt') . ' ' . esc_html__('选择目标状态后点击确认;取消仅收起面板。', 'aksrt') . ' '; echo '';
echo '';
echo '';
echo ' ';
// 勾选后在确认时把关联订单推到已退款;订单本已退款时呈现为不可改的已选状态
echo '';
echo '';
echo '';
echo '';
echo ' | ||||||||
' . esc_html__('暂无处理记录', 'aksrt') . '
'; } $service = \AKSRT\Payment\AfterSaleService::class; $html = '' . esc_html($map[$code]) . '
' . esc_html(sanitize_text_field((string) wp_unslash($_GET['after_sale_error']))) . '