Experiment/merge annur (#15)
Build Docker Image / build-backend (push) Successful in 23s

Co-authored-by: ISMAIL MASSERAN <topaz@Mac.dlinkrouter.local>
Reviewed-on: #15
This commit was merged in pull request #15.
This commit is contained in:
2026-09-20 12:49:53 +08:00
parent 79bc41d211
commit 9fa0172017
27 changed files with 930 additions and 298 deletions
+33 -16
View File
@@ -11,6 +11,7 @@ use App\Negeri;
use App\Lelong;
use App\Transaction;
use App\Cawangan;
use App\Feature;
use App\Gadai;
use App\TuntutBaki;
use App\WTD;
@@ -26,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;
@@ -604,16 +606,7 @@ class LelongController extends Controller
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
if($cawangan['tagarrahnbid'] == 1){
if(env('APP_ENV') != 'production'){
$link = 'https://adminbid-kopkb.erahn.com.my/api/portalApi';
}else{
$link = 'https://adminbid-kopkb.erahn.com.my/api/portalApi';
}
$lelong = Http::withOptions(['verify' => true])->get($link,[
'norujukan' => $request->norujukan
])->json();
$lelong = ($lelong != null) ? $lelong['lelong'] : [];
$lelong = $this->fetchPortalLelong($request->kodcaw, $request->norujukan);
if( $lelong == null )
{
$lelong = Lelong::on($cawangan['mysql'])
@@ -656,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(config('app_parameter.api_arrahnbid').'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'])
@@ -729,8 +719,8 @@ class LelongController extends Controller
if($cawangan['tagarrahnbid'] == 1)
{
$lelong = Http::withOptions(['verify' => true])->get(config('app_parameter.api_arrahnbid').'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();
}
@@ -2009,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;
}
}
}