feat(order): 平台订单号落库 oaid_order_source_code 并在订单列表展示
- 拉单写入状态表时,把店管家「订单编号」(PlatformOrderId)落 oaid_order_source_code (来源订单号仍是平台「系统编号」),随单推 WMS 的 deliveryOrder.oaidOrderSourceCode - 新增迁移 20261103000300:把历史行 extend_props.platform_order_no 回填到 oaid_order_source_code(已执行:pending 17 条 / void 12 条) - 订单列表新增「平台订单号」列(手工单显示 -),订单详情、导出列同步使用该字段 - 前端 OrderStatusItem 补充 oaid_order_source_code 类型 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
69b26bf7cc
commit
5376dff3de
@ -367,6 +367,8 @@ class ExternalPrintOrderService extends Service {
|
||||
// 系统预设平台编码/名称(推 WMS 的 sourcePlatformCode/sourcePlatformName 同源)
|
||||
source_platform_code: truncateText(item.platform_code || item.platform_type, 50),
|
||||
source_platform_name: truncateText(item.platform_name || item.platform_type, 200),
|
||||
// 来源订单号用的是平台「系统编号」,平台自己的「订单编号」落在这里随单推给 WMS
|
||||
oaid_order_source_code: item.platform_order_no ? truncateText(item.platform_order_no, 50) : null,
|
||||
buyer_message: truncateText(item.remark, 500),
|
||||
place_order_time: item.external_created_at,
|
||||
pay_time: item.external_updated_at,
|
||||
|
||||
@ -234,6 +234,7 @@ const ORDER_COLUMNS = [
|
||||
{ key: 'id', header: 'ID' },
|
||||
{ key: 'order_no', header: '订单号' },
|
||||
{ key: 'parent_order_no', header: '来源订单号' },
|
||||
{ key: 'oaid_order_source_code', header: '平台订单号' },
|
||||
{ key: 'status', header: '状态', format: labels(ORDER_STATUS_LABELS) },
|
||||
{ key: 'order_type', header: '订单类型' },
|
||||
{ key: 'shop_id', header: '店铺ID' },
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* 外部打单平台订单:把平台「订单编号」(PlatformOrderId)回填到 oaid_order_source_code。
|
||||
*
|
||||
* 背景:来源订单号(order_index.parent_order_no)已改用店管家「系统编号」LogicOrderId,
|
||||
* 平台自己的「订单编号」只存在 extend_props.platform_order_no 里;该值需要随单推给 WMS,
|
||||
* 因此统一落到 oaid_order_source_code(推单时映射为 deliveryOrder.oaidOrderSourceCode)。
|
||||
*
|
||||
* 只回填 oaid_order_source_code 为空、且 extend_props 里带 platform_order_no 的行,
|
||||
* 手工单(无 extend_props.platform_order_no)不受影响。
|
||||
*/
|
||||
const STATUS_TABLES = [
|
||||
'order_status_pending',
|
||||
'order_status_queued',
|
||||
'order_status_exception',
|
||||
'order_status_outsourcing',
|
||||
'order_status_delivery',
|
||||
'order_status_void',
|
||||
'order_status_canceled',
|
||||
'order_status_history',
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface) {
|
||||
for (const table of STATUS_TABLES) {
|
||||
await queryInterface.sequelize.query(
|
||||
`UPDATE \`${table}\`
|
||||
SET oaid_order_source_code = JSON_UNQUOTE(JSON_EXTRACT(extend_props, '$.platform_order_no'))
|
||||
WHERE oaid_order_source_code IS NULL
|
||||
AND extend_props IS NOT NULL
|
||||
AND JSON_EXTRACT(extend_props, '$.platform_order_no') IS NOT NULL`
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
async down() {
|
||||
// 数据回填不做回滚(回滚会丢掉平台单号,且不影响表结构)
|
||||
},
|
||||
};
|
||||
@ -101,6 +101,8 @@ export interface OrderStatusItem {
|
||||
source_platform_code?: string | null
|
||||
/** 来源平台名称(如「拼多多」) */
|
||||
source_platform_name?: string | null
|
||||
/** 平台自己的订单编号(店管家「订单编号」,来源订单号用的是其「系统编号」) */
|
||||
oaid_order_source_code?: string | null
|
||||
remark: string | null
|
||||
/** —— 老发货单口径字段(为容纳老表而扩展) —— */
|
||||
order_type?: string | null
|
||||
|
||||
@ -548,9 +548,13 @@ function fmtNum(value: unknown): string {
|
||||
return Number.isFinite(num) ? String(Number(num.toFixed(2))) : String(value)
|
||||
}
|
||||
|
||||
/** 外部打单平台订单的平台单号(店管家「订单编号」,来源订单号用的是其「系统编号」) */
|
||||
/** 外部打单平台订单的平台单号(店管家「订单编号」;来源订单号用的是其「系统编号」) */
|
||||
function platformOrderNoOf(row: Record<string, any> | null): string {
|
||||
const props = row && (row.extend_props as Record<string, unknown> | null)
|
||||
if (!row) return ''
|
||||
// 现在落库在 oaid_order_source_code(随单推给 WMS),老数据回退到 extend_props
|
||||
const direct = row.oaid_order_source_code
|
||||
if (typeof direct === 'string' && direct) return direct
|
||||
const props = row.extend_props as Record<string, unknown> | null
|
||||
const value = props && props.platform_order_no
|
||||
return typeof value === 'string' ? value : ''
|
||||
}
|
||||
@ -706,6 +710,9 @@ onMounted(async () => {
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="parent_order_no" label="来源订单号" width="140" show-overflow-tooltip />
|
||||
<el-table-column label="平台订单号" width="160" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.oaid_order_source_code || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="店铺" width="120" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.shop_name || '-' }}</template>
|
||||
</el-table-column>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user