feat(api): category-based family grouping, tree family info and custom goods family attribution
This commit is contained in:
@@ -68,11 +68,16 @@ describe('SyncService family hooks', () => {
|
||||
expect(og2.warehouseLabel).toBeNull();
|
||||
});
|
||||
|
||||
it('新链接自动挂族:唯一命中族则挂载并触发重算', async () => {
|
||||
it('新链接自动挂族:按 SDS 分类唯一命中族则挂载并触发重算', async () => {
|
||||
const sdsCat = `cat-hook-${stamp}`;
|
||||
const cat = await prisma.category.create({
|
||||
data: { categoryName: `挂族测试分类-${stamp}`, sdsCategoryId: sdsCat },
|
||||
});
|
||||
const seed = await prisma.originGood.create({
|
||||
data: {
|
||||
sdsGoodId: `hook-${stamp}-seed`,
|
||||
goodName: `自动挂${stamp}(包邮)卫衣-ZZA${stamp}-单面印花`,
|
||||
sdsCategoryId: sdsCat,
|
||||
craftLabel: '单面印花',
|
||||
logisticsLabel: '包邮',
|
||||
},
|
||||
@@ -105,11 +110,11 @@ describe('SyncService family hooks', () => {
|
||||
const before = await prisma.productFamily.findUniqueOrThrow({ where: { id: family.id } });
|
||||
expect((before.priceMatrix as any).rows).toHaveLength(1);
|
||||
|
||||
// 同键新链接(多一个仓库段)→ 自动挂进唯一族
|
||||
// 同分类新链接(不同工艺)→ 自动挂进唯一族
|
||||
const newSdsId = `hook-${stamp}-new`;
|
||||
await (service as any).upsertOriginGood(
|
||||
sdsProduct(newSdsId, `自动挂${stamp}(包邮)卫衣-ZZA${stamp}-单面印花-某仓`),
|
||||
'cat-1',
|
||||
sdsProduct(newSdsId, `自动挂${stamp}(不包邮)卫衣-ZZA${stamp}-双面印花-某仓`),
|
||||
sdsCat,
|
||||
);
|
||||
const newOg = await prisma.originGood.findUniqueOrThrow({ where: { sdsGoodId: newSdsId } });
|
||||
createdOriginGoodIds.push(newOg.id);
|
||||
@@ -117,6 +122,7 @@ describe('SyncService family hooks', () => {
|
||||
|
||||
// 入队的重算已执行(等待异步完成)
|
||||
await new Promise((r) => setTimeout(r, 200));
|
||||
await prisma.category.delete({ where: { id: cat.id } }).catch(() => undefined);
|
||||
});
|
||||
|
||||
it('多族命中时不确定归属 → 不挂载', async () => {
|
||||
|
||||
Reference in New Issue
Block a user