From 639288be0cc1a15ec5c6a0daa44c4b7c78fccfa1 Mon Sep 17 00:00:00 2001 From: 18631081161 <2088094923@qq.com> Date: Wed, 1 Apr 2026 10:58:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/views/order/OrderList.vue | 26 ++++++++++++++++++-------- server/src/controllers/adminOrder.ts | 25 +++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/admin/src/views/order/OrderList.vue b/admin/src/views/order/OrderList.vue index 01a3fcac..215d2fc9 100644 --- a/admin/src/views/order/OrderList.vue +++ b/admin/src/views/order/OrderList.vue @@ -83,7 +83,10 @@
-
{{ item.product_name }}
+
+ {{ item.product_name }} + 已退货 +
款号:{{ item.style_no }} 条形码:{{ item.barcode }} @@ -523,7 +526,7 @@ - +
暂无退货记录
@@ -540,13 +543,20 @@ 退款时间: {{ formatTime(record.refund_time) }}
- - - - - + + + + + + + + + + diff --git a/server/src/controllers/adminOrder.ts b/server/src/controllers/adminOrder.ts index b6e48fda..042ff434 100644 --- a/server/src/controllers/adminOrder.ts +++ b/server/src/controllers/adminOrder.ts @@ -98,7 +98,8 @@ export async function adminGetOrders(req: Request, res: Response): Promise const [itemRows] = await pool.execute( `SELECT oi.order_id, oi.id, oi.product_id, oi.spec_data_id, oi.quantity, oi.unit_price, oi.spec_snapshot, p.name as product_name, p.thumb, p.banner_images, p.style_no, - sd.model_name, sd.fineness, sd.main_stone, sd.sub_stone, sd.ring_size, sd.barcode + sd.model_name, sd.fineness, sd.main_stone, sd.sub_stone, sd.ring_size, sd.barcode, + IFNULL((SELECT SUM(ori.quantity) FROM order_return_items ori WHERE ori.order_item_id = oi.id), 0) as returned_qty FROM order_items oi LEFT JOIN products p ON oi.product_id = p.id LEFT JOIN spec_data sd ON oi.spec_data_id = sd.id @@ -488,7 +489,14 @@ export async function adminGetOrderReturns(req: Request, res: Response): Promise 'quantity', ri.quantity, 'unitPrice', ri.unit_price, 'productName', IFNULL(p.name, ''), - 'modelName', IFNULL(sd.model_name, '') + 'styleNo', IFNULL(p.style_no, ''), + 'modelName', IFNULL(sd.model_name, ''), + 'barcode', IFNULL(sd.barcode, ''), + 'fineness', IFNULL(sd.fineness, ''), + 'mainStone', IFNULL(sd.main_stone, ''), + 'subStone', IFNULL(sd.sub_stone, ''), + 'ringSize', IFNULL(sd.ring_size, ''), + 'specSnapshot', oi.spec_snapshot ) ) AS items FROM order_returns r @@ -504,6 +512,19 @@ export async function adminGetOrderReturns(req: Request, res: Response): Promise for (const r of returns as any[]) { if (typeof r.items === 'string') r.items = JSON.parse(r.items) + // Fill from snapshot if spec_data was deleted + for (const item of r.items || []) { + if (!item.modelName && item.specSnapshot) { + const snap = typeof item.specSnapshot === 'string' ? JSON.parse(item.specSnapshot) : item.specSnapshot + item.modelName = snap.model_name || '' + item.barcode = snap.barcode || '' + item.fineness = snap.fineness || '' + item.mainStone = snap.main_stone || '' + item.subStone = snap.sub_stone || '' + item.ringSize = snap.ring_size || '' + } + delete item.specSnapshot + } } res.json({ code: 0, data: returns })