This commit is contained in:
2025-12-13 21:39:35 +03:30
parent 212f6c44f7
commit 835f2a3853
4 changed files with 16 additions and 7 deletions
+8 -4
View File
@@ -69,20 +69,24 @@ export class UserService {
return this.userRepository.findOne({ id });
}
async create(phone: string): Promise<User> {
async create(phone: string, restId: string): Promise<User> {
const normalizedPhone = normalizePhone(phone);
const _raw = {
phone: normalizedPhone,
firstName: normalizedPhone,
birthDate: undefined,
marriageDate: undefined,
wallet: 0,
points: 0,
};
// get registerscore from restaurant
const restaurant = await this.restaurantRepository.findOne({ id: restId });
if (!restaurant) {
throw new NotFoundException(`Restaurant not found.`);
}
const points = Number(restaurant.score?.registerScore || 0);
const createData = _raw as unknown as RequiredEntityData<User>;
const user = this.userRepository.create(createData);
this.userWalletRepository.create({ user: user, restaurant: restaurant, wallet: 0, points: points });
await this.em.persistAndFlush(user);
return user;
}