Newbie Spellweaver
- Joined
- Jan 15, 2024
- Messages
- 30
- Reaction score
- 3
Good afternoon. Does anyone know how to fix this issue? There’s a roulette game on the site; I selected a character and spun, but it keeps saying "delivered."
In the AionWorld_110 database, the `dbo.user_mail` table has these values at the end.
id to_id to_name from_id from_name title content item_id item_nameid item_amount money state arrive_time express_mail item_tid
3791 1002 Sorgravity 1072 Webshop Выигрыш: Большой су. Поздравляем! Вы выиграли Большой сундук (1 Шт) в рулетке. Награда отправлена на почту. 96007 188053101 5 0 0 1782393408 1 0
3792 1002 Sorgravity 1072 Webshop Выигрыш: Свиток тел. Поздравляем! Вы выиграли Свиток телепорта (10 Шт) в рулетке. Награда отправлена на почту. 96008 164002238 10 0 0 1782393431 1 0
And there is express mail in the game, but it doesn’t open. I go to the mailbox and there are letters there, but they are not clickable. I also forcefully read the letters, and then I can open them, but there is nothing there.
And here is the backend API for email.
app.post('/api/mail/send', checkSession, async (req, res) => {
try {
const {
fromName,
fromId,
toName,
toId,
title,
content,
itemId,
itemAmount,
money = 0,
expressMail = 1
} = req.body;
console.log(`\n
Отправка почты:`);
console.log(` → От: ${fromName} (ID: ${fromId})`);
console.log(` → Кому: ${toName} (ID: ${toId})`);
console.log(` → Тема: ${title}`);
console.log(` → Предмет ID: ${itemId}, Кол-во: ${itemAmount}`);
console.log(` → Деньги: ${money}`);
console.log(` → Экспресс: ${expressMail ? 'Да' : 'Нет'}`);
if (!toName || !toId) {
return res.status(400).json({
success: false,
error: 'Не указан получатель'
});
}
if (!title) {
return res.status(400).json({
success: false,
error: 'Не указана тема письма'
});
}
const pool = await getPool();
// unix timestamp
const now = Math.floor(Date.now() / 1000);
let cleanTitle = title || 'Рулетка';
if (cleanTitle.length > 20) {
cleanTitle = cleanTitle.substring(0, 20);
}
console.log(` → Очищенный заголовок: ${cleanTitle} (${cleanTitle.length} симв.)`);
// Получаем максимальный item_id из таблицы
const maxIdResult = await pool.request()
.query(`
SELECT ISNULL(MAX(item_id), 96006) as max_id
FROM AionWorld_110.dbo.user_mail
`);
let maxId = maxIdResult.recordset[0]?.max_id || 96006;
// Если максимальный ID меньше 96007, начинаем с 96007
if (maxId < 96007) {
maxId = 96006;
}
// Следующий ID = максимальный + 1 (ЧИСЛОВОЕ СЛОЖЕНИЕ, а не конкатенация!)
let nextItemId = Number(maxId) + 1;
console.log(` → Максимальный item_id в БД: ${maxId}`);
console.log(` → Следующий item_id: ${nextItemId}`);
console.log(` → item_nameid (ID предмета из рулетки): ${itemId}`);
// Обрезаем содержимое до 1000 символов
let cleanContent = content || '';
if (cleanContent.length > 1000) {
cleanContent = cleanContent.substring(0, 997) + '...';
}
// ИСПОЛЬЗУЕМ ДАННЫЕ ИЗ ЗАПРОСА (fromId, fromName, title)
// item_id = уникальный ID (96007, 96008...)
// item_nameid = ID предмета из рулетки
// item_tid = 0
const result = await pool.request()
.input('toId', sql.Int, toId)
.input('toName', sql.NVarChar, toName)
.input('fromId', sql.Int, fromId || 0)
.input('fromName', sql.NVarChar, fromName || '$$ABYSS_REWARD_MAIL')
.input('title', sql.NVarChar, cleanTitle)
.input('content', sql.NVarChar, cleanContent)
.input('itemId', sql.BigInt, nextItemId) // Уникальный ID письма
.input('itemNameid', sql.Int, itemId || 0) // ID предмета из рулетки
.input('itemAmount', sql.BigInt, itemAmount || 0)
.input('money', sql.BigInt, money || 0)
.input('state', sql.TinyInt, 0)
.input('arriveTime', sql.Int, now)
.input('expressMail', sql.TinyInt, expressMail ? 1 : 0)
.input('itemTid', sql.BigInt, 0) // Всегда 0
.query(`
INSERT INTO AionWorld_110.dbo.user_mail (
to_id, to_name, from_id, from_name,
title, content, item_id, item_nameid, item_amount,
money, state, arrive_time, express_mail, item_tid
) VALUES (
@toId, @toName, @fromId, @fromName,
@title, @content, @itemId, @itemNameid, @itemAmount,
Money, @state, @arriveTime, @expressMail, @itemTid
);
SELECT SCOPE_IDENTITY() as id;
`);
const mailId = result.recordset[0]?.id || null;
console.log(`
Письмо отправлено! ID: ${mailId}`);
console.log(` → Получатель: ${toName} получит награду на почту`);
console.log(` → from_name: ${fromName}`);
console.log(` → title: ${cleanTitle}`);
console.log(` → item_id (уникальный): ${nextItemId}`);
console.log(` → item_nameid (предмет): ${itemId}`);
console.log(` → express_mail: ${expressMail}`);
return res.json({
success: true,
message: 'Письмо успешно отправлено',
mailId: mailId,
itemId: nextItemId
});
} catch (error) {
console.error('
Ошибка отправки почты:', error);
return res.status(500).json({
success: false,
error: error.message || 'Внутренняя ошибка сервера'
});
}
});
And here is the API from the file. Roulette.jsx
const sendMail = async (toName, toId, title, content, itemId, itemAmount, money = 0) => {
try {
const token = localStorage.getItem('authToken');
const response = await fetch('/api/mail/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
fromName: 'Webshop',
fromId: 1072,
toName: toName,
toId: toId,
title: title,
content: content,
itemId: itemId,
itemAmount: itemAmount,
money: money,
expressMail: 1
})
});
const data = await response.json();
return data;
} catch (error) {
console.error('
Ошибка отправки почты:', error);
return { success: false, error: error.message };
}
};
In the AionWorld_110 database, the `dbo.user_mail` table has these values at the end.
id to_id to_name from_id from_name title content item_id item_nameid item_amount money state arrive_time express_mail item_tid
3791 1002 Sorgravity 1072 Webshop Выигрыш: Большой су. Поздравляем! Вы выиграли Большой сундук (1 Шт) в рулетке. Награда отправлена на почту. 96007 188053101 5 0 0 1782393408 1 0
3792 1002 Sorgravity 1072 Webshop Выигрыш: Свиток тел. Поздравляем! Вы выиграли Свиток телепорта (10 Шт) в рулетке. Награда отправлена на почту. 96008 164002238 10 0 0 1782393431 1 0
And there is express mail in the game, but it doesn’t open. I go to the mailbox and there are letters there, but they are not clickable. I also forcefully read the letters, and then I can open them, but there is nothing there.
And here is the backend API for email.
app.post('/api/mail/send', checkSession, async (req, res) => {
try {
const {
fromName,
fromId,
toName,
toId,
title,
content,
itemId,
itemAmount,
money = 0,
expressMail = 1
} = req.body;
console.log(`\n
console.log(` → От: ${fromName} (ID: ${fromId})`);
console.log(` → Кому: ${toName} (ID: ${toId})`);
console.log(` → Тема: ${title}`);
console.log(` → Предмет ID: ${itemId}, Кол-во: ${itemAmount}`);
console.log(` → Деньги: ${money}`);
console.log(` → Экспресс: ${expressMail ? 'Да' : 'Нет'}`);
if (!toName || !toId) {
return res.status(400).json({
success: false,
error: 'Не указан получатель'
});
}
if (!title) {
return res.status(400).json({
success: false,
error: 'Не указана тема письма'
});
}
const pool = await getPool();
// unix timestamp
const now = Math.floor(Date.now() / 1000);
let cleanTitle = title || 'Рулетка';
if (cleanTitle.length > 20) {
cleanTitle = cleanTitle.substring(0, 20);
}
console.log(` → Очищенный заголовок: ${cleanTitle} (${cleanTitle.length} симв.)`);
// Получаем максимальный item_id из таблицы
const maxIdResult = await pool.request()
.query(`
SELECT ISNULL(MAX(item_id), 96006) as max_id
FROM AionWorld_110.dbo.user_mail
`);
let maxId = maxIdResult.recordset[0]?.max_id || 96006;
// Если максимальный ID меньше 96007, начинаем с 96007
if (maxId < 96007) {
maxId = 96006;
}
// Следующий ID = максимальный + 1 (ЧИСЛОВОЕ СЛОЖЕНИЕ, а не конкатенация!)
let nextItemId = Number(maxId) + 1;
console.log(` → Максимальный item_id в БД: ${maxId}`);
console.log(` → Следующий item_id: ${nextItemId}`);
console.log(` → item_nameid (ID предмета из рулетки): ${itemId}`);
// Обрезаем содержимое до 1000 символов
let cleanContent = content || '';
if (cleanContent.length > 1000) {
cleanContent = cleanContent.substring(0, 997) + '...';
}
// ИСПОЛЬЗУЕМ ДАННЫЕ ИЗ ЗАПРОСА (fromId, fromName, title)
// item_id = уникальный ID (96007, 96008...)
// item_nameid = ID предмета из рулетки
// item_tid = 0
const result = await pool.request()
.input('toId', sql.Int, toId)
.input('toName', sql.NVarChar, toName)
.input('fromId', sql.Int, fromId || 0)
.input('fromName', sql.NVarChar, fromName || '$$ABYSS_REWARD_MAIL')
.input('title', sql.NVarChar, cleanTitle)
.input('content', sql.NVarChar, cleanContent)
.input('itemId', sql.BigInt, nextItemId) // Уникальный ID письма
.input('itemNameid', sql.Int, itemId || 0) // ID предмета из рулетки
.input('itemAmount', sql.BigInt, itemAmount || 0)
.input('money', sql.BigInt, money || 0)
.input('state', sql.TinyInt, 0)
.input('arriveTime', sql.Int, now)
.input('expressMail', sql.TinyInt, expressMail ? 1 : 0)
.input('itemTid', sql.BigInt, 0) // Всегда 0
.query(`
INSERT INTO AionWorld_110.dbo.user_mail (
to_id, to_name, from_id, from_name,
title, content, item_id, item_nameid, item_amount,
money, state, arrive_time, express_mail, item_tid
) VALUES (
@toId, @toName, @fromId, @fromName,
@title, @content, @itemId, @itemNameid, @itemAmount,
Money, @state, @arriveTime, @expressMail, @itemTid
);
SELECT SCOPE_IDENTITY() as id;
`);
const mailId = result.recordset[0]?.id || null;
console.log(`
console.log(` → Получатель: ${toName} получит награду на почту`);
console.log(` → from_name: ${fromName}`);
console.log(` → title: ${cleanTitle}`);
console.log(` → item_id (уникальный): ${nextItemId}`);
console.log(` → item_nameid (предмет): ${itemId}`);
console.log(` → express_mail: ${expressMail}`);
return res.json({
success: true,
message: 'Письмо успешно отправлено',
mailId: mailId,
itemId: nextItemId
});
} catch (error) {
console.error('
return res.status(500).json({
success: false,
error: error.message || 'Внутренняя ошибка сервера'
});
}
});
And here is the API from the file. Roulette.jsx
const sendMail = async (toName, toId, title, content, itemId, itemAmount, money = 0) => {
try {
const token = localStorage.getItem('authToken');
const response = await fetch('/api/mail/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
fromName: 'Webshop',
fromId: 1072,
toName: toName,
toId: toId,
title: title,
content: content,
itemId: itemId,
itemAmount: itemAmount,
money: money,
expressMail: 1
})
});
const data = await response.json();
return data;
} catch (error) {
console.error('
return { success: false, error: error.message };
}
};

