This commit is contained in:
@@ -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,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user