TopSapp: fix API show blocked services from client
Signed-off-by: Rodrigo Bertoldo de Sousa Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
1 parent
b5711753c1
commit
cfbc730e70
1 file changed
+27
-5
+27
-5
@@ -3097,7 +3097,19 @@ Digite /help para ver todos os comandos disponíveis!
|
||||
return;
|
||||
}
|
||||
|
||||
const faturas = resultado.data?.faturas || resultado.data || [];
|
||||
// Corrigir acesso aos dados: resultado.data é um objeto { resultado: true, dados: [...] }
|
||||
const faturas = resultado.data?.dados || resultado.data?.faturas || resultado.faturas || [];
|
||||
|
||||
// Verificar se é realmente um array
|
||||
if (!Array.isArray(faturas)) {
|
||||
console.error('❌ Faturas não é um array:', typeof faturas, faturas);
|
||||
await this.bot.sendMessage(chatId,
|
||||
`❌ **Erro ao processar faturas**\n\n` +
|
||||
`⚠️ Formato de resposta inválido`,
|
||||
{ parse_mode: 'Markdown' }
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (faturas.length === 0) {
|
||||
await this.bot.sendMessage(chatId,
|
||||
@@ -3113,7 +3125,12 @@ Digite /help para ver todos os comandos disponíveis!
|
||||
message += `📊 **Total de faturas**: ${faturas.length}\n\n`;
|
||||
|
||||
faturas.forEach((fatura, index) => {
|
||||
message += `${index + 1}. 📋 **Fatura #${fatura.id || fatura.numero}**\n`;
|
||||
// Verificar se está paga
|
||||
const isPago = fatura.pago && fatura.pago.toUpperCase() === 'SIM';
|
||||
const statusEmoji = isPago ? '✅' : '🔴';
|
||||
const statusTexto = isPago ? 'PAGO' : 'EM ABERTO';
|
||||
|
||||
message += `${index + 1}. ${statusEmoji} **Fatura #${fatura.id || fatura.numero_fatura}**\n`;
|
||||
|
||||
if (fatura.valor) {
|
||||
const valor = parseFloat(fatura.valor);
|
||||
@@ -3124,9 +3141,14 @@ Digite /help para ver todos os comandos disponíveis!
|
||||
message += ` 📅 Vencimento: ${fatura.vencimento}\n`;
|
||||
}
|
||||
|
||||
if (fatura.status) {
|
||||
const statusEmoji = fatura.status === 'aberto' || fatura.status === 'pendente' ? '🔴' : '✅';
|
||||
message += ` ${statusEmoji} Status: ${fatura.status}\n`;
|
||||
message += ` 📊 Status: ${statusTexto}\n`;
|
||||
|
||||
if (fatura.historico) {
|
||||
message += ` 📝 Descrição: ${fatura.historico}\n`;
|
||||
}
|
||||
|
||||
if (isPago && fatura.datapagto) {
|
||||
message += ` 💳 Pago em: ${fatura.datapagto}\n`;
|
||||
}
|
||||
|
||||
message += `\n`;
|
||||
|
||||
Reference in new issue
Block a user