diff --git a/app/Http/Controllers/GadaiController.php b/app/Http/Controllers/GadaiController.php index 34195ee..0c8006f 100644 --- a/app/Http/Controllers/GadaiController.php +++ b/app/Http/Controllers/GadaiController.php @@ -629,8 +629,7 @@ class GadaiController extends Controller "alamat1" => optional($customer)->alamat1, "t_gadai" => $g->t_gadai, "norujukan" => $g->norujukan, - "cara_terima" => $g->cara_terima, - "norujukan"=> $g->norujukan, + "cara_terima" => strtoupper((string) ($g->cara_terima ?: 'TUNAI')), "nokp"=> $g->nokp, "semakbarcode"=> $g->semakbarcode, diff --git a/app/Http/Controllers/LelongController.php b/app/Http/Controllers/LelongController.php index e2dbadb..e32dbfa 100644 --- a/app/Http/Controllers/LelongController.php +++ b/app/Http/Controllers/LelongController.php @@ -27,6 +27,7 @@ use App\Tunai; use App\Audit; use App\GlDetail; use App\Pembeli; +use Illuminate\Http\Client\ConnectionException; use Illuminate\Http\Request; use Illuminate\Support\Facades\Http; use App\Services\RingkasanHarianServices; @@ -605,10 +606,7 @@ class LelongController extends Controller $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first(); if($cawangan['tagarrahnbid'] == 1){ - $lelong = Http::withOptions(['verify' => true])->get(Feature::arrahnbidUrl($request->kodcaw).'portalApi',[ - 'norujukan' => $request->norujukan - ])->json(); - $lelong = ($lelong != null) ? $lelong['lelong'] : []; + $lelong = $this->fetchPortalLelong($request->kodcaw, $request->norujukan); if( $lelong == null ) { $lelong = Lelong::on($cawangan['mysql']) @@ -651,10 +649,7 @@ class LelongController extends Controller $cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $request->kodcaw)->first(); if ($cawangan['tagarrahnbid'] == 0){ - $lelong = Http::withOptions(['verify' => true])->get(Feature::arrahnbidUrl($request->kodcaw).'portalApi',[ - 'norujukan' => $request->norujukan - ])->json(); - $lelong = ($lelong != null) ? $lelong['lelong'] : []; + $lelong = $this->fetchPortalLelong($request->kodcaw, $request->norujukan); if( $lelong == null ) { $lelong = Lelong::on($cawangan['mysql']) @@ -724,8 +719,8 @@ class LelongController extends Controller if($cawangan['tagarrahnbid'] == 1) { - $lelong = Http::withOptions(['verify' => true])->get(Feature::arrahnbidUrl($request->kodcaw).'portalApi',['norujukan' => $request->norujukan])->json(); - $lelong = ($lelong != null) ? $lelong['lelong'] : []; + $lelong = $this->fetchPortalLelong($request->kodcaw, $request->norujukan); + $lelong = ($lelong != null) ? $lelong : []; }else{ $lelong = Lelong::on($cawangan['mysql'])->where([['norujukan',$request->norujukan]])->first(); } @@ -2004,4 +1999,31 @@ class LelongController extends Controller ], 200); } + /** + * Fetch lelong status from arrahnbid. Returns null when the portal is + * unreachable so callers can fall back to the local lelong table. + */ + private function fetchPortalLelong($kodcaw, $norujukan) + { + try { + $payload = Http::withOptions(['verify' => true]) + ->timeout(5) + ->get(Feature::arrahnbidUrl($kodcaw).'portalApi', [ + 'norujukan' => $norujukan, + ]) + ->json(); + + return ($payload != null) ? ($payload['lelong'] ?? null) : null; + } catch (ConnectionException $e) { + Log::warning('Arrahnbid portal unreachable; falling back to local lelong.', [ + 'kodcaw' => $kodcaw, + 'norujukan' => $norujukan, + 'url' => Feature::arrahnbidUrl($kodcaw).'portalApi', + 'error' => $e->getMessage(), + ]); + + return null; + } + } + }