whallets upgrade function

This commit is contained in:
NW
2024-12-16 23:43:44 +00:00
parent d51bc9f0b9
commit 21465022b3
4 changed files with 108 additions and 92 deletions

View File

@@ -1,3 +1,23 @@
class WalletService {
import db from "../config/database.js";
}
class WalletService {
static async getArchivedWalletsCount(user) {
try {
// Получаем количество архивных кошельков пользователя
const archivedWallets = await db.getAsync(
`SELECT COUNT(*) AS total
FROM crypto_wallets
WHERE user_id = ? AND wallet_type LIKE '%#_%' ESCAPE '#'`, // Считаем только архивные кошельки
[user.id]
);
console.log('[SERVICE] Fetching archived wallets for user:', user.id, 'with telegramId:', user.telegram_id, ' and tolal arhived wallet: ', archivedWallets.total);
// Возвращаем количество архивных кошельков
return archivedWallets.total;
} catch (error) {
console.error('Error fetching archived wallets count:', error);
throw new Error('Failed to fetch archived wallets count');
}
}
}
export default WalletService;