update untuk paparan keuntungan arcc
This commit is contained in:
@@ -841,50 +841,83 @@ class CallCenterController extends Controller
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
|
||||
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/norujukan/'. $request->norujukan)->json();
|
||||
$norujukan = $request->norujukan;
|
||||
$gadai = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get(config('api.url') . '/api/gadai/norujukan/' . $norujukan)
|
||||
->json();
|
||||
|
||||
if(sizeof($gadai) > 0)
|
||||
{
|
||||
$history = $gadai[0][0]['historygadaian'];
|
||||
$dahtebus = $gadai[0][0]['sttebus'];
|
||||
$norujukan = $gadai[0][0]['norujukan'];
|
||||
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
$arrayhist = [];
|
||||
|
||||
while($history != "0" && $history != '' || $dahtebus == 'T')
|
||||
{
|
||||
if($history != "0" && $history != '')
|
||||
{
|
||||
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/norujukan/'. $history)->json();
|
||||
$tebus = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/listpenebusanhistory/'. $gadai[0][0]['kodcaw'],[
|
||||
"norujukan" => $history
|
||||
])->json();
|
||||
if (sizeof($gadai) > 0) {
|
||||
$history = $gadai[0][0]['historygadaian'];
|
||||
$dahtebus = $gadai[0][0]['sttebus'];
|
||||
$kodcaw = $gadai[0][0]['kodcaw'];
|
||||
// Kalau belum ada history, ambil rekod asal sahaja
|
||||
if ($dahtebus == 'T') {
|
||||
|
||||
$tebusList = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get(config('api.url') . '/api/listpenebusanhistory/' . $kodcaw, [
|
||||
'norujukan' => $norujukan
|
||||
])
|
||||
->json();
|
||||
|
||||
if(sizeof($gadai) > 0)
|
||||
{
|
||||
if($history == $gadai[0][0]['historygadaian'])
|
||||
$history = 0;
|
||||
else{
|
||||
array_push($arrayhist,["tagbaru" => ((isset($gadai[0][0]['tagbaru'])) ? $gadai[0][0]['tagbaru'] : 0),"hargajualan" => ((isset($gadai[0][0]['hargajualan'])) ? $gadai[0][0]['hargajualan'] : ''), "pinjaman" => ((isset($tebus[0])) ? $tebus[0]['pinjaman'] : 0),"norujukan" => $history,"jenistebus" => ((isset($tebus[0])) ? $tebus[0]['jenistebus'] : 0),"jbg" => ((isset($tebus[0])) ? $tebus[0]['jbg'] : 0),"t_tebus" => ((isset($tebus[0])) ? $tebus[0]['t_tebus'] : 0)]);
|
||||
$history = $gadai[0][0]['historygadaian'];
|
||||
$tebus = collect($tebusList)->firstWhere('norujukan', $norujukan);
|
||||
|
||||
$arrayhist[] = [
|
||||
"tagbaru" => $gadai[0][0]['tagbaru'] ?? 0,
|
||||
"hargajualan" => $gadai[0][0]['hargajualan'] ?? '',
|
||||
"pinjaman" => $tebus['pinjaman'] ?? 0,
|
||||
"norujukan" => $norujukan,
|
||||
"jenistebus" => $tebus['jenistebus'] ?? 0,
|
||||
"jbg" => $tebus['jbg'] ?? 0,
|
||||
"t_tebus" => $tebus['t_tebus'] ?? 0,
|
||||
"bayaran_keuntungan" => $tebus['bayaran_keuntungan'] ?? 0,
|
||||
"bayaran_pembiayaan" => $tebus['bayaran_pembiayaan'] ?? 0,
|
||||
"duit_masuk" => $tebus['duit_masuk'] ?? 0,
|
||||
"trans_type" => $tebus['trans_type'] ?? 0,
|
||||
];
|
||||
} else {
|
||||
// Loop ke belakang (rekod lepas-lepas)
|
||||
while ($history != "0" && $history != '') {
|
||||
$prevGadai = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get(config('api.url') . '/api/gadai/norujukan/' . $history)
|
||||
->json();
|
||||
|
||||
$prevKodcaw = $prevGadai[0][0]['kodcaw'] ?? null;
|
||||
|
||||
if (!$prevKodcaw) break;
|
||||
|
||||
$tebusList = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get(config('api.url') . '/api/listpenebusanhistory/' . $prevKodcaw, [
|
||||
'norujukan' => $history
|
||||
])
|
||||
->json();
|
||||
|
||||
$tebus = collect($tebusList)->firstWhere('norujukan', $history);
|
||||
|
||||
$arrayhist[] = [
|
||||
"tagbaru" => $prevGadai[0][0]['tagbaru'] ?? 0,
|
||||
"hargajualan" => $prevGadai[0][0]['hargajualan'] ?? '',
|
||||
"pinjaman" => $tebus['pinjaman'] ?? 0,
|
||||
"norujukan" => $history,
|
||||
"jenistebus" => $tebus['jenistebus'] ?? 0,
|
||||
"jbg" => $tebus['jbg'] ?? 0,
|
||||
"t_tebus" => $tebus['t_tebus'] ?? 0,
|
||||
"bayaran_keuntungan" => $tebus['bayaran_keuntungan'] ?? 0,
|
||||
"bayaran_pembiayaan" => $tebus['bayaran_pembiayaan'] ?? 0,
|
||||
"duit_masuk" => $tebus['duit_masuk'] ?? 0,
|
||||
"trans_type" => $tebus['trans_type'] ?? 0,
|
||||
];
|
||||
|
||||
$nextHistory = $prevGadai[0][0]['historygadaian'] ?? '0';
|
||||
|
||||
// Elakkan infinite loop
|
||||
if ($nextHistory == $history) {
|
||||
break;
|
||||
}
|
||||
|
||||
$history = $nextHistory;
|
||||
}
|
||||
|
||||
$count++;
|
||||
|
||||
}
|
||||
else{
|
||||
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/norujukan/'. $norujukan)->json();
|
||||
$tebus = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/listpenebusanhistory/'. $gadai[0][0]['kodcaw'],[
|
||||
"norujukan" => $norujukan
|
||||
])->json();
|
||||
|
||||
|
||||
array_push($arrayhist,["tagbaru" => ((isset($gadai[0][0]['tagbaru'])) ? $gadai[0][0]['tagbaru'] : 0), "hargajualan" => ((isset($gadai[0][0]['hargajualan'])) ? $gadai[0][0]['hargajualan'] : ''),"pinjaman" => ((isset($tebus[0])) ? $tebus[0]['pinjaman'] : 0),"norujukan" => $norujukan,"jenistebus" => ((isset($tebus[0])) ? $tebus[0]['jenistebus'] : 0),"jbg" => ((isset($tebus[0])) ? $tebus[0]['jbg'] : 0),"t_tebus" => ((isset($tebus[0])) ? $tebus[0]['t_tebus'] : 0)]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user