fix: error vehiculo robo
This commit is contained in:
parent
1784e3065b
commit
ca5b1ad8ed
@ -12,7 +12,6 @@
|
||||
use App\Models\Owner;
|
||||
use App\Models\File;
|
||||
use App\Models\Tag;
|
||||
use App\Models\Error;
|
||||
use App\Models\VehicleTagLog;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@ -99,7 +98,7 @@ public function vehicleInscription(VehicleStoreRequest $request)
|
||||
$niv = $vehicleData['niv'];
|
||||
|
||||
// Verificar robo (API Repuve Nacional)
|
||||
$resultadoRobo = $this->checkIfStolen($placa, $niv);
|
||||
$resultadoRobo = $this->checkIfStolen($niv, $placa);
|
||||
$isStolen = $resultadoRobo;
|
||||
|
||||
if ($isStolen) {
|
||||
@ -282,7 +281,7 @@ public function vehicleInscription(VehicleStoreRequest $request)
|
||||
}
|
||||
}
|
||||
|
||||
private function checkIfStolen(?string $placa = null, ?string $niv = null)
|
||||
private function checkIfStolen(?string $niv = null, ?string $placa = null)
|
||||
{
|
||||
return $this->repuveService->verificarRobo($niv, $placa);
|
||||
}
|
||||
|
||||
@ -167,14 +167,35 @@ private function parseVehicleResponse(string $soapResponse, string $niv)
|
||||
public function verificarRobo(?string $niv = null, ?string $placa = null): array
|
||||
{
|
||||
try {
|
||||
|
||||
if (empty($niv) && empty($placa)) {
|
||||
logger()->warning('REPUVE verificarRobo: No se proporcionó NIV ni PLACA');
|
||||
return [
|
||||
'is_robado' => false,
|
||||
'has_error' => true,
|
||||
'error_message' => 'Debe proporcionar al menos NIV o PLACA para verificar robo',
|
||||
];
|
||||
}
|
||||
|
||||
$url = $this->baseUrl . $this->roboEndpoint;
|
||||
|
||||
$campo1 = $niv ?? '';
|
||||
$campo2 = '';
|
||||
$campo3 = $placa ?? '';
|
||||
$campo4_8 = str_repeat('|', 5);
|
||||
// Construir arg2 según los parámetros enviados
|
||||
if (!empty($niv) && !empty($placa)) {
|
||||
$arg2 = $niv . '|' . $placa . str_repeat('|', 5);
|
||||
} elseif (!empty($niv)) {
|
||||
$arg2 = $niv . str_repeat('|', 7);
|
||||
} else {
|
||||
$arg2 = '||' . $placa . str_repeat('|', 5);
|
||||
}
|
||||
|
||||
logger()->info('REPUVE verificarRobo: Cadena construida', [
|
||||
'niv' => $niv,
|
||||
'placa' => $placa,
|
||||
'arg2' => $arg2,
|
||||
'total_pipes' => substr_count($arg2, '|'),
|
||||
'ejemplo_visual' => str_replace('|', ' | ', $arg2),
|
||||
]);
|
||||
|
||||
$arg2 = $campo1 . '|' . $campo2 . '|' . $campo3 . '|' . $campo4_8;
|
||||
|
||||
$soapBody = <<<XML
|
||||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://consultaRpv.org/wsdl">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user