fix: prevent duplicate homepage financing records and update API and login configuration
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\PembiayaanService;
|
||||
use App\Services\CustomerInfoService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
@@ -31,16 +31,7 @@ class HomeController extends Controller
|
||||
$homeUrl = route('home');
|
||||
$authUser = Auth::user();
|
||||
|
||||
$responses = Http::pool(fn ($pool) => [
|
||||
$pool->withOptions(['verify' => config('app.api_verify')])
|
||||
->get(config('api.url') . '/portal/customer/info', ['ic' => $authUser['icno']]),
|
||||
|
||||
$pool->withOptions(['verify' => config('app.api_verify')])
|
||||
->get(config('api.url_koop') . '/portal/customer/info', ['ic' => $authUser['icno']]),
|
||||
]);
|
||||
|
||||
$customer_pkb = $responses[0]->json();
|
||||
$customer_koop = $responses[1]->json();
|
||||
[$customer_pkb, $customer_koop] = CustomerInfoService::get($authUser['icno']);
|
||||
|
||||
$customerLelong = $this->getCustomerInfoLelong($authUser['icno']);
|
||||
|
||||
@@ -82,16 +73,7 @@ class HomeController extends Controller
|
||||
|
||||
$authUser = Auth::user();
|
||||
|
||||
$responses = Http::pool(fn ($pool) => [
|
||||
$pool->withOptions(['verify' => config('app.api_verify')])
|
||||
->get(config('api.url') . '/portal/customer/info', ['ic' => $authUser['icno']]),
|
||||
|
||||
$pool->withOptions(['verify' => config('app.api_verify')])
|
||||
->get(config('api.url_koop') . '/portal/customer/info', ['ic' => $authUser['icno']]),
|
||||
]);
|
||||
|
||||
$customer_pkb = $responses[0]->json();
|
||||
$customer_koop = $responses[1]->json();
|
||||
[$customer_pkb, $customer_koop] = CustomerInfoService::get($authUser['icno']);
|
||||
|
||||
|
||||
$customerLelong = $this->getCustomerInfoLelong($authUser['icno']);
|
||||
@@ -124,13 +106,7 @@ class HomeController extends Controller
|
||||
}
|
||||
|
||||
private function getCustomerInfoLelong($icno){
|
||||
$customerLelong = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get(config('api.url') . '/portal/customer/info/lelong', ['ic' => $icno])
|
||||
->json();
|
||||
|
||||
$customerLelongKoop = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get(config('api.url_koop') . '/portal/customer/info/lelong', ['ic' => $icno])
|
||||
->json();
|
||||
[$customerLelong, $customerLelongKoop] = CustomerInfoService::get($icno, '/portal/customer/info/lelong');
|
||||
|
||||
// Extract data with null safety
|
||||
$bakiLelong = isset($customerLelong['success']) && $customerLelong['success']
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\CompanyStatus;
|
||||
use App\Services\CustomerInfoService;
|
||||
use App\Models\LelongBid;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@@ -31,8 +32,7 @@ class InformationController extends Controller
|
||||
{
|
||||
$auth_user = Auth::User();
|
||||
|
||||
$customer_pkb = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/portal/customer/info',['ic' => $auth_user['icno']])->json();
|
||||
$customer_koop = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url_koop') .'/portal/customer/info',['ic' => $auth_user['icno']])->json();
|
||||
[$customer_pkb, $customer_koop] = CustomerInfoService::get($auth_user['icno']);
|
||||
|
||||
$pembiayaansemasa = [];
|
||||
if(isset($customer_pkb['gadai'])){
|
||||
@@ -98,8 +98,7 @@ class InformationController extends Controller
|
||||
{
|
||||
$auth_user = Auth::User();
|
||||
|
||||
$customer_pkb = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/portal/customer/info',['ic' => $auth_user['icno']])->json();
|
||||
$customer_koop = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url_koop') .'/portal/customer/info',['ic' => $auth_user['icno']])->json();
|
||||
[$customer_pkb, $customer_koop] = CustomerInfoService::get($auth_user['icno']);
|
||||
|
||||
$melebihi6bulan = [];
|
||||
|
||||
@@ -138,8 +137,7 @@ class InformationController extends Controller
|
||||
{
|
||||
$auth_user = Auth::User();
|
||||
|
||||
$customer_pkb = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/portal/customer/info',['ic' => $auth_user['icno']])->json();
|
||||
$customer_koop = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url_koop') .'/portal/customer/info',['ic' => $auth_user['icno']])->json();
|
||||
[$customer_pkb, $customer_koop] = CustomerInfoService::get($auth_user['icno']);
|
||||
|
||||
$lelong = [];
|
||||
if(isset($customer_pkb['lelong'])){
|
||||
|
||||
@@ -133,7 +133,7 @@ class TacController extends Controller
|
||||
|
||||
|
||||
$mobileno = '6' . $customer['telefon'];
|
||||
$messages = 'AR-RAHN PKB PORTAL : TAC: ' . $tac_token . ' ' . $currentDateTime . '. HUBUNGI AR-RAHN CARELINE CENTRE';
|
||||
$messages = 'E-RAHN CLICK : TAC: ' . $tac_token . ' ' . $currentDateTime . '. HUBUNGI AR-RAHN CARELINE CENTRE';
|
||||
|
||||
$status = Http::get('http://gateway.onewaysms.com.my:10001/api.aspx',[
|
||||
'apiusername' => 'APIUK330HDAFO',
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class CustomerInfoService
|
||||
{
|
||||
public static function get($icno, $endpoint = '/portal/customer/info')
|
||||
{
|
||||
$pkbUrl = rtrim(config('api.url'), '/');
|
||||
$koopUrl = rtrim(config('api.url_koop'), '/');
|
||||
|
||||
// A shared API must only contribute once to the combined customer data.
|
||||
$responses = Http::pool(function ($pool) use ($pkbUrl, $koopUrl, $icno, $endpoint) {
|
||||
$requests = [
|
||||
$pool->withOptions(['verify' => config('app.api_verify')])
|
||||
->get($pkbUrl . $endpoint, ['ic' => $icno]),
|
||||
];
|
||||
|
||||
if ($koopUrl !== $pkbUrl) {
|
||||
$requests[] = $pool->withOptions(['verify' => config('app.api_verify')])
|
||||
->get($koopUrl . $endpoint, ['ic' => $icno]);
|
||||
}
|
||||
|
||||
return $requests;
|
||||
});
|
||||
|
||||
return [$responses[0]->json(), isset($responses[1]) ? $responses[1]->json() : []];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user