diff --git a/furniture-3d-system/src/server/services/__tests__/supply-chain-product-archive-sync.service.test.ts b/furniture-3d-system/src/server/services/__tests__/supply-chain-product-archive-sync.service.test.ts index 4b2b3f40..48c69283 100644 --- a/furniture-3d-system/src/server/services/__tests__/supply-chain-product-archive-sync.service.test.ts +++ b/furniture-3d-system/src/server/services/__tests__/supply-chain-product-archive-sync.service.test.ts @@ -4,6 +4,7 @@ import { PRODUCT_DEVELOPMENT_ARCHIVE_SOURCE_CODE, SupplyChainProductArchiveSyncService, mapProductCatalogWideArchiveSource, + normalizeProductArchiveBrand, } from '../supply-chain-product-archive-sync.service' import { recordProductArchiveFieldChanges, @@ -101,6 +102,20 @@ describe('supply-chain product archive wide-catalog sync', () => { ) }) + it('corrects mislabeled Sofia products from the GBSFY SKU prefix', () => { + const mapped = mapProductCatalogWideArchiveSource({ + ...createSourceRecord(), + archive_spu: 'GBSFY-XG0293', + archive_sku: 'GBSFY-XG029301', + barcode_business_key: 'GBSFY-XG029301N1441V01', + brand_name: '其他品牌-普通大货', + }) + + expect(mapped?.archive.brand).toBe('代理品牌-索菲亚') + expect(normalizeProductArchiveBrand('gbsfy-ad036001', '')).toBe('代理品牌-索菲亚') + expect(normalizeProductArchiveBrand('CZ014006', '其他品牌-普通大货')).toBe('其他品牌-普通大货') + }) + it('leaves the image empty when the current SKU has no image', () => { const mapped = mapProductCatalogWideArchiveSource({ ...createSourceRecord(), diff --git a/furniture-3d-system/src/server/services/supply-chain-product-archive-sync.service.ts b/furniture-3d-system/src/server/services/supply-chain-product-archive-sync.service.ts index ee67b8a5..4081aea5 100644 --- a/furniture-3d-system/src/server/services/supply-chain-product-archive-sync.service.ts +++ b/furniture-3d-system/src/server/services/supply-chain-product-archive-sync.service.ts @@ -87,6 +87,13 @@ export function resolveProductArchivePackageType(value: string) { return PACKAGE_TYPE_BY_SET_COUNT[value.trim()] ?? '' } +/** 索菲亚货号以 GBSFY 开头;源品牌字段偶有误标,以货号前缀纠正。 */ +export function normalizeProductArchiveBrand(sku: string, brand: string) { + return sku.trim().toUpperCase().startsWith('GBSFY') + ? '代理品牌-索菲亚' + : brand.trim() +} + export function calculateProductArchiveVolume( length: string, width: string, @@ -160,7 +167,7 @@ export function mapProductCatalogWideArchiveSource( installDocId: text(record.drawing_id), installMethod: text(record.install_method), spec: text(record.archive_spec), - brand: text(record.brand_name), + brand: normalizeProductArchiveBrand(text(record.archive_sku), text(record.brand_name)), orderType: normalizeProductArchiveOrderType(record.purchase_order_method), inOutWarehouse: text(record.factory_warehouse), isSeasonal: '',