优化了订单展示
This commit is contained in:
@@ -924,7 +924,9 @@ function mapAdminTaskListItem(task) {
|
||||
|
||||
function mapAdminOrderListItem(item) {
|
||||
const tasks = listTasksByOrderId(item.id)
|
||||
const orderItems = listOrderItemsByOrderId(item.id)
|
||||
const bindingSummary = buildOrderBindingSummary(tasks)
|
||||
const itemSummary = summarizeOrderItems(orderItems)
|
||||
|
||||
return {
|
||||
orderId: item.id,
|
||||
@@ -935,12 +937,18 @@ function mapAdminOrderListItem(item) {
|
||||
platformOrderId: item.platform_order_id,
|
||||
orderStatus: item.order_status,
|
||||
payStatus: item.pay_status,
|
||||
buyerId: item.buyer_id || '',
|
||||
buyerName: item.buyer_name,
|
||||
receiverContact: item.receiver_contact || '',
|
||||
totalAmount: formatFenToAmount(item.total_amount),
|
||||
totalAmountFen: normalizeFen(item.total_amount),
|
||||
currency: item.currency,
|
||||
paidAt: item.paid_at,
|
||||
createdAt: item.created_at,
|
||||
updatedAt: item.updated_at,
|
||||
itemCount: orderItems.length,
|
||||
totalQuantity: orderItems.reduce((sum, orderItem) => sum + Math.max(1, Number(orderItem.quantity || 1)), 0),
|
||||
itemSummary,
|
||||
taskCount: Number(item.task_count || tasks.length || 0),
|
||||
systemBindingStatus: bindingSummary.systemBindingStatus,
|
||||
userBindingStatus: bindingSummary.userBindingStatus,
|
||||
@@ -949,6 +957,23 @@ function mapAdminOrderListItem(item) {
|
||||
}
|
||||
}
|
||||
|
||||
function summarizeOrderItems(items) {
|
||||
const normalizedItems = Array.isArray(items) ? items : []
|
||||
|
||||
if (normalizedItems.length === 0) {
|
||||
return ''
|
||||
}
|
||||
|
||||
const [firstItem] = normalizedItems
|
||||
const firstLabel = String(firstItem?.sku_name || firstItem?.sku_code || '').trim()
|
||||
|
||||
if (normalizedItems.length === 1) {
|
||||
return firstLabel
|
||||
}
|
||||
|
||||
return `${firstLabel} 等 ${normalizedItems.length} 项`
|
||||
}
|
||||
|
||||
function buildOrderBindingSummary(tasks) {
|
||||
const normalizedTasks = Array.isArray(tasks) ? tasks : []
|
||||
const totalTaskCount = normalizedTasks.length
|
||||
|
||||
Reference in New Issue
Block a user