feat(product-family): derive tags per link name (印花数量/工艺/物流 rules)

This commit is contained in:
yeuimu
2026-08-28 15:33:11 +08:00
parent f5a3b8c840
commit ee336968a0
5 changed files with 314 additions and 112 deletions
+7 -12
View File
@@ -13,6 +13,7 @@ import { BatchPriorityDto } from './dto/batch-priority.dto';
import { GoodDetailDto, GoodDto, PaginatedGoods } from './dto/good.dto';
import { SyncService } from '../sync/sync.service';
import { FamilyRecomputeService } from '../product-families/family-recompute.service';
import { isAutoTagGroupName } from '../product-families/auto-tag-rules';
import { randomUUID } from 'crypto';
import {
CreateCustomGoodDto,
@@ -619,24 +620,18 @@ export class GoodsService {
if (!c) throw new BadRequestException(`Category ${id} not found`);
}
/** 有族商品:剔除自动组(物流/工艺/位置)标签——它们由族同步管理 */
/** 有族商品:剔除自动组(物流/工艺/印花数量等)标签——它们由族按链接名称派生 */
private async stripAutoGroupTags(
tagIds: number[],
familyId: bigint | null,
): Promise<number[]> {
if (!familyId || !tagIds.length) return tagIds;
const autoGroups = await this.prisma.tagGroup.findMany({
where: {
OR: [
{ groupName: { contains: '物流' } },
{ groupName: { contains: '工艺' } },
{ groupName: { contains: '位置' } },
],
},
select: { id: true },
const groups = await this.prisma.tagGroup.findMany({
select: { id: true, groupName: true },
});
if (!autoGroups.length) return tagIds;
const autoIds = new Set(autoGroups.map((g) => g.id.toString()));
const autoIds = new Set(
groups.filter((g) => isAutoTagGroupName(g.groupName)).map((g) => g.id.toString()),
);
const tags = await this.prisma.tag.findMany({
where: { id: { in: tagIds.map((id) => BigInt(id)) } },
select: { id: true, tagGroupId: true },