Resolve conflicts
This commit is contained in:
+8
-6
@@ -3,16 +3,18 @@ APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
API_URL=http://api_arrahn.test
|
||||
API_LELONG_URL=https://niklah.arrahn.com.my
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=laravel
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
DB_CONNECTION_MYSQL=mysql
|
||||
DB_HOST_MYSQL=127.0.0.1
|
||||
DB_PORT_MYSQL=3306
|
||||
DB_DATABASE_MYSQL=laravel
|
||||
DB_USERNAME_MYSQL=root
|
||||
DB_PASSWORD_MYSQL=
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class UpdateTransactionMaster extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'update:transaction-master';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update arrahn transactions';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$updateOnline = Http::arrahn()->get('/api/transaction/online/update')->json();
|
||||
|
||||
if($updateOnline == 'success'){
|
||||
return 0;
|
||||
}else{
|
||||
Log::error('Update transaction master failed');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,22 +2,13 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\TransactionOnlineStatus;
|
||||
use App\Services\BillplzService;
|
||||
use App\Services\OnlineTransactionLoggerService;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Session;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
use Billplz\Client;
|
||||
use Http\Client\Common\HttpMethodsClient;
|
||||
use Http\Adapter\Guzzle6\Client as GuzzleHttpClient;
|
||||
use Http\Message\MessageFactory\GuzzleMessageFactory;
|
||||
use Money\Money;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class updateUnsuccess extends Command
|
||||
class UpdateUnsuccess extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
@@ -33,61 +24,50 @@ class updateUnsuccess extends Command
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
if(config('app.env') != 'production'){
|
||||
$this->api_key = 'abecfd0c-98d8-4635-abc2-2fcba8c60c11';
|
||||
$this->XSignature_Key = 'S-GWr7z03XjAhqPsFfu_H5nQ';
|
||||
$this->collection_id = 'z0r4kjhi';
|
||||
}else{
|
||||
$this->api_key = 'f3e82fe1-a422-4660-97f0-65cc59ff6c47';
|
||||
$this->XSignature_Key = 'S-alZUbzmD2_TF3vmrRqgehQ';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(BillplzService $billplzService)
|
||||
{
|
||||
$http = new HttpMethodsClient(
|
||||
new GuzzleHttpClient(),
|
||||
new GuzzleMessageFactory()
|
||||
);
|
||||
|
||||
$billplz = new Client($http, $this->api_key);
|
||||
if(config('app.env') != 'production'){
|
||||
$billplz->useSandbox();
|
||||
}
|
||||
$billplz->useVersion('v4');
|
||||
|
||||
$transaction = $billplz->bill();
|
||||
|
||||
$list_transaction = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/transaction/online/unsuccessful')->json();
|
||||
|
||||
if($list_transaction){
|
||||
foreach($list_transaction as $index=>$list){
|
||||
$show_transaction = $transaction->transaction($list['billplz_id']);
|
||||
$data = $show_transaction->toArray();
|
||||
|
||||
if(!empty($data['transactions'])){
|
||||
if($data['transactions'][0]['status'] == 'completed'){
|
||||
Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/transaction/online/unsuccesfull/update',[
|
||||
'billplz_id' => $data['bill_id'],
|
||||
'status' => 'PAID',
|
||||
'paid_at' => $data['transactions'][0]['completed_at']
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$getFailedOnlineTransaction = fn() => Http::arrahn()->get('/api/transaction/online/unsuccessful')->json();
|
||||
|
||||
$FailedBillplzID = array_map(fn($x) => $x['billplz_id'], $getFailedOnlineTransaction());
|
||||
|
||||
if(sizeof($FailedBillplzID) < 0){
|
||||
return;
|
||||
}
|
||||
|
||||
$billplzUpdatedTransactionStatus = array_map(fn($x) => $billplzService->getTransactionByBillId($x), $FailedBillplzID);
|
||||
|
||||
$getCompletedBillplzTransaction = function() use($billplzUpdatedTransactionStatus){
|
||||
|
||||
$dataNotNull = array_filter($billplzUpdatedTransactionStatus, fn($x) => $x !== null);
|
||||
|
||||
$dataHaveTransaction = array_filter($dataNotNull, fn($x) => sizeof($x['transactions']) > 0);
|
||||
|
||||
return array_filter($dataHaveTransaction, fn($x) => $x['transactions'][0]['status'] == 'completed');
|
||||
};
|
||||
|
||||
foreach($getCompletedBillplzTransaction() as $transaction){
|
||||
$transactionData = [
|
||||
'billplz_id' => $transaction['bill_id'],
|
||||
'status' => 'PAID',
|
||||
'paid_at' => $transaction['transactions'][0]['completed_at']
|
||||
];
|
||||
|
||||
try {
|
||||
$response = Http::arrahn()->put('/api/transaction/online/unsuccesfull/update', $transactionData);
|
||||
OnlineTransactionLoggerService::logs($transaction['bill_id'], $transactionData, $response, TransactionOnlineStatus::UPDATE_UNSUCCESSFUL_TRANSACTION );
|
||||
|
||||
} catch (\Exception $e) {
|
||||
OnlineTransactionLoggerService::logs($transaction['bill_id'], $transactionData, $e->getMessage(), TransactionOnlineStatus::UPDATE_UNSUCCESSFUL_TRANSACTION );
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,226 +2,141 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
use Billplz\Client;
|
||||
use Session;
|
||||
use Http\Client\Common\HttpMethodsClient;
|
||||
use Http\Adapter\Guzzle6\Client as GuzzleHttpClient;
|
||||
use Http\Message\MessageFactory\GuzzleMessageFactory;
|
||||
use Money\Money;
|
||||
|
||||
use App\Http\Requests\PaymentRequest;
|
||||
use App\Models\TransactionOnlineStatus;
|
||||
use App\Services\BillplzService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Log\Logger;
|
||||
use Illuminate\Http\Client\Pool;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Money\Money;
|
||||
use App\Services\OnlineTransactionLoggerService;
|
||||
|
||||
class BayaranController extends Controller
|
||||
{
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
if(config('app.env') != 'production'){
|
||||
$this->api_key = 'abecfd0c-98d8-4635-abc2-2fcba8c60c11';
|
||||
$this->XSignature_Key = 'S-GWr7z03XjAhqPsFfu_H5nQ';
|
||||
$this->collection_id = '5aosv2dg';
|
||||
}else{
|
||||
$this->api_key = 'f3e82fe1-a422-4660-97f0-65cc59ff6c47';
|
||||
$this->XSignature_Key = 'S-alZUbzmD2_TF3vmrRqgehQ';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function SenaraiPembayaran()
|
||||
{
|
||||
|
||||
$api_url = config('api.url');
|
||||
|
||||
$arraysag = [];
|
||||
|
||||
$auth_user = Auth::user();
|
||||
|
||||
$belum_tebus = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/customers/'. $auth_user['icno'] . '/gadai/' . 'belum_tebus')->json();
|
||||
|
||||
if(is_array($belum_tebus))
|
||||
{
|
||||
if(sizeof($belum_tebus) > 0)
|
||||
{
|
||||
foreach($belum_tebus as $index=>$bt)
|
||||
{
|
||||
foreach($bt as $index1=>$bet)
|
||||
{
|
||||
array_push($arraysag,$bet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$belum_tebus = $arraysag;
|
||||
|
||||
// return view('pembayaran.senaraibayaran', compact('belum_tebus'));
|
||||
return view('includes.bayaran.senaraibayaransag', compact('belum_tebus','api_url'));
|
||||
}
|
||||
|
||||
public function PembayaranAction(PaymentRequest $request)
|
||||
{
|
||||
$request->validated();
|
||||
|
||||
$arraybayar = $this->setUpahTawarruq($request->getPembiayaanFromNorujukan());
|
||||
|
||||
$validated = $request->validate([
|
||||
'chkboxsag' => 'required',
|
||||
]);
|
||||
|
||||
$arraybayar = array();
|
||||
|
||||
foreach($request->chkboxsag as $index=>$sag)
|
||||
{
|
||||
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/norujukan/'. $sag)->json();
|
||||
|
||||
$sagonline = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/portal/searchsagonline/',['norujukan' => $sag])->json();
|
||||
|
||||
if($sagonline == true)
|
||||
return redirect()->route('home')->with('errorsagonline','Sila Tunggu Sebentar!');
|
||||
//$array_lelong = Http::withOptions(['verify' => config('app.api_verify')])->get('https://niklah.arrahn.com.my/api/portalApi',['norujukan' => $sag])->json();
|
||||
//if($array_lelong['lelong'] !== null){
|
||||
// return redirect()->route('home')->with('error','Barangan Sedang Dilelong.');
|
||||
//}
|
||||
|
||||
if($gadai[0][0]['tempoh'] >= 12){
|
||||
// return redirect()->route('home')->with('error','SAG Yang Dipilih melebihi tempoh 12 bulan ke atas.');
|
||||
return redirect()->route('home')->with('error','SAG Yang Dipilih Akan/Telah Tamat Kontrak 12 Bulan. Sila Hadir Ke Kaunter Cawangan Untuk Pembayaran/Penebusan.');
|
||||
}
|
||||
|
||||
$arraybayar[] = $gadai[0][0];
|
||||
}
|
||||
|
||||
|
||||
// return view('pembayaran.checkout',compact('arraybayar'));
|
||||
return view('includes.bayaran.pembayaransag',compact('arraybayar'));
|
||||
return view('includes.bayaran.pembayaransag', compact('arraybayar'));
|
||||
}
|
||||
|
||||
public function PembayaranEngine(Request $request)
|
||||
public function PembayaranEngine(Request $request, BillplzService $billplzService)
|
||||
{
|
||||
// $arraybayaran = array();
|
||||
['email' => $customerEmail, 'notel' => $customerPhoneNumber, 'name' => $customerName, 'icno' => $customerIcno] = auth()->user()->toArray();
|
||||
|
||||
// dd($request);
|
||||
// foreach($request->txtnorujukanhidden as $index1=>$norujukan)
|
||||
// {
|
||||
// // $updategadai = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url').'/api/gadai/'. $request->txtkodcawhidden[$index1] .'/norujukan/' . $norujukan,[
|
||||
// // 'bayaran' => $request->txtbayaranhidden[$index1]
|
||||
// // ])->json();
|
||||
$bayaranArrahn = array_filter($request->txtjenisbayaran, fn($x) => $x == 'arrahn');
|
||||
$bayaranOthers = array_filter($request->txtjenisbayaran, fn($x) => $x != 'arrahn');
|
||||
|
||||
$bayaranArrahnArray = array_map(function ($x) use ($customerName, $customerIcno, $request) {
|
||||
return [
|
||||
'customer_name' => $customerName,
|
||||
'nokp' => $customerIcno,
|
||||
'kodcaw' => $request->txtkodcawhidden[$x],
|
||||
'norujukan' => $request->txtnorujukanhidden[$x],
|
||||
'bayaran' => $request->txtbayaranhidden[$x],
|
||||
'txtjbghidden' => $request->txtjbghidden[$x],
|
||||
'txtupahhidden' => $request->txtupahhidden[$x],
|
||||
];
|
||||
}, array_keys($bayaranArrahn));
|
||||
|
||||
// array_push($arraybayaran,['norujukan' => $norujukan, 'kodcaw' => $request->txtkodcawhidden[$index1], 'bayaran' => $request->txtbayaranhidden[$index1]]);
|
||||
// }
|
||||
$bayaranOthersArray = array_map(function ($x) use ($customerName, $customerIcno, $request) {
|
||||
return [
|
||||
'customer_name' => $customerName,
|
||||
'nokp' => $customerIcno,
|
||||
'kodcaw' => $request->txtkodcawhidden[$x],
|
||||
'norujukan' => $request->txtnorujukanhidden[$x],
|
||||
'bayaran' => $request->txtbayaranhidden[$x],
|
||||
];
|
||||
}, array_keys($bayaranOthers));
|
||||
|
||||
// $arraycollection_id = array();
|
||||
$collection_id = '5aosv2dg';
|
||||
$paymentArray = array_merge($bayaranArrahnArray, $bayaranOthersArray);
|
||||
|
||||
$http = new HttpMethodsClient(
|
||||
new GuzzleHttpClient(),
|
||||
new GuzzleMessageFactory()
|
||||
);
|
||||
$getPaymentSum = function () use ($paymentArray) {
|
||||
$billPlzTransactionFee = Money::MYR(100);
|
||||
$sum = fn() => array_reduce($paymentArray, fn($accumulator, $currentItem) => $accumulator + round($currentItem['bayaran'], 1), 0) * 100;
|
||||
return Money::MYR($sum())->add($billPlzTransactionFee);
|
||||
};
|
||||
|
||||
$billplz = new Client($http, $this->api_key);
|
||||
if(config('app.env') != 'production'){
|
||||
$billplz->useSandbox();
|
||||
}
|
||||
$bill = $billplzService->createBill([$customerEmail, $customerPhoneNumber, $customerName, $getPaymentSum()]);
|
||||
|
||||
$billplz->useVersion('v4');
|
||||
$isRecordTransactionSuccess = $this->recordTransaction($paymentArray, $bill);
|
||||
|
||||
$bill = $billplz->bill();
|
||||
if ($isRecordTransactionSuccess) {
|
||||
session([
|
||||
'array_payment' => $paymentArray,
|
||||
'payment_method' => 'login',
|
||||
]);
|
||||
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
return redirect($bill['url'] . '?auto_submit=true');
|
||||
}
|
||||
}
|
||||
|
||||
$day = $current->day;
|
||||
$month = $current->month;
|
||||
$year = $current->format('y');
|
||||
public function recordTransaction($paymentArray, $bill)
|
||||
{
|
||||
['name' => $customerName, 'icno' => $customerIcno] = auth()->user()->toArray();
|
||||
|
||||
$array_payment = [];
|
||||
|
||||
$total_bayaran = 0;
|
||||
|
||||
foreach($request->txtnorujukanhidden as $index1=>$norujukan)
|
||||
{
|
||||
if($request->txtjenisbayaran[$index1] == 'arrahn')
|
||||
{
|
||||
array_push($array_payment,['customer_name' => Auth::user()->name,'kodcaw'=>$request->txtkodcawhidden[$index1],'norujukan'=>$norujukan,'bayaran'=>$request->txtbayaranhidden[$index1],'jbg' => $request->txtjbghidden[$index1],'upah' => $request->txtupahhidden[$index1]]);
|
||||
Session::put('payment_jenis','arrahn');
|
||||
}
|
||||
else
|
||||
{
|
||||
array_push($array_payment,['customer_name' => Auth::user()->name,'nokp' => Auth::user()->icno,'kodcaw'=>$request->txtkodcawhidden[$index1],'norujukan'=>$norujukan,'bayaran'=>round($request->txtbayaranhidden[$index1],1)]);
|
||||
$getlatestNoSiri = function () {
|
||||
$previous_siri = Http::arrahn()->get('/api/online/transaction')->json();
|
||||
if ($previous_siri) {
|
||||
return $previous_siri['nosiri'] + 1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
//$total_bayaran += $request->txtbayaranhidden[$index1];
|
||||
$total_bayaran += round($request->txtbayaranhidden[$index1],1);
|
||||
$generateTransactionReferenceNumber = function () use ($getlatestNoSiri) {
|
||||
[$day, $month, $year] = [now()->day, now()->month, now()->format('y')];
|
||||
|
||||
return 'APKB' . $day . $month . $year . sprintf('%08d', $getlatestNoSiri());
|
||||
};
|
||||
|
||||
try {
|
||||
Http::pool(
|
||||
fn(Pool $pool) => collect($paymentArray)->map(
|
||||
fn($payment) => $pool->arrahn()->post('/api/online/transaction', [
|
||||
'nokp' => $customerIcno,
|
||||
'reference_no' => $generateTransactionReferenceNumber(),
|
||||
'nosiri' => $getlatestNoSiri(),
|
||||
'billplz_id' => $bill['id'],
|
||||
'norujukan' => $payment['norujukan'],
|
||||
'kodcaw' => $payment['kodcaw'],
|
||||
'total_payment' => $payment['bayaran'],
|
||||
'customer_name' => $customerName,
|
||||
]),
|
||||
),
|
||||
);
|
||||
|
||||
OnlineTransactionLoggerService::logs($bill['id'], $paymentArray, 1, TransactionOnlineStatus::INITIALIZED_TRANSACTION);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
OnlineTransactionLoggerService::logs($bill['id'], $paymentArray, $e->getMessage(), TransactionOnlineStatus::INITIALIZED_TRANSACTION);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$total_bayaran = ($total_bayaran * 100) + 100;
|
||||
try {
|
||||
$response = Http::arrahn()
|
||||
->put('/api/transaction/online/tagportal', [
|
||||
'billplz_id' => $bill['id'],
|
||||
])
|
||||
->json();
|
||||
|
||||
Session::put('array_payment',$array_payment);
|
||||
Session::put('payment_method','login');
|
||||
Session::save();
|
||||
OnlineTransactionLoggerService::logs($bill['id'], $paymentArray, $response, TransactionOnlineStatus::UPDATED_TAG_PORTAL);
|
||||
|
||||
// foreach($request->txtkodcawhidden as $index2=>$kodcaw)
|
||||
// {
|
||||
// if(config('app.env') != 'production'){
|
||||
// $collection_id = $this->collection_id;
|
||||
// }else{
|
||||
// $collection_id = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/api/billplz/collectionid',[
|
||||
// 'kodcaw' => $kodcaw
|
||||
// ])->json();
|
||||
// }
|
||||
// array_push($arraycollection_id,$collection_id);
|
||||
// }
|
||||
|
||||
|
||||
$response = $bill->create(
|
||||
$collection_id,
|
||||
Auth::user()->email,
|
||||
Auth::user()->notel,
|
||||
Auth::user()->name,
|
||||
Money::MYR($total_bayaran),
|
||||
route('pay.callback'),
|
||||
'Bayaran Ansuran',
|
||||
['redirect_url' => route('pay.paymentStatus')]
|
||||
);
|
||||
|
||||
$billcode = $response->toArray();
|
||||
|
||||
foreach($array_payment as $index1=>$arraypay)
|
||||
{
|
||||
$previous_siri = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/online/transaction')->json();
|
||||
if($previous_siri){
|
||||
$nosiri = $previous_siri['nosiri'] + 1;
|
||||
}else{
|
||||
$nosiri = 1;
|
||||
}
|
||||
|
||||
$reference_no = 'APKB' . $day . $month . $year . sprintf("%08d", $nosiri);
|
||||
|
||||
$new_transaction = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url') . '/api/online/transaction',[
|
||||
'nokp'=> Auth::user()->icno,
|
||||
'reference_no'=> $reference_no,
|
||||
'nosiri'=> $nosiri,
|
||||
'billplz_id' => $billcode['id'],
|
||||
'norujukan' => $arraypay['norujukan'],
|
||||
'kodcaw' => $arraypay['kodcaw'],
|
||||
'total_payment'=> $arraypay['bayaran'],
|
||||
'customer_name' => Auth::user()->name,
|
||||
])->json();
|
||||
} catch (\Exception $e) {
|
||||
|
||||
OnlineTransactionLoggerService::logs($bill['id'], $paymentArray, $e->getMessage(), TransactionOnlineStatus::UPDATED_TAG_PORTAL);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$tagportal = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/transaction/online/tagportal',[
|
||||
'billplz_id'=> $billcode['id']
|
||||
])->json();
|
||||
|
||||
return redirect($billcode['url'] . '?auto_submit=true');
|
||||
|
||||
// return view('pembayaran.result.berjaya',compact('arraybayaran'));
|
||||
return true;
|
||||
}
|
||||
|
||||
public function ResitBayaran(Request $request)
|
||||
@@ -230,160 +145,177 @@ class BayaranController extends Controller
|
||||
|
||||
$kpbaru = Auth::User()->icno;
|
||||
|
||||
$customer = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/customers/'.$kpbaru)->json();
|
||||
$customer = Http::arrahn()
|
||||
->get('/api/customers/' . $kpbaru)
|
||||
->json();
|
||||
$customer_details = $customer;
|
||||
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
$date = $current->toDateTimeString();
|
||||
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $payment_details['kodcaw'])->json();
|
||||
$cawangan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/detail/'. $payment_details['kodcaw'])->json();
|
||||
$cawangan_detail = $cawangan[0];
|
||||
$nama_cawangan = $cawangan_info['details_caw'];
|
||||
$cawangan_info = Http::arrahn()
|
||||
->get('/api/cawangan/' . $payment_details['kodcaw'])
|
||||
->json();
|
||||
$cawangan = Http::arrahn()
|
||||
->get('/api/cawangan/detail/' . $payment_details['kodcaw'])
|
||||
->json();
|
||||
$cawangan_detail = $cawangan[0];
|
||||
$nama_cawangan = $cawangan_info['details_caw'];
|
||||
|
||||
$gadai_details = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/gadai/norujukan/'.$payment_details['norujukan'])->json();
|
||||
$gadai = $gadai_details[0][0];
|
||||
// if($gadai_details[0][0]['hargajualan'] > 0)
|
||||
// {
|
||||
// $baki_harga_jualan_sebelum = $gadai_details[0][0]['bakihargajualan'] + $payment_details['total_payment'];
|
||||
// $baki_harga_jualan_semasa = $gadai_details[0][0]['bakihargajualan'];
|
||||
|
||||
return view('pembayaran.resit.resitportal',compact('customer_details','payment_details','cawangan_detail','nama_cawangan','gadai'));
|
||||
// }else{
|
||||
|
||||
// $gadai_details = $gadai_details[0][0];
|
||||
|
||||
// $koskeuntungan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/upahbukantawarruq/' . $payment_details['kodcaw'] . '/' . $payment_details['norujukan'])->json();
|
||||
|
||||
// $jbg = $gadai_details['jbg'];
|
||||
|
||||
// return view('pembayaran.resit.resit_baru_sebelum',compact('customer_details','payment_details','date','koskeuntungan','jbg'));
|
||||
// }
|
||||
$gadai_details = Http::arrahn()
|
||||
->get('/api/gadai/norujukan/' . $payment_details['norujukan'])
|
||||
->json();
|
||||
$gadai = $gadai_details[0][0];
|
||||
|
||||
return view('pembayaran.resit.resitportal', compact('customer_details', 'payment_details', 'cawangan_detail', 'nama_cawangan', 'gadai'));
|
||||
}
|
||||
|
||||
public function callback(Request $request, BillplzService $billplzService)
|
||||
{
|
||||
$data = $billplzService->webhook($request->toArray());
|
||||
|
||||
public function callback(Request $request){
|
||||
logger('REQUEST');
|
||||
logger($request);
|
||||
$http = new HttpMethodsClient(
|
||||
new GuzzleHttpClient(),
|
||||
new GuzzleMessageFactory()
|
||||
);
|
||||
$isBillUnpaid = $data['paid'] !== true;
|
||||
|
||||
$billplz = new Client($http, $this->api_key);
|
||||
if(config('app.env') != 'production'){
|
||||
$billplz->useSandbox();
|
||||
}
|
||||
$billplz->useVersion('v4');
|
||||
if ($isBillUnpaid) {
|
||||
Http::arrahn()->put('/api/online/transaction', [
|
||||
'billplz_id' => $data['id'],
|
||||
'status' => 'UNSUCCESSFUL',
|
||||
'paid_at' => null,
|
||||
]);
|
||||
|
||||
$bill = $billplz->bill();
|
||||
return response(200);
|
||||
}
|
||||
|
||||
$data = $bill->webhook($request->toArray());
|
||||
Http::arrahn()->put('/api/online/transaction', [
|
||||
'billplz_id' => $data['id'],
|
||||
'status' => 'PAID',
|
||||
'paid_at' => $data['paid_at']->format('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
if($data['billplz']['paid'] == 'true'){
|
||||
Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/online/transaction',[
|
||||
'billplz_id' => $data['billplz']['id'],
|
||||
'status' => 'PAID',
|
||||
'paid_at' => $data['billplz']['paid_at']
|
||||
]);
|
||||
return response(200);
|
||||
}
|
||||
|
||||
$transactionOnline = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/transaction/online/express',[
|
||||
'billplz_id' => $data['billplz']['id']
|
||||
])->json();
|
||||
public function response(Request $request, BillplzService $billplzService)
|
||||
{
|
||||
$data = $billplzService->redirect($request->toArray());
|
||||
|
||||
// \Mail::to(Auth::user()->email)->send(new \App\Mail\BayaranMail($array_payment));
|
||||
|
||||
// return redirect()->route('pay.success',[
|
||||
// 'transactionOnline' => $transactionOnline
|
||||
// ]);
|
||||
return response(200);
|
||||
$isBillUnpaid = $data['paid'] !== true;
|
||||
|
||||
}else{
|
||||
Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/online/transaction',[
|
||||
'billplz_id' => $data['billplz']['id'],
|
||||
'status' => 'UNSUCCESSFUL',
|
||||
'paid_at' => null
|
||||
]);
|
||||
if ($isBillUnpaid) {
|
||||
Http::arrahn()->put('/api/online/transaction', [
|
||||
'billplz_id' => $data['id'],
|
||||
'status' => 'UNSUCCESSFUL',
|
||||
'paid_at' => null,
|
||||
]);
|
||||
|
||||
// return redirect()->route('pay.failed');
|
||||
return response(500);
|
||||
}
|
||||
}
|
||||
$transactionOnline = Http::arrahn()
|
||||
->get('/api/transaction/online/login', [
|
||||
'billplz_id' => $data['id'],
|
||||
])
|
||||
->json();
|
||||
|
||||
public function response(Request $request){
|
||||
$http = new HttpMethodsClient(
|
||||
new GuzzleHttpClient(),
|
||||
new GuzzleMessageFactory()
|
||||
);
|
||||
return redirect()->route('pay.failed');
|
||||
}
|
||||
|
||||
$billplz = new Client($http, $this->api_key);
|
||||
if(config('app.env') != 'production'){
|
||||
$billplz->useSandbox();
|
||||
}
|
||||
$billplz->useVersion('v4');
|
||||
Http::arrahn()->put('/api/online/transaction', [
|
||||
'billplz_id' => $data['id'],
|
||||
'status' => 'PAID',
|
||||
'paid_at' => $data['paid_at']->format('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
$bill = $billplz->bill();
|
||||
$transactionOnline = Http::arrahn()
|
||||
->get('/api/transaction/online/login', [
|
||||
'billplz_id' => $data['id'],
|
||||
])
|
||||
->json();
|
||||
|
||||
$data = $bill->webhook($request->toArray());
|
||||
if($data['billplz']['paid'] == 'true'){
|
||||
Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/online/transaction',[
|
||||
'billplz_id' => $data['billplz']['id'],
|
||||
'status' => 'PAID',
|
||||
'paid_at' => $data['billplz']['paid_at']
|
||||
]);
|
||||
return redirect()->route('pay.success', [
|
||||
'transactionOnline' => $transactionOnline,
|
||||
]);
|
||||
}
|
||||
|
||||
$transactionOnline = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/transaction/online/login',[
|
||||
'billplz_id' => $data['billplz']['id']
|
||||
])->json();
|
||||
public function successPayment(Request $request)
|
||||
{
|
||||
$transactionOnline = $request->transactionOnline;
|
||||
|
||||
return redirect()->route('pay.success',[
|
||||
'transactionOnline' => $transactionOnline
|
||||
]);
|
||||
$arraygadai = array_map(
|
||||
fn($x) => Http::arrahn()
|
||||
->get('/api/gadai/norujukan/' . $x['norujukan'])
|
||||
->json()[0][0],
|
||||
$transactionOnline,
|
||||
);
|
||||
|
||||
}else{
|
||||
Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/online/transaction',[
|
||||
'billplz_id' => $data['billplz']['id'],
|
||||
'status' => 'UNSUCCESSFUL',
|
||||
'paid_at' => null
|
||||
]);
|
||||
return redirect()->route('pay.failed');
|
||||
}
|
||||
}
|
||||
$arraycawangan = array_map(
|
||||
fn($x) => Http::arrahn()
|
||||
->get('/api/cawangan/detail/' . $x['kodcaw'])
|
||||
->json()[0],
|
||||
$transactionOnline,
|
||||
);
|
||||
|
||||
public function successPayment(Request $request){
|
||||
$transactionOnline = $request->transactionOnline;
|
||||
return view('pembayaran.result.berjayaportal', compact('transactionOnline', 'arraycawangan', 'arraygadai'));
|
||||
}
|
||||
|
||||
// dd($transactionOnline);
|
||||
public function failedPayment()
|
||||
{
|
||||
return view('pembayaran.result.gagalportal');
|
||||
}
|
||||
|
||||
$arraygadai = array();
|
||||
$arraycawangan = array();
|
||||
// dd($transactionOnline);
|
||||
foreach($transactionOnline as $index1=>$trans)
|
||||
{
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $trans['kodcaw'])->json();
|
||||
$cawangan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/detail/'. $trans['kodcaw'])->json();
|
||||
$cawangan_detail = $cawangan[0];
|
||||
$nama_cawangan = $cawangan_info['details_caw'];
|
||||
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/gadai/norujukan/'.$trans['norujukan'])->json();
|
||||
$gadai = $gadai[0][0];
|
||||
public function SenaraiPembayaran()
|
||||
{
|
||||
$api_url = config('api.url');
|
||||
|
||||
array_push($arraygadai,$gadai);
|
||||
array_push($arraycawangan,$cawangan_detail);
|
||||
$arraysag = [];
|
||||
|
||||
$auth_user = Auth::user();
|
||||
|
||||
}
|
||||
$belum_tebus = Http::arrahn()
|
||||
->get('/api/customers/' . $auth_user['icno'] . '/gadai/' . 'belum_tebus')
|
||||
->json();
|
||||
|
||||
// dd($arraygadai,$arraycawangan);
|
||||
if (is_array($belum_tebus)) {
|
||||
if (sizeof($belum_tebus) > 0) {
|
||||
foreach ($belum_tebus as $index => $bt) {
|
||||
foreach ($bt as $index1 => $bet) {
|
||||
array_push($arraysag, $bet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// return view('pembayaran.result.berjaya',compact('transactionOnline','arraycawangan','arraygadai'));
|
||||
return view('pembayaran.result.berjayaportal',compact('transactionOnline','arraycawangan','arraygadai'));
|
||||
}
|
||||
$belum_tebus = $arraysag;
|
||||
|
||||
public function failedPayment(){
|
||||
// return view('pembayaran.result.gagal');
|
||||
return view('pembayaran.result.gagalportal');
|
||||
}
|
||||
return view('includes.bayaran.senaraibayaransag', compact('belum_tebus', 'api_url'));
|
||||
}
|
||||
|
||||
private function setUpahTawarruq($pembiayaan)
|
||||
{
|
||||
$getJenisKeuntungan = function ($x) {
|
||||
$jenisKeuntungan = [
|
||||
'1' => 'onepercent',
|
||||
'0' => 'asal',
|
||||
];
|
||||
|
||||
return $jenisKeuntungan[$x['tagbaru']];
|
||||
};
|
||||
|
||||
$getUpahTawarruqPerPembiayaan = function ($x) use ($getJenisKeuntungan) {
|
||||
$jenisKeuntungan = $getJenisKeuntungan($x);
|
||||
$upahTawarruq = Http::arrahn()
|
||||
->get('/api/upahtawarruq/' . $x['kodcaw'] . '/' . $x['norujukan'], ['jeniskeuntungan' => $jenisKeuntungan])
|
||||
->json();
|
||||
|
||||
if ($jenisKeuntungan == 'onepercent') {
|
||||
$x['upah_tawarruq'] = $upahTawarruq['keuntungan'] + $upahTawarruq['ujrah'];
|
||||
}
|
||||
|
||||
if ($jenisKeuntungan == 'asal') {
|
||||
$x['upah_tawarruq'] = $upahTawarruq;
|
||||
}
|
||||
|
||||
return $x;
|
||||
};
|
||||
|
||||
return array_map($getUpahTawarruqPerPembiayaan, $pembiayaan);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\BillplzService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class BillplzTransactionReviewController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request, BillplzService $billplzService)
|
||||
{
|
||||
$date = $request->date ?? Carbon::now()->toDateString();
|
||||
|
||||
$billplzTransactionReview = $billplzService->getBillplzTransactionReview($date);
|
||||
|
||||
return response()->json($billplzTransactionReview, 200);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
use App\Services\PembiayaanService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
private $pembiayaanService;
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(PembiayaanService $pembiayaanService)
|
||||
{
|
||||
$this->middleware(['auth','verified']);
|
||||
$this->pembiayaanService = $pembiayaanService;
|
||||
$this->middleware(['auth', 'verified']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -21,67 +26,30 @@ class HomeController extends Controller
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index()
|
||||
public function index(Request $request)
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
// $harga_emas = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/harga_emas/')->json();
|
||||
$pembiayaan = $this->pembiayaanService->getPembiayaan($request->filter);
|
||||
|
||||
// $hargaemasterdahulu = array();
|
||||
$authUser = Auth::user();
|
||||
$customerInfo = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get(config('api.url') . '/portal/customer/info', ['ic' => $authUser['icno']])
|
||||
->json();
|
||||
|
||||
// foreach($harga_emas as $index=>$harga)
|
||||
// {
|
||||
// $hargaemassandaran = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/harga_emas/rekod/sandaran',['karat' => $harga['karat']])->json();
|
||||
['gadai' => $customer_gadai, 'lelong' => $customer_lelong] = $customerInfo;
|
||||
|
||||
// only get lelong that is harga jualan that is not null or 0
|
||||
$customer_lelong = array_filter($customer_lelong, fn($x) => $x['hargajualan'] != null && $x['hargajualan'] != 0);
|
||||
|
||||
// $percentnaik = (floatval($harga['harga']) - floatval($hargaemassandaran[1]['harga'])) / ($hargaemassandaran[1]['harga']) * 100;
|
||||
$formatMoney = fn($x) => number_format($x, 2);
|
||||
$getTotal = fn($x) => array_reduce($x, fn($accumulator, $current_item) => $accumulator + $current_item['bakipjm'], 0);
|
||||
$total = $formatMoney($getTotal($customer_gadai));
|
||||
|
||||
// array_push($hargaemasterdahulu,['karat' => $harga['karat'],'hargasemasa' => $harga['harga'], 'hargadahulu' => $hargaemassandaran[1]['harga'],'percent' => $percentnaik]);
|
||||
$sixMonths = sizeOf(array_filter($customer_gadai, fn($x) => $x['tempoh'] >= 6));
|
||||
|
||||
// }
|
||||
$bilanganLelong = sizeOf($customer_lelong);
|
||||
|
||||
$CustomerInfo = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/portal/customer/info',['ic' => $auth_user['icno']]);
|
||||
//dd($CustomerInfo)
|
||||
$bilangan = sizeof($customer_gadai) + sizeOf($customer_lelong);
|
||||
|
||||
$total = 0.00;
|
||||
$sixmonths = 0;
|
||||
$bilangan = 0;
|
||||
foreach($CustomerInfo['gadai'] as $index=>$gadai)
|
||||
{
|
||||
$bilangan++;
|
||||
$total += $gadai['bakipjm'];
|
||||
|
||||
if($gadai['tempoh'] >= 6)
|
||||
{
|
||||
$sixmonths++;
|
||||
}
|
||||
}
|
||||
|
||||
$bilanganlelong = 0;
|
||||
foreach($CustomerInfo['lelong'] as $index1=>$lelong)
|
||||
{
|
||||
$bilangan++;
|
||||
$bilanganlelong += 1;
|
||||
}
|
||||
|
||||
// $arraysag = [];
|
||||
// $belum_tebus = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/customers/'. $auth_user['icno'] . '/gadai/' . 'belum_tebus')->json();
|
||||
|
||||
// if(is_array($belum_tebus))
|
||||
// {
|
||||
// if(sizeof($belum_tebus) > 0)
|
||||
// {
|
||||
// foreach($belum_tebus as $index=>$bt)
|
||||
// {
|
||||
// foreach($bt as $index1=>$bet)
|
||||
// {
|
||||
// array_push($arraysag,$bet);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// $belum_tebus = $arraysag;
|
||||
$api_url = config('api.url');
|
||||
|
||||
return view('includes.home',compact('api_url','bilangan','sixmonths','total','bilanganlelong'));
|
||||
return view('includes.home', compact('bilangan', 'sixMonths', 'total', 'bilanganLelong', 'pembiayaan'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,11 @@ class InformationController extends Controller
|
||||
if(isset($CustomerInfo['lelong'])){
|
||||
if(sizeof($CustomerInfo['lelong']) > 0){
|
||||
foreach($CustomerInfo['lelong'] as $index=>$lelong){
|
||||
// $array_lelong = Http::withOptions(['verify' => config('app.api_verify')])->get('https://adminbid.arrahn.com.my/api/portalApi',['norujukan' => $lelong['norujukan']])->json();
|
||||
$array_lelong = Http::withOptions(['verify' => config('app.api_verify')])->get('https://niklah.arrahn.com.my/api/portalApi',['norujukan' => $lelong['norujukan']])->json();
|
||||
$array_lelong = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api-lelong.url') . '/api/portalApi',['norujukan' => $lelong['norujukan']])->json();
|
||||
|
||||
if($array_lelong === null){
|
||||
continue;
|
||||
}
|
||||
|
||||
if($array_lelong['lelong'] !== null){
|
||||
$CustomerInfo['lelong'][$index] = collect($lelong)->merge($array_lelong['lelong'])->toArray();
|
||||
@@ -89,8 +92,12 @@ class InformationController extends Controller
|
||||
if(isset($CustomerInfo['lelong'])){
|
||||
if(sizeof($CustomerInfo['lelong']) > 0){
|
||||
foreach($CustomerInfo['lelong'] as $index=>$lel){
|
||||
$array_lelong = Http::withOptions(['verify' => config('app.api_verify')])->get('https://niklah.arrahn.com.my/api/portalApi',['norujukan' => $lel['norujukan']])->json();
|
||||
// $array_lelong = Http::withOptions(['verify' => config('app.api_verify')])->get('http://lelong.test/api/portalApi/',['norujukan' => $lel['norujukan']]);
|
||||
$array_lelong = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api-lelong.url') . '/api/portalApi',['norujukan' => $lel['norujukan']])->json();
|
||||
|
||||
if($array_lelong === null){
|
||||
continue;
|
||||
}
|
||||
|
||||
if($array_lelong['lelong'] !== null){
|
||||
$CustomerInfo['lelong'][$index] = collect($lel)->merge($array_lelong['lelong'])->toArray();
|
||||
}
|
||||
@@ -112,4 +119,3 @@ class InformationController extends Controller
|
||||
return view('auth.termasyarat', compact('termasyarat'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TransactionOnlineStatus extends Model
|
||||
{
|
||||
const BILL_CREATED = 1;
|
||||
const INITIALIZED_TRANSACTION = 2;
|
||||
const UPDATED_TAG_PORTAL = 3;
|
||||
const UPDATE_TRANSACTION_CALLBACK = 4;
|
||||
const UPDATE_TRANSACTION_REDIRECT = 5;
|
||||
const CRONJOB_UPDATE_TRANSACTION = 6;
|
||||
const CRONJOB_UPDATE_TRANSAKSI_KEUNTUNGAN = 7;
|
||||
const CRONJOB_UDPATE_GADAI = 8;
|
||||
const CRONJOB_REGISTER_AUDIT = 9;
|
||||
const CRONJOB_REGISTER_GLDETAIL = 10;
|
||||
const CRONJOB_UPDATE_TRANSAKSI_ONLINE_CRONJOB = 11;
|
||||
const UPDATE_UNSUCCESSFUL_TRANSACTION = 12;
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Http\Client\PendingRequest;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
@@ -23,6 +25,14 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
Http::macro('arrahn', function () {
|
||||
return Http::withOptions(['verify' => config('app.api_verify')])->baseUrl(config('api.url'));
|
||||
});
|
||||
|
||||
PendingRequest::macro('arrahn', function () {
|
||||
$this->options['verify'] = config('app.api_verify');
|
||||
$this->baseUrl(config('api.url'));
|
||||
return $this;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Illuminate\Http\Client\Pool;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class BayaranHistoryService
|
||||
{
|
||||
public $norujukanList;
|
||||
|
||||
public function __construct($norujukanList) {
|
||||
$this->norujukanList = $norujukanList;
|
||||
}
|
||||
|
||||
public function getBayaranHistory()
|
||||
{
|
||||
$getBayaranHistory = function () {
|
||||
return Http::pool(function (Pool $pool){
|
||||
foreach ($this->norujukanList as $norujukan) {
|
||||
$pool->get(config('api.url') . '/api/transaction/' . $norujukan);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$bayaranHistoryResponse = array_map(fn($x) => $x->json(), $getBayaranHistory());
|
||||
|
||||
$formatBayaranHistoryData = function ($x) {
|
||||
if (sizeof($x) === 0) {
|
||||
return $x;
|
||||
}
|
||||
|
||||
$formatDate = fn($x) => Carbon::parse($x)->format('d/m/Y');
|
||||
$setResitAnsuranLink = fn($x) => route("resit.ansuran", $x);
|
||||
|
||||
return array_map(function ($y) use ($formatDate, $setResitAnsuranLink) {
|
||||
$y['created_at'] = $formatDate($y['created_at']);
|
||||
$y['resit_ansuran_link'] = $setResitAnsuranLink($y['id']);
|
||||
return $y;
|
||||
}, $x);
|
||||
};
|
||||
|
||||
return array_map($formatBayaranHistoryData, $bayaranHistoryResponse);
|
||||
}
|
||||
|
||||
public static function from($norujukanList)
|
||||
{
|
||||
return new static($norujukanList);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\TransactionOnlineStatus;
|
||||
use Billplz\Client;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class BillplzService
|
||||
{
|
||||
public $client;
|
||||
public $config;
|
||||
public $callbackUrl;
|
||||
public $paymentTitle;
|
||||
public $redirectUrl;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$appEnvironment = config('app.env');
|
||||
$billplzConfig = $appEnvironment == 'production' ? config('services.billplz.production') : config('services.billplz.sandbox');
|
||||
|
||||
$client = Client::make($billplzConfig['api_key'], $billplzConfig['x_signature']);
|
||||
$client->useVersion('v4');
|
||||
|
||||
if ($appEnvironment != 'production') {
|
||||
$client->useSandbox();
|
||||
}
|
||||
|
||||
$this->callbackUrl = route('pay.callback');
|
||||
$this->redirectUrl = ['redirect_url' => route('pay.paymentStatus')];
|
||||
$this->paymentTitle = "Pembayaran Ansuran";
|
||||
$this->config = $billplzConfig;
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
public function getCollections()
|
||||
{
|
||||
return $this->client->collection()->all()->toArray();
|
||||
}
|
||||
|
||||
public function createBill(array $data)
|
||||
{
|
||||
$composed_data = [
|
||||
$this->config['collection_id'],
|
||||
...$data,
|
||||
$this->callbackUrl,
|
||||
$this->paymentTitle,
|
||||
$this->redirectUrl,
|
||||
];
|
||||
|
||||
|
||||
try{
|
||||
$response = $this->client->bill()->create(...$composed_data)->toArray();
|
||||
|
||||
OnlineTransactionLoggerService::logs($response['id'], $composed_data, $response, TransactionOnlineStatus::BILL_CREATED);
|
||||
|
||||
return $response;
|
||||
|
||||
} catch(\Exception $e){
|
||||
if($e->getCode() === 404){
|
||||
|
||||
$errorMessage = 'Please check your billplz payment gateway collection. Ensure that api_key, x_signature, and collection_id are correctly entered';
|
||||
|
||||
OnlineTransactionLoggerService::logs( null, $composed_data, $errorMessage, TransactionOnlineStatus::BILL_CREATED);
|
||||
|
||||
throw new \ErrorException($errorMessage);
|
||||
|
||||
} else {
|
||||
OnlineTransactionLoggerService::logs( null, $composed_data, $e->getMessage(), TransactionOnlineStatus::BILL_CREATED);
|
||||
};
|
||||
|
||||
throw $e;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function redirect($request)
|
||||
{
|
||||
try{
|
||||
|
||||
$response = $this->client->bill()->redirect($request);
|
||||
|
||||
OnlineTransactionLoggerService::logs($request['billplz']['id'], $request, $response, TransactionOnlineStatus::UPDATE_TRANSACTION_REDIRECT);
|
||||
|
||||
return $response;
|
||||
|
||||
} catch(\Exception $e){
|
||||
OnlineTransactionLoggerService::logs($request['billplz']['id'], $request, $e->getMessage(), TransactionOnlineStatus::UPDATE_TRANSACTION_REDIRECT);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function webhook($request)
|
||||
{
|
||||
try {
|
||||
$response = $this->client->webhook($request);
|
||||
|
||||
OnlineTransactionLoggerService::logs($request['billplz']['id'], $request, $response, TransactionOnlineStatus::UPDATE_TRANSACTION_CALLBACK);
|
||||
|
||||
return $response;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
OnlineTransactionLoggerService::logs($request['billplz']['id'], $request, $e->getMessage(), TransactionOnlineStatus::UPDATE_TRANSACTION_CALLBACK);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function getTransactions($date)
|
||||
{
|
||||
$arrahnTransactions = $this->getArrahnTransactions($date);
|
||||
$billplzID = collect($arrahnTransactions)->pluck('billplz_id')->unique()->values();
|
||||
|
||||
$billplzTransactions = collect($billplzID)->map(function ($billId) {
|
||||
return $this->client->transaction()->get($billId)->toArray();
|
||||
})
|
||||
->map(function ($data) {
|
||||
$latestTransaction = reset($data['transactions']) == false ? [] : reset($data['transactions']);
|
||||
$billId = ['bill_id' => $data['bill_id']];
|
||||
return array_merge($billId, $latestTransaction);
|
||||
})
|
||||
->keyBy('bill_id');
|
||||
|
||||
return $billplzTransactions;
|
||||
}
|
||||
|
||||
public function getArrahnTransactions($date)
|
||||
{
|
||||
return Http::arrahn()->get('/api/transaction/online/query', ['date' => $date])->json();
|
||||
}
|
||||
|
||||
public function getBillplzTransactionReview($date)
|
||||
{
|
||||
$date = Carbon::now()->toDateString();
|
||||
$arrahnTransactions = $this->getArrahnTransactions($date);
|
||||
|
||||
// sort array by tarikh desc and masa key desc
|
||||
array_multisort(array_column($arrahnTransactions, 'tarikh'), SORT_DESC, array_column($arrahnTransactions, 'masa'), SORT_DESC, $arrahnTransactions);
|
||||
|
||||
|
||||
$arrahnTransactionsGroupedByBill = collect($arrahnTransactions)->groupBy('billplz_id');
|
||||
$billplzID = $arrahnTransactionsGroupedByBill->keys();
|
||||
$billplzTransactions = $this->getTransactions($date);
|
||||
|
||||
$merged = $billplzID->map(function ($billId) use ($arrahnTransactionsGroupedByBill, $billplzTransactions) {
|
||||
return [
|
||||
'bill_id' => $billId,
|
||||
'arrahn_transactions' => $arrahnTransactionsGroupedByBill->get($billId)->toArray(),
|
||||
'billplz_latest_transaction' => $billplzTransactions->get($billId),
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
$summarizedBillplzTransactions = collect($merged)->map(function ($data) {
|
||||
$data['arrahn_transactions'] = collect($data['arrahn_transactions'])->map(function ($transaction) {
|
||||
return[
|
||||
'nokp' => $transaction['nokp'],
|
||||
'norujukan' => $transaction['norujukan'],
|
||||
'kodcaw' => $transaction['kodcaw'],
|
||||
'total_payment' => $transaction['total_payment'],
|
||||
'customer_name' => $transaction['customer_name'],
|
||||
'status' => $transaction['status'],
|
||||
'paid_at' => $transaction['paid_at'],
|
||||
'tarikh_attempt_bayar' => $transaction['tarikh'],
|
||||
'masa_attempt_bayar' => $transaction['masa'],
|
||||
'portal' => $transaction['tagportal'] == 1 ? 'Arrahn Pay' : 'SPARE',
|
||||
];
|
||||
});
|
||||
|
||||
return $data;
|
||||
});
|
||||
|
||||
return $summarizedBillplzTransactions;
|
||||
}
|
||||
|
||||
public function getTransactionByBillId($billId)
|
||||
{
|
||||
try {
|
||||
return $this->client->bill()->transaction($billId)->toArray();
|
||||
} catch (\Throwable $th) {
|
||||
logger()->error('Error when querying billplz id : ' . $billId);
|
||||
logger()->error($th->getMessage());
|
||||
throw $th;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class MarhunService
|
||||
{
|
||||
public $norujukanList;
|
||||
|
||||
public function __construct($norujukanList) {
|
||||
$this->norujukanList = $norujukanList;
|
||||
}
|
||||
|
||||
public function getMarhunDetails()
|
||||
{
|
||||
$getMarhunDetails = function ($x) {
|
||||
return Http::arrahn()->get('/api/marhun/' . $x)->json();
|
||||
};
|
||||
|
||||
$getMarhunTypeFullName = function ($code) {
|
||||
return Http::arrahn()->get('/api/jemas/nama_marhun', ['marhun' => $code['marhun']])->json()['descpt'];
|
||||
};
|
||||
|
||||
$formatMarhunDetailData = function ($x) use($getMarhunTypeFullName) {
|
||||
return array_map(function ($y) use ($getMarhunTypeFullName) {
|
||||
$y['marhun'] = $getMarhunTypeFullName($y);
|
||||
return $y;
|
||||
}, $x);
|
||||
};
|
||||
|
||||
$marhunDetailPipelines = [
|
||||
fn($x) => array_map($getMarhunDetails, $x),
|
||||
fn($x) => array_map(fn($y) => $x == null ? [] : $y, $x),
|
||||
fn($x) => array_map(fn($y) => array_merge([], ...$y), $x),
|
||||
fn($x) => array_map($formatMarhunDetailData, $x),
|
||||
];
|
||||
|
||||
return array_reduce($marhunDetailPipelines, fn($x, $y) => $y($x), $this->norujukanList);
|
||||
}
|
||||
|
||||
public static function from($norujukanList)
|
||||
{
|
||||
return new static($norujukanList);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class OnlineTransactionLoggerService
|
||||
{
|
||||
public static function logs($bill_id, $request, $response, $status)
|
||||
{
|
||||
try {
|
||||
Http::arrahn()->post('/api/transaction/online/log', [
|
||||
'bill_id' => $bill_id,
|
||||
'payload' => json_encode($request),
|
||||
'response' => json_encode($response),
|
||||
'status' => json_encode($status),
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
// Log the exception itself
|
||||
Log::error('Failed to log activity: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Http\Controllers\InformationController;
|
||||
use Illuminate\Http\Client\Pool;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class PembiayaanService
|
||||
{
|
||||
|
||||
public function getPembiayaan($filter)
|
||||
{
|
||||
$getPembiayaan = fn() => (new InformationController())->pembiayaanaktif()->getData();
|
||||
|
||||
if ($filter === 'pembiayaan-6-bulan') {
|
||||
$getPembiayaan = fn() => (new InformationController())->pembiayaanmelebihi6bulan()->getData();
|
||||
}
|
||||
|
||||
if ($filter === 'pembiayaan-akan-dilelong') {
|
||||
$getPembiayaan = fn() => (new InformationController())->pembiayaanakandilelong()->getData();
|
||||
}
|
||||
|
||||
$pembiayaan = array_filter($getPembiayaan(), fn($x) => $x->hargajualan != null || $x->hargajualan != 0);
|
||||
$pembiayaan = $this->setUpahTawarruq($pembiayaan);
|
||||
$pembiayaan = $this->formatPembiayaanData($pembiayaan);
|
||||
$pembiayaan = $this->attachMarhunModalData($pembiayaan);
|
||||
$pembiayaan = $this->checkPembiayaanPaymentDisabled($pembiayaan);
|
||||
|
||||
return $pembiayaan;
|
||||
}
|
||||
|
||||
private function setUpahTawarruq($pembiayaan)
|
||||
{
|
||||
$getJenisKeuntungan = function ($x) {
|
||||
|
||||
$jenisKeuntungan = [
|
||||
'1' => 'onepercent',
|
||||
'0' => 'asal',
|
||||
];
|
||||
|
||||
return $jenisKeuntungan[$x->tagbaru];
|
||||
};
|
||||
|
||||
$getUpahTawarruqPerPembiayaan = function ($x) use ($getJenisKeuntungan) {
|
||||
$jenisKeuntungan = $getJenisKeuntungan($x);
|
||||
$upahTawarruq = Http::arrahn()->get('/api/upahtawarruq/' . $x->kodcaw . '/' . $x->norujukan, ['jeniskeuntungan' => $jenisKeuntungan])->json();
|
||||
|
||||
if ($jenisKeuntungan == 'onepercent') {
|
||||
$x->upah_tawarruq = $upahTawarruq['keuntungan'] + $upahTawarruq['ujrah'];
|
||||
}
|
||||
|
||||
if ($jenisKeuntungan == 'asal') {
|
||||
$x->upah_tawarruq = $upahTawarruq;
|
||||
}
|
||||
|
||||
return $x;
|
||||
};
|
||||
|
||||
return array_map($getUpahTawarruqPerPembiayaan, $pembiayaan);
|
||||
}
|
||||
|
||||
private function formatPembiayaanData($pembiayaan)
|
||||
{
|
||||
$allCawangan = Http::arrahn()->get('/api/cawangan')->json();
|
||||
|
||||
$setCawanganFullName = function ($pembiayaan) use ($allCawangan) {
|
||||
$cawangan = array_filter($allCawangan, fn($x) => $x['kodcaw'] === $pembiayaan->kodcaw);
|
||||
$pembiayaan->cawangan_name = array_pop($cawangan)['details_caw'];
|
||||
return $pembiayaan;
|
||||
};
|
||||
|
||||
$setUpahTawarruqFormatted = function ($pembiayaan) {
|
||||
$pembiayaan->upah_tawarruq_formatted = number_format((float) $pembiayaan->upah_tawarruq, 2, '.', '');
|
||||
return $pembiayaan;
|
||||
};
|
||||
|
||||
$setTarikhAkhir = function ($pembiayaan) {
|
||||
$pembiayaan->tarikh_akhir = $pembiayaan->lelong_tawarruq != 0 ? '-' : Carbon::parse($pembiayaan->t_matang1)->format('d/m/Y');
|
||||
return $pembiayaan;
|
||||
};
|
||||
|
||||
$setTLelongFormatted = function ($pembiayaan) {
|
||||
$t_lelong = $pembiayaan->t_lelong;
|
||||
$isTLelongNotAvailable = $t_lelong == 0 || $t_lelong == '';
|
||||
|
||||
$pembiayaan->t_lelong_formatted = $isTLelongNotAvailable ? '-' : Carbon::parse($pembiayaan->t_lelong)->format('d/m/Y');
|
||||
|
||||
return $pembiayaan;
|
||||
};
|
||||
|
||||
$formatted = array_map(function ($x) use ($setCawanganFullName, $setUpahTawarruqFormatted, $setTarikhAkhir, $setTLelongFormatted) {
|
||||
$x = $setCawanganFullName($x);
|
||||
$x = $setUpahTawarruqFormatted($x);
|
||||
$x = $setTarikhAkhir($x);
|
||||
$x = $setTLelongFormatted($x);
|
||||
return $x;
|
||||
}, $pembiayaan);
|
||||
|
||||
return $formatted;
|
||||
}
|
||||
|
||||
private function attachMarhunModalData($pembiayaan)
|
||||
{
|
||||
$marhunModalData = $this->getMarhunModalData($pembiayaan);
|
||||
|
||||
return array_map(
|
||||
function ($x, $y) {
|
||||
$x->marhunModalData = $y;
|
||||
return $x;
|
||||
},
|
||||
$pembiayaan,
|
||||
$marhunModalData,
|
||||
);
|
||||
}
|
||||
|
||||
public function getMarhunModalData($pembiayaan)
|
||||
{
|
||||
$norujukanList = array_map(fn($x) => $x->norujukan, $pembiayaan);
|
||||
|
||||
$marhunDetails = MarhunService::from($norujukanList)->getMarhunDetails();
|
||||
|
||||
$bayaranHistoryDetails = BayaranHistoryService::from($norujukanList)->getBayaranHistory();
|
||||
|
||||
return array_map(
|
||||
fn($x, $y, $z) => [
|
||||
'nilaimarhun' => $x->nilaimarhun,
|
||||
'berat' => $x->berat,
|
||||
'bakiupah' => $x->bakiupah,
|
||||
'pinjaman' => $x->pinjaman,
|
||||
'bakipjm' => $x->bakipjm,
|
||||
'taglel' => $x->taglel,
|
||||
'marhun' => $x->marhun,
|
||||
'pinjaman' => $x->pinjaman,
|
||||
'norujukan' => $x->norujukan,
|
||||
'hargajualan' => $x->hargajualan,
|
||||
'kodcaw' => $x->kodcaw,
|
||||
'tempoh' => $x->tempoh,
|
||||
'cawangan_name' => $x->cawangan_name,
|
||||
'marhun_details' => $y,
|
||||
'bayaran_history' => $z,
|
||||
],
|
||||
$pembiayaan,
|
||||
$marhunDetails,
|
||||
$bayaranHistoryDetails,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
private function getNorujukanRecentlyAttemptPayment($norujukanList)
|
||||
{
|
||||
$getRecentlyAttemptPayment = function () use ($norujukanList) {
|
||||
return Http::pool(function (Pool $pool) use ($norujukanList) {
|
||||
foreach ($norujukanList as $norujukan) {
|
||||
$pool->get(config('api.url') . '/portal/searchsagonline/', ['norujukan' => $norujukan]);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$recentlyAttemptPaymentResponse = array_map(
|
||||
fn($x, $y) => ['norujukan' => $x, 'isRecentlyAttemptPayment' => $y->json()],
|
||||
$norujukanList,
|
||||
$getRecentlyAttemptPayment()
|
||||
);
|
||||
|
||||
$filterRecentlyAttemptPayment = array_filter(
|
||||
$recentlyAttemptPaymentResponse,
|
||||
fn($x) => $x['isRecentlyAttemptPayment'] === true
|
||||
);
|
||||
|
||||
return array_map(fn($x) => $x['norujukan'], $filterRecentlyAttemptPayment);
|
||||
|
||||
}
|
||||
|
||||
private function checkPembiayaanPaymentDisabled($pembiayaan)
|
||||
{
|
||||
$norujukanList = array_map(fn($x) => $x->norujukan, $pembiayaan);
|
||||
|
||||
$norujukanRecentlyAttemptPayment = $this->getNorujukanRecentlyAttemptPayment($norujukanList);
|
||||
|
||||
$getPembiayaanAkanDilelong = fn() => (new InformationController())->pembiayaanakandilelong()->getData();
|
||||
|
||||
$isCurrentDateGreaterThanEqual3DaysBeforeLelong = function ($x) {
|
||||
$tarikhLelong = Carbon::parse($x->t_lelong);
|
||||
$currentDate = Carbon::now();
|
||||
|
||||
if ($currentDate->gte($tarikhLelong->subDays(3))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
$pembiayaanAkanDilelong = array_filter($getPembiayaanAkanDilelong(), $isCurrentDateGreaterThanEqual3DaysBeforeLelong);
|
||||
|
||||
$norujukanAkanDilelong = array_map(fn($x) => $x->norujukan, $pembiayaanAkanDilelong);
|
||||
|
||||
$setDefaultFasaIfNotAvailable = function ($x) {
|
||||
if (!isset($x->fasa)) {
|
||||
$x->fasa = 1;
|
||||
}
|
||||
return $x;
|
||||
};
|
||||
|
||||
$pembiayaanWithFasa = array_map($setDefaultFasaIfNotAvailable, $getPembiayaanAkanDilelong());
|
||||
$pembiayaanInFasa2 = array_filter($pembiayaanWithFasa, fn($x) => $x->fasa == 2);
|
||||
$norujukanInFasa2 = array_map(fn($x) => $x->norujukan, $pembiayaanInFasa2);
|
||||
|
||||
$getPayableUjrahBranches = fn() => Http::arrahn()->get('/api/payable-ujrah-branches')->json();
|
||||
$branchesNotPermitPaymentUjrah = array_filter($getPayableUjrahBranches(), fn($x) => $x['gadaian_ujrah_payable'] == 0);
|
||||
$kodCawanganBranchesNotPermitPaymentUjrah = array_map(fn($x) => $x['kodcaw'], $branchesNotPermitPaymentUjrah);
|
||||
|
||||
$isNorujukanPaymentRecentlyAttempted = function ($x) use ($norujukanRecentlyAttemptPayment) {
|
||||
return in_array($x->norujukan, $norujukanRecentlyAttemptPayment);
|
||||
};
|
||||
|
||||
$isNorujukanAkanDilelong = function ($x) use ($norujukanAkanDilelong) {
|
||||
return in_array($x->norujukan, $norujukanAkanDilelong);
|
||||
};
|
||||
|
||||
$isNorujukanUjrah = function ($x) {
|
||||
return $x->tagbaru === 1 ? true : false;
|
||||
};
|
||||
|
||||
$isNorujukanIsInFasa2 = function ($x) use ($norujukanInFasa2) {
|
||||
return in_array($x->norujukan, $norujukanInFasa2);
|
||||
};
|
||||
|
||||
$isCawanganNotPermitUjrahPayment = function ($x) use ($kodCawanganBranchesNotPermitPaymentUjrah, $isNorujukanUjrah) {
|
||||
|
||||
if ($isNorujukanUjrah($x)) {
|
||||
return in_array($x->kodcaw, $kodCawanganBranchesNotPermitPaymentUjrah);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
return array_map(function ($x) use ($isNorujukanPaymentRecentlyAttempted, $isNorujukanAkanDilelong, $isNorujukanIsInFasa2, $isCawanganNotPermitUjrahPayment) {
|
||||
|
||||
$x->disabled_payment = false;
|
||||
|
||||
if (
|
||||
$isNorujukanAkanDilelong($x)
|
||||
|| $isNorujukanIsInFasa2($x)
|
||||
|| $isNorujukanPaymentRecentlyAttempted($x)
|
||||
|| $isCawanganNotPermitUjrahPayment($x)
|
||||
) {
|
||||
$x->disabled_payment = true;
|
||||
}
|
||||
|
||||
return $x;
|
||||
|
||||
}, $pembiayaan);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+11
-4
@@ -8,13 +8,17 @@
|
||||
"php": "^7.3|^8.0",
|
||||
"fideloper/proxy": "^4.4",
|
||||
"fruitcake/laravel-cors": "^2.0",
|
||||
"guzzlehttp/guzzle": "^6.3",
|
||||
"jomweb/billplz": "^1.0",
|
||||
"guzzlehttp/guzzle": "^7.0.1",
|
||||
"guzzlehttp/psr7": "^2.6",
|
||||
"jomweb/billplz": "^4.3.1",
|
||||
"laravel-frontend-presets/argon": "^1.1",
|
||||
"laravel/framework": "^8.40",
|
||||
"laravel/tinker": "^2.5",
|
||||
"laravel/ui": "^3.3",
|
||||
"php-http/guzzle6-adapter": "^1.1",
|
||||
"php-http/discovery": "^1.19",
|
||||
"php-http/guzzle7-adapter": "^1.0",
|
||||
"php-http/message": "^1.16",
|
||||
"php-http/message-factory": "^1.1",
|
||||
"rap2hpoutre/laravel-log-viewer": "^2.2"
|
||||
},
|
||||
"require-dev": {
|
||||
@@ -58,7 +62,10 @@
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"php-http/discovery": true
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
|
||||
Generated
+1188
-747
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return [
|
||||
'url' => env('API_LELONG_URL', 'https://niklah.arrahn.com.my')
|
||||
];
|
||||
+14
-1
@@ -12,7 +12,7 @@ return [
|
||||
| location for this type of information, allowing packages to have
|
||||
| a conventional file to locate the various service credentials.
|
||||
|
|
||||
*/
|
||||
*/
|
||||
|
||||
'mailgun' => [
|
||||
'domain' => env('MAILGUN_DOMAIN'),
|
||||
@@ -30,4 +30,17 @@ return [
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
],
|
||||
|
||||
'billplz' => [
|
||||
'production' => [
|
||||
'api_key' => env('BILLPLZ_PRODUCTION_API_KEY', 'f3e82fe1-a422-4660-97f0-65cc59ff6c47'),
|
||||
'x_signature' => env('BILLPLZ_PRODUCTION_X_SIGNATURE', 'S-alZUbzmD2_TF3vmrRqgehQ'),
|
||||
'collection_id' => env('BILLPLZ_SANDBOX_COLLECTION_ID', '5aosv2dg'),
|
||||
],
|
||||
'sandbox' => [
|
||||
'api_key' => env('BILLPLZ_SANDBOX_API_KEY', 'abecfd0c-98d8-4635-abc2-2fcba8c60c11'),
|
||||
'x_signature' => env('BILLPLZ_SANDBOX_X_SIGNATURE', 'S-GWr7z03XjAhqPsFfu_H5nQ'),
|
||||
'collection_id' => env('BILLPLZ_PRODUCTION_COLLECTION_ID', 'z0r4kjhi'),
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
@props([
|
||||
'title' => '',
|
||||
'subtitle' => '',
|
||||
'icon' => '',
|
||||
'iconState' => 'info',
|
||||
'cardBackgroundState' => 'white',
|
||||
'link' => '#',
|
||||
])
|
||||
|
||||
<div class="col-xl-3 col-lg-6" >
|
||||
<div class="card card-stats mb-4 mb-xl-0 {{ 'bg-'.$cardBackgroundState}}">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h6 class="card-title text-uppercase mb-0 {{ $cardBackgroundState == 'white' ? 'text-muted' : 'text-white' }}">{{ $title }}</h6>
|
||||
<span class="h5 font-weight-bold mb-0 {{ $cardBackgroundState == 'white' ? 'text-black' : 'text-white' }}">{{ $subtitle }}</span>
|
||||
</div>
|
||||
<div class="col-auto text-center">
|
||||
<a href="{{ $link }}">
|
||||
<div class="icon icon-shape bg-{{ $iconState }} rounded-circle shadow text-center">
|
||||
<i class="{{ $icon }}"></i>
|
||||
</div>
|
||||
</a>
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,3 @@
|
||||
<div style="margin-bottom: 15px;" class="">
|
||||
{{ $slot }}
|
||||
</div>
|
||||
@@ -0,0 +1,7 @@
|
||||
@props([
|
||||
'content' => '',
|
||||
])
|
||||
|
||||
<div>
|
||||
<i class="text-danger" style="font-size:12px;">{{ $content }}</i><br>
|
||||
</div>
|
||||
@@ -85,8 +85,9 @@
|
||||
{{ $t_akhir }}
|
||||
</td>
|
||||
@php
|
||||
$upahtawarruq = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/upahtawarruq/'. $bayar['kodcaw'] . '/' . $bayar['norujukan'])->json();
|
||||
$upahtawarruq = $bayar['upah_tawarruq'];
|
||||
$upahtawarruq = floatval(str_replace(',','',$upahtawarruq));
|
||||
|
||||
$totalupahasal = $totalupahasal + $upahtawarruq;
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -30,6 +30,10 @@
|
||||
<!-- <link href="{{ asset('css/loader.css') }}" rel="stylesheet"> -->
|
||||
|
||||
<style>
|
||||
.bg-crimson {
|
||||
background-color: crimson;
|
||||
}
|
||||
|
||||
.portalloader {
|
||||
/* display: none;
|
||||
position: fixed;
|
||||
@@ -122,4 +126,4 @@
|
||||
// $(".portalloader").fadeOut(300);
|
||||
// // }, 300)
|
||||
// })
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<div class="table-responsive table-bordered table-hover">
|
||||
<table class="table align-items-center table-flush border" id="main-table" style="text-align: center; width: 100%">
|
||||
<thead class="thead-light bg-dark text-white text-center">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>No Rujukan</th>
|
||||
<th>T Lelong</th>
|
||||
<th class="hide-xs">Cawangan</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="list">
|
||||
@foreach ($pembiayaan as $data)
|
||||
<tr>
|
||||
<td>
|
||||
<input type="checkbox" name="chkboxsag[]" value="{{ $data->norujukan }}"
|
||||
id="sag-{{ $loop->iteration }}" data-norujukan="{{ $data->norujukan }}"
|
||||
{{ $data->disabled_payment ? 'disabled' : '' }} />
|
||||
</td>
|
||||
<td>
|
||||
<a href="#" class="marhun-detail-link">
|
||||
<span class="text-sm text-info"
|
||||
data-marhun-modal="{{ json_encode($data->marhunModalData) }}">{{ $data->norujukan }}</span>
|
||||
</a>
|
||||
</td>
|
||||
<td>{{ $data->t_lelong_formatted }}</td>
|
||||
<td class="hide-xs">{{ $data->cawangan_name }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
<i class="hide-xs text-success" style="font-size:12px;">"Swipe" ke kiri</i>
|
||||
</div>
|
||||
@@ -0,0 +1,36 @@
|
||||
<div class="table-responsive table-bordered table-hover">
|
||||
<table class="table align-items-center table-flush border" id="main-table" style="text-align: center; width: 100%">
|
||||
<thead class="thead-light bg-dark text-white text-center">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>No Rujukan</th>
|
||||
<th class="hide-xs">Tempoh</th>
|
||||
<th>T Akhir</th>
|
||||
<th>Keuntungan</th>
|
||||
<th class="hide-xs">Cawangan</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="list">
|
||||
@foreach ($pembiayaan as $data)
|
||||
<tr>
|
||||
<td>
|
||||
<input type="checkbox" name="chkboxsag[]" value="{{ $data->norujukan }}"
|
||||
id="sag-{{ $loop->iteration }}" data-norujukan="{{ $data->norujukan }}"
|
||||
{{ $data->disabled_payment ? 'disabled' : '' }} />
|
||||
</td>
|
||||
<td>
|
||||
<a href="#" class="marhun-detail-link">
|
||||
<span class="text-sm text-info"
|
||||
data-marhun-modal="{{ json_encode($data->marhunModalData) }}">{{ $data->norujukan }}</span>
|
||||
</a>
|
||||
</td>
|
||||
<td class="hide-xs">{{ $data->tempoh }}</td>
|
||||
<td>{{ $data->tarikh_akhir }}</td>
|
||||
<td>{{ $data->upah_tawarruq_formatted }}</td>
|
||||
<td class="hide-xs">{{ $data->cawangan_name }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
<i class="hide-xs text-success" style="font-size:12px;">"Swipe" ke kiri</i>
|
||||
</div>
|
||||
@@ -20,10 +20,11 @@
|
||||
</section>
|
||||
</div>
|
||||
@include('includes.main.footerwhite')
|
||||
@stack('additional_js_scripts')
|
||||
</body>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -9,15 +9,15 @@
|
||||
{{-- <h5 class="modal-title">Senarai Marhun</h5> --}}
|
||||
<ul class="nav nav-tabs nav-fill">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="pill" href="#home" role="tab" aria-controls="pills-marhun" aria-selected="true">Marhun</a>
|
||||
<a class="nav-link active" data-toggle="pill" href="#home" role="tab" aria-controls="pills-marhun" aria-selected="true">Marhun</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="pill" href="#rekod" role="tab" aria-controls="pills-rekod" aria-selected="false">Rekod Bayaran</a>
|
||||
<a class="nav-link" data-toggle="pill" href="#rekod" role="tab" aria-controls="pills-rekod" aria-selected="false">Rekod Bayaran</a>
|
||||
</li>
|
||||
<li class="show-xs nav-item test">
|
||||
<a class="show-xs nav-link" data-toggle="pill" href="#detail" role="tab" aria-controls="pills-detail" aria-selected="false">Detail SAG</a>
|
||||
<a class="show-xs nav-link" data-toggle="pill" href="#detail" role="tab" aria-controls="pills-detail" aria-selected="false">Detail SAG</a>
|
||||
</li>
|
||||
</ul>
|
||||
</ul>
|
||||
<!-- <button type="button" class="close" data-dismiss="modal">×</button> -->
|
||||
</div>
|
||||
|
||||
@@ -75,66 +75,84 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="p-2 rounded bg-warning text-center text-dark mb-2"><div class="inner"><b>Pembiayaan Asal: <span id="pembiayaan"></span></b></div></div>
|
||||
<div class="p-2 rounded bg-warning text-center text-dark mb-2">
|
||||
<div class="inner"><b>Pembiayaan Asal: <span id="pembiayaan"></span></b></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-6">
|
||||
<div class="p-2 rounded bg-warning text-center text-dark mb-2"><div class="inner"><b>Baki Pembiayaan: <span id="bpembiayaan"></span></b></div></div>
|
||||
<div class="p-2 rounded bg-warning text-center text-dark mb-2">
|
||||
<div class="inner"><b>Baki Pembiayaan: <span id="bpembiayaan"></span></b></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-6">
|
||||
<div class="p-2 rounded bg-warning text-center text-dark mb-2"><div class="inner"><b>Nilai Marhun: <span id="nm"></span></b></div></div>
|
||||
<div class="p-2 rounded bg-warning text-center text-dark mb-2">
|
||||
<div class="inner"><b>Nilai Marhun: <span id="nm"></span></b></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{{-- <div class="col-4">
|
||||
<div class="p-2 rounded bg-warning text-center text-dark mb-2"><div class="inner"><b>T.Matang: <span id="berat"></span></b></div></div>
|
||||
</div> --}}
|
||||
{{-- <div class="col-4">
|
||||
</div> --}}
|
||||
|
||||
|
||||
<div class="col-6">
|
||||
<div class="p-2 rounded bg-warning text-center text-dark mb-2"><div class="inner"><b>Keuntungan 6 bulan: <span id="koskeun"></span></b></div></div>
|
||||
<div class="p-2 rounded bg-warning text-center text-dark mb-2">
|
||||
<div class="inner"><b>Keuntungan 6 bulan: <span id="koskeun"></span></b></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- <div class="col-4">
|
||||
<div class="p-2 rounded bg-warning text-center text-dark mb-2"><div class="inner"><b>T.Lanjut: <span id="berat"></span></b></div></div>
|
||||
</div> --}}
|
||||
</div>
|
||||
|
||||
<div style="overflow-x: auto;">
|
||||
</div>
|
||||
|
||||
<div style="overflow-x: auto;">
|
||||
<table id="tablehistorybayaran" class="table table-striped table-bordered text-center">
|
||||
<thead class="bg-dark text-white">
|
||||
<tr>
|
||||
<th>Bil</th>
|
||||
<th>Tarikh</th>
|
||||
<th>Bayaran</th>
|
||||
<!-- <th>Tindakan</th> -->
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
<thead class="bg-dark text-white">
|
||||
<tr>
|
||||
<th>Bil</th>
|
||||
<th>Tarikh</th>
|
||||
<th>Bayaran</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- <p style="font-size: 12px;"><i>*Dengan bayaran serendah jumlah keuntungan <span class="text-danger font-weight-bold">6 bulan</span>, anda layak mendapat lanjutan tempoh selama <span class="text-danger font-weight-bold">6 bulan</span> lagi.</i></p> -->
|
||||
</div>
|
||||
<!-- <p style="font-size: 12px;"><i>*Dengan bayaran serendah jumlah keuntungan <span class="text-danger font-weight-bold">6 bulan</span>, anda layak mendapat lanjutan tempoh selama <span class="text-danger font-weight-bold">6 bulan</span> lagi.</i></p> -->
|
||||
|
||||
</div>
|
||||
|
||||
<div class="show-xs tab-pane fade " id="detail" role="tabpanel" aria-labelledby="detail-tab">
|
||||
|
||||
<div class="row show-xs">
|
||||
<div class="row show-xs">
|
||||
<div class="col-6">
|
||||
<div class="show-xs p-2 rounded bg-warning text-center text-dark mb-2"><div class="inner"><b>No Rujukan: <span id="norujukan"></span></b></div></div>
|
||||
<div class="show-xs p-2 rounded bg-warning text-center text-dark mb-2">
|
||||
<div class="inner"><b>No Rujukan: <span id="norujukan"></span></b></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-6">
|
||||
<div class="show-xs p-2 rounded bg-warning text-center text-dark mb-2"><div class="inner"><b>Tempoh: <span id="tempoh"></span></b></div></div>
|
||||
<div class="show-xs p-2 rounded bg-warning text-center text-dark mb-2">
|
||||
<div class="inner"><b>Tempoh: <span id="tempoh"></span></b></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-6">
|
||||
<div class="show-xs p-2 rounded bg-warning text-center text-dark mb-2"><div class="inner"><b>Cawangan: <span id="namacaw"></span></b></div></div>
|
||||
<div class="show-xs p-2 rounded bg-warning text-center text-dark mb-2">
|
||||
<div class="inner"><b>Cawangan: <span id="namacaw"></span></b></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -142,9 +160,83 @@
|
||||
|
||||
<!-- Modal footer -->
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Tutup</button>
|
||||
<button type="button" class="btn btn-secondary">Tutup</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('additional_js_scripts')
|
||||
<script>
|
||||
const showMarhunDetailModal = function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
const formatter = new Intl.NumberFormat('en-US', {
|
||||
minimumFractionDigits: 2
|
||||
});
|
||||
|
||||
let data = JSON.parse(event.target.dataset.marhunModal);
|
||||
|
||||
$('#pembiayaan').text('RM' + formatter.format(data.pinjaman));
|
||||
$('#bpembiayaan').text('RM' + formatter.format(data.bakipjm));
|
||||
$('#nm').text('RM' + formatter.format(data.nilaimarhun));
|
||||
$('#berat').text(data.berat + 'g');
|
||||
$('#koskeun').text('RM' + formatter.format(data.bakiupah));
|
||||
$('#norujukan').text(data.norujukan);
|
||||
$('#tempoh').text(data.tempoh);
|
||||
$('#namacaw').text(data.cawangan_name);
|
||||
$('#pemb').text('RM ' + data.pinjaman);
|
||||
$('#bpemb').text('RM ' + data.bakipjm);
|
||||
$('#statuslelong').text(data.taglel === 1 ? 'Akan Dilelong' : '-');
|
||||
$('#norujukan_modal').val(data.norujukan);
|
||||
$('#pinjaman_modal').val(data.pinjaman);
|
||||
$('#marhunModal').modal('show');
|
||||
|
||||
$('#tablehistorybayaran').DataTable().clear().destroy();
|
||||
let table_bayaran_history = $('#tablehistorybayaran').DataTable();
|
||||
|
||||
$('#biasa').DataTable().clear().destroy();
|
||||
let table_marhun = $('#biasa').DataTable();
|
||||
|
||||
data.bayaran_history.forEach((x, index) => {
|
||||
table_bayaran_history.row.add([
|
||||
index + 1,
|
||||
x.created_at,
|
||||
`RM ${x.duit_masuk} <a target='_blank' href="${x.resit_ansuran_link}" class='btn btn-info btn-sm'><span class='fas fa-print'></span></a>`,
|
||||
]).draw(false)
|
||||
});
|
||||
|
||||
data.marhun_details.forEach((x, index) => {
|
||||
table_marhun.row.add([
|
||||
index + 1,
|
||||
x.marhun,
|
||||
x.berat,
|
||||
x.karat,
|
||||
`RM ${formatter.format(x.n_marhun)}`,
|
||||
x.nota
|
||||
]).draw(false)
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
|
||||
$('#main-table').on('click', 'a.marhun-detail-link', function(e) {
|
||||
showMarhunDetailModal(e)
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
document.querySelector('#marhunModal .modal-footer button').addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
$('#marhunModal').modal('hide');
|
||||
});
|
||||
|
||||
document.querySelector('#marhunModal').addEventListener('hidden.bs.modal', function(e) {
|
||||
document.querySelector('#marhunModal .modal-header a[aria-controls="pills-marhun"]').click();
|
||||
});
|
||||
</script>')
|
||||
@endpush
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\BillplzTransactionReviewController;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
@@ -17,3 +18,5 @@ use Illuminate\Support\Facades\Route;
|
||||
Route::middleware('auth:api')->get('/user', function (Request $request) {
|
||||
return $request->user();
|
||||
});
|
||||
|
||||
Route::get('/billplz-transaction-review', BillplzTransactionReviewController::class)->name('billplz-transaction-review');
|
||||
|
||||
Reference in New Issue
Block a user