|
@@ -303,27 +303,32 @@ bot.onText(/\/deposit (.+)/, async (msg, match) => {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- try {
|
|
|
- const transactionData = {
|
|
|
- groupId: msg.chat.id.toString(),
|
|
|
- groupName: msg.chat.title || '未命名群组',
|
|
|
- amount: amount
|
|
|
- };
|
|
|
+ const transactionData = {
|
|
|
+ groupId: msg.chat.id.toString(),
|
|
|
+ groupName: msg.chat.title || '未命名群组',
|
|
|
+ amount: amount
|
|
|
+ };
|
|
|
|
|
|
+ try {
|
|
|
const result = await Transaction.deposit(transactionData);
|
|
|
-
|
|
|
if (result.success) {
|
|
|
- sendMessage(msg.chat.id, generateBillMessage(msg.chat.id), {
|
|
|
- reply_markup: generateInlineKeyboard(msg.chat.id)
|
|
|
- });
|
|
|
- console.log('机器人已准备就绪!');
|
|
|
+ const billMessage = await generateBillMessage(msg.chat.id);
|
|
|
+ if (billMessage) {
|
|
|
+ await sendMessage(msg.chat.id, billMessage, {
|
|
|
+ reply_markup: generateInlineKeyboard(msg.chat.id)
|
|
|
+ });
|
|
|
+ console.log(`入款成功 - 群组: ${msg.chat.title}, 金额: ${amount}, 时间: ${new Date().toLocaleString()}`);
|
|
|
+ } else {
|
|
|
+ await sendMessage(msg.chat.id, '入款成功,但获取账单信息失败');
|
|
|
+ console.log(`入款成功(无账单) - 群组: ${msg.chat.title}, 金额: ${amount}, 时间: ${new Date().toLocaleString()}`);
|
|
|
+ }
|
|
|
} else {
|
|
|
- sendMessage(msg.chat.id, result.message);
|
|
|
- console.log('机器人已准备就绪!');
|
|
|
+ await sendMessage(msg.chat.id, result.message || '入款失败');
|
|
|
+ console.log(`入款失败 - 群组: ${msg.chat.title}, 金额: ${amount}, 原因: ${result.message}, 时间: ${new Date().toLocaleString()}`);
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error('记录入款失败:', error);
|
|
|
- sendMessage(msg.chat.id, '记录入款失败,请稍后重试');
|
|
|
+ await sendMessage(msg.chat.id, '记录入款失败,请稍后重试');
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -340,25 +345,32 @@ bot.onText(/\/withdraw (.+)/, async (msg, match) => {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- try {
|
|
|
- const transactionData = {
|
|
|
- groupId: msg.chat.id.toString(),
|
|
|
- groupName: msg.chat.title || '未命名群组',
|
|
|
- amount: amount
|
|
|
- };
|
|
|
+ const transactionData = {
|
|
|
+ groupId: msg.chat.id.toString(),
|
|
|
+ groupName: msg.chat.title || '未命名群组',
|
|
|
+ amount: amount
|
|
|
+ };
|
|
|
|
|
|
+ try {
|
|
|
const result = await Transaction.withdrawal(transactionData);
|
|
|
-
|
|
|
if (result.success) {
|
|
|
- sendMessage(msg.chat.id, generateBillMessage(msg.chat.id), {
|
|
|
- reply_markup: generateInlineKeyboard(msg.chat.id)
|
|
|
- });
|
|
|
+ const billMessage = await generateBillMessage(msg.chat.id);
|
|
|
+ if (billMessage) {
|
|
|
+ await sendMessage(msg.chat.id, billMessage, {
|
|
|
+ reply_markup: generateInlineKeyboard(msg.chat.id)
|
|
|
+ });
|
|
|
+ console.log(`出款成功 - 群组: ${msg.chat.title}, 金额: ${amount}, 时间: ${new Date().toLocaleString()}`);
|
|
|
+ } else {
|
|
|
+ await sendMessage(msg.chat.id, '出款成功,但获取账单信息失败');
|
|
|
+ console.log(`出款成功(无账单) - 群组: ${msg.chat.title}, 金额: ${amount}, 时间: ${new Date().toLocaleString()}`);
|
|
|
+ }
|
|
|
} else {
|
|
|
- sendMessage(msg.chat.id, result.message);
|
|
|
+ await sendMessage(msg.chat.id, result.message || '出款失败');
|
|
|
+ console.log(`出款失败 - 群组: ${msg.chat.title}, 金额: ${amount}, 原因: ${result.message}, 时间: ${new Date().toLocaleString()}`);
|
|
|
}
|
|
|
} catch (error) {
|
|
|
- console.error('记录下发失败:', error);
|
|
|
- sendMessage(msg.chat.id, '记录下发失败,请稍后重试');
|
|
|
+ console.error('记录出款失败:', error);
|
|
|
+ await sendMessage(msg.chat.id, '记录出款失败,请稍后重试');
|
|
|
}
|
|
|
});
|
|
|
|