diff --git a/backend/app/lib/printPlatform/dgj.js b/backend/app/lib/printPlatform/dgj.js index bdaedfb..ac9cc77 100644 --- a/backend/app/lib/printPlatform/dgj.js +++ b/backend/app/lib/printPlatform/dgj.js @@ -652,6 +652,7 @@ function parseOrderTime(value) { /** 分销渠道 → 系统平台编码:1688 分销单取号必须用下游渠道的面单模板 */ const DISTRIBUTE_CHANNEL_PLATFORM = { douyin: 'DYXD', + kuaishou: 'KS', }; /** @@ -2431,7 +2432,8 @@ class DgjService extends PrintPlatformService { const distributeChannel = this.resolveOrderDistributeChannel(data); // 硬规则(分销代发业务口径):1688 单不按 1688 出号,统一换算成实际取号渠道 // - 抖音分销单(OutChannel=douyin / douyin_plaintext)→ 抖音小店(DYXD) - // - 其它分销渠道(OutChannel=未知值,如 kuaishou/thyny)→ 其他(OTHER),原始报文与渠道留痕,等待后续映射 + // - 快手分销单(OutChannel=kuaishou)→ 快手(KS) + // - 其它分销渠道(OutChannel=未知值,如 thyny/chaoshibianli)→ 其他(OTHER),原始报文与渠道留痕,等待后续映射 // - 非分销单(无 OutChannel 标签)→ 淘宝(TB) // 否则按 1688 永远匹配不到面单模板,取号必失败 let platformCode = platform.code; @@ -2485,7 +2487,7 @@ class DgjService extends PrintPlatformService { * 取订单的分销渠道(Tags/OrderTags 里 `Tag=OutChannel` 的 `TagValue`) * * 1688 分销/代发采购单会带这个标签,值是对下游渠道的标识(实测 `douyin`、 - * `douyin_plaintext`、`chaoshibianli_plaintext`、`thyny_plaintext`、`kuaishou` 等)。 + * `douyin_plaintext`、`kuaishou`、`chaoshibianli_plaintext`、`thyny_plaintext` 等)。 * 分销单必须用下游渠道的电子面单,所以「平台」要按下游渠道算,不能按 1688 算, * 否则取号永远匹配不到模板。标签里的明文/密文后缀由 `normalizeDistributeChannel` 归一化。 * 少数分销单没有 OutChannel 标签,但 `ExtField1` 记了同一个渠道名(实测 `douyin`),一并兜底。 diff --git a/backend/test/app/lib/dgjOrderPlatformRule.test.js b/backend/test/app/lib/dgjOrderPlatformRule.test.js index 255575d..e93044d 100644 --- a/backend/test/app/lib/dgjOrderPlatformRule.test.js +++ b/backend/test/app/lib/dgjOrderPlatformRule.test.js @@ -89,6 +89,18 @@ describe('printPlatform/dgj normalizeOrder 平台换算硬规则', () => { assert.strictEqual(order.original_platform_code, '1688'); }); + it('1688 快手分销单 → 快手(KS),生产有快手模板', () => { + const order = service.normalizeOrder(buildRow({ + ExtField1: 'kuaishou', + Tags: [{ Tag: 'OutChannel', TagType: 'Order', TagValue: 'kuaishou' }], + })); + console.log('快手分销:', order.platform_code, order.platform_name, order.distribute_channel); + assert.strictEqual(order.platform_code, 'KS'); + assert.strictEqual(order.platform_name, '快手'); + assert.strictEqual(order.distribute_channel, 'kuaishou'); + assert.strictEqual(order.original_platform_code, '1688'); + }); + it('1688 未识别的分销渠道 → 其他(保留渠道与原始报文)', () => { const order = service.normalizeOrder(buildRow({ Tags: [{ Tag: 'OutChannel', TagValue: 'thyny_plaintext' }],