edit payment
This commit is contained in:
@@ -32,35 +32,58 @@ class AccountController extends Controller
|
||||
|
||||
public function listbayaranonline($lelong_id){
|
||||
|
||||
$listwinner = Payment::join('lelongbid', 'payment.lelongbid_id', '=', 'lelongbid.id')
|
||||
->join('lelongbidder', 'payment.lelongbidder_id', '=', 'lelongbidder.id')
|
||||
// $listwinner = Payment::join('lelongbid', 'payment.lelongbid_id', '=', 'lelongbid.id')
|
||||
// ->join('lelongbidder', 'payment.lelongbidder_id', '=', 'lelongbidder.id')
|
||||
// ->where('lelongbidder.status_bidder', 1)
|
||||
// ->where('lelongbid.lelong_id', $lelong_id)
|
||||
// ->select('payment.user_id'
|
||||
// )
|
||||
// ->groupBy('payment.user_id')
|
||||
// ->get();
|
||||
$listwinner = LelongBidder::join('lelongbid', 'lelongbidder.lelongbid_id', '=', 'lelongbid.id')
|
||||
->where('lelongbidder.status_bidder', 1)
|
||||
->where('lelongbid.lelong_id', $lelong_id)
|
||||
->select('payment.user_id'
|
||||
->select('.lelongbidder.user_id'
|
||||
)
|
||||
->groupBy('payment.user_id')
|
||||
->groupBy('lelongbidder.user_id')
|
||||
->get();
|
||||
|
||||
|
||||
foreach($listwinner as $index1=>$winner){
|
||||
|
||||
$userdetails = User::where('id', $winner['user_id'])->first();
|
||||
$SAGWin = Payment::join('lelongbid', 'payment.lelongbid_id', '=', 'lelongbid.id')
|
||||
->join('lelongbidder', 'payment.lelongbidder_id', '=', 'lelongbidder.id')
|
||||
->where('payment.user_id', $winner['user_id'])
|
||||
// $SAGWin = Payment::join('lelongbid', 'payment.lelongbid_id', '=', 'lelongbid.id')
|
||||
// ->join('lelongbidder', 'payment.lelongbidder_id', '=', 'lelongbidder.id')
|
||||
// ->where('payment.user_id', $winner['user_id'])
|
||||
// ->where('lelongbidder.status_bidder', 1)
|
||||
// ->where('lelongbid.lelong_id', $lelong_id)
|
||||
// ->get();
|
||||
|
||||
$SAGWin = LelongBidder::join('lelongbid', 'lelongbidder.lelongbid_id', '=', 'lelongbid.id')
|
||||
->where('lelongbidder.user_id', $winner['user_id'])
|
||||
->where('lelongbidder.status_bidder', 1)
|
||||
->where('lelongbid.lelong_id', $lelong_id)
|
||||
->get();
|
||||
// dd($SAGWin->sum('hargabida'));
|
||||
|
||||
|
||||
$id_payment = LelongBidder::join('lelongbid', 'lelongbidder.lelongbid_id', '=', 'lelongbid.id')
|
||||
->where('lelongbidder.user_id', $winner['user_id'])
|
||||
->where('lelongbidder.status_bidder', 1)
|
||||
->where('lelongbid.lelong_id', $lelong_id)
|
||||
->select('lelongbidder.payment_id')
|
||||
->groupBy('lelongbidder.payment_id')
|
||||
->get();
|
||||
|
||||
$total_payment = 0;
|
||||
foreach($SAGWin as $SAG){
|
||||
$payment = Payment::where('lelongbid_id', $SAG->lelongbid_id)
|
||||
foreach($id_payment as $id){
|
||||
$payment = Payment::where('id', $id->payment_id)
|
||||
->first();
|
||||
|
||||
if($payment){
|
||||
$total_payment = $total_payment + $payment->total_payment;
|
||||
}
|
||||
}
|
||||
|
||||
$listwinner[$index1]['details'] = $userdetails;
|
||||
$listwinner[$index1]['total_surat'] = sizeof($SAGWin);
|
||||
$listwinner[$index1]['totalBid'] = $SAGWin->sum('hargabida');
|
||||
@@ -74,8 +97,8 @@ class AccountController extends Controller
|
||||
|
||||
public function sahsagonline($lelong_id, $user_id)
|
||||
{
|
||||
$senaraisag = LelongBid::join('lelongbidder', 'lelongbid.id', '=', 'lelongbidder.lelongbid_id')
|
||||
->join('payment', 'lelongbid.id', '=', 'payment.lelongbid_id')
|
||||
$senaraisag = LelongBidder::join('lelongbid', 'lelongbidder.lelongbid_id', '=', 'lelongbid.id')
|
||||
->join('payment', 'lelongbidder.payment_id', '=', 'payment.id')
|
||||
->where('lelongbid.lelong_id', $lelong_id)
|
||||
->where('lelongbidder.user_id', $user_id)
|
||||
->where('lelongbidder.status_bidder', 1)
|
||||
@@ -101,23 +124,31 @@ class AccountController extends Controller
|
||||
|
||||
$user = Auth::user();
|
||||
|
||||
$senaraisag = LelongBid::join('lelongbidder', 'lelongbid.id', '=', 'lelongbidder.lelongbid_id')
|
||||
->join('payment', 'lelongbid.id', '=', 'payment.lelongbid_id')
|
||||
$senaraisag = LelongBidder::join('lelongbid', 'lelongbidder.lelongbid_id', '=', 'lelongbid.id')
|
||||
->join('payment', 'lelongbidder.payment_id', '=', 'payment.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)
|
||||
->select(
|
||||
'lelongbid.id as lelongbid_id',
|
||||
'payment.id as payment_id',
|
||||
'lelongbid.lelong_id',
|
||||
'lelongbidder.user_id',
|
||||
)
|
||||
->get();
|
||||
|
||||
|
||||
$total_payment = 0;
|
||||
foreach($senaraisag as $sag)
|
||||
{
|
||||
$payment = Payment::where('lelong_id', $request->lelong_id)
|
||||
->where('user_id', $request->user_id)
|
||||
->where('lelongbid_id',$sag->lelongbid_id)
|
||||
$payment = Payment::join('lelongbidder', 'payment.id', '=', 'lelongbidder.payment_id')
|
||||
->where('payment.lelong_id', $request->lelong_id)
|
||||
->where('payment.user_id', $request->user_id)
|
||||
// ->where('lelongbidder.lelongbid_id', $sag->lelongbid_id)
|
||||
->first();
|
||||
|
||||
// dd($payment);
|
||||
|
||||
$payment->disahkan_oleh = $user->id;
|
||||
$payment->disahkan_pada = $currentdate;
|
||||
$payment->save();
|
||||
|
||||
@@ -52,9 +52,16 @@ class PaymentController extends Controller
|
||||
->where('lelongbid.lelong_id', $lelong_id)
|
||||
->get();
|
||||
|
||||
|
||||
$payment_id = $$SAGWin = LelongBidder::join('lelongbid', 'lelongbidder.lelongbid_id', '=', 'lelongbid.id')
|
||||
->where('user_id', $winner['user_id'])
|
||||
->where('lelongbidder.status_bidder', 1)
|
||||
->where('lelongbid.lelong_id', $lelong_id)
|
||||
->select('payment_id')->groupBy('payment_id')->get();
|
||||
// dd($payment_id);
|
||||
$total_payment = 0;
|
||||
foreach($SAGWin as $SAG){
|
||||
$payment = Payment::where('lelongbid_id', $SAG->lelongbid_id)
|
||||
foreach($payment_id as $id){
|
||||
$payment = Payment::where('id', $id->payment_id)
|
||||
->first();
|
||||
|
||||
if($payment){
|
||||
@@ -121,6 +128,29 @@ class PaymentController extends Controller
|
||||
->first();
|
||||
|
||||
$total_hargabida = 0;
|
||||
$payment = Payment::create([
|
||||
'user_id' => $request->user_id,
|
||||
'lelong_id' => $request->lelong_id,
|
||||
'kodcaw' => $user->kodcaw,
|
||||
'status_payment_opt' => 1,
|
||||
'status' => 2,
|
||||
'remark' => 'BAYARAN DI KAUNTER',
|
||||
'resit_id' => $resit->id,
|
||||
'total_payment' => $request->amaunkiraan,
|
||||
'1sen' => $request->ambilansen1,
|
||||
'5sen' => $request->ambilansen5,
|
||||
'10sen' => $request->ambilansen10,
|
||||
'20sen' => $request->ambilansen20,
|
||||
'50sen' => $request->ambilansen50,
|
||||
'rm1' => $request->ambilanring1,
|
||||
'rm5' => $request->ambilanring5,
|
||||
'rm10' => $request->ambilanring10,
|
||||
'rm20' => $request->ambilanring20,
|
||||
'rm50' => $request->ambilanring50,
|
||||
'rm100' => $request->ambilanring100,
|
||||
'disahkan_oleh' => $user->id,
|
||||
'disahkan_pada' => $currentdate
|
||||
]);
|
||||
foreach($bid_id as $bid){
|
||||
|
||||
$eachbid = LelongBidder::join('lelongbid', 'lelongbidder.lelongbid_id', '=', 'lelongbid.id')
|
||||
@@ -137,39 +167,17 @@ class PaymentController extends Controller
|
||||
|
||||
$total_hargabida = $total_hargabida + $eachbid->hargabida;
|
||||
// dd($total_hargabida);
|
||||
$payment = Payment::create([
|
||||
'user_id' => $request->user_id,
|
||||
'lelongbidder_id' => $eachbid->lelongbidder_id,
|
||||
'lelongbid_id' => $bid,
|
||||
'lelong_id' => $eachbid->lelong_id,
|
||||
'kodcaw' => $user->kodcaw,
|
||||
'status_payment_opt' => 1,
|
||||
'status' => 2,
|
||||
'remark' => 'BAYARAN DI KAUNTER',
|
||||
'resit_id' => $resit->id,
|
||||
'total_payment' => $request->amaunkiraan,
|
||||
'1sen' => $request->ambilansen1,
|
||||
'5sen' => $request->ambilansen5,
|
||||
'10sen' => $request->ambilansen10,
|
||||
'20sen' => $request->ambilansen20,
|
||||
'50sen' => $request->ambilansen50,
|
||||
'rm1' => $request->ambilanring1,
|
||||
'rm5' => $request->ambilanring5,
|
||||
'rm10' => $request->ambilanring10,
|
||||
'rm20' => $request->ambilanring20,
|
||||
'rm50' => $request->ambilanring50,
|
||||
'rm100' => $request->ambilanring100,
|
||||
'disahkan_oleh' => $user->id,
|
||||
'disahkan_pada' => $currentdate
|
||||
]);
|
||||
|
||||
|
||||
$updatelelbidbidder = LelongBidder::where('lelongbid_id', $eachbid->lelongbid_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 = '1';
|
||||
$eachbidupdate->t_jual = $currentdate;
|
||||
$eachbidupdate->save();
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ class CreateLelongbidderTable extends Migration
|
||||
$table->decimal('nilaimarhun');
|
||||
$table->decimal('cajlelong');
|
||||
$table->integer('status_bidder')->nullable(); //1 = win
|
||||
$table->integer('payment_id')->nullable();
|
||||
$table->integer('status_payment')->nullable(); // 1=paid
|
||||
$table->datetime('masa_bidaan');
|
||||
$table->timestamps();
|
||||
|
||||
@@ -16,8 +16,6 @@ class CreatePaymentTable extends Migration
|
||||
Schema::create('payment', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->unsignedBigInteger('user_id')->unsigned();
|
||||
$table->unsignedBigInteger('lelongbidder_id')->unsigned()->nullable();
|
||||
$table->unsignedBigInteger('lelongbid_id')->unsigned()->nullable();
|
||||
$table->unsignedBigInteger('lelong_id')->unsigned();
|
||||
$table->string('kodcaw')->nullable();
|
||||
$table->string('back_acc_pembeli')->nullable();
|
||||
@@ -48,14 +46,6 @@ class CreatePaymentTable extends Migration
|
||||
->references('id')->on('users')
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign('lelongbid_id')
|
||||
->references('id')->on('lelongbid')
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign('lelongbidder_id')
|
||||
->references('id')->on('lelongbidder')
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign('lelong_id')
|
||||
->references('id')->on('lelong')
|
||||
->onDelete('cascade');
|
||||
|
||||
Reference in New Issue
Block a user