Co-authored-by: ISMAIL MASSERAN <topaz@Mac.dlinkrouter.local> Reviewed-on: #3
This commit was merged in pull request #3.
This commit is contained in:
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\PembiayaanOnline\ModalOnlineService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ModalOnlineController extends Controller
|
||||
{
|
||||
protected $service;
|
||||
|
||||
public function __construct(ModalOnlineService $service = null)
|
||||
{
|
||||
$this->service = $service ?: new ModalOnlineService();
|
||||
}
|
||||
|
||||
protected function respond(array $result)
|
||||
{
|
||||
return response()->json($result['payload'], $result['status']);
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/modal-online/{kodcaw}
|
||||
* Read-only: does not create today's row.
|
||||
*/
|
||||
public function get($kodcaw)
|
||||
{
|
||||
return $this->respond($this->service->get($kodcaw));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Alias of get() — no longer auto-creates RM100k.
|
||||
*/
|
||||
public function getOrCreate($kodcaw)
|
||||
{
|
||||
return $this->get($kodcaw);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/modal-online/{kodcaw}/reserve
|
||||
*/
|
||||
public function reserve($kodcaw, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->reserve($kodcaw, $request->input('amaun', 0)));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/initiate/modal-online?zone=all|{zone}
|
||||
*/
|
||||
public function initiate(Request $request)
|
||||
{
|
||||
return $this->respond($this->service->initiate($request->input('zone', 'all')));
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/modal-online/{kodcaw}/topup/request
|
||||
* PC mohon had (hari pertama) atau tambah modal. Body: amaun, dimohon_oleh, nota?
|
||||
*/
|
||||
public function requestTopUp($kodcaw, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->requestTopUp(
|
||||
$kodcaw,
|
||||
$request->input('amaun', 0),
|
||||
$request->input('dimohon_oleh', ''),
|
||||
$request->input('nota')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/modal-online/{kodcaw}/topup/requests?status=&tarikh=
|
||||
*/
|
||||
public function listTopUpByCawangan($kodcaw, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->listTopUpRequests(
|
||||
$kodcaw,
|
||||
$request->input('status'),
|
||||
$request->input('tarikh')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/modal-online/operasi/topup/requests?status=PENDING&tarikh=
|
||||
*/
|
||||
public function listTopUpOperasi(Request $request)
|
||||
{
|
||||
$status = $request->input('status', 'PENDING');
|
||||
if ($status === 'all' || $status === '') {
|
||||
$status = null;
|
||||
}
|
||||
|
||||
return $this->respond($this->service->listTopUpRequests(
|
||||
null,
|
||||
$status,
|
||||
$request->input('tarikh')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/modal-online/operasi/topup/{id}/approve
|
||||
* Body: diluluskan_oleh, nota?, amaun? (optional override)
|
||||
*/
|
||||
public function approveTopUp($id, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->approveTopUp(
|
||||
$id,
|
||||
$request->input('diluluskan_oleh', ''),
|
||||
$request->input('nota'),
|
||||
null,
|
||||
$request->input('amaun')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/modal-online/operasi/topup/{id}/reject
|
||||
* Body: diluluskan_oleh, nota?
|
||||
*/
|
||||
public function rejectTopUp($id, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->rejectTopUp(
|
||||
$id,
|
||||
$request->input('diluluskan_oleh', ''),
|
||||
$request->input('nota')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/modal-online/{kodcaw}/close
|
||||
* Body: ditutup_oleh
|
||||
*/
|
||||
public function close($kodcaw, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->close(
|
||||
$kodcaw,
|
||||
$request->input('ditutup_oleh', '')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/modal-online/operasi/eod?zone=all&tarikh=
|
||||
*/
|
||||
public function listToday(Request $request)
|
||||
{
|
||||
return $this->respond($this->service->listToday(
|
||||
$request->input('zone', 'all'),
|
||||
$request->input('tarikh')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/modal-online/operasi/eod/close-all
|
||||
* Body: ditutup_oleh, zone?
|
||||
*/
|
||||
public function closeAll(Request $request)
|
||||
{
|
||||
return $this->respond($this->service->closeAll(
|
||||
$request->input('ditutup_oleh', ''),
|
||||
$request->input('zone', 'all')
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user