|
@@ -440,9 +440,9 @@ bot.onText(/\/help/, (msg) => {
|
|
|
// 生成账单消息
|
|
|
async function generateBillMessage(chatId) {
|
|
|
try {
|
|
|
- // 获取群组的最后加入时间
|
|
|
+ // 获取群组的最后加入时间和费率信息
|
|
|
const [groupInfo] = await pool.query(
|
|
|
- 'SELECT last_join_time FROM groups WHERE group_id = ?',
|
|
|
+ 'SELECT last_join_time, fee_rate FROM groups WHERE group_id = ?',
|
|
|
[chatId.toString()]
|
|
|
);
|
|
|
|
|
@@ -451,15 +451,16 @@ async function generateBillMessage(chatId) {
|
|
|
}
|
|
|
|
|
|
const lastJoinTime = groupInfo[0].last_join_time;
|
|
|
+ const feeRate = parseFloat(groupInfo[0].fee_rate) || 0;
|
|
|
|
|
|
// 获取机器人加入后的交易记录
|
|
|
const [records] = await pool.query(`
|
|
|
SELECT * FROM transactions
|
|
|
WHERE group_id = ?
|
|
|
- AND time >= ?
|
|
|
+ AND DATE(time) = CURDATE()
|
|
|
ORDER BY time DESC
|
|
|
LIMIT 10
|
|
|
- `, [chatId.toString(), lastJoinTime]);
|
|
|
+ `, [chatId.toString()]);
|
|
|
|
|
|
if (!records || records.length === 0) {
|
|
|
return '暂无交易记录';
|
|
@@ -470,8 +471,8 @@ async function generateBillMessage(chatId) {
|
|
|
|
|
|
const totalDeposit = deposits.reduce((sum, d) => sum + parseFloat(d.amount), 0);
|
|
|
const totalWithdrawal = withdrawals.reduce((sum, w) => sum + parseFloat(w.amount), 0);
|
|
|
- const depositFee = totalDeposit * (process.env.DEPOSIT_FEE_RATE || 0);
|
|
|
- const withdrawalFee = totalWithdrawal * (process.env.WITHDRAWAL_FEE_RATE || 0);
|
|
|
+ const depositFee = totalDeposit * (feeRate / 100);
|
|
|
+ const withdrawalFee = totalWithdrawal * (feeRate / 100);
|
|
|
const remaining = totalDeposit - depositFee - totalWithdrawal - withdrawalFee;
|
|
|
|
|
|
let message = `📊 *账单明细*\n\n`;
|
|
@@ -497,8 +498,7 @@ async function generateBillMessage(chatId) {
|
|
|
// 添加统计信息
|
|
|
message += `📈 *统计信息*\n`;
|
|
|
message += `• 总入款:${totalDeposit.toFixed(2)}\n`;
|
|
|
- message += `• 入款费率:${((process.env.DEPOSIT_FEE_RATE || 0) * 100).toFixed(1)}%\n`;
|
|
|
- message += `• 下发费率:${((process.env.WITHDRAWAL_FEE_RATE || 0) * 100).toFixed(1)}%\n`;
|
|
|
+ message += `• 费率:${feeRate.toFixed(1)}%\n`;
|
|
|
message += `• 应下发:${(totalDeposit - depositFee).toFixed(2)}\n`;
|
|
|
message += `• 总下发:${totalWithdrawal.toFixed(2)}\n`;
|
|
|
message += `• 下发单笔附加费:0.0\n`;
|