删除门店的多银行账户列表

This commit is contained in:
2026-09-08 14:23:00 +08:00
parent 253430b291
commit 8f25f823d5
22 changed files with 214 additions and 902 deletions
@@ -161,11 +161,20 @@ export class FinanceBankAccountService {
}
private async collectAll(): Promise<FinanceBankAccountDto[]> {
const [storeRows, partnerRows, logisticsRows, otherRows, notes, winery] = await Promise.all([
this.prisma.storeBankAccount.findMany({
where: { status: 'ACTIVE' },
include: { store: { select: { id: true, name: true, cityId: true, cityName: true } } },
orderBy: { id: 'asc' },
const [storeBindings, partnerRows, logisticsRows, otherRows, notes, winery] = await Promise.all([
this.prisma.storeAccountStore.findMany({
include: {
store: { select: { id: true, name: true, cityId: true, cityName: true } },
storeAccount: {
select: {
isPrimary: true,
bankAccountName: true,
bankAccountNo: true,
bankBranch: true,
},
},
},
orderBy: [{ storeAccount: { isPrimary: 'desc' } }, { storeAccountId: 'asc' }],
}),
this.prisma.partnerAccount.findMany({
where: { status: 'ACTIVE', parentAccountId: null, isPrimary: 1 },
@@ -202,23 +211,25 @@ export class FinanceBankAccountService {
const items: FinanceBankAccountDto[] = [];
for (const row of storeRows) {
const name = row.bankAccountName.trim();
const no = row.bankAccountNo.replace(/\s+/g, '');
const seenStores = new Set<string>();
for (const binding of storeBindings) {
const sourceId = binding.store.id.toString();
if (seenStores.has(sourceId)) continue;
seenStores.add(sourceId);
const name = binding.storeAccount.bankAccountName?.trim() ?? '';
const no = binding.storeAccount.bankAccountNo?.replace(/\s+/g, '') ?? '';
if (!name || !no) continue;
const sourceId = row.id.toString();
items.push({
id: `STORE:${sourceId}`,
type: 'STORE',
ownerName: row.store.name,
ownerId: row.store.id.toString(),
cityId: row.store.cityId.toString(),
cityName: row.store.cityName,
ownerName: binding.store.name,
ownerId: sourceId,
cityId: binding.store.cityId.toString(),
cityName: binding.store.cityName,
bankAccountName: name,
bankAccountNo: no,
bankBranch: row.bankBranch,
bankBranch: binding.storeAccount.bankBranch,
remark: noteMap.get(`STORE:${sourceId}`) ?? null,
isDefault: row.isDefault === 1,
editable: false,
});
}