check first before check in trolley and added cron for deletecarts hourly and added updateunsuccess split 2 parts and logging change to daily

This commit is contained in:
Hafifie PKB
2025-01-26 10:40:10 +08:00
parent d8b984856d
commit 2bcf74e8dc
4 changed files with 129 additions and 11 deletions
@@ -33,6 +33,16 @@ class BayaranController extends Controller
$list_pkb = json_decode($exist_carts['list_pkb'],true);
$list_koop = json_decode($exist_carts['list_koop'],true);
if($this->checkSAG($list_pkb, 'PKB')){
$this->removeCartsInternal();
return redirect()->route('buffer');
}
if($this->checkSAG($list_koop, 'KOPKB')){
$this->removeCartsInternal();
return redirect()->route('buffer');
}
if($exist_carts['status_pkb'] == 'PENDING') $list_pkb = ($list_pkb) ? $this->setUpahTawarruq($list_pkb) : []; else $list_pkb = [];
if($exist_carts['status_koop'] == 'PENDING') $list_koop = ($list_koop) ? $this->setUpahTawarruq($list_koop) : []; else $list_koop = [];
@@ -551,4 +561,49 @@ class BayaranController extends Controller
: Http::arrahn_koop();
}
private function checkSAG($list_sag, $company)
{
$CallableHttp = $company == 'PKB'
? Http::arrahn()
: Http::arrahn_koop();
foreach ($list_sag as $x) {
$array_lelong = Http::withOptions(['verify' => config('app.api_verify')])
->get(config('api-lelong.url') . '/api/portalApi', ['norujukan' => $x['norujukan']])
->json();
$array_gadai = $CallableHttp->get('/api/gadai/norujukan/' . $x['norujukan'])->json();
$isdisabled = $CallableHttp->get('/portal/searchsagonline/', ['norujukan' => $x['norujukan']])->json();
if ($array_lelong['lelong'] != null) {
return true;
}
if ($isdisabled) {
return true;
}
if (sizeof($array_gadai) != 0) {
$array_gadai = $array_gadai[0][0];
if ($array_gadai['sttebus'] == 'T' || $array_gadai['sttebus'] == 'L') {
return true;
}
}
}
return false;
}
private function removeCartsInternal(){
$exist_carts = PersonalCarts::where('ic_no', Auth::user()->icno)
->where('user_id', Auth::user()->id)
->first();
if ($exist_carts) {
$exist_carts->delete();
}
return $exist_carts;
}
}