Merge branch 'amirah' of https://gitlab.com/azfararsyad/lelong into amirah
This commit is contained in:
@@ -90,12 +90,12 @@ class AccountController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
return view('account.sahsagonline', compact('senaraisag', 'user_id', 'lelong_id','total_payment'));
|
||||
return view('account.sahsagonline', compact('senaraisag', 'lelong_id', 'user_id', 'total_payment'));
|
||||
}
|
||||
|
||||
public function sahbayaronline($lelong_id, $user_id)
|
||||
public function sahbayaronline(Request $request)
|
||||
{
|
||||
|
||||
// dd($request->all());
|
||||
$currentdate = Carbon::now();
|
||||
$currentdate = $currentdate->toDateTimeString();
|
||||
|
||||
@@ -103,25 +103,26 @@ class AccountController extends Controller
|
||||
|
||||
$senaraisag = LelongBid::join('lelongbidder', 'lelongbid.id', '=', 'lelongbidder.lelongbid_id')
|
||||
->join('payment', 'lelongbid.id', '=', 'payment.lelongbid_id')
|
||||
->where('lelongbid.lelong_id', $lelong_id)
|
||||
->where('lelongbidder.user_id', $user_id)
|
||||
->where('lelongbid.lelong_id', $request->lelong_id)
|
||||
->where('lelongbidder.user_id', $request->user_id)
|
||||
->where('lelongbidder.status_bidder', 1)
|
||||
->where('payment.status_payment_opt', 2)
|
||||
->get();
|
||||
->get();
|
||||
|
||||
|
||||
$total_payment = 0;
|
||||
foreach($senaraisag as $sag)
|
||||
{
|
||||
$payment = Payment::where('lelong_id', $lelong_id)
|
||||
->where('user_id', $user_id)
|
||||
$payment = Payment::where('lelong_id', $request->lelong_id)
|
||||
->where('user_id', $request->user_id)
|
||||
->where('lelongbid_id',$sag->lelongbid_id)
|
||||
->first();
|
||||
|
||||
$payment->disahkan_oleh = $user->id;
|
||||
$payment->disahkan_pada = $currentdate;
|
||||
$payment->save();
|
||||
|
||||
$total_payment = $total_payment + $payment->total_payment;
|
||||
|
||||
$updatelelbidbidder = LelongBidder::where('lelongbid_id', $sag->lelongbid_id)
|
||||
->first();
|
||||
$updatelelbidbidder->status_payment = 1;
|
||||
@@ -133,14 +134,14 @@ class AccountController extends Controller
|
||||
$eachbid->save();
|
||||
|
||||
}
|
||||
|
||||
|
||||
$senaraisagallpayment = LelongBid::join('lelongbidder', 'lelongbid.id', '=', 'lelongbidder.lelongbid_id')
|
||||
->where('lelongbid.lelong_id', $lelong_id)
|
||||
->where('lelongbidder.user_id', $user_id)
|
||||
->where('lelongbid.lelong_id', $request->lelong_id)
|
||||
->where('lelongbidder.user_id', $request->user_id)
|
||||
->where('lelongbidder.status_bidder', 1)
|
||||
->get();
|
||||
// dd($senaraisagallpayment);
|
||||
$resit = Resit::where('id',$payment->resit_id)->first();
|
||||
|
||||
$resit = Resit::where('id', $payment->resit_id)->first();
|
||||
$resit->total_payment = $resit->total_payment + $total_payment;
|
||||
|
||||
if($resit->total_payment >= $senaraisagallpayment->sum('hargabida'))
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\notislelong;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use App\Models\User;
|
||||
|
||||
class MailController extends Controller {
|
||||
|
||||
public function sendEmail() {
|
||||
|
||||
$users = User::where('user_type', 2)
|
||||
->get();
|
||||
|
||||
foreach($users as $user)
|
||||
{
|
||||
$email = $user->email;
|
||||
|
||||
$mailData = [
|
||||
'title' => 'Notis Lelongan Gadaian',
|
||||
'url' => 'https://www.positronx.io' // show unpaid gadaian
|
||||
];
|
||||
|
||||
Mail::to($email)->send(new notislelong($mailData));
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Email has been sent.'
|
||||
], Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,6 @@ class NotisController extends Controller
|
||||
public function notislelong()
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
|
||||
|
||||
$lelongid = CawanganLelong::join('lelong','cawangan_lelong.lelong_id','=','lelong.id')
|
||||
->join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
||||
@@ -112,8 +110,6 @@ class NotisController extends Controller
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function listnotis(Request $request){
|
||||
|
||||
|
||||
@@ -155,9 +151,6 @@ class NotisController extends Controller
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -117,6 +117,7 @@ class PaymentController extends Controller
|
||||
|
||||
$resit = Resit::where('lelong_id', $request->lelong_id)
|
||||
->where('user_id',$request->user_id)
|
||||
->where('resit_type', 2)
|
||||
->first();
|
||||
|
||||
$total_hargabida = 0;
|
||||
@@ -170,6 +171,7 @@ class PaymentController extends Controller
|
||||
$eachbidupdate = LelongBid::where('id',$bid)->first();
|
||||
$eachbidupdate->status_jual = 1;
|
||||
$eachbidupdate->t_jual = $currentdate;
|
||||
$eachbidupdate->hargajual = $eachbid->hargabida;
|
||||
$eachbidupdate->save();
|
||||
|
||||
}
|
||||
|
||||
@@ -284,6 +284,7 @@ class SimulasiController extends Controller
|
||||
$simulasi = Simulasi::where('id','=',$id)->first();
|
||||
$cawangansim = CawanganSimulasi::where('simulasi_id','=',$id)->get();
|
||||
$simkarat = SimKarat::where('simulasi_id','=',$id)->get();
|
||||
$jeniskarat = JenisKarat::all();
|
||||
|
||||
$arraydata = [];
|
||||
$arraycaw = [];
|
||||
@@ -444,7 +445,8 @@ class SimulasiController extends Controller
|
||||
'total14K',
|
||||
'total9K',
|
||||
'simkarat',
|
||||
'simulasi_id'));
|
||||
'simulasi_id',
|
||||
'jeniskarat'));
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
@@ -461,6 +463,65 @@ class SimulasiController extends Controller
|
||||
|
||||
}
|
||||
|
||||
public function kemaskini(Request $request)
|
||||
{
|
||||
$simkarat = SimKarat::where('simulasi_id','=',$request->idsimulasi)->get();
|
||||
|
||||
foreach($simkarat as $karat) //save old harga asas
|
||||
{
|
||||
$simkarat_temp = new SimKarat_temp;
|
||||
$simkarat_temp->simulasi_id = $request->idsimulasi;
|
||||
$simkarat_temp->karat = $karat->karat;
|
||||
$simkarat_temp->keterangan = $karat->keterangan;
|
||||
$simkarat_temp->harga = $karat->harga;
|
||||
$simkarat_temp->harga2 = $karat->harga2;
|
||||
$simkarat_temp->save();
|
||||
}
|
||||
foreach($simkarat as $index=>$karat) //update harga asas
|
||||
{
|
||||
$karat->karat = $karat->karat;
|
||||
$karat->keterangan = $karat->keterangan;
|
||||
$karat->harga = $request->harga[$index];
|
||||
$karat->harga2 = $request->harga2[$index];
|
||||
$karat->save();
|
||||
}
|
||||
|
||||
//update marhun
|
||||
$simulasibid = SimulasiBid::where('simulasi_id','=',$request->idsimulasi)->get();
|
||||
|
||||
foreach($simulasibid as $bid)
|
||||
{
|
||||
$sumhargaasas = 0;
|
||||
$simulasibidmarhun = SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)->get();
|
||||
foreach($simulasibidmarhun as $marhun)
|
||||
{
|
||||
$simkarat = SimKarat::where('simulasi_id','=',$bid->simulasi_id)->get();
|
||||
// dd($simkarat);
|
||||
foreach($simkarat as $karat)
|
||||
{
|
||||
|
||||
if($karat->karat == $marhun->karat)
|
||||
{
|
||||
$val = round($marhun->berat * $karat->harga);
|
||||
$sumhargaasas = $sumhargaasas + $val;
|
||||
|
||||
$marhun->harga = $karat->harga;
|
||||
$marhun->n_marhun = $marhun->berat * $karat->harga;
|
||||
$marhun->hargaasas = floatval(number_format($val,2));
|
||||
$marhun->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
$bid->hargaasas = $sumhargaasas;
|
||||
$bid->baki = $sumhargaasas-$bid->pinjaman - $bid->bakiupah - $bid->cajlelong;
|
||||
$bid->save();
|
||||
|
||||
}
|
||||
|
||||
return redirect()->route('analisa.senaraisimulasi',$request->idsimulasi)
|
||||
->with('success','Kemaskini Berjaya');
|
||||
}
|
||||
|
||||
|
||||
// PDF SIMULASI KESELURUHAN SEMUA CAWANGAN
|
||||
public function export(Request $request)
|
||||
|
||||
Reference in New Issue
Block a user