Merge branch 'faiqahzaman' of https://gitlab.com/azfararsyad/lelong into faiqahzaman

This commit is contained in:
faiqahzaman
2022-03-09 10:16:47 +08:00
8 changed files with 340 additions and 68 deletions
+195 -1
View File
@@ -163,7 +163,7 @@ class ApiController extends Controller
Money::MYR($total_bayaran),
route('pay.callback'),
'Bayaran Borang',
['redirect_url' => 'http://192.168.0.88:8003/api/pembayaran/response']
['redirect_url' => 'http://192.168.88:8003/api/pembayaran/response']
);
// dd($response);
$previous_siri = Resit::orderBy('id','desc')->first();
@@ -296,6 +296,200 @@ class ApiController extends Controller
$resit->paid_at = null;
$resit->save();
event(new PaymentNotify('UNSUCCESSFUL',$resit->user_id));
return response()->json([
'success' => false,
'resit' => $resit
]);
}
}
public function bidpayment(Request $request)
{
$arraycollection_id = array();
$http = new HttpMethodsClient(
new GuzzleHttpClient(),
new GuzzleMessageFactory()
);
$billplz = new Client($http, $this->api_key);
if(config('app.env') != 'production'){
$billplz->useSandbox();
}
$billplz->useVersion('v4');
$bill = $billplz->bill();
$current = Carbon::now();
$current = new Carbon();
$day = $current->day;
$month = $current->month;
$year = $current->format('y');
$total_bayaran = ($request->total)*100;
$collection_id = $this->collection_id;
$response = $bill->create(
$collection_id,
$request->email,
$request->notel,
$request->name,
Money::MYR($total_bayaran),
route('pay.bidcallback'),
'Bayaran Bidaan',
['redirect_url' => 'http://192.168.88:8003/api/pembayaran/bidresponse']
);
// dd($response);
$previous_siri = Resit::orderBy('id','desc')->first();
if($previous_siri){
$nosiri = $previous_siri->id + 1;
}else{
$nosiri = 1;
}
$billcode = $response->toArray();
// dd($billcode);
// $billcode['redirect_url'] = 'http://192.168.0.10:8003/api/pembayaran/response';
// dd($billcode);
$reference_no = 'LPKB' . $day . $month . $year . sprintf("%08d", $nosiri);
// $response2 = $bill->get($billcode['id']);
// dd($response2->toArray());
$resit = new Resit;
$resit->user_id = $request->user_id;
$resit->lelong_id = $request->lelong_id;
$resit->reference_no = $reference_no;
$resit->billplz_id = $billcode['id'];
$resit->resit_type = 3; //billplz resit for bid payment
$resit->total_payment = $request->total;
$resit->save();
return redirect($billcode['url'] . '?auto_submit=true');
// return view('pembayaran.result.berjaya',compact('arraybayaran'));
}
public function bidcallback(Request $request){
// dd('hye callback');
$http = new HttpMethodsClient(
new GuzzleHttpClient(),
new GuzzleMessageFactory()
);
$billplz = new Client($http, $this->api_key);
if(config('app.env') != 'production'){
$billplz->useSandbox();
}
$billplz->useVersion('v4');
$bill = $billplz->bill();
$data = $bill->webhook($request->toArray());
if($data['billplz']['paid'] == 'true'){
$resit = Resit::where('billplz_id','=',$data['billplz']['id'])->first();
$resit->status = 'PAID';
$resit->paid_at = $data['billplz']['paid_at'];
$resit->save();
$resitoriginal = Resit::where('user_id', $resit->user_id)
->where('lelong_id', $resit->lelong_id)
->where('resit_type', 2)
->first();
$payment = $resit->total_payment;
$resitoriginal->total_payment = $resitoriginal->total_payment + $payment;
$resitoriginal->save();
$payment = new Payment;
$payment->user_id = $resitoriginal->user_id;
$payment->lelong_id = $resitoriginal->lelong_id;
$payment->total_payment = $resit->total_payment;
$payment->resit_id = $resitoriginal->id;
$payment->status_payment_opt = 2; //bayar secara online 2
$payment->status = 1; //fee rm10 - 1
$payment->remark = 'BAYARAN ONLINCE';
$payment->save();
event(new PaymentNotify('PAID',$resitoriginal->user_id));
return response()->json([
'success' => true,
'resit' => $resitoriginal
]);
}else{
$resit = Resit::where('billplz_id','=',$data['billplz']['id'])->first();
$resit->status = 'UNSUCCESSFUL';
$resit->paid_at = null;
$resit->save();
event(new PaymentNotify('UNSUCCESSFUL',$resit->user_id));
return response()->json([
'success' => false,
'resit' => $resit
]);
}
}
public function bidresponse(Request $request){
// dd('hye response');
$http = new HttpMethodsClient(
new GuzzleHttpClient(),
new GuzzleMessageFactory()
);
$billplz = new Client($http, $this->api_key);
if(config('app.env') != 'production'){
$billplz->useSandbox();
}
$billplz->useVersion('v4');
$bill = $billplz->bill();
$req = $request->toArray();
$response = $bill->get($req['billplz']['id']);
$data = $response->toArray();
// dd($data);
if($data['paid'] == 'true'){
$resit = Resit::where('billplz_id','=',$data['id'])->first();
$resit->status = 'PAID';
$resit->paid_at = $data['paid_at'];
$resit->save();
$resitoriginal = Resit::where('user_id', $resit->user_id)
->where('lelong_id', $resit->lelong_id)
->where('resit_type', 2)
->first();
$resitoriginal->total_payment = $resitoriginal->total_payment + $resit->total_payment;
$resitoriginal->save();
$payment = new Payment;
$payment->user_id = $resitoriginal->user_id;
$payment->lelong_id = $resitoriginal->lelong_id;
$payment->total_payment = $resit->total_payment;
$payment->resit_id = $resitoriginal->id;
$payment->status_payment_opt = 2; //bayar secara online 2
$payment->status = 1; //fee rm10 - 1
$payment->remark = 'BAYARAN ONLINCE';
$payment->save();
event(new PaymentNotify('PAID',$resit->user_id));
return response()->json([
'success' => true,
'resit' => $resit
]);
}else{
$resit = Resit::where('billplz_id','=',$data['id'])->first();
$resit->status = 'UNSUCCESSFUL';
$resit->paid_at = null;
$resit->save();
event(new PaymentNotify('UNSUCCESSFUL',$resit->user_id));
return response()->json([
'success' => false,
@@ -474,6 +474,7 @@ class LelongController extends Controller
$previous_siri = Resit::orderBy('id','desc')->first();
$checkdata = Resit::where('user_id', $bidder->user_id)
->where('lelong_id', $id)
->where('resit_type', 2)
->first();
if(!$checkdata){
if($previous_siri){
@@ -180,4 +180,69 @@ class LelongMobileController extends Controller
return response()->json($lelong);
}
public function bidresult($user_id)
{
$sag = LelongBidder::join('lelongbid', 'lelongbidder.lelongbid_id', '=', 'lelongbid.id')
->join('lelong', 'lelongbid.lelong_id', '=', 'lelong.id')
->where('lelongbidder.user_id',$user_id)
// ->where('lelongbid.lelong_id',$lelong_id)
->where('lelongbidder.status_bidder',1)
->whereNull('lelongbidder.status_payment')
->select(
'lelongbid.lelong_id',
'lelongbidder.user_id',
'lelongbidder.lelongbid_id',
'lelongbidder.hargabida',
'lelongbidder.status_payment',
'lelongbid.norujukan'
)
->get();
// dd($sag);
$data = [];
$total_hargabida = $sag->sum('hargabida');
array_push($data,[
'sag'=> $sag,
'total_hargabida'=> $total_hargabida
]);
// dd($winner);
return response()->json($data);
}
public function updatebiditem(Request $request)
{
// dd($request->norujukan->toArray());
// foreach($request->norujukan as $norujukan)
// {
// dd($norujukan);
// }
$currentdate = Carbon::now();
$currentdate = $currentdate->toDateTimeString();
$lelongbid = LelongBid::whereIn('norujukan',$request->norujukan)
->where('lelong_id',$request->lelong_id)
->get();
foreach($lelongbid as $bid)
{
$lelongbidder = LelongBidder::where('lelongbid_id',$bid->id)->first();
$lelongbidder->status_payment =1;
$lelongbidder->save();
$lelongbid = LelongBid::where('id',$bid->id)->first();
$lelongbid->status_jual = 1;
$lelongbid->t_jual = $currentdate;
$lelongbid->hargajual = $lelongbidder->hargabida;
$lelongbid->save();
}
$response = [
'success' => "success",
'message' => "Bidaan berjaya dibayar"
];
return response()->json($response, 201);
}
}
@@ -179,6 +179,7 @@ class PaymentController extends Controller
$eachbidupdate->status_jual = 1;
$eachbidupdate->status_payment = '1';
$eachbidupdate->t_jual = $currentdate;
$eachbidupdate->hargajual = $eachbid->hargabida;
$eachbidupdate->save();
}
+11 -15
View File
@@ -560,7 +560,8 @@ class SimulasiController extends Controller
foreach($cawangansim as $cawsim)
{
$cawangan = Cawangan::where('id','=',$cawsim->caw_id)->first();
$databid = SimulasiBid::where('simulasi_id','=',$simulasi_id)->get();
$databid = SimulasiBid::where('simulasi_id','=',$simulasi_id)
->get();
@@ -638,23 +639,14 @@ class SimulasiController extends Controller
$total9K += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','9.0K')
->sum('berat');
}
array_push($arraycaw,[
'cawangan'=>$cawangan->caw_name,
't_lelong'=>$simulasi->tarikh_lelong,
'bil_marhun'=>sizeof($databid),
'berat'=>$berat,
'n_marhun'=>$nilai_marhun,
'pinjaman'=>$pinjaman,
'upah'=>0,
'hargaasas'=>$hargaasas,
'cajlelong'=>$cajlelong,
'rugilelong'=>$rugilelong,
'bakilelong'=>$bakilelong,
]);
$total_marhun = $total_marhun + sizeof($databid);
$total_berat = $total_berat + $berat;
@@ -665,6 +657,7 @@ class SimulasiController extends Controller
$total_cazlelong = $total_cazlelong + $cajlelong;
$total_rugilelong = $total_rugilelong + $rugilelong;
$total_bakilelong = $total_bakilelong + $bakilelong;
}
@@ -691,7 +684,10 @@ class SimulasiController extends Controller
'total14K',
'total9K',
'simkarat',
'simulasi_id'))->setPaper('a4', 'landscape');
'simulasi_id',
'databid',
'cawangan',
'bid'))->setPaper('a4', 'potrait');
return $pdf->download('Simulasi Keseluruhan.pdf');
+1 -1
View File
@@ -67,7 +67,7 @@ return [
|
*/
'timezone' => 'UTC',
'timezone' => 'Asia/Kuala_Lumpur',
/*
|--------------------------------------------------------------------------
+60 -51
View File
@@ -3,7 +3,7 @@
<style>
#sim {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size:10px;
font-size:8px;
border-collapse: collapse;
width: 100%;
}
@@ -11,7 +11,7 @@
#sim td {padding:3px 5px 3px 5px; padding-right:10px;}, #sim th {
border: 0px solid;
padding: 1px;
text-align: center;
text-align: left;
}
@@ -20,8 +20,8 @@
#sim tr:hover {}
#sim th {
text-align: center;
border: 1px solid;
text-align: left;
border: 0px solid;
table-layout:auto;
color: black;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
@@ -81,7 +81,7 @@ tr:nth-child(even) {
<br><br>
<table cellspacing="" cellpadding="5" text-align="left" border="1" height="25" align="left" id="sim">
<table cellspacing="" cellpadding="5" text-align="left" border="0" height="25" align="left" id="sim">
<thead>
<br>
<tr>
@@ -92,7 +92,7 @@ tr:nth-child(even) {
</thead>
</table>
<table cellspacing="" cellpadding="5" text-align="left" border="1" height="25" align="left" id="sim">
<table cellspacing="" cellpadding="5" text-align="left" border="0" height="25" align="left" id="sim">
<thead>
<tr>
<td>Rugi Lelong Keseluruhan: RM{{ number_format($total_rugilelong, 2, '.', ',') }}</td>
@@ -106,81 +106,87 @@ tr:nth-child(even) {
<br>
<br>
<table cellspacing="0" cellpadding="5" style="float:right;" border="1" width="100%" height="80" align="center" id="sim">
<table cellspacing="0" cellpadding="5" style="float:right;" border="0" width="100%" height="80" align="left" id="sim">
<thead>
<tr>
<th width="2%" align="center">No</th>
<th width="9%" align="center">Cawangan</th>
<th width="6%" align="center">Tarikh Lelong</th>
<th width="5%" align="center">Bil Marhun (Paket)</th>
<th width="5%" align="center">Berat(gm)</th>
<th width="9%" align="center">Nilai Marhun(RM)</th>
<th width="9%" align="center">Pembiayaan(RM)</th>
<th width="9%" align="center">Keuntungan(RM)</th>
<th width="9%" align="center">Harga Asas(RM)</th>
<th width="9%" align="center">Caj Lelong(RM)</th>
<th width="9%" align="center">Baki Lelong(RM)</th>
<th width="9%" align="center">Rugi Lelong(RM)</th>
<th width="2%" align="left">No</th>
<th width="9%" align="left">Cawangan</th>
<th width="6%" align="left">Tarikh Lelong</th>
<th width="5%" align="left">No Rujukan</th>
<th width="5%" align="left">Berat(gm)</th>
<th width="9%" align="left">Nilai Marhun(RM)</th>
<th width="9%" align="left">Pembiayaan(RM)</th>
<th width="9%" align="left">Keuntungan(RM)</th>
<th width="9%" align="left">Harga Asas(RM)</th>
<th width="9%" align="left">Caj Lelong(RM)</th>
<th width="9%" align="left">Baki/Rugi Lelong(RM)</th>
{{-- <th width="9%" align="left">Rugi Lelong(RM)</th> --}}
</tr>
</thead>
@foreach ($arraycaw as $index=>$caw)
@foreach ($databid as $index=>$caw)
<tr>
<td>{{$index+1}}</td>
<td>{{ $caw['cawangan'] }}</td>
<td>{{ $caw['t_lelong'] }}</td>
<td>{{ $caw['bil_marhun'] }}</td>
<td>{{ number_format($caw['berat'], 2, '.', ',') }}</td>
<td>{{ number_format($caw['n_marhun'], 2, '.', ',') }}</td>
<td>{{ number_format($caw['pinjaman'], 2, '.', ',') }}</td>
<td>{{ number_format($caw['upah'], 2, '.', ',') }}</td>
<td>{{ number_format($caw['hargaasas'], 2, '.', ',') }}</td>
<td>{{ number_format($caw['cajlelong'], 2, '.', ',') }}</td>
<td>{{ number_format($caw['bakilelong'], 2, '.', ',') }}</td>
<td>({{ number_format($caw['rugilelong'], 2, '.', ',') }})</td>
<td>{{ $cawangan['caw_name'] }}</td>
<td>{{ ($caw['t_lelong']) }}</td>
<td>{{ ($caw['norujukan']) }}</td>
<td>{{ ($caw['berat']) }}</td>
<td>{{ ($caw['nilaimarhun']) }}</td>
<td>{{ ($caw['pinjaman']) }}</td>
<td>{{ ($caw['upahsimpan']) }}</td>
<td>{{ ($caw['hargaasas']) }}</td>
<td>{{ ($caw['cajlelong']) }}</td>
<td>{{ ($caw['baki']) }}</td>
{{-- <td>{{ ($bid['bakilelong']) }}</td>
<td>{{ ($bid['rugilelong']) }}</td> --}}
</tr>
@endforeach
<tr>
<td colspan="3" align="left"><strong>Jumlah Keseluruhan</strong></td>
<td>{{ $total_marhun }}</td>
<td></td>
<td>{{ number_format($total_berat, 2, '.', ',') }}</td>
<td>{{ number_format($total_nmarhun, 2, '.', ',') }}</td>
<td>{{ number_format($total_pinjaman, 2, '.', ',') }}</td>
<td>{{ number_format($total_upah, 2, '.', ',') }}</td>
<td>{{ number_format($total_hargaasas, 2, '.', ',') }}</td>
<td>{{ number_format($total_cazlelong, 2, '.', ',') }}</td>
<td>{{ number_format($total_bakilelong, 2, '.', ',') }}</td>
<td>({{ number_format($total_rugilelong, 2, '.', ',') }})</td>
<td></td>
{{-- <td>{{ number_format($total_bakilelong, 2, '.', ',') }}</td>
<td>({{ number_format($total_rugilelong, 2, '.', ',') }})</td> --}}
</tr>
</table>
</table>
<br><br><br><br><br><br>
<table width="100%" border="0" id="sim">
<tr>
<td><h5>.</h5></td>
</tr>
<table cellspacing="0" cellpadding="2" style="float:right;" border="1" width="100%" height="80" align="right" id="sim">
<thead>
<tr>
<tr>
<th style="text-align:center;" colspan="10"><h3><b>JUMLAH BERAT MENGIKUT MUTU (KESELURUHAN)</b></h3></th>
</tr>
</thead>
<tr>
<td colspan="1" align="left"><strong>MUTU &nbsp;</strong></td>
<td colspan="1" align="center">24Kgb &nbsp;</td>
<td colspan="1" align="center">24K&nbsp;</td>
<td colspan="1" align="center">23K&nbsp;</td>
<td colspan="1" align="center">22K&nbsp;</td>
<td colspan="1" align="center">21K&nbsp;</td>
<td colspan="1" align="center">20K&nbsp;</td>
<td colspan="1" align="center">18K&nbsp;</td>
<td colspan="1" align="center">14K&nbsp;</td>
<td colspan="1" align="center">9K&nbsp;</td>
<td colspan="1" align="center">24Kgb</td>
<td colspan="1" align="center">24K</td>
<td colspan="1" align="center">23K</td>
<td colspan="1" align="center">22K</td>
<td colspan="1" align="center">21K</td>
<td colspan="1" align="center">20K</td>
<td colspan="1" align="center">18K</td>
<td colspan="1" align="center">14K</td>
<td colspan="1" align="center">9K</td>
</tr>
<tr>
<td colspan="1" align="left"><strong>BERAT(gm)</strong></td>
@@ -194,6 +200,9 @@ tr:nth-child(even) {
<td colspan="1" align="center">{{$total14K}}</td>
<td colspan="1" align="center">{{$total9K}}</td>
</tr>
</table>
</table>
</tbody>
+6
View File
@@ -35,6 +35,10 @@ Route::post('/feepayment', [ApiController::class, 'feepayment'])->name('feepaym
Route::get('/pembayaran/response', [ApiController::class, 'response'])->name('pay.paymentStatus');
Route::get('/pembayaran/backend', [ApiController::class, 'callback'])->name('pay.callback');
Route::post('/bidpayment', [ApiController::class, 'bidpayment'])->name('bidpayment');
Route::get('/pembayaran/bidresponse', [ApiController::class, 'bidresponse'])->name('pay.bidpaymentStatus');
Route::get('/pembayaran/bidbackend', [ApiController::class, 'bidbackend'])->name('pay.bidcallback');
//Protected routes
Route::group(['middleware' => ['auth:sanctum']], function () {
@@ -55,10 +59,12 @@ Route::group(['middleware' => ['auth:sanctum']], function () {
Route::get('/lelongDetails/today', [LelongMobileController::class, 'getlelongdetails']);
Route::get('/lelongDetails/cawangan', [LelongMobileController::class, 'searchLelByCaw']);
Route::get('/karat', [LelongMobileController::class, 'getListKarat']);
Route::get('/result/{user_id}', [LelongMobileController::class, 'bidresult']);
// Lelong => Bidder
Route::post('/bidder/biditem', [LelongMobileController::class, 'bidderSelectBidItem']);
Route::get('/bidder/listbiditem', [LelongMobileController::class, 'listBidItem']);
Route::post('/bidder/updatebiditem', [LelongMobileController::class, 'updatebiditem']);
});