feat(pull): 「新增 0、更新 N」时说明这些单为什么不在待审核
拉单结果只报「新增 0 / 更新 N」,用户会以为「拉到 8 单却没落库」。 实际是拉单按平台单号(老表 orders.order_no = 平台code-平台单号)去重: 已在系统里的单只刷新平台状态与收件人,不会重复新增,也不会把已审核过的单退回待审核。 - externalPrintOrder.buildRefreshHint:created=0 且 updated>0 时给出说明 (已在「待推送 / 配送 / 历史」,或因平台侧已发货被自动作废,可按平台单号搜索) - 接进 syncOrders 的 hint 链(零单/补查/兜底都不命中时才用) - 单测补 1 例(含「有新增不提示」「0 更新不提示」) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
9f067c1b58
commit
349f7f2949
@ -190,10 +190,29 @@ class ExternalPrintOrderService extends Service {
|
||||
supplementHosts: result.supplementHosts || [],
|
||||
hint: this.buildZeroOrderHint(shopPlain, result, { startTime, endTime })
|
||||
|| this.buildSupplementHint(shopPlain, result)
|
||||
|| this.buildFallbackHint(result),
|
||||
|| this.buildFallbackHint(result)
|
||||
|| this.buildRefreshHint(saved),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 「本次全是更新、没有新增」时的说明
|
||||
*
|
||||
* 拉单按平台单号(老表 `orders.order_no = 平台code-平台单号`)去重:已在系统里的单只刷新平台状态/收件人,
|
||||
* 不会重复新增,也不会把已审核过的单退回「待审核」。没有这条提示时,「新增 0、更新 N」
|
||||
* 看起来很像「拉到了却没落库」。
|
||||
* @param {Object} saved saveOrders 的写入统计
|
||||
* @return {string} 提示(无需提示时为空字符串)
|
||||
*/
|
||||
buildRefreshHint(saved) {
|
||||
const created = Number((saved && saved.created) || 0);
|
||||
const updated = Number((saved && saved.updated) || 0);
|
||||
if (created > 0 || updated <= 0) return '';
|
||||
return `本次拉到的 ${updated} 单在系统里都已存在(按平台单号去重),只刷新了平台状态与收件信息;` +
|
||||
'若在「待审核」看不到,说明它们已审核过——可能已在「待推送 / 配送 / 历史」,或因平台侧已发货被自动作废,' +
|
||||
'可用平台单号在对应视图搜索';
|
||||
}
|
||||
|
||||
/**
|
||||
* 有分区走了「不支持状态过滤 → 时间窗全量」兜底时的提示
|
||||
*
|
||||
|
||||
@ -84,4 +84,17 @@ describe('service/externalPrintOrder 拉单 0 单的排查提示', () => {
|
||||
assert.strictEqual(service.buildFallbackHint({ total: 0, fallbackHosts: [] }), '');
|
||||
assert.strictEqual(service.buildFallbackHint(null), '');
|
||||
});
|
||||
|
||||
it('全部都是更新、没有新增时说明「已在系统里、不会退回待审核」', () => {
|
||||
const hint = service.buildRefreshHint({ created: 0, updated: 8 });
|
||||
console.log('全更新提示:', hint);
|
||||
assert.match(hint, /8 单/);
|
||||
assert.match(hint, /都已存在/);
|
||||
assert.match(hint, /待推送/);
|
||||
assert.match(hint, /自动作废/);
|
||||
// 有新增时不提示
|
||||
assert.strictEqual(service.buildRefreshHint({ created: 2, updated: 8 }), '');
|
||||
assert.strictEqual(service.buildRefreshHint({ created: 0, updated: 0 }), '');
|
||||
assert.strictEqual(service.buildRefreshHint(null), '');
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user