feat(product-family): replace legacy good merge with family mechanism in config view and public detail

This commit is contained in:
yeuimu
2026-08-28 14:14:58 +08:00
parent 14c53504f0
commit 4eadb67c36
11 changed files with 2894 additions and 2710 deletions
@@ -40,6 +40,7 @@ describe('ProductFamiliesService', () => {
});
it('create:挂成员、重算、familyCode 冲突自动加后缀', async () => {
const code = `DG${stamp}T`;
const a = await mkOriginGood('美国(包邮)T恤-DGTEST-单面印花', {
craftLabel: '单面印花',
logisticsLabel: '包邮',
@@ -58,18 +59,18 @@ describe('ProductFamiliesService', () => {
});
const f1 = (await service.create({
familyName: '测试T恤',
familyCode: 'DGTEST',
familyCode: code,
originGoodIds: [a.id.toString()],
primaryOriginGoodId: a.id.toString(),
})) as any;
createdFamilyIds.push(BigInt(f1.id));
expect(f1.familyCode).toBe('DGTEST');
expect(f1.familyCode).toBe(code);
expect(f1._count.originGoods).toBe(1);
expect((f1.priceMatrix as any).rows).toHaveLength(1);
const f2 = (await service.create({ familyName: '测试T恤二号', familyCode: 'DGTEST' })) as any;
const f2 = (await service.create({ familyName: '测试T恤二号', familyCode: code })) as any;
createdFamilyIds.push(BigInt(f2.id));
expect(f2.familyCode).toBe('DGTEST-2');
expect(f2.familyCode).toBe(`${code}-2`);
});
it('detail:不存在 404', async () => {
@@ -77,11 +78,12 @@ describe('ProductFamiliesService', () => {
});
it('listkeyword 过滤 familyName/familyCode + 分页字段', async () => {
const code = `DG${stamp}T`;
const res = (await service.list({ keyword: `测试T恤`, page: 1, pageSize: 10 })) as any;
expect(res.total).toBeGreaterThanOrEqual(2);
expect(res.items.length).toBeGreaterThanOrEqual(2);
expect(res.page).toBe(1);
const byCode = (await service.list({ keyword: 'DGTEST-2' })) as any;
const byCode = (await service.list({ keyword: `${code}-2` })) as any;
expect(byCode.total).toBe(1);
});