Untitled
raw download clone
TEXT
views 38
,
size 2376 b
public function konfirmasiAdmSupport($kdRtRwNet, Request $req){
      $imageupload          = new ImageAll();
      $saldoPelanggan       = $req->get('saldoPelanggan'); 
      $totalTagihanSubmit   = $req->get('totalTagihanSubmit'); 
      $kurang               = $req->get('kurang'); 
      $idPemesanan          = $req->get('idPemesanan'); 
      $metodePembayaran     = $req->get('metodePembayaran'); 
      $tanggalPembayaran    = $req->get('tanggalPembayaran'); 
      $nominalTransfer      = $req->get('nominalTransfer'); 
      $tipePengembalian     = $req->get('tipePengembalian'); 
      $namaSubnet           = DB::table('ms_rtrwnet')->where('kdRtRwNet','=',$kdRtRwNet)->first()->nama;      
      
      $fileBukti = $req->file('fileBuktiPembayaran');
      if ($fileBukti != null) {
        $filename = $imageupload->uploadFoto($fileBukti);        
      }else{
        $filename = '';
      }
      
      if($metodePembayaran == 'saldo'){
        if($kurang == 1){
          DB::table('ms_rtrwnet')->where('kdRtRwNet','=',$kdRtRwNet)->update(array('saldo'=>0));
          $this->updatePesanan($idPemesanan,$saldoPelanggan,$nominalTransfer,$filename);
        }else{
          $totalSaldo = $saldoPelanggan - $totalTagihanSubmit;
          DB::table('ms_rtrwnet')->where('kdRtRwNet',$kdRtRwNet)->update(array('saldo' => $totalSaldo));
          $this->updatePesanan($idPemesanan,$totalTagihanSubmit,0,$filename);
        }
      }
      
      if($metodePembayaran == 'transfer'){
        $this->updatePesanan($idPemesanan,0,$nominalTransfer,$filename);
      }

      $notif->sendSmsGateway($kdRtRwNet,"Pembayaran Administrasi Support "." sebesar Rp. ".number_format($totalTagihanSubmit,0,',','.')." oleh Subnet ".$namaSubnet." telah dilakukan.");
      $log->tambahLog($kdRtRwNet,Auth::user()->id,"Administrasi Support","Konfirmasi pembayaran Administrasi  sebesar RP. ".number_format($$totalTagihanSubmit,0,',','.'));
    }
    
    private function updatePesanan($idPemesanan,$saldoPelanggan,$nominalTransfer,$filename){
      $update = [
        'buktiTransfer'   => $filename,
        'nominalSaldo'    => $saldoPelanggan,
        'nominalTransfer' => $nominalTransfer,
        'status'          => '3'
      ];
      DB::table('ms_pemesanan')->where('kdPemesanan', $idPemesanan)->update($update);
      
    }
close fullscreen
Login or Register to edit or fork this paste. It's free.