优化后台订单列表展示并支持商品标题与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
@@ -130,6 +130,7 @@ export async function syncWorkOrdersFromKuaishouSendCode(
if (order) {
const orderItems = await applyKuaishouSendCodeItemData(
order.id,
await listOrderItemsByOrderId(order.id),
sourceData,
input.rawParams,
@@ -381,6 +382,7 @@ export function resolveKuaishouSendCodeShopName(
}
async function applyKuaishouSendCodeItemData(
orderId: number,
orderItems: OrderItemRow[],
sourceData: KuaishouSendCodeWorkOrderData,
rawPayload: JsonObject,
@@ -390,6 +392,34 @@ async function applyKuaishouSendCodeItemData(
return orderItems
}
if (orderItems.length === 0) {
return replaceOrderItems(orderId, [
{
skuCode: sourceData.itemId || sourceData.skuId || 'default',
skuName: sourceData.skuNick || sourceData.itemTitle,
quantity: sourceData.quantity || 1,
specJson: JSON.stringify({
sellerId: sourceData.sellerId,
skuId: sourceData.skuId,
itemTitle: sourceData.itemTitle,
relItemId: sourceData.relItemId,
relSkuId: sourceData.relSkuId,
skuNick: sourceData.skuNick,
quantity: sourceData.quantity,
paymentFen: sourceData.paymentFen,
source: KUAISHOU_SEND_CODE_SOURCE,
}),
itemSnapshotJson: JSON.stringify({
source: KUAISHOU_SEND_CODE_SOURCE,
params: rawPayload,
kuaishouSendCode: sourceData,
}),
createdAt: now,
updatedAt: now,
},
])
}
const matchedIds = findKuaishouSendCodeItemIds(orderItems, sourceData)
if (matchedIds.size === 0) {
return orderItems
@@ -402,6 +432,12 @@ async function applyKuaishouSendCodeItemData(
}
const snapshot = safeParseJson(item.item_snapshot_json)
const spec = safeParseJson(item.spec_json)
const mergedSpec = {
...spec,
itemTitle: sourceData.itemTitle || spec.itemTitle,
skuNick: sourceData.skuNick || spec.skuNick,
}
const snapshotJson = {
...item,
item_snapshot_json: {
@@ -417,6 +453,7 @@ async function applyKuaishouSendCodeItemData(
const updated = await updateOrderItemSourceSnapshot(item.id, {
skuName: sourceData.skuNick || item.sku_name,
itemSnapshotJson: JSON.stringify(snapshotJson.item_snapshot_json),
specJson: JSON.stringify(mergedSpec),
updatedAt: now,
})
return updated || item