Taio_O 1 сар өмнө
parent
commit
440e404834
2 өөрчлөгдсөн 41 нэмэгдсэн , 29 устгасан
  1. 2 2
      admin/.env
  2. 39 27
      admin/index.js

+ 2 - 2
admin/.env

@@ -1,7 +1,7 @@
 BOT_TOKEN=7723001997:AAEh1MeZ_KOojZzms9CJa2lvUh9FowTWmUI
 ADMIN_IDS=管理员ID列表(用逗号分隔)
-DEPOSIT_FEE_RATE=入款费率
-WITHDRAWAL_FEE_RATE=下发费率
+DEPOSIT_FEE_RATE=0.05
+WITHDRAWAL_FEE_RATE=0
 BILL_PAGE_BASE_URL=账单页面基础URL
 BUSINESS_ACCOUNT_URL=商务账号URL
 DB_FILE=数据文件路径

+ 39 - 27
admin/index.js

@@ -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, '记录出款失败,请稍后重试');
     }
 });