优化后台订单列表展示并支持商品标题与SKU规格

This commit is contained in:
yml2213
2026-09-10 09:39:19 +08:00
parent fe2a28454d
commit 4544622cb3
13 changed files with 655 additions and 51 deletions
@@ -235,16 +235,27 @@ export async function getOrderItemById(orderItemId: number | string): Promise<Or
export async function updateOrderItemSourceSnapshot(
orderItemId: number | string,
input: { skuName: string; itemSnapshotJson: string; updatedAt: string },
input: { skuName: string; itemSnapshotJson: string; updatedAt: string; specJson?: string },
): Promise<OrderItemRow | null> {
const specClause = input.specJson ? ', spec_json = $5::jsonb' : ''
const params: unknown[] = [
input.skuName,
input.itemSnapshotJson,
input.updatedAt,
Number(orderItemId),
]
if (input.specJson) {
params.push(input.specJson)
}
const result = await query<{ id: number }>(
`
UPDATE order_items
SET sku_name = $1, item_snapshot_json = $2::jsonb, updated_at = $3
SET sku_name = $1, item_snapshot_json = $2::jsonb, updated_at = $3 ${specClause}
WHERE id = $4
RETURNING id
`,
[input.skuName, input.itemSnapshotJson, input.updatedAt, Number(orderItemId)],
params,
)
return result.rows[0] ? getOrderItemById(orderItemId) : null
}