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:
@@ -403,58 +403,31 @@ class CustomerController extends Controller
|
||||
}
|
||||
|
||||
public function assignAnggota($noic, Request $request)
|
||||
{
|
||||
// Semak sama ada pelanggan wujud
|
||||
$customer = Customer::on('mysql7')
|
||||
->where('kpbaru', $noic)
|
||||
->orWhere('kplama', $noic)
|
||||
->first();
|
||||
{
|
||||
// Semak sama ada pelanggan wujud
|
||||
$customer = Customer::on('mysql7')
|
||||
->where('kpbaru', $noic)
|
||||
->orWhere('kplama', $noic)
|
||||
->first();
|
||||
|
||||
if (!$customer) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Pelanggan tidak dijumpai.'
|
||||
], 404);
|
||||
}
|
||||
|
||||
// Kemaskini tag_anggota
|
||||
$customer->tag_anggota = 1;
|
||||
$customer->save();
|
||||
|
||||
if (!$customer) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Pelanggan tidak dijumpai.'
|
||||
], 404);
|
||||
'success' => true,
|
||||
'message' => 'Tag anggota berjaya dikemaskini.',
|
||||
'data' => $customer
|
||||
], 200);
|
||||
}
|
||||
|
||||
// Kemaskini tag_anggota
|
||||
$customer->tag_anggota = 1;
|
||||
$customer->save();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Tag anggota berjaya dikemaskini.',
|
||||
'data' => $customer
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
|
||||
public function assignAnggota($noic, Request $request)
|
||||
{
|
||||
// Semak sama ada pelanggan wujud
|
||||
$customer = Customer::on('mysql7')
|
||||
->where('kpbaru', $noic)
|
||||
->orWhere('kplama', $noic)
|
||||
->first();
|
||||
|
||||
if (!$customer) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Pelanggan tidak dijumpai.'
|
||||
], 404);
|
||||
}
|
||||
|
||||
// Kemaskini tag_anggota
|
||||
$customer->tag_anggota = 1;
|
||||
$customer->save();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Tag anggota berjaya dikemaskini.',
|
||||
'data' => $customer
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function customerUpdateKaunter($nokp,$kodcaw, Request $request){
|
||||
$current = Carbon::now();
|
||||
|
||||
@@ -889,14 +862,6 @@ class CustomerController extends Controller
|
||||
}
|
||||
|
||||
|
||||
public function anggotaKoperasi(Request $request){
|
||||
|
||||
$anggota = Anggota::where('noic',$request->noic)->first();
|
||||
|
||||
return response()->json($anggota);
|
||||
}
|
||||
|
||||
|
||||
public function showCustomerByEachCawangan($ic)
|
||||
{
|
||||
$cawangan_all = Cawangan::on('mysql7')->get();
|
||||
|
||||
@@ -145,15 +145,19 @@ class KomuditiController extends Controller
|
||||
$komuditi_current = KomuditiPurchase::on('mysql7')->where('date_purchase','=',$current->toDateString())->orderBy('created_at','desc')->first();
|
||||
|
||||
$unit_current = $komuditi_current['unit_komuditi'];
|
||||
|
||||
$update_unit = $unit_current - $request->unit_komuditi;
|
||||
|
||||
// $unit_current = round((float) $komuditi_current['unit_komuditi'], 2);
|
||||
// $unit_komuditi = round((float) $request->unit_komuditi, 2);
|
||||
// $update_unit = round($unit_current - $unit_komuditi, 2);
|
||||
|
||||
$update_komuditi = KomuditiPurchase::on('mysql7')->where('id','=',$komuditi_current['id'])->update([
|
||||
'unit_komuditi' => $update_unit
|
||||
]);
|
||||
|
||||
$komuditi_transaksi = KomuditiTransaksi::on('mysql7')->create([
|
||||
'unit_komuditi' => $request->unit_komuditi,
|
||||
// 'unit_komuditi' => $unit_komuditi,
|
||||
'nosijil'=>$komuditi_current['no_sijil'],
|
||||
'norujukan' => $request->norujukan,
|
||||
'kodcaw' => $request->kodcaw ,
|
||||
|
||||
@@ -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')
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\PembiayaanOnline\PembiayaanOnlineService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PembiayaanOnlineController extends Controller
|
||||
{
|
||||
protected $service;
|
||||
|
||||
public function __construct(PembiayaanOnlineService $service = null)
|
||||
{
|
||||
$this->service = $service ?: new PembiayaanOnlineService();
|
||||
}
|
||||
|
||||
protected function respond(array $result)
|
||||
{
|
||||
return response()->json($result['payload'], $result['status']);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/pembiayaan-online/{kodcaw}
|
||||
*/
|
||||
public function store($kodcaw, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->store($kodcaw, $request->all()));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/pembiayaan-online/{kodcaw}/by-norujukan/{norujukan}
|
||||
*/
|
||||
public function show($kodcaw, $norujukan)
|
||||
{
|
||||
return $this->respond($this->service->show($kodcaw, $norujukan));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/pembiayaan-online/{kodcaw}/queue
|
||||
*/
|
||||
public function queue($kodcaw, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->queue($kodcaw, $request->input('status')));
|
||||
}
|
||||
|
||||
/**
|
||||
* PUT /api/pembiayaan-online/{kodcaw}/lines/{id}
|
||||
*/
|
||||
public function updateLine($kodcaw, $id, Request $request)
|
||||
{
|
||||
// Prefer only present keys so "has" semantics match previous controller.
|
||||
$input = [];
|
||||
foreach ([
|
||||
'kodbank', 'noakaun', 'nama_bank', 'nama_akaun', 'nota',
|
||||
'bukti_akaun_file_id', 'borang_file_id', 'update_customer_bank',
|
||||
] as $key) {
|
||||
if ($request->has($key)) {
|
||||
$input[$key] = $request->input($key);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->respond($this->service->updateLine($kodcaw, $id, $input));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/pembiayaan-online/{kodcaw}/batches
|
||||
*/
|
||||
public function listBatches($kodcaw, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->listBatches(
|
||||
$kodcaw,
|
||||
$request->input('tarikh'),
|
||||
$request->input('status')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/pembiayaan-online/{kodcaw}/batches/{batchId}
|
||||
*/
|
||||
public function showBatch($kodcaw, $batchId)
|
||||
{
|
||||
return $this->respond($this->service->showBatch($kodcaw, $batchId));
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/pembiayaan-online/{kodcaw}/batches/submit
|
||||
*/
|
||||
public function submitBatch($kodcaw, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->submitBatch(
|
||||
$kodcaw,
|
||||
$request->input('ids', []),
|
||||
$request->input('pc_submitted_by', ''),
|
||||
$request->input('slot')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/pembiayaan-online/operasi/batches
|
||||
*/
|
||||
public function operasiListBatches(Request $request)
|
||||
{
|
||||
return $this->respond($this->service->operasiListBatches(
|
||||
$request->input('status', 'SUBMITTED'),
|
||||
$request->input('tarikh')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/pembiayaan-online/operasi/{kodcaw}/batches/{batchId}
|
||||
*/
|
||||
public function operasiShowBatch($kodcaw, $batchId)
|
||||
{
|
||||
return $this->showBatch($kodcaw, $batchId);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/pembiayaan-online/operasi/{kodcaw}/lines/{id}/approve
|
||||
*/
|
||||
public function operasiApproveLine($kodcaw, $id, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->operasiApproveLine(
|
||||
$kodcaw,
|
||||
$id,
|
||||
$request->input('ops_by', '')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/pembiayaan-online/operasi/{kodcaw}/lines/{id}/reject
|
||||
*/
|
||||
public function operasiRejectLine($kodcaw, $id, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->operasiRejectLine(
|
||||
$kodcaw,
|
||||
$id,
|
||||
$request->input('ops_by', ''),
|
||||
$request->input('reject_reason', '')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/pembiayaan-online/operasi/{kodcaw}/batches/{batchId}/approve
|
||||
*/
|
||||
public function operasiApproveBatch($kodcaw, $batchId, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->operasiApproveBatch(
|
||||
$kodcaw,
|
||||
$batchId,
|
||||
$request->input('ops_by', '')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/pembiayaan-online/operasi/{kodcaw}/lines/{id}/paid
|
||||
* Body: ops_by, no_rujukan_bayaran, tarikh_bayaran?,
|
||||
* bukti_data + bukti_filename + bukti_type OR bukti_file_id
|
||||
*/
|
||||
public function operasiMarkPaid($kodcaw, $id, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->operasiMarkPaid($kodcaw, $id, $request->all()));
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/pembiayaan-online/operasi/{kodcaw}/batches/{batchId}/paid
|
||||
*/
|
||||
public function operasiMarkPaidBatch($kodcaw, $batchId, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->operasiMarkPaidBatch($kodcaw, $batchId, $request->all()));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/pembiayaan-online/{kodcaw}/lines/{id}/bukti
|
||||
*/
|
||||
public function getBukti($kodcaw, $id)
|
||||
{
|
||||
return $this->respond($this->service->getBukti($kodcaw, $id));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/pembiayaan-online/{kodcaw}/paid?blast_sent=0
|
||||
*/
|
||||
public function paidQueue($kodcaw, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->paidQueue(
|
||||
$kodcaw,
|
||||
$request->input('blast_sent')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/pembiayaan-online/{kodcaw}/paid/blast
|
||||
* Body: ids[] (or ids), blast_by?
|
||||
*/
|
||||
public function markBlastSent($kodcaw, Request $request)
|
||||
{
|
||||
$ids = $request->input('ids', $request->input('id'));
|
||||
return $this->respond($this->service->markBlastSent(
|
||||
$kodcaw,
|
||||
$ids,
|
||||
$request->input('blast_by')
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -400,12 +400,14 @@ class VaultController extends Controller
|
||||
}
|
||||
|
||||
|
||||
$bakiakhirVault = $vault ? $vault['bakiakhir'] : 0;
|
||||
|
||||
if($total != 0)
|
||||
{
|
||||
$totalbakiakhirtunai = $vault['bakiakhir'] + $total;
|
||||
$totalbakiakhirtunai = $bakiakhirVault + $total;
|
||||
}else
|
||||
{
|
||||
$totalbakiakhirtunai = $vault['bakiakhir'];
|
||||
$totalbakiakhirtunai = $bakiakhirVault;
|
||||
}
|
||||
|
||||
return response()->json($totalbakiakhirtunai);
|
||||
|
||||
Reference in New Issue
Block a user