Fix transaction summary not showing
This commit is contained in:
@@ -11,23 +11,30 @@ class BillplzController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request)
|
||||
{
|
||||
$companyMapping = [
|
||||
'PKB',
|
||||
'KOPKB',
|
||||
];
|
||||
|
||||
$bills = array_reduce($companyMapping, function($carry, $company_code) use($request){
|
||||
$billplz_ids = json_decode($request->bill_ids, true);
|
||||
|
||||
$account_own_by_PKB = array_filter($billplz_ids, fn($x) => $x['account_own_by'] == 'PKB');
|
||||
$account_own_by_KOPKB = array_filter($billplz_ids, fn($x) => $x['account_own_by'] == 'KOOP');
|
||||
|
||||
$bill_ids_PKB = array_map(fn($x) => $x['bill_id'], $account_own_by_PKB);
|
||||
$bill_ids_PKB = array_values($bill_ids_PKB);
|
||||
|
||||
$bill_ids_KOPKB = array_map(fn($x) => $x['bill_id'], $account_own_by_KOPKB);
|
||||
$bill_ids_KOPKB = array_values($bill_ids_KOPKB);
|
||||
|
||||
$getBillDetailFromBillplz = function($company_code, $bill_ids) {
|
||||
$billplzService = new BillplzService($company_code);
|
||||
$billIdArray = json_decode($request->bill_ids);
|
||||
$billIdArray = $billplzService->getBills($billIdArray);
|
||||
$carry[$company_code] = array_filter($billIdArray, function($bill) {
|
||||
return $bill !== [];
|
||||
});
|
||||
return $carry;
|
||||
}, []);
|
||||
|
||||
return $bills;
|
||||
|
||||
|
||||
return $billplzService->getBills($bill_ids);
|
||||
};
|
||||
|
||||
$billDetailsKOPKB = $getBillDetailFromBillplz('KOPKB', $bill_ids_KOPKB);
|
||||
$billDetailsPKB = $getBillDetailFromBillplz('PKB', $bill_ids_PKB);
|
||||
|
||||
return [
|
||||
'KOPKB' => $billDetailsKOPKB,
|
||||
'PKB' => $billDetailsPKB,
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user