优化后台订单列表展示并支持商品标题与SKU规格
This commit is contained in:
@@ -201,6 +201,27 @@ export async function listKuaishouIndustryVouchersByOid(
|
||||
return result.rows
|
||||
}
|
||||
|
||||
export async function listKuaishouIndustryVouchersByOids(
|
||||
oids: string[],
|
||||
): Promise<KuaishouIndustryVoucherRow[]> {
|
||||
const normalizedOids = oids.map((oid) => String(oid || '').trim()).filter(Boolean)
|
||||
if (normalizedOids.length === 0) {
|
||||
return []
|
||||
}
|
||||
|
||||
const result = await query<KuaishouIndustryVoucherRow>(
|
||||
`
|
||||
SELECT *
|
||||
FROM kuaishou_industry_vouchers
|
||||
WHERE oid = ANY($1::text[])
|
||||
ORDER BY unit_index ASC, id ASC
|
||||
`,
|
||||
[normalizedOids],
|
||||
)
|
||||
|
||||
return result.rows
|
||||
}
|
||||
|
||||
export type KuaishouIndustryVoucherWorkOrderSyncSource = {
|
||||
oid: string
|
||||
raw_payload_json: string | Record<string, unknown>
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -243,7 +243,8 @@ export async function listOrdersWithExecutor(
|
||||
filters.push(`(
|
||||
(
|
||||
o.platform_order_id || ' ' || o.shop_id || ' ' || o.shop_name || ' ' ||
|
||||
o.buyer_id || ' ' || o.buyer_name || ' ' || o.receiver_contact
|
||||
o.buyer_id || ' ' || o.buyer_name || ' ' || o.receiver_contact || ' ' ||
|
||||
o.raw_payload_json::text
|
||||
) ILIKE ${keywordParam}
|
||||
OR EXISTS (
|
||||
SELECT 1
|
||||
@@ -252,7 +253,8 @@ export async function listOrdersWithExecutor(
|
||||
AND (
|
||||
oi.sku_code || ' ' || oi.sku_name || ' ' ||
|
||||
COALESCE(oi.item_snapshot_json->'kuaishouSendCode'->>'itemTitle', '') || ' ' ||
|
||||
COALESCE(oi.item_snapshot_json->'kuaishouSendCode'->>'skuNick', '')
|
||||
COALESCE(oi.item_snapshot_json->'kuaishouSendCode'->>'skuNick', '') || ' ' ||
|
||||
COALESCE(oi.spec_json::text, '')
|
||||
) ILIKE ${keywordParam}
|
||||
)
|
||||
)`)
|
||||
|
||||
Reference in New Issue
Block a user