fix: verificar solicitud de recarga antes de llamar Gemini Vision e IMAP
Sin solicitud activa el bot mostraba el análisis completo (Gemini + IMAP) antes de rechazar. Ahora se valida primero: si no hay solicitud pendiente, se rechaza de inmediato sin gastar API. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
a7d7c32350
commit
437adc531f
@@ -475,6 +475,16 @@ class PublicChat extends Component
|
||||
$this->procesandoImagen = true;
|
||||
|
||||
try {
|
||||
// Verificar solicitud activa ANTES de cualquier llamada de API
|
||||
$solicitud = $this->userId ? \App\Models\SolicitudRecarga::pendiente($this->userId) : null;
|
||||
if (! $solicitud) {
|
||||
$this->procesandoImagen = false;
|
||||
$this->fotoComprobante = null;
|
||||
$this->guardarMensajeBot($this->convId, "⚠️ No tienes ninguna solicitud de recarga activa. Primero inicia el proceso de recarga desde el menú.");
|
||||
$this->cargarMensajes();
|
||||
return;
|
||||
}
|
||||
|
||||
$path = $this->fotoComprobante->store('comprobantes', 'public');
|
||||
$url = asset('storage/' . $path);
|
||||
|
||||
@@ -500,21 +510,6 @@ class PublicChat extends Component
|
||||
return;
|
||||
}
|
||||
|
||||
$resultado = app(\App\Services\PagoValidadorService::class)->validar(
|
||||
$datosPago, $this->userId, $this->nombreUsuario, 'web'
|
||||
);
|
||||
|
||||
$monto = (int) ($datosPago['valor'] ?? 0);
|
||||
$botones = [];
|
||||
|
||||
// Verificar solicitud activa
|
||||
$solicitud = $this->userId ? \App\Models\SolicitudRecarga::pendiente($this->userId) : null;
|
||||
if (! $solicitud) {
|
||||
$this->guardarMensajeBot($this->convId, "No tienes ninguna solicitud de recarga activa. Inicia una recarga desde el menu para poder enviar el comprobante.");
|
||||
$this->cargarMensajes();
|
||||
return;
|
||||
}
|
||||
|
||||
// Verificar que el monto coincida con la solicitud
|
||||
$valorIA = (int) ($datosPago['valor'] ?? 0);
|
||||
if ($valorIA !== $solicitud->monto) {
|
||||
@@ -523,6 +518,10 @@ class PublicChat extends Component
|
||||
return;
|
||||
}
|
||||
|
||||
$resultado = app(\App\Services\PagoValidadorService::class)->validar(
|
||||
$datosPago, $this->userId, $this->nombreUsuario, 'web'
|
||||
);
|
||||
|
||||
$motivo = $resultado['motivo'] ?? '';
|
||||
|
||||
if ($resultado['estado'] === 'confirmado') {
|
||||
|
||||
Reference in New Issue
Block a user