Add billplz transaction summary
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class BillplzTransactionSummaryController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$date = $request->selectedDate ?? Carbon::now()->toDateString();
|
||||
|
||||
$transactionData = Http::get(config('api.url_arrahn_portal') . '/api/billplz-transaction-review', ['date' => $date])->effectiveUri();
|
||||
|
||||
$transactionData = collect( Http::get(config('api.url_arrahn_portal') . '/api/billplz-transaction-review', ['date' => $date])->json() );
|
||||
|
||||
$transactionData = $transactionData->filter(fn($x) => $x['arrahn_transactions'][0]['paid_at'] != null);
|
||||
|
||||
$billIds = $transactionData->pluck('bill_id');
|
||||
$billplzBills = Http::get(config('api.url_arrahn_portal') . '/api/billplz', ['bill_ids' => json_encode($billIds)])->json();
|
||||
$billplzBills = array_map(function($bill) {
|
||||
$bill['paid_amount_formatted'] = floatval($bill['paid_amount']['amount']) / 100;
|
||||
return $bill;
|
||||
}, $billplzBills);
|
||||
|
||||
$sumOfArrahnTransactions = $transactionData->sum(fn($x) => $x['arrahn_transactions'][0]['total_payment']);
|
||||
$sumOfBillplzTransactions = collect($billplzBills)->sum(fn($x) => $x['paid_amount_formatted']);
|
||||
$numberOfArrahnTransactions = $transactionData->count();
|
||||
|
||||
$paymentGatewayCost = 'RM ' . number_format($sumOfBillplzTransactions - $sumOfArrahnTransactions, 2);
|
||||
$sumOfArrahnTransactions = 'RM ' . number_format($sumOfArrahnTransactions, 2);
|
||||
$sumOfBillplzTransactions = 'RM ' . number_format($sumOfBillplzTransactions, 2);
|
||||
|
||||
if ($transactionData->count() !== count($billplzBills)) {
|
||||
throw new \Exception("The number of items in transactionData and billplzBills must be the same.");
|
||||
}
|
||||
|
||||
$billPlzTransactionReview = $transactionData->zip($billplzBills)->map(function ($zippedItem) {
|
||||
[$transactionData, $billplzBill] = $zippedItem;
|
||||
|
||||
$transactionData['billplz_bill'] = $billplzBill;
|
||||
|
||||
return $transactionData;
|
||||
});
|
||||
|
||||
|
||||
return view('online.billplz-transaction-summary.index', compact( 'billPlzTransactionReview', 'sumOfArrahnTransactions', 'sumOfBillplzTransactions', 'paymentGatewayCost', 'numberOfArrahnTransactions', 'date'));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
@props([
|
||||
'title' => '',
|
||||
'subtitle' => '',
|
||||
])
|
||||
|
||||
<div class="px-4">
|
||||
<div class="container">
|
||||
<div class="flex w-full">
|
||||
<div class="p-8 pb-4 pt-0 mx-auto" style="min-width: 323px;">
|
||||
<div class="bg-yellow-500 text-gray-200 px-6 py-2 rounded-t-lg">
|
||||
<span class="text-center mx-auto text-white font-bold">{{ $title }}</span>
|
||||
</div>
|
||||
<div class="bg-gray-600 px-6 py-2">
|
||||
<p class="text-white">{{ $subtitle }}</p>
|
||||
</div>
|
||||
<!-- Rest of your existing card content -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,96 @@
|
||||
@extends('layouts.app')
|
||||
@section('content')
|
||||
|
||||
@section('title', 'Billplz Transaction Summary')
|
||||
|
||||
<breadcrumb
|
||||
:items="[{ 'title': 'Debug Transaksi Online', 'icon': 'fas fa-file-invoice', 'url': {{ json_encode(route('transaction.online.home')) }} },
|
||||
{ 'title': 'Billplz Transaction Summary', 'icon': 'fas fa-file-invoice' }
|
||||
]">
|
||||
</breadcrumb>
|
||||
|
||||
<div class="container mx-auto p-4 bg-yellow-50">
|
||||
<x-filter-date-card title="Billplz Transaction Summary" action="{{ route('transaction.online.billplz-transaction-summary.index') }}" :selectedDate="$date" />
|
||||
|
||||
<div class="flex flex-row space-x-4 mt-6">
|
||||
<x-card title="Sum of Billplz Transactions" subtitle="{{ $sumOfBillplzTransactions }}"></x-card>
|
||||
<div class="flex items-center"><span class="text-5xl font-bold">-</span></div>
|
||||
<x-card title="Sum of Arrahn Transactions" subtitle="{{ $sumOfArrahnTransactions }}"></x-card>
|
||||
<div class="flex items-center"><span class="text-5xl font-bold"> = </span></div>
|
||||
<x-card title="Payment Gateway Cost" subtitle="{{ $paymentGatewayCost }}"></x-card>
|
||||
</div>
|
||||
<hr class="border-b-2 border-gray-300 border-solid my-4">
|
||||
<div class="flex flex-row space-x-4 mb-6">
|
||||
<x-card title="No of Arrahn Transactions" subtitle="{{ $numberOfArrahnTransactions }}"></x-card>
|
||||
<div class="flex items-center"><span class="text-5xl font-bold">x</span></div>
|
||||
<x-card title="Charge Per Transaction" subtitle="RM 1.00"></x-card>
|
||||
<div class="flex items-center"><span class="text-5xl font-bold"> = </span></div>
|
||||
<x-card title="Payment Gateway Cost" subtitle="RM {{ number_format($numberOfArrahnTransactions * 100 / 100, 2) }}"></x-card>
|
||||
|
||||
</div>
|
||||
<x-table>
|
||||
<x-slot name="header">
|
||||
<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 ($billPlzTransactionReview as $data)
|
||||
<tr>
|
||||
<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">
|
||||
status : <span
|
||||
class="inline-block bg-green-600 text-white px-2 py-0.5 rounded text-xs font-medium">{{ $transaction['status'] }}</span>
|
||||
<br>
|
||||
total_payment:
|
||||
{{ number_format((float) $transaction['total_payment'], 2, '.', '') }}<br>
|
||||
norujukan: {{ $transaction['norujukan'] }}
|
||||
|
||||
</p>
|
||||
<br>
|
||||
<p class="text-gray-900 whitespace-no-wrap">
|
||||
kodcaw: {{ $transaction['kodcaw'] }} <br>
|
||||
customer_name: {{ $transaction['customer_name'] }} <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">
|
||||
billplz_status : <span
|
||||
class="inline-block bg-green-600 text-white px-2 py-0.5 rounded text-xs font-medium">{{ $data['billplz_bill']['state'] ?? '' }}</span>
|
||||
<br>
|
||||
billplz_paid_amount:
|
||||
{{ number_format($data['billplz_bill']['paid_amount']['amount'] / 100, 2, '.', '') }}
|
||||
<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>
|
||||
@endsection
|
||||
@@ -30,18 +30,23 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
|
||||
<div class=" flex justify-center items-center mx-auto">
|
||||
<a href="{{ route('transaction.online.trail') }}" class="bg-white shadow px-6 py-4 border border-solid rounded-lg w-1/6 hover:bg-yellow-300 hover:transition-all cursor-pointer transition transform hover:-translate-y-1 ">
|
||||
<div class=" flex justify-center items-center mx-auto pt-5 mr-3">
|
||||
<a href="{{ route('transaction.online.trail') }}" class="bg-white shadow px-6 py-4 border border-solid rounded-lg mr-3 w-1/6 hover:bg-yellow-300 hover:transition-all cursor-pointer transition transform hover:-translate-y-1 ">
|
||||
<div class="flex justify-center items-center">
|
||||
<svg fill="#000000" width="128px" height="128px" viewBox="0 0 256 256" id="Flat" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M208,72V184a7.99989,7.99989,0,0,1-8,8H176V104L136,64H80V40.00006a7.99989,7.99989,0,0,1,8-8L168,32Z" opacity="0.2"></path> <path d="M213.65723,66.34326l-40-40A8.00076,8.00076,0,0,0,168,24H88A16.01833,16.01833,0,0,0,72,40V56H56A16.01833,16.01833,0,0,0,40,72V216a16.01833,16.01833,0,0,0,16,16H168a16.01833,16.01833,0,0,0,16-16V200h16a16.01833,16.01833,0,0,0,16-16V72A8.00035,8.00035,0,0,0,213.65723,66.34326ZM168,216H56V72h76.68652L168,107.314l.00781,84.53083c-.001.05212-.00781.10284-.00781.15521,0,.05255.00684.10345.00781.15576l.002,23.84375Zm32-32H184V104a8.00035,8.00035,0,0,0-2.34277-5.65674l-40-40A8.00076,8.00076,0,0,0,136,56H88V40h76.68652L200,75.314Zm-56-32a8.00008,8.00008,0,0,1-8,8H88a8,8,0,0,1,0-16h48A8.00008,8.00008,0,0,1,144,152Zm0,32a8.00008,8.00008,0,0,1-8,8H88a8,8,0,0,1,0-16h48A8.00008,8.00008,0,0,1,144,184Z"></path> </g></svg>
|
||||
</div>
|
||||
<h2 class="mx-auto text-center font-bold text-2xl mt-4 uppercase">Trail Transaksi Online</h2>
|
||||
</a>
|
||||
</div>
|
||||
<a href="{{ route('transaction.online.billplz-transaction-summary.index') }}" class="bg-white shadow px-6 py-4 border border-solid rounded-lg w-1/6 hover:bg-yellow-300 hover:transition-all cursor-pointer transition transform hover:-translate-y-1 ml-5">
|
||||
<div class="flex justify-center items-center">
|
||||
<svg width="128px" height="128px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="#000000"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path fill="#444" d="M15.81 10l-2.5-5h0.69c0.276 0 0.5-0.224 0.5-0.5s-0.224-0.5-0.5-0.5h-0.79c-1.056-1.145-2.541-1.881-4.198-1.95l-0.012-0.050c0-0.552-0.448-1-1-1s-1 0.448-1 1v0.050c-1.681 0.073-3.178 0.807-4.247 1.947l-0.753 0.003c-0.276 0-0.5 0.224-0.5 0.5s0.224 0.5 0.5 0.5h0.69l-2.5 5h-0.19c0 1.1 1.34 2 3 2s3-0.9 3-2h-0.19l-2.55-5.090c0.064-0.039 0.118-0.089 0.159-0.148 0.873-1.019 2.148-1.669 3.575-1.702l0.006 10.94h-1v1h-2v1h8v-1h-2v-1h-1v-10.94c1.418 0.030 2.679 0.682 3.524 1.693 0.053 0.084 0.117 0.145 0.193 0.186l-2.527 5.061h-0.19c0 1.1 1.34 2 3 2s3-0.9 3-2h-0.19zM5 10h-4l2-3.94zM11 10l2-3.94 2 3.94h-4z"></path> </g></svg>
|
||||
</div>
|
||||
<h2 class="mx-auto text-center font-bold text-2xl mt-4 uppercase">Summary Transaksi Billplz</h2>
|
||||
</a>
|
||||
|
||||
<div class=" flex justify-center items-center mx-auto pt-5 mr- 3">
|
||||
</div>
|
||||
|
||||
<div class=" flex justify-center items-center mx-auto pt-5 mr-3">
|
||||
<a href="{{ route('transaction.online.log.index') }}" class="bg-white shadow px-6 py-4 border border-solid rounded-lg w-1/6 mr-3 hover:bg-yellow-300 hover:transition-all cursor-pointer transition transform hover:-translate-y-1 ">
|
||||
<div class="flex justify-center items-center">
|
||||
<svg width="128px" height="128px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path fill-rule="evenodd" clip-rule="evenodd" d="M5 4C5 3.44772 5.44772 3 6 3V21C5.44772 21 5 20.5523 5 20V4ZM8 21V3H19V21H8ZM7 23H6C4.34315 23 3 21.6569 3 20V4C3 2.34315 4.34315 1 6 1H7H19C20.1046 1 21 1.89543 21 3V21C21 22.1046 20.1046 23 19 23H7Z" fill="#000000"></path> </g></svg>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\BillplzTransactionReviewController;
|
||||
use App\Http\Controllers\BillplzTransactionSummaryController;
|
||||
use App\Http\Controllers\OnlineTransactionController;
|
||||
use App\Http\Controllers\OnlineTransactionGadaianController;
|
||||
use App\Http\Controllers\OnlineTransactionLogController;
|
||||
@@ -177,6 +178,7 @@ Route::get('/transaction/online/home', OnlineTransactionController::class)->nam
|
||||
Route::get('/transaction/online/trail', OnlineTransactionTrailController::class)->name('transaction.online.trail');
|
||||
Route::get('/transaction/online/billplz-transaction-review', [BillplzTransactionReviewController::class, 'index'])->name('transaction.online.billplz-transaction-review.index');
|
||||
Route::get('/transaction/online/billplz-transaction-review/{bill_id}', [BillplzTransactionReviewController::class, 'show'])->name('transaction.online.billplz-transaction-review.show');
|
||||
Route::get('/transaction/online/billplz-transaction-summary', [BillplzTransactionSummaryController::class, 'index'])->name('transaction.online.billplz-transaction-summary.index');
|
||||
Route::get('/transaction/online/log', [OnlineTransactionLogController::class, 'index'])->name('transaction.online.log.index');
|
||||
Route::get('/transaction/online/log/{bill_id}', [OnlineTransactionLogController::class, 'show'])->name('transaction.online.log.show');
|
||||
Route::get('/transaction/online/gadaian/{norujukan}', OnlineTransactionGadaianController::class)->name('transaction.online.gadaian');
|
||||
|
||||
Reference in New Issue
Block a user