From 956d66182af09f37c9a53e6caa9c3b2becaff7ae Mon Sep 17 00:00:00 2001 From: hafifierahman Date: Mon, 24 Feb 2025 21:25:47 +0800 Subject: [PATCH] added reject time from 7pm and 11pm,Furthermore, fix 5cent in create transaction --- .../TransactionOnlineController.php | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/TransactionOnlineController.php b/app/Http/Controllers/TransactionOnlineController.php index 213aabc..b6683a7 100644 --- a/app/Http/Controllers/TransactionOnlineController.php +++ b/app/Http/Controllers/TransactionOnlineController.php @@ -25,8 +25,7 @@ class TransactionOnlineController extends Controller { public function getTransactionOnline(Request $request) { - $transactionOnline = TransactionOnline::on('mysql7')->where('billplz_id', $request->billplz_id)->first(); - + $transactionOnline = TransactionOnline::on('mysql7')->where('norujukan',$request->norujukan)->where('billplz_id', $request->billplz_id)->first(); return response()->json($transactionOnline); } @@ -117,6 +116,13 @@ class TransactionOnlineController extends Controller $transactions = TransactionOnline::on('mysql7')->where([['status', '=', 'PAID'], ['update_status', 0]])->get(); $current = Carbon::now(); $current = new Carbon(); + + $checkTime = $this->checkTime(); + + if($checkTime == 'rejected'){ + return response()->json('rejected-time'); + } + foreach ($transactions as $index => $transaction) { $cawangan = Cawangan::on('mysql7') ->where('kodcaw', '=', $transaction['kodcaw']) @@ -451,8 +457,10 @@ class TransactionOnlineController extends Controller $ujrah_calculation = $this->getUjrah($kodcaw, $norujukan); $onepercent = new Calculation(); + $ujrahasal = $onepercent->getRoundedMethod($ujrahasal); + $onepercentasal = $onepercent->getRoundedMethod($onepercentasal); $ujrah = $onepercent->getRoundedMethod($ujrahasal * $bilang_bln); - $ujrah_rebate = $onepercent->getRoundedMethod($ujrah_calculation['ujrah_sebenar'] - $ujrah_calculation['ujrah_rebet']); + $ujrah_rebate = $onepercent->getRoundedMethod($keuntungan['ujrah'] * $bilang_bln); $keun = $onepercent->getRoundedMethod($onepercentasal * $bilang_bln); $keuntungan_rebate = $onepercent->getRoundedMethod($keuntungan['onepercent'] * $bilang_bln); @@ -745,5 +753,21 @@ class TransactionOnlineController extends Controller } } + private function checkTime(){ + $current = Carbon::now(); + + $startRange1 = Carbon::today()->setTime(19, 0); + $endRange1 = Carbon::today()->setTime(19, 30); + + $startRange2 = Carbon::today()->setTime(23, 0); + $endRange2 = Carbon::today()->setTime(23, 30); + + if ($current->between($startRange1, $endRange1) || $current->between($startRange2, $endRange2)) { + return 'rejected'; + } + } + + + }