init title lokasi, dan penambahan api
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\TransaksiParkir;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ParkingOperationController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$transaksi = $this->show($request->input('transaksi'))->getData();
|
||||
|
||||
// dd($transaksi)->status;
|
||||
// dd($transaksi->getData());
|
||||
Log::info(get_class($transaksi));
|
||||
dd(get_class($transaksi));
|
||||
// if ($transaksi->status === true && $transaksi->member === false) {
|
||||
// }
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$transaksi = TransaksiParkir::where('no_pol','LIKE', '%' .$id . '%')->first();
|
||||
|
||||
if (!$transaksi) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Kendaraan belum masuk atau transaksi tidak ditemukan'
|
||||
]);
|
||||
}
|
||||
|
||||
$isMember = $transaksi->status_transaksi == '3' ? true : false;
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'member' => $isMember,
|
||||
'data' => [
|
||||
'id' => $transaksi->id,
|
||||
'no_pol' => $transaksi->no_pol,
|
||||
'id_kendaraan' => $transaksi->id_mobil,
|
||||
'waktu_masuk' => $transaksi->waktu_masuk,
|
||||
'status' => $transaksi->status,
|
||||
'status_transaksi' => $transaksi->status_transaksi
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public function show($id)
|
||||
// } else (
|
||||
// $condition = where('no_pol', $id);
|
||||
// )
|
||||
// $vehicle = JenisMobil::all();
|
||||
// $vehicle = VehicleItem::all();
|
||||
// $data = TransaksiParkir::select('no_pol','waktu_masuk','waktu_keluar','jm.nama as vehicle','id_kendaraan','np.nama as gateIn', 'id_pintu_masuk','jm.nama as vehiclename')
|
||||
// ->leftJoin('jenis_mobil as jm', 'jm.id', '=', 'transaksi_parkir.id_kendaraan')
|
||||
// ->leftJoin('nama_pos as np', 'np.id', '=', 'transaksi_parkir.id_pintu_masuk')
|
||||
@@ -76,7 +76,7 @@ public function show($id)
|
||||
// ]);
|
||||
Log::info('ID: ' . $id);
|
||||
|
||||
$vehicle = JenisMobil::all();
|
||||
$vehicle = VehicleItem::all();
|
||||
|
||||
$query = TransaksiParkir::select(
|
||||
'no_pol',
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Http\Setup\Vehicle;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\VehicleItem;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class MasterVehicleController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$vehicle = VehicleItem::orderBy('id')->get();
|
||||
|
||||
// dd($vehicle);
|
||||
|
||||
return view ('setup.vehicle.vehicle', compact('vehicle'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Http\Setup\Vehicle;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\MasterTarif;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ModifiedVehiclepriceController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
// Log::info($id);
|
||||
$id = str($id);
|
||||
$vehicleRates = DB::table('tarif')->where('id_mobil', $id)->first();
|
||||
|
||||
Log::info(json_encode($vehicleRates));
|
||||
return $vehicleRates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
// Log::info($request->all());
|
||||
// $id = $request->id_mobil;
|
||||
|
||||
$dataQuery = MasterTarif::find($id);
|
||||
try {
|
||||
|
||||
Log::info($request->all());
|
||||
|
||||
$dataQuery->fill($request->all());
|
||||
|
||||
if (! $dataQuery->isDirty()) {
|
||||
// if($dataQuery->isDirty()) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Tidak ada perubahan data'
|
||||
]);
|
||||
// }
|
||||
|
||||
}
|
||||
Log::info('Data yang di simpan' . json_encode($dataQuery->getDirty()));
|
||||
$dataQuery->save();
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'message' => 'Data berhasil di ubah'
|
||||
]);
|
||||
} catch (\Throwable $th) {
|
||||
//throw $th;
|
||||
Log::info('Data yang di simpan' . json_encode($dataQuery->getDirty()));
|
||||
|
||||
// Log::info($request->all());
|
||||
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Gagal menyimpan data ' . $th->getMessage(),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class JenisMobil extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'jenis_mobil';
|
||||
|
||||
protected $casts = [
|
||||
'id' => 'string',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'nama','short_cut'
|
||||
];
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MasterTarif extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'tarif';
|
||||
protected $primaryKey = 'id_mobil'; // Primary key tabel
|
||||
public $timestamps = false;
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'id_mobil', 'tarif', 'tarif_interval','interval',
|
||||
'waktu_tarif', 'waktu_gratis', 'bayar_dimuka', 'denda','maksimum',
|
||||
'tanggal','tarif2','waktu2','tarif_period','max_per_hari',
|
||||
'min_per_hari','time_base','tarif_inap','batas_min_inap',
|
||||
'max_kena_charge','tarif_member','tarif_voucher','voucher_frek',
|
||||
'voucher_time','voucher_base','voucher_base_time','asuransi_incl',
|
||||
'denda_only_casual','frek_interval','frek_waktu2','free_for_validasi',
|
||||
'time_base_maks','free_pos_default','tarif_valet','start_time_member_charge',
|
||||
'stop_time_member_charge','min_time_tarif_member','type_tarif_member','tarif3',
|
||||
'waktu3','frek_waktu3','denda_member','valet_extra_time','extra_charge_value',
|
||||
'extra_charge_time','denda_only'
|
||||
];
|
||||
}
|
||||
@@ -26,6 +26,6 @@ public function stiker_details ()
|
||||
// Relasi ke tabel jenis_mobil
|
||||
public function vehicle()
|
||||
{
|
||||
return $this->belongsTo(JenisMobil::class, 'id', 'jenis_mobil');
|
||||
return $this->belongsTo(VehicleItem::class, 'id', 'jenis_mobil');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,19 @@
|
||||
|
||||
class VehicleItem extends Model
|
||||
{
|
||||
protected $connection = 'pgsql_second';
|
||||
// protected $connection = 'pgsql_second';
|
||||
protected $table = 'jenis_mobil';
|
||||
protected $primaryKey = 'id';
|
||||
public $timestamps = false;
|
||||
protected $keyType = 'string';
|
||||
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'id', 'nama', 'tanggal', 'short_cut', 'orang', 'validasi', 'need_access'
|
||||
];
|
||||
|
||||
public function VehiclePrice () {
|
||||
return $this->hasOne(MasterTarif::class, 'id', 'id_mobil');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Parking;
|
||||
|
||||
use App\Models\MasterTarif;
|
||||
use App\Models\VehicleItem;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class RateParkingService
|
||||
{
|
||||
public function calc ($transaksi, $times)
|
||||
{
|
||||
$duration = $times; ## Parse lama parkir berdasarkan detik
|
||||
$tarifVehicle = MasterTarif::find($transaksi);
|
||||
$parkingPrice = 0; //Tarif pertama
|
||||
Log::info("\n" . '------------------======== Starting tarif Begin ==============----------------------');
|
||||
Log::info('Mulai perhitungan tarif dengan durasi : ' . $duration .' (Rp. '. $parkingPrice .')');
|
||||
|
||||
// Grace Periode
|
||||
if ($duration < $tarifVehicle->waktu_gratis) {
|
||||
Log::info('GP Rules : ');
|
||||
return $parkingPrice;
|
||||
} else if ( $tarifVehicle->waktu_gratis !== 0 && $tarifVehicle->tarif_periode !== 0) {
|
||||
Log::info('GP Rules : ');
|
||||
$parkingPrice = $parkingPrice + $tarifVehicle->tarif_period;
|
||||
$duration = $duration - $tarifVehicle->waktu_gratis;
|
||||
Log::info('Setelah GP : ' . $parkingPrice . ' Durasi parkir : ' . $duration);
|
||||
}
|
||||
|
||||
## Hitung Tarif pertama
|
||||
$firstPrice = 0;
|
||||
$firstDuration = $tarifVehicle->frek_interval * ($tarifVehicle->interval * 60);
|
||||
Log::info('Firstime rules : ' . $firstDuration);
|
||||
// if ($duration >= $firstDuration) {
|
||||
do {
|
||||
$duration -= ($tarifVehicle->interval * 60);
|
||||
$parkingPrice += $tarifVehicle->tarif_interval;
|
||||
$firstPrice++;
|
||||
} while ($firstPrice < $tarifVehicle->frek_interval);
|
||||
Log::info('Tarif jam pertama : ' . $parkingPrice . ' Sisa durasi : ' . $duration);
|
||||
// }
|
||||
|
||||
// Log::info($firstDuration);
|
||||
## Hitung tarif kedua
|
||||
$secondPrice = 1;
|
||||
// Log::info($tarifVehicle->frek_waktu2 . ' - ' . $tarifVehicle->waktu2);
|
||||
$secondDuration = $tarifVehicle->frek_waktu2 * ($tarifVehicle->waktu2 * 60);
|
||||
if ($duration >= $secondDuration) {
|
||||
Log::info('');
|
||||
Log::info('Secondtime rules : ' . $secondDuration);
|
||||
do {
|
||||
$duration -= ($tarifVehicle->waktu2 * 60);
|
||||
$parkingPrice += $tarifVehicle->tarif_interval;
|
||||
$secondPrice++;
|
||||
} while ($secondPrice < $tarifVehicle->frek_waktu2);
|
||||
|
||||
Log::info('Tarif jam kedua : ' . $parkingPrice . ' Sisa durasi : ' . $duration);
|
||||
}
|
||||
|
||||
$nextDuration = 0;
|
||||
$lastDuration = $tarifVehicle->waktu_tarif * 60;
|
||||
if ($duration <= $lastDuration && $duration > 0) {
|
||||
Log::info('');
|
||||
Log::info('Sisa Durasi ' . $duration);
|
||||
do {
|
||||
$duration -= ($tarifVehicle->waktu_tarif * 60);
|
||||
$parkingPrice += $tarifVehicle->tarif;
|
||||
// $nextDuration++;
|
||||
} while ($duration > 0);
|
||||
Log::info('Tarif jam berikutnya : ' . $parkingPrice . ' Sisa durasi : ' . $duration);
|
||||
}
|
||||
|
||||
Log::info('Tarif Parkir Anda : ' . $parkingPrice . ' Sisa durasi : ' . $duration);
|
||||
|
||||
|
||||
// if ($tarifVehicle->time_base_maks == 1) {
|
||||
// if ($parkingPrice > $tarifVehicle->maksimum) {
|
||||
// $parkingPrice = $tarifVehicle->maksimum;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
return $parkingPrice;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user