Item purchase

This commit is contained in:
Artyom Ashirov 2024-11-19 05:01:13 +03:00
parent 626435a3de
commit 6fa273f0b6
5 changed files with 674 additions and 562 deletions

View File

@ -95,6 +95,8 @@ const initDb = async () => {
city TEXT,
district TEXT,
status INTEGER DEFAULT 0,
total_balance REAL DEFAULT 0,
bonus_balance REAL DEFAULT 0,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
`);

View File

@ -370,6 +370,10 @@ export default class AdminProductHandler {
text: 'No products for this location',
markup: {
inline_keyboard: [
[{
text: '📥 Import Products',
callback_data: `add_product_${locationId}_${categoryId}_${subcategoryId}`
}],
[{text: '« Back', callback_data: `prod_category_${locationId}_${categoryId}`}]
]
}

File diff suppressed because it is too large Load Diff

View File

@ -239,6 +239,9 @@ bot.on('callback_query', async (callbackQuery) => {
} else if (action.startsWith('buy_product_')) {
logDebug(action, 'handleBuyProduct');
await userProductHandler.handleBuyProduct(callbackQuery);
} else if (action.startsWith('pay_with_')) {
logDebug(action, 'handlePay');
await userProductHandler.handlePay(callbackQuery);
}
// Admin location management
else if (action === 'add_location') {
@ -287,7 +290,7 @@ bot.on('callback_query', async (callbackQuery) => {
logDebug(action, 'handleSubcategorySelection');
await adminProductHandler.handleSubcategorySelection(callbackQuery);
} else if (action.startsWith('list_products_')) {
logDebug(action, 'handleSubcategorySelection');
logDebug(action, 'handleProductListPage');
await adminProductHandler.handleProductListPage(callbackQuery);
} else if (action.startsWith('add_product_')) {
logDebug(action, 'handleAddProduct');
@ -299,7 +302,7 @@ bot.on('callback_query', async (callbackQuery) => {
logDebug(action, 'handleProductEdit');
await adminProductHandler.handleProductEdit(callbackQuery)
} else if (action.startsWith('delete_product_')) {
logDebug(action, 'handleViewProduct');
logDebug(action, 'handleProductDelete');
await adminProductHandler.handleProductDelete(callbackQuery);
} else if (action.startsWith('confirm_delete_product_')) {
logDebug(action, 'handleConfirmDelete');
@ -310,13 +313,13 @@ bot.on('callback_query', async (callbackQuery) => {
logDebug(action, 'handleViewUser');
await adminUserHandler.handleViewUser(callbackQuery);
} else if (action.startsWith('list_users_')) {
logDebug(action, 'handleViewUser');
logDebug(action, 'handleUserListPage');
await adminUserHandler.handleUserListPage(callbackQuery);
} else if (action.startsWith('delete_user_')) {
logDebug(action, 'handleDeleteUser');
await adminUserHandler.handleDeleteUser(callbackQuery);
} else if (action.startsWith('block_user_')) {
logDebug(action, 'handleDeleteUser');
logDebug(action, 'handleBlockUser');
await adminUserHandler.handleBlockUser(callbackQuery);
} else if (action.startsWith('confirm_delete_user_')) {
logDebug(action, 'handleConfirmDelete');

View File

@ -103,4 +103,8 @@ export default class User {
throw error;
}
}
static async recalculateBalance(telegramId) {
}
}