|
|
@@ -55,8 +55,48 @@ class OrderController extends APIController
|
|
|
/**
|
|
|
* 获取订单详情
|
|
|
*
|
|
|
- * @param int $id
|
|
|
- * @return JsonResponse
|
|
|
+ * GET /api/customer/orders/{id}
|
|
|
+ *
|
|
|
+ * @param int $id 订单ID
|
|
|
+ * @return JsonResponse {
|
|
|
+ * success: bool,
|
|
|
+ * message: string,
|
|
|
+ * data: {
|
|
|
+ * id: int, // 订单主键
|
|
|
+ * increment_id: string, // 订单号
|
|
|
+ * status: string, // 订单状态
|
|
|
+ * status_label: string, // 状态中文标签
|
|
|
+ * customer_email: string, // 客户邮箱
|
|
|
+ * customer_first_name: string,// 客户名
|
|
|
+ * customer_last_name: string, // 客户姓
|
|
|
+ * channel_name: string, // 渠道
|
|
|
+ * order_currency_code: string,// 货币
|
|
|
+ * sub_total: float, // 商品小计
|
|
|
+ * shipping_amount: float, // 运费
|
|
|
+ * tax_amount: float, // 税费
|
|
|
+ * discount_amount: float, // 折扣
|
|
|
+ * grand_total: float, // 订单总额
|
|
|
+ * total_qty_ordered: int, // 商品总数量
|
|
|
+ * shipping_method: string, // 配送方式
|
|
|
+ * shipping_title: string, // 配送标题
|
|
|
+ * billing_address: ?object, // 账单地址
|
|
|
+ * shipping_address: ?object, // 收货地址
|
|
|
+ * payment: ?{method, method_title}, // 支付信息
|
|
|
+ * items: [{ // 订单商品
|
|
|
+ * id, name, sku, type,
|
|
|
+ * qty_ordered, qty_shipped, qty_invoiced, qty_canceled, qty_refunded,
|
|
|
+ * price, total, weight, product_id
|
|
|
+ * }],
|
|
|
+ * invoices: [{id, increment_id, state, email_sent, total_qty, sub_total, grand_total, created_at, items}],
|
|
|
+ * shipments: [{id, increment_id, status, total_qty, total_weight, carrier_code, carrier_title, track_number, created_at, items}],
|
|
|
+ * refunds: [{id, increment_id, state, total_qty, grand_total, created_at}],
|
|
|
+ * comments: [{comment, customer_notified, created_at}],
|
|
|
+ * can_cancel: bool, // 是否可取消
|
|
|
+ * can_reorder: bool, // 是否可重新下单
|
|
|
+ * created_at: string, // 创建时间
|
|
|
+ * updated_at: string // 更新时间
|
|
|
+ * }
|
|
|
+ * }
|
|
|
*/
|
|
|
public function show(int $id): JsonResponse
|
|
|
{
|
|
|
@@ -66,22 +106,7 @@ class OrderController extends APIController
|
|
|
}
|
|
|
|
|
|
$order = Order::query()
|
|
|
- ->with([
|
|
|
- 'items' => function ($q) {
|
|
|
- $q->whereNull('parent_id');
|
|
|
- },
|
|
|
- 'items.child',
|
|
|
- 'items.additional',
|
|
|
- 'billing_address',
|
|
|
- 'shipping_address',
|
|
|
- 'payment',
|
|
|
- 'invoices',
|
|
|
- 'invoices.items',
|
|
|
- 'shipments',
|
|
|
- 'shipments.items',
|
|
|
- 'refunds',
|
|
|
- 'comments',
|
|
|
- ])
|
|
|
+ ->with(['items', 'addresses', 'payment', 'invoices', 'shipments', 'refunds', 'comments'])
|
|
|
->where('customer_id', $customer->id)
|
|
|
->where('id', $id)
|
|
|
->first();
|
|
|
@@ -169,7 +194,7 @@ class OrderController extends APIController
|
|
|
'total' => (float) $item->total,
|
|
|
'weight' => (float) ($item->weight ?? 0),
|
|
|
'product_id' => $item->product_id,
|
|
|
- 'additional' => $item->additional ? $item->additional->toArray() : null,
|
|
|
+ //'additional' => $item->additional ? $item->additional->toArray() : null,
|
|
|
])->values(),
|
|
|
|
|
|
'invoices' => $order->invoices->map(fn ($invoice) => [
|