This commit is contained in:
2025-05-08 20:27:30 +05:00
parent f51de7b2aa
commit 179c7e66e2
2 changed files with 12 additions and 38 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Modules\LoanRemainingOrder\Actions\FetchRemainingLoanFromBilling;
use App\Repos\System\Settings\Legal\PassportRepo; use App\Repos\System\Settings\Legal\PassportRepo;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@@ -22,43 +23,17 @@ class FetchLoanRemainingController extends Controller
'account_number' => ['required', 'string', 'max:255'], 'account_number' => ['required', 'string', 'max:255'],
]); ]);
$passport_serie = $request->passport_serie; $response = FetchRemainingLoanFromBilling::make()->handle(
$passport_id = $request->passport_id; passport_serie: $request->passport_serie,
$account_number = $request->account_number; passport_id: $request->passport_id,
account_number: $request->account_number,
);
$curl = curl_init(); info([
'response' => $response,
curl_setopt_array($curl, [ 'type' => gettype($response)
CURLOPT_URL => 'http://10.3.158.102:9999/api/loaninfo',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => sprintf('
{
"idSeria": "%s",
"idNo": "%s",
"accountCode": "%s"
}
',
$passport_serie,
$passport_id,
$account_number,
),
CURLOPT_HTTPHEADER => [
'Authorization: Basic dGJ1c2VyOlFBWndzeDEyMw==',
'Content-Type: application/json',
],
]); ]);
/** @var array<string, int|bool|null|string>|bool */
$response = curl_exec($curl);
curl_close($curl);
return response()->json($response); return response()->json($response);
} }
} }

View File

@@ -15,9 +15,9 @@ class FetchRemainingLoanFromBilling
* @param string $passport_id * @param string $passport_id
* @param string $account_number * @param string $account_number
* *
* @return array<string, int|bool|null|string> * @return mixed
*/ */
public function handle(string $passport_serie, int|string $passport_id, int|string $account_number): array public function handle(string $passport_serie, int|string $passport_id, int|string $account_number): mixed
{ {
if (app()->isLocal()) { if (app()->isLocal()) {
return $this->sampleResponse(); return $this->sampleResponse();
@@ -51,12 +51,11 @@ class FetchRemainingLoanFromBilling
], ],
]); ]);
/** @var array<string, int|bool|null|string>|bool */
$response = curl_exec($curl); $response = curl_exec($curl);
curl_close($curl); curl_close($curl);
return is_array($response) ? $response : []; return $response;
} }
/** /**