update 14/6
This commit is contained in:
@@ -12,6 +12,8 @@ use App\Models\LelongBidder;
|
||||
use App\Models\LelongBidMarhun;
|
||||
use App\Models\Payment;
|
||||
use App\Models\User;
|
||||
use App\Models\File;
|
||||
use App\Models\FileResit;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
@@ -83,6 +85,7 @@ class PaymentController extends Controller
|
||||
foreach($payment_id as $id){
|
||||
$payment = Payment::where('id', $id->payment_id)
|
||||
->first();
|
||||
// dd($payment);
|
||||
|
||||
if($payment){
|
||||
$total_payment = $total_payment + $payment->total_payment;
|
||||
@@ -128,8 +131,20 @@ class PaymentController extends Controller
|
||||
'lelongbidder.status_payment'
|
||||
)
|
||||
->get();
|
||||
// dd($eachbid);
|
||||
|
||||
$getresit = FileResit::join('payment', 'fileresit.payment_id', '=', 'payment.id')
|
||||
->where('payment.lelong_id', $lelong_id)
|
||||
->where('payment.user_id', $user_id)
|
||||
->get()->toArray();
|
||||
|
||||
return view('pembayaran.SAGBidItem',compact('SAGBidItem', 'eachbid', 'lelong_id','user_id'));
|
||||
$array_resit = [];
|
||||
foreach($getresit as $index1=>$resit)
|
||||
{
|
||||
$getresit[$index1]['resit64'] = 'data:image/' . $resit['file_type'] . ';base64' . base64_encode($resit['filename']);
|
||||
}
|
||||
|
||||
return view('pembayaran.SAGBidItem',compact('SAGBidItem', 'eachbid', 'lelong_id','user_id', 'getresit'));
|
||||
}
|
||||
|
||||
public function paymentdenokaunter(Request $request){
|
||||
@@ -243,66 +258,112 @@ class PaymentController extends Controller
|
||||
public function banktransfer(Request $request)
|
||||
{
|
||||
// dd($request->all());
|
||||
//eachbid = lelongbid_id
|
||||
|
||||
$currentdate = Carbon::now();
|
||||
$currentdate = $currentdate->toDateTimeString();
|
||||
|
||||
$user = Auth::user();
|
||||
|
||||
// $totalcheck = implode(",", $request->checkboxdata);
|
||||
$bid_id = explode(",", $request->eachbid); //bid_id = lelongbid_id
|
||||
|
||||
$resit = Resit::where('lelong_id', $request->lelong_id)
|
||||
->where('user_id',$request->user_id)
|
||||
->where('resit_type', 2)
|
||||
$paymentexist = Payment::join('fileresit', 'payment.id', '=', 'fileresit.payment_id')
|
||||
->where('payment.lelong_id', $request->lelong_id)
|
||||
->where('payment.user_id', $request->user_id)
|
||||
->first();
|
||||
|
||||
$payment = new Payment;
|
||||
$payment->user_id = $request->user_id;
|
||||
$payment->lelong_id = $request->lelong_id;
|
||||
$payment->kodcaw = $user->kodcaw;
|
||||
$payment->status_payment_opt = 3;
|
||||
$payment->status = 2;
|
||||
$payment->remark = 'BAYARAN CDM';
|
||||
$payment->resit_id = $resit->id;
|
||||
$payment->total_payment = $request->total;
|
||||
$payment->diminta_pada = $currentdate;
|
||||
$payment->diminta_oleh = $user->id;
|
||||
$payment->save();
|
||||
|
||||
foreach($bid_id as $bid){
|
||||
if($paymentexist)
|
||||
{
|
||||
$getpayment = Payment::join('fileresit', 'payment.id', '=', 'fileresit.payment_id')
|
||||
->where('payment.lelong_id', $request->lelong_id)
|
||||
->where('payment.user_id', $request->user_id)
|
||||
->select('payment.id as payment_id',
|
||||
'payment.lelong_id',
|
||||
'payment.user_id',
|
||||
'fileresit.id as fileresit_id',
|
||||
'fileresit.file_type',
|
||||
'fileresit.filename'
|
||||
)
|
||||
->first();
|
||||
|
||||
$eachbid = LelongBidder::join('lelongbid', 'lelongbidder.lelongbid_id', '=', 'lelongbid.id')
|
||||
->join('users', 'lelongbidder.user_id', '=', 'users.id')
|
||||
->where('lelongbidder.lelongbid_id', $bid)
|
||||
->select('lelongbidder.hargabida',
|
||||
'lelongbid.hargaasas',
|
||||
'lelongbid.norujukan',
|
||||
'lelongbidder.lelongbid_id',
|
||||
'lelongbidder.id as lelongbidder_id',
|
||||
'lelongbid.lelong_id as lelong_id'
|
||||
)
|
||||
->first();
|
||||
$data = base64_encode($request->resit->get());
|
||||
$file_type = $request->resit->extension();
|
||||
|
||||
$updatepayment = FileResit::where('payment_id', $getpayment['payment_id'])
|
||||
->where('id', $getpayment['fileresit_id'])
|
||||
->first();
|
||||
$updatepayment->id;
|
||||
$updatepayment->user_id = $request->user_id;
|
||||
$updatepayment->payment_id = $updatepayment->payment_id;
|
||||
$updatepayment->file_type = $file_type;
|
||||
$updatepayment->filename = $data;
|
||||
$updatepayment->update();
|
||||
|
||||
return redirect()->route('pembayaran.kaunterpembayaran', $request->lelong_id)
|
||||
->with('success','Ubah Resit Berjaya, Tunggu Pengesahan Akaun');
|
||||
}
|
||||
else
|
||||
{
|
||||
$bid_id = $request->eachbid;
|
||||
$currentdate = Carbon::now();
|
||||
$currentdate = $currentdate->toDateTimeString();
|
||||
|
||||
$updatelelbidbidder = LelongBidder::where('lelongbid_id', $eachbid->lelongbid_id)
|
||||
->where('user_id',$request->user_id)
|
||||
->first();
|
||||
$updatelelbidbidder->status_payment = 1;
|
||||
$updatelelbidbidder->payment_id = $payment->id;
|
||||
$updatelelbidbidder->save();
|
||||
|
||||
$eachbidupdate = LelongBid::where('id',$bid)->first();
|
||||
$eachbidupdate->status_jual = 1;
|
||||
$eachbidupdate->status_payment = 2;
|
||||
$eachbidupdate->t_jual = $currentdate;
|
||||
$eachbidupdate->hargajual = $eachbid->hargabida;
|
||||
$eachbidupdate->save();
|
||||
$user = Auth::user();
|
||||
|
||||
// $imageName = time().'.'.$request->resit->extension();
|
||||
$data = base64_encode($request->resit->get());
|
||||
$file_type = $request->resit->extension();
|
||||
|
||||
$resit = Resit::where('lelong_id', $request->lelong_id)
|
||||
->where('user_id',$request->user_id)
|
||||
->where('resit_type', 2)
|
||||
->first();
|
||||
|
||||
$payment = new Payment;
|
||||
$payment->user_id = $request->user_id;
|
||||
$payment->lelong_id = $request->lelong_id;
|
||||
$payment->kodcaw = $user->kodcaw;
|
||||
$payment->status_payment_opt = 3;
|
||||
$payment->status = 2;
|
||||
$payment->remark = 'BAYARAN CDM';
|
||||
$payment->resit_id = $resit->id;
|
||||
$payment->total_payment = $request->total_payment;
|
||||
$payment->diminta_pada = $currentdate;
|
||||
$payment->diminta_oleh = $user->id;
|
||||
$payment->save();
|
||||
|
||||
$addfile = new FileResit;
|
||||
$addfile->user_id = $request->user_id;
|
||||
$addfile->payment_id = $payment->id;
|
||||
$addfile->file_type = $file_type;
|
||||
$addfile->filename = $data;
|
||||
$addfile->save();
|
||||
|
||||
foreach($bid_id as $bid)
|
||||
{
|
||||
$eachbid = LelongBidder::join('lelongbid', 'lelongbidder.lelongbid_id', '=', 'lelongbid.id')
|
||||
->join('users', 'lelongbidder.user_id', '=', 'users.id')
|
||||
->where('lelongbidder.lelongbid_id', $bid)
|
||||
->select('lelongbidder.hargabida',
|
||||
'lelongbid.hargaasas',
|
||||
'lelongbid.norujukan',
|
||||
'lelongbidder.lelongbid_id',
|
||||
'lelongbidder.id as lelongbidder_id',
|
||||
'lelongbid.lelong_id as lelong_id'
|
||||
)
|
||||
->first();
|
||||
|
||||
$updatelelbidbidder = LelongBidder::where('lelongbid_id', $eachbid->lelongbid_id)
|
||||
->where('user_id',$request->user_id)
|
||||
->first();
|
||||
$updatelelbidbidder->status_payment = 2;
|
||||
$updatelelbidbidder->payment_id = $payment->id;
|
||||
$updatelelbidbidder->save();
|
||||
|
||||
$eachbidupdate = LelongBid::where('id',$bid)->first();
|
||||
$eachbidupdate->hargajual = $eachbid->hargabida;
|
||||
$eachbidupdate->save();
|
||||
|
||||
}
|
||||
|
||||
|
||||
return redirect()->route('pembayaran.kaunterpembayaran', $request->lelong_id)
|
||||
->with('success','Menunggu Pengesahan Akaun');
|
||||
|
||||
}
|
||||
|
||||
|
||||
return redirect()->route('pembayaran.SenaraiLelongBayar')
|
||||
->with('success','Menunggu Pengesahan Account');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user