Fix most errors on debug transaksi online

This commit is contained in:
Afiq Hamzah
2025-04-09 16:06:00 +08:00
parent 66fc240d9b
commit 9a9e870ec2
12 changed files with 323 additions and 33 deletions
@@ -11,15 +11,19 @@ class BillplzTransactionReviewController extends Controller
{
$date = request()->selectedDate ?? Carbon::now()->toDateString();
$billPlzTransactionReview = Http::get(config('api.url_arrahn_portal') . '/api/billplz-transaction-review', ['date' => $date])->json();
[$pkbTransactionsReview, $kopkbTransactionsReview] = Http::get(config('api.url_arrahn_portal') . '/api/billplz-transaction-review', ['date' => $date])->json();
return view('online.billplz-transaction-review.index', compact('billPlzTransactionReview', 'date'));
return view('online.billplz-transaction-review.index', compact('pkbTransactionsReview', 'kopkbTransactionsReview', 'date'));
}
public function show($bill_id)
{
$billPlzTransactionReview = Http::get(config('api.url_arrahn_portal') . '/api/billplz-transaction-review/'. $bill_id)->json();
$billPlzTransactionReview = array_filter($billPlzTransactionReview, fn($x) => $x[0]['billplz_latest_transaction'] !== null);
$billPlzTransactionReview = array_pop($billPlzTransactionReview);
return view('online.billplz-transaction-review.show', compact('billPlzTransactionReview', 'bill_id'));
}
}
@@ -13,16 +13,17 @@ class BillplzTransactionSummaryController extends Controller
$transactionDataPKB = collect( Http::arrahn()->get('/api/transaction/online/query', ['date' => $date, 'status' => 'paid'])->json() );
$transactionDataPKB = $transactionDataPKB->map(function($x){
$x['account_own_by'] = 'KOOP';
$x['account_own_by'] = 'PKB';
return $x;
});
$transactionDataKOOP = collect( Http::arrahn_koop()->get('/api/transaction/online/query', ['date' => $date, 'status' => 'paid'])->json() );
$transactionDataKOOP = $transactionDataKOOP->map(function($x){
$x['account_own_by'] = 'PKB';
$x['account_own_by'] = 'KOOP';
return $x;
});
$transactionData = $transactionDataPKB->merge($transactionDataKOOP);
$transactionDataPKB = $this->processArrahnTransactions($transactionDataPKB);
@@ -32,7 +33,7 @@ class BillplzTransactionSummaryController extends Controller
$billIds = $transactionData->map(fn($x) => ['bill_id' => $x['bill_id'], 'account_own_by' => $x['account_own_by']]);
$billplzBills = Http::get(config('api.url_arrahn_portal') . '/api/billplz', ['bill_ids' => json_encode($billIds)])->json();
$data = array_map(fn($x, $y) => $this->processBillplzBills($x, $y), $billplzBills, [$transactionDataPKB, $transactionDataKOOP]);
$data = array_map(fn($x, $y) => $this->processBillplzBills($x, $y), $billplzBills, [$transactionDataKOOP, $transactionDataPKB]);
[$billPlzTransactionSummaryKOOP, $billPlzTransactionSummaryPKB] = $data;
@@ -7,10 +7,16 @@ use Carbon\Carbon;
class OnlineTransactionGadaianController extends Controller
{
public function __invoke($norujukan)
public function __invoke($norujukan, Request $request)
{
$gadaian = Http::arrahn()->get('/api/gadai/norujukan/'.$norujukan)->json()[0][0];
if($request->account_own_by === 'pkb'){
$gadaian = Http::arrahn()->get('/api/gadai/norujukan/'.$norujukan)->json()[0][0];
}
if($request->account_own_by === 'kopkb'){
$gadaian = Http::arrahn_koop()->get('/api/gadai/norujukan/'.$norujukan)->json()[0][0];
}
return view('online.gadaian.show', compact('gadaian'));
}
}
@@ -11,18 +11,34 @@ class OnlineTransactionLogController extends Controller
{
$date = request()->selectedDate ?? Carbon::now()->toDateString();
$transactionLog = Http::get(config('api.url') . '/api/transaction/online/log', ['date' => $date])->json();
$logs = collect($transactionLog)->groupBy('bill_id');
return view('online.log.index', compact('logs', 'date'));
$transactionLogPKB = Http::arrahn()->get('/api/transaction/online/log', ['date' => $date])->json();
$transactionLogKOPKB = Http::arrahn_koop()->get('/api/transaction/online/log', ['date' => $date])->json();
$groupLogsByBillID = fn($x) => collect($x)->groupBy('bill_id');
$transactionLogPKB = $groupLogsByBillID($transactionLogPKB);
$transactionLogKOPKB = $groupLogsByBillID($transactionLogKOPKB);
$key_transactionLogKOPKB = $transactionLogKOPKB->keys();
$key_transactionLogPKB = $transactionLogPKB->keys();
// remove the KOPKB keys that are inside of PKB keys
$key_transactionLogPKB = $key_transactionLogPKB->diff($key_transactionLogKOPKB);
$transactionMain = collect($transactionLogPKB->all());
$transactionLogPKB = $transactionMain->only($key_transactionLogPKB);
$transactionLogKOPKB = $transactionMain->only($key_transactionLogKOPKB);
return view('online.log.index', compact('transactionLogPKB','transactionLogKOPKB','date'));
}
public function show($bill_id)
public function show($bill_id, Request $request)
{
$transactionLog = Http::arrahn()->get('/api/transaction/online/log/'.$bill_id)->json();
$transactionLog = Http::arrahn()->get('/api/transaction/online/log/'.$bill_id)->json();
$logs = collect($transactionLog)->groupBy('bill_id');
return view('online.log.show', compact('logs', 'bill_id'));
@@ -47,12 +47,12 @@ class OnlineTransactionTrailController extends Controller
'isGroupedByNorujukan' => $isGroupedByNorujukan,
];
$transactionTrailKOOP = Http::arrahn()->get('/api/transaction/online/trail', $queries)->json();
$transactionTrailKOOP = Http::arrahn_koop()->get('/api/transaction/online/trail', $queries)->json();
$transactionTrailPKB = Http::arrahn_koop()->get('/api/transaction/online/trail', $queries)->json();
$transactionTrailPKB = Http::arrahn()->get('/api/transaction/online/trail', $queries)->json();
$branchesPKB = Http::arrahn_koop()->get('/api/cawangan')->json();
$branchesKOOP = Http::arrahn()->get('/api/cawangan')->json();
$branchesPKB = Http::arrahn()->get('/api/cawangan')->json();
$branchesKOOP = Http::arrahn_koop()->get('/api/cawangan')->json();
$branches = array_merge($branchesKOOP, $branchesPKB);
return view('online.trail.index', compact('transactionTrailPKB', 'transactionTrailKOOP', 'startDate', 'endDate', 'norujukan', 'selectedStatus', 'statuses', 'billplzBillId', 'branches', 'selectedBranch'));
+2 -2
View File
@@ -26,12 +26,12 @@ class AppServiceProvider extends ServiceProvider
public function boot()
{
Http::macro('arrahn', function () {
return Http::withOptions(['verify' => config('app.api_verify')])->baseUrl(config('api.url'));
return Http::withOptions(['verify' => config('app.api_verify')])->baseUrl(config('api.url_pkb'));
});
PendingRequest::macro('arrahn', function () {
$this->options['verify'] = config('app.api_verify');
$this->baseUrl(config('api.url'));
$this->baseUrl(config('api.url_pkb'));
return $this;
});
@@ -27,8 +27,18 @@
@endif
</div>
<div class="container mx-auto p-4 bg-yellow-50">
<x-table>
<div class="container mx-auto ">
<div class="flex mb-0 border-b border-gray-200">
<button class="flex items-center tab-button active" data-tab="pkb-transactions-review">
<span>PKB (v2)</span>
</button>
<button class="flex items-center tab-button" data-tab="kopkb-transactions-review">
<span>KOPKB (v3)</span>
</button>
</div>
<div class="p-4 bg-yellow-50 border-t-4 border-yellow-500">
<div id="pkb-transactions-review" class="tab-content active">
<x-table>
<x-slot name="header">
<x-table.header content="No." />
<x-table.header content="billplz_id" />
@@ -36,7 +46,7 @@
<x-table.header content="Transaction Billplz" />
</x-slot>
<x-slot name="body">
@forelse ($billPlzTransactionReview as $data)
@forelse ($pkbTransactionsReview as $data)
<tr>
<x-table.data :content="$loop->iteration" />
<x-table.data :content="$data['bill_id']" />
@@ -91,5 +101,127 @@
@endforelse
</x-slot>
</x-table>
</div>
<div id="kopkb-transactions-review" class="tab-content">
<x-table>
<x-slot name="header">
<x-table.header content="No." />
<x-table.header content="billplz_id" />
<x-table.header content="Transaction Arrahn" />
<x-table.header content="Transaction Billplz" />
</x-slot>
<x-slot name="body">
@forelse ($kopkbTransactionsReview as $data)
<tr>
<x-table.data :content="$loop->iteration" />
<x-table.data :content="$data['bill_id']" />
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
<div class="flex items-center">
<div class="ml-3 text-gray-900 whitespace-no-wrap">
@foreach ($data['arrahn_transactions'] as $transaction)
<div class="flex items-center">
<div class="ml-3">
<p class="text-gray-900 whitespace-no-wrap">
portal: {{ $transaction['portal'] }} <br>
norujukan: {{ $transaction['norujukan'] }} <br>
kodcaw: {{ $transaction['kodcaw'] }} <br>
customer_name: {{ $transaction['customer_name'] }} <br>
nokp: {{ $transaction['nokp'] }} <br>
total_payment: {{ $transaction['total_payment'] }} <br>
status: {{ $transaction['status'] }} <br>
tarikh_attempt_bayar: {{ $transaction['tarikh_attempt_bayar'] }} <br>
masa_attempt_bayar: {{ $transaction['masa_attempt_bayar'] }} <br>
paid_at: {{ $transaction['paid_at'] }} <br>
</p>
</div>
</div>
<br>
@endforeach
</div>
</div>
</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
<div class="flex items-center">
<div class="ml-3 text-gray-900 whitespace-no-wrap">
<div class="flex items-center">
<div class="ml-3">
<p class="text-gray-900 whitespace-no-wrap">
bill_id: {{ $data['billplz_latest_transaction']['bill_id'] }} <br>
id: {{ $data['billplz_latest_transaction']['id'] ?? '' }} <br>
status: {{ $data['billplz_latest_transaction']['status'] ?? '' }} <br>
completed_at: {{ $data['billplz_latest_transaction']['completed_at'] ?? '' }} <br>
payment_channel: {{ $data['billplz_latest_transaction']['payment_channel'] ?? '' }} <br>
</p>
</div>
</div>
<br>
</div>
</div>
</td>
</tr>
@empty
<tr>
<x-table.data colspan="3" class="text-center" content="No data available" />
</tr>
@endforelse
</x-slot>
</x-table>
</div>
</div>
</div>
@endsection
@push('additional_scripts')
<script>
document.addEventListener('DOMContentLoaded', function() {
const tabButtons = document.querySelectorAll('.tab-button');
const tabContents = document.querySelectorAll('.tab-content');
tabButtons.forEach(button => {
button.addEventListener('click', () => {
const tabId = button.getAttribute('data-tab');
// Deactivate all tabs
tabButtons.forEach(btn => btn.classList.remove('active'));
tabContents.forEach(content => content.classList.remove('active'));
// Activate the clicked tab
button.classList.add('active');
console.log(tabId)
document.getElementById(tabId).classList.add('active');
});
});
});
</script>
@endpush
@push('additional_styles')
<style>
.tab-button {
padding: 10px 15px;
background-color: #f3f4f6;
border: none;
cursor: pointer;
transition: background-color 0.3s;
}
.tab-button.active {
background-color: #ffffff;
border-bottom: 2px solid #3b82f6;
}
.tab-button-diff.active {
background-color: #f87171;
}
.tab-content {
display: none;
}
.tab-content.active {
display: block;
}
</style>
@endpush
@@ -349,7 +349,7 @@
</tr>
<tr>
<th class="border border-gray-300 bg-gray-100 p-2 font-bold text-left w-3/12">pampasan</th>
<td class="border border-gray-300 p-2 bg-white w-9/12">{{ $gadaian['pampasan'] }}</td>
<td class="border border-gray-300 p-2 bg-white w-9/12">{{ $gadaian['pampasan'] ?? 'tiada column pampasan' }}</td>
</tr>
<tr>
<th class="border border-gray-300 bg-gray-100 p-2 font-bold text-left w-3/12">lel1stop</th>
+131 -1
View File
@@ -42,8 +42,86 @@
@endif
</div>
<div class="container mx-auto">
<div class="flex border-b-4 border-yellow-500">
<button class="flex items-center tab-button outer-tab-button active" data-tab="pkb-transactions-log">
<span>PKB (v2)</span>
</button>
<button class="flex items-center tab-button outer-tab-button" data-tab="kopkb-transactions-log">
<span>KOPKB (v3)</span>
</button>
</div>
<div class="container mx-auto p-4 bg-yellow-50">
@forelse ($logs as $bill_id => $logs)
<div id="pkb-transactions-log" class="container mx-auto tab-content active">
@forelse ($transactionLogPKB as $bill_id => $logs)
<div class="mb-4">
<button class="accordion-toggle w-full bg-gray-600 text-gray-100 p-2 text-left focus:outline-none">
<h2 class="inline-block">Bill ID: {{ $bill_id }}</h2>
@php
$isSpareCustomer = json_decode($logs[0]['payload']) != null && $logs[0]['status'] == '6' || $logs[0]['status'] == '12';
$isArrahnPayCustomer = json_decode($logs[0]['payload']) != null && $logs[0]['status'] == '1';
$extractedCustomerName = 'error';
if($isSpareCustomer) {
$extractedCustomerName = 'SPARE';
}elseif($isArrahnPayCustomer) {
$extractedCustomerName = json_decode($logs[0]['payload'])[3];
}
@endphp
@if($isSpareCustomer)
<span class="ml-4 bg-gray-200 text-gray-800 text-xs font-semibold mr-2 px-2.5 py-0.5 rounded dark:bg-gray-200 dark:text-gray-800"><h2 class="inline-block">{{ $extractedCustomerName }}</h2></span>
@elseif($isArrahnPayCustomer)
<span class="ml-4 bg-green-200 text-green-800 text-xs font-semibold mr-2 px-2.5 py-0.5 rounded dark:bg-green-200 dark:text-green-800"><h2 class="inline-block">Customer Name: {{ $extractedCustomerName }}</h2></span>
@else
<span class="ml-4 bg-red-200 text-red-800 text-xs font-semibold mr-2 px-2.5 py-0.5 rounded dark:bg-red-200 dark:text-red-800"><h2 class="inline-block">{{ $extractedCustomerName }}</h2></span>
@endif
<span class="acccordian-arrow float-right">&#9660;</span>
</button>
<div class="accordion-content hidden">
@foreach ($logs as $log)
<div class="bg-gray-600 text-white border-black p-0 pl-3 py-1 flex justify-between items-center">
@php
$formatTime = fn($x) => \Carbon\Carbon::parse($x, 'UTC')->setTimezone('Asia/Kuala_Lumpur')->format('d/m/Y g:i:s A');
@endphp
<span>{{ $formatTime($log['created_at']) }}</span>
</div>
<div class="bg-gray-500 text-white border-black p-3 flex justify-between items-center">
<span>{{ $log['status_label'] }}</span>
<span
class="inline-block bg-yellow-200 text-yellow-800 text-xs font-semibold mr-2 px-2.5 py-0.5 rounded dark:bg-yellow-200 dark:text-yellow-800">
{{ $log['status'] }}
</span>
<!-- More log details here -->
</div>
<div class="flex w-full ">
<div class="w-1/2 bg-gray-800 text-black border-r border-green-500">
<div class="bg-green-600 text-gray-800">Request</div>
<div class="pr-3 bg-gray-800 text-green-600">
<pre>{{ json_encode(json_decode($log['payload']), JSON_PRETTY_PRINT) }}</pre>
</div>
</div>
<div class="w-1/2 bg-gray-800 text-black">
<div class="bg-green-600 text-gray-800">Response</div>
<div class="pl-3 bg-gray-800 text-green-600">
<pre>{{ json_encode(json_decode($log['response']), JSON_PRETTY_PRINT) }}</pre>
</div>
</div>
</div>
<br>
@endforeach
</div>
</div>
@empty
<div class="bg-white text-center py-6">
No data available for the date selected
</div>
@endforelse
</div>
<div id="kopkb-transactions-log" class="container mx-auto tab-content">
@forelse ($transactionLogKOPKB as $bill_id => $logs)
<div class="mb-4">
<button class="accordion-toggle w-full bg-gray-600 text-gray-100 p-2 text-left focus:outline-none">
<h2 class="inline-block">Bill ID: {{ $bill_id }}</h2>
@@ -150,3 +228,55 @@
</script>
@endpush
@endsection
@push('additional_scripts')
<script>
document.addEventListener('DOMContentLoaded', function() {
const tabButtons = document.querySelectorAll('.tab-button');
const tabContents = document.querySelectorAll('.tab-content');
tabButtons.forEach(button => {
button.addEventListener('click', () => {
const tabId = button.getAttribute('data-tab');
// Deactivate all tabs
tabButtons.forEach(btn => btn.classList.remove('active'));
tabContents.forEach(content => content.classList.remove('active'));
// Activate the clicked tab
button.classList.add('active');
console.log(tabId)
document.getElementById(tabId).classList.add('active');
});
});
});
</script>
@endpush
@push('additional_styles')
<style>
.tab-button {
padding: 10px 15px;
background-color: #f3f4f6;
border: none;
cursor: pointer;
transition: background-color 0.3s;
}
.tab-button.active {
background-color: #ffffff;
border-bottom: 2px solid #3b82f6;
}
.tab-button-diff.active {
background-color: #f87171;
}
.tab-content {
display: none;
}
.tab-content.active {
display: block;
}
</style>
@endpush
+5 -4
View File
@@ -54,7 +54,7 @@
@endphp
<div>
<div id="pkb-transactions-summary" class="p-4 bg-yellow-50 tab-content outer-tab-content active">
<div class="flex border-b border-gray-200 mb-4">
<div class="flex border-b-4 border-black-600 pb-0 mb-0">
<button class="tab-button inner-tab-button active flex items-center" data-tab="transactions-online">
<span>Table transaction_online</span>
@php
@@ -146,7 +146,7 @@
</div>
</div>
<div id="kopkb-transactions-summary" class="p-4 bg-yellow-50 tab-content outer-tab-content">
<div class="flex border-b border-gray-200 mb-4">
<div class="flex border-b-4 border-black-600 pb-0 mb-0">
<button class="tab-button inner-tab-button flex items-center" data-tab="transactions-online-kopkb">
<span>Table transaction_online</span>
@php
@@ -303,6 +303,7 @@
function scrollContent(tabId, direction) {
const scrollContainer = document.querySelector(`#${tabId} .scroll-content`);
console.log(tabId);
const scrollAmount = 300; // Adjust this value to control scroll distance
if (direction === 'left') {
@@ -429,7 +430,7 @@
document.querySelectorAll('.search_billplz_id').forEach(function(element) {
element.addEventListener('click', function(event) {
document.getElementById('reset-button').dispatchEvent(new Event('click'));
let billpliz_id_value = element.previousElementSibling.innerHTML.trim();
let billpliz_id_value = element.parentNode.children[0].innerText.trim();
alert('search billplz bill id : '+billpliz_id_value)
document.getElementById('billplzBillId').value = billpliz_id_value;
window.scrollTo(0, 0);
@@ -444,7 +445,7 @@
document.querySelectorAll('.search_norujukan').forEach(function(element) {
element.addEventListener('click', function(event) {
document.getElementById('reset-button').dispatchEvent(new Event('click'));
let norujukan = element.previousElementSibling.innerHTML.trim();
let norujukan = element.parentNode.children[0].innerText.trim();
alert('search norujukan : '+norujukan);
document.getElementById('norujukan').value = norujukan;
window.scrollTo(0, 0);
@@ -30,8 +30,8 @@
<x-table.data-status-orb :content="$data['update_status']" />
<x-table.data-status-orb :content="$data['update_serahan']" />
<x-table.data :content="$data['status']" />
<x-table.data-link :content="$data['billplz_id']" :url="route('transaction.online.log.show', $data['billplz_id'])" searchId="search_billplz_id" tooltip="View Log" />
<x-table.data-link :content="$data['norujukan']" :url="route('transaction.online.gadaian', $data['norujukan'])" searchId="search_norujukan" tooltip="View Gadai Detail" />
<x-table.data-link :content="$data['billplz_id']" :url="route('transaction.online.log.show', ['bill_id' => $data['billplz_id'], 'account_own_by' => 'kopkb'])" searchId="search_billplz_id" tooltip="View Log" />
<x-table.data-link :content="$data['norujukan']" :url="route('transaction.online.gadaian', ['norujukan' => $data['norujukan'], 'account_own_by' => 'kopkb'])" searchId="search_norujukan" tooltip="View Gadai Detail" />
<x-table.data-link :content="$data['total_payment']" :url="route('transaction.online.billplz-transaction-review.show', $data['billplz_id'])" tooltip="Refer Billplz" />
<x-table.data :content="$data['paid_at']" />
<x-table.data :content="$data['nokp']" />
@@ -30,8 +30,8 @@
<x-table.data-status-orb :content="$data['update_status']" />
<x-table.data-status-orb :content="$data['update_serahan']" />
<x-table.data :content="$data['status']" />
<x-table.data-link :content="$data['billplz_id']" :url="route('transaction.online.log.show', $data['billplz_id'])" searchId="search_billplz_id" tooltip="View Log" />
<x-table.data-link :content="$data['norujukan']" :url="route('transaction.online.gadaian', $data['norujukan'])" searchId="search_norujukan" tooltip="View Gadai Detail" />
<x-table.data-link :content="$data['billplz_id']" :url="route('transaction.online.log.show', ['bill_id' => $data['billplz_id'], 'account_own_by' => 'pkb'])" searchId="search_billplz_id" tooltip="View Log" />
<x-table.data-link :content="$data['norujukan']" :url="route('transaction.online.gadaian', ['norujukan' => $data['norujukan'], 'account_own_by' => 'pkb'])" searchId="search_norujukan" tooltip="View Gadai Detail" />
<x-table.data-link :content="$data['total_payment']" :url="route('transaction.online.billplz-transaction-review.show', $data['billplz_id'])" tooltip="Refer Billplz" />
<x-table.data :content="$data['paid_at']" />
<x-table.data :content="$data['nokp']" />