feat(orders): order detail modal, list actions, use configured prefix
Wire admin payment_order_prefix into order number generation (with 32-char cap for gateways), make 查看 open a full order-detail modal with status-aware footer actions, keep type badge top-left only, and right-align unpaid list actions with countdown on the left.
This commit is contained in:
1 parent
5e1e2e2634
commit
a1e35a4499
5 files changed
+492
-46
No files matched your search
@@ -185,7 +185,9 @@ class UserOrders {
|
||||
$can_receipt = $is_shop && $status === Order::STATUS_DELIVERED;
|
||||
$can_review = $is_shop && $status === Order::STATUS_PENDING_REVIEW;
|
||||
$can_rebuy = $is_shop && in_array($status, [Order::STATUS_COMPLETED, Order::STATUS_PENDING_REVIEW], true);
|
||||
$can_view = $permalink !== '' && in_array($status, [
|
||||
// Order detail modal is always available; product permalink is optional.
|
||||
$can_view = true;
|
||||
$can_view_product = $permalink !== '' && in_array($status, [
|
||||
Order::STATUS_PAID,
|
||||
Order::STATUS_DELIVERED,
|
||||
Order::STATUS_COMPLETED,
|
||||
@@ -232,14 +234,16 @@ class UserOrders {
|
||||
'shipping_records' => $shipping_records,
|
||||
'pay_url' => '#',
|
||||
'actions' => [
|
||||
'can_pay' => $can_pay,
|
||||
'can_cancel' => $can_cancel,
|
||||
'can_after_sale' => $can_after_sale,
|
||||
'can_receipt' => $can_receipt,
|
||||
'can_review' => $can_review,
|
||||
'can_rebuy' => $can_rebuy,
|
||||
'can_view' => $can_view,
|
||||
'can_pay' => $can_pay,
|
||||
'can_cancel' => $can_cancel,
|
||||
'can_after_sale' => $can_after_sale,
|
||||
'can_receipt' => $can_receipt,
|
||||
'can_review' => $can_review,
|
||||
'can_rebuy' => $can_rebuy,
|
||||
'can_view' => $can_view,
|
||||
'can_view_product' => $can_view_product,
|
||||
],
|
||||
'quantity' => $this->resolve_order_quantity($order_items, $meta),
|
||||
'time_left' => $this->get_order_countdown($expires_at, $status),
|
||||
'secondary_url' => $this->resolve_secondary_url($product_type),
|
||||
'secondary_label' => $this->resolve_secondary_label($product_type),
|
||||
@@ -534,4 +538,25 @@ class UserOrders {
|
||||
$left = strtotime($expires_at) - time();
|
||||
return max(0, (int) $left);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sum line quantities for display (shop multi-item or single meta item).
|
||||
*
|
||||
* @param array<int, array<string, mixed>> $order_items
|
||||
* @param array<string, mixed> $meta
|
||||
*/
|
||||
private function resolve_order_quantity(array $order_items, array $meta): int {
|
||||
$qty = 0;
|
||||
$source = !empty($order_items) ? $order_items : (is_array($meta['items'] ?? null) ? $meta['items'] : []);
|
||||
foreach ($source as $row) {
|
||||
if (!is_array($row)) {
|
||||
continue;
|
||||
}
|
||||
$qty += max(1, (int) ($row['quantity'] ?? $row['qty'] ?? 1));
|
||||
}
|
||||
if ($qty <= 0) {
|
||||
$qty = max(1, (int) ($meta['quantity'] ?? $meta['qty'] ?? 1));
|
||||
}
|
||||
return $qty;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user