41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\CompanyStatus;
|
|
use App\Services\BillplzService;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Http\Request;
|
|
|
|
class BillplzController extends Controller
|
|
{
|
|
public function __invoke(Request $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);
|
|
return $billplzService->getBills($bill_ids);
|
|
};
|
|
|
|
$billDetailsKOPKB = $getBillDetailFromBillplz('KOPKB', $bill_ids_KOPKB);
|
|
$billDetailsPKB = $getBillDetailFromBillplz('PKB', $bill_ids_PKB);
|
|
|
|
return [
|
|
'KOPKB' => $billDetailsKOPKB,
|
|
'PKB' => $billDetailsPKB,
|
|
];
|
|
|
|
}
|
|
}
|