Update billplz transaction review response contd

This commit is contained in:
Afiq Hamzah
2025-02-16 22:54:14 +08:00
parent fdbb910f97
commit f2b995158b
2 changed files with 9 additions and 9 deletions
+5 -4
View File
@@ -16,16 +16,17 @@ class BillplzController extends Controller
'KOPKB',
];
$bills = array_map(function($company_code) use($request){
$bills = array_reduce($companyMapping, function($carry, $company_code) use($request){
$billplzService = new BillplzService($company_code);
$billIdArray = json_decode($request->bill_ids);
$billIdArray = $billplzService->getBills($billIdArray);
return array_filter($billIdArray, function($bill) {
$carry[$company_code] = array_filter($billIdArray, function($bill) {
return $bill !== [];
});
}, $companyMapping);
return $carry;
}, []);
return array_merge(...$bills);
return $bills;
}
@@ -18,13 +18,12 @@ class BillplzTransactionReviewController extends Controller
'KOPKB',
];
$billplzTransactionReview = array_reduce($companyMapping, function($carry, $company_code) use($date){
$billplzTransactionReview = array_map(function($company_code) use($date){
$billplzService = new BillplzService($company_code);
$carry[$company_code] = $billplzService->getBillplzTransactionReview($date)->toArray();
return $carry;
}, []);
return $billplzService->getBillplzTransactionReview($date)->toArray();
}, $companyMapping);
return response()->json($billplzTransactionReview, 200);
return response()->json(array_merge(...$billplzTransactionReview), 200);
}
public function show(Request $request)