优化后台订单列表展示并支持商品标题与SKU规格
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user