From 49fb70fcbf4e9738dfb19c5011a5cec6dd281fa6 Mon Sep 17 00:00:00 2001 From: liufumingren Date: Wed, 7 Oct 2026 23:26:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(wave):=20=E6=B3=A2=E6=AC=A1=E5=BF=AB?= =?UTF-8?q?=E9=80=92=E5=8F=B7=E5=88=86=E9=85=8D=E5=90=8E=E5=8F=B0=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=AD=89=E5=BE=85=E5=88=86=E9=85=8D=E7=9C=9F=E6=AD=A3?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=B9=B6=E6=98=BE=E5=BC=8F=E4=BC=A0=E4=BB=93?= =?UTF-8?q?=E5=BA=93ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/systemMethods/order/wave.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/service/systemMethods/order/wave.js b/app/service/systemMethods/order/wave.js index 5d291b7..9ee9968 100644 --- a/app/service/systemMethods/order/wave.js +++ b/app/service/systemMethods/order/wave.js @@ -10259,7 +10259,8 @@ class WaveService extends OrderBaseService { /** * 执行批次分配快递号后台任务。 * - * 任务仅负责提交分配请求到快递分配流水线,实际分配过程由快递服务异步处理。 + * 任务会等待快递分配流水线中所有批次真正完成分配(awaitTasks=true)后 + * 才写入 success 状态,避免进度接口在分配尚未完成时提前返回完成。 * * @param {Object} params 任务参数。 * @param {string} params.taskId 任务ID。 @@ -10494,7 +10495,13 @@ class WaveService extends OrderBaseService { totalOrderCount: normalizedOrders.length, sampleOrderIds: normalizedOrders.slice(0, 20).map(item => Number(item && item.order_id || 0)).filter(Boolean), }); - const pipelineResult = await this.service.systems.express.createWaybillCodePipeline(normalizedOrders); + // awaitTasks=true:等待所有批次真正分配完成后再返回,避免任务被提前标记 success。 + // warehouseId 显式传入:后台任务运行在 setImmediate 异步上下文中,ctx.user 可能已失效, + // 防止 getCurrentWarehouseId() 返回 0 导致跨仓/无效仓查询。 + const pipelineResult = await this.service.systems.express.createWaybillCodePipeline(normalizedOrders, { + awaitTasks: true, + warehouseId, + }); const durationMs = Date.now() - startTime; this.ctx.logger.info('[wave.batchAllocateExpress] 快递号分配流水线执行完成', {