تغییرات کلی در backend و frontend
This commit is contained in:
1 parent
a74f4bda48
commit
3dedc89ee1
41 files changed
+2373
-1957
No files matched your search
@@ -9,8 +9,19 @@ export class UsersService {
|
||||
return this.prisma.user.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
pets: true,
|
||||
pets: {
|
||||
include: {
|
||||
medicalConditions: true,
|
||||
reminders: {
|
||||
include: {
|
||||
completions: true
|
||||
}
|
||||
},
|
||||
healthLogs: true,
|
||||
}
|
||||
},
|
||||
orders: {
|
||||
orderBy: { createdAt: 'desc' },
|
||||
include: {
|
||||
orderItems: {
|
||||
include: { product: true }
|
||||
@@ -18,7 +29,10 @@ export class UsersService {
|
||||
}
|
||||
},
|
||||
addresses: true,
|
||||
walletTransactions: true
|
||||
walletTransactions: {
|
||||
orderBy: { createdAt: 'desc' },
|
||||
take: 50
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -103,6 +117,30 @@ export class UsersService {
|
||||
});
|
||||
}
|
||||
|
||||
async topUpWallet(userId: string, amount: number) {
|
||||
if (amount <= 0) {
|
||||
throw new Error('مبلغ شارژ باید بزرگتر از صفر باشد');
|
||||
}
|
||||
|
||||
const [transaction] = await this.prisma.$transaction([
|
||||
this.prisma.walletTransaction.create({
|
||||
data: {
|
||||
userId,
|
||||
amount,
|
||||
type: 'deposit',
|
||||
status: 'completed',
|
||||
description: 'شارژ کیف پول',
|
||||
},
|
||||
}),
|
||||
this.prisma.user.update({
|
||||
where: { id: userId },
|
||||
data: { walletBalance: { increment: amount } },
|
||||
}),
|
||||
]);
|
||||
|
||||
return transaction;
|
||||
}
|
||||
|
||||
async findByPhone(phoneNumber: string) {
|
||||
return this.prisma.user.findUnique({
|
||||
where: { mobile: phoneNumber },
|
||||
|
||||
Reference in new issue
Block a user