From 7f78691f917dddaa17a61991f5bc582f4bb3f6e7 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Sun, 26 Jul 2026 14:29:25 +0330 Subject: [PATCH] update national code --- src/modules/users/providers/customers.service.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/modules/users/providers/customers.service.ts b/src/modules/users/providers/customers.service.ts index 24ab064..6d0627c 100755 --- a/src/modules/users/providers/customers.service.ts +++ b/src/modules/users/providers/customers.service.ts @@ -135,6 +135,7 @@ export class CustomersService { password, phone, birthDate, + nationalCode, }; // const addressUpdateData = { @@ -169,7 +170,7 @@ export class CustomersService { if (nationalCode) { const existingNationalCode = await queryRunner.manager.findOne(this.realUserRepository.target, { - where: { nationalCode: nationalCode, id: Not(user.id) }, + where: { nationalCode: nationalCode, user: { id: Not(user.id) } }, }); if (existingNationalCode) throw new BadRequestException(UserMessage.NATIONAL_CODE_EXIST); } @@ -180,6 +181,15 @@ export class CustomersService { await queryRunner.manager.update(this.userRepository.target, { id: customerId }, { password: hashPassword }); } + if (nationalCode) { + const realUser = await queryRunner.manager.findOne(this.realUserRepository.target, { + where: { user: { id: customerId } }, + }); + if (realUser) { + await queryRunner.manager.update(this.realUserRepository.target, { id: realUser.id }, { nationalCode }); + } + } + const hasLegalUpdateData = Boolean( registrationName || economicCode || nationalIdentity || registrationCode || postalCode || address || cityId, );