DONE: remove cache, and remove dto financing
This commit is contained in:
@@ -180,15 +180,12 @@ class GadaianController extends Controller
|
||||
Session::put('nopelanggan', $customer_info['nopelanggan']);
|
||||
Session::put('page_reload', true);
|
||||
Session::forget('borang_online_printed');
|
||||
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url') . '/api/gadai/' . $auth_user['cawangan'], [
|
||||
Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url') . '/api/gadai/' . $auth_user['cawangan'], [
|
||||
'norujukan' => $norujukan,
|
||||
'nopelanggan' => $customer_info['nopelanggan'],
|
||||
'nokp' => $noic,
|
||||
'sirig' => $new_sirig,
|
||||
'shoraka_new' => true,
|
||||
])->throw()->json();
|
||||
$norujukan = $gadai['norujukan'];
|
||||
Session::put('norujukan', $norujukan);
|
||||
])->throw();
|
||||
} else {
|
||||
$norujukan = Session::get('norujukan');
|
||||
$nokp = Session::get('nokp');
|
||||
@@ -208,15 +205,13 @@ class GadaianController extends Controller
|
||||
Session::put('nopelanggan', $nopelanggan);
|
||||
Session::put('page_reload', true);
|
||||
Session::forget('borang_online_printed');
|
||||
$gadai_baru = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url') . '/api/gadai/' . $auth_user['cawangan'], [
|
||||
Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url') . '/api/gadai/' . $auth_user['cawangan'], [
|
||||
'norujukan' => $norujukan_baru,
|
||||
'nopelanggan' => $nopelanggan,
|
||||
'nokp' => $nokp,
|
||||
'sirig' => $new_sirig,
|
||||
'shoraka_new' => true,
|
||||
])->throw()->json();
|
||||
$norujukan = $gadai_baru['norujukan'];
|
||||
Session::put('norujukan', $norujukan);
|
||||
])->throw();
|
||||
$norujukan = $norujukan_baru;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\ShorakaFinancing;
|
||||
use App\Services\ShorakaFinancingService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@@ -12,8 +11,7 @@ class ShorakaController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$records = ShorakaFinancing::where('kodcaw', Auth::user()->cawangan)
|
||||
->orderByDesc('id')->limit(100)->get();
|
||||
$records = app(ShorakaFinancingService::class)->listForBranch(Auth::user()->cawangan);
|
||||
$cawangan_info = ['details_caw' => Auth::user()->cawangan, 'kodcaw' => Auth::user()->cawangan];
|
||||
return view('shoraka.index', compact('records', 'cawangan_info'));
|
||||
}
|
||||
@@ -29,28 +27,10 @@ class ShorakaController extends Controller
|
||||
'date_from' => 'nullable|date_format:Y-m-d',
|
||||
'date_to' => 'nullable|date_format:Y-m-d' . ($request->filled('date_from') ? '|after_or_equal:date_from' : ''),
|
||||
]);
|
||||
$branchQuery = ShorakaFinancing::select('kodcaw');
|
||||
if (!$isOperasi) {
|
||||
$branchQuery->where('kodcaw', Auth::user()->cawangan);
|
||||
}
|
||||
$branches = $branchQuery->distinct()->orderBy('kodcaw')->pluck('kodcaw');
|
||||
$query = ShorakaFinancing::select('id', 'kodcaw', 'norujukan', 'teller', 'action', 'state', 'created_at', 'updated_at');
|
||||
if (!$isOperasi) {
|
||||
$query->where('kodcaw', Auth::user()->cawangan);
|
||||
}
|
||||
foreach (['kodcaw', 'norujukan', 'state'] as $field) {
|
||||
if (!empty($filters[$field])) {
|
||||
$query->where($field, $filters[$field]);
|
||||
}
|
||||
}
|
||||
if (!empty($filters['date_from'])) {
|
||||
$query->where('created_at', '>=', $filters['date_from'] . ' 00:00:00');
|
||||
}
|
||||
if (!empty($filters['date_to'])) {
|
||||
$query->where('created_at', '<', \Carbon\Carbon::parse($filters['date_to'])->addDay()->format('Y-m-d') . ' 00:00:00');
|
||||
}
|
||||
$records = $query->orderByDesc('created_at')->orderByDesc('id')
|
||||
->paginate(25)->appends($filters);
|
||||
[$records, $branches] = app(ShorakaFinancingService::class)->search(
|
||||
$filters,
|
||||
$isOperasi ? null : Auth::user()->cawangan
|
||||
);
|
||||
$cawangan_info = ['details_caw' => Auth::user()->cawangan, 'kodcaw' => Auth::user()->cawangan];
|
||||
return view('shoraka.operasi', compact('records', 'branches', 'filters', 'isOperasi', 'cawangan_info'));
|
||||
}
|
||||
@@ -78,15 +58,15 @@ class ShorakaController extends Controller
|
||||
public function poll(Request $request, string $norujukan, ShorakaFinancingService $service)
|
||||
{
|
||||
$record = $service->local($norujukan);
|
||||
abort_unless($record && $record->teller === Auth::user()->name && $record->action === 'gadai', 403);
|
||||
if ($record->state === 'DONE') {
|
||||
abort_unless($record && ($record['teller'] ?? null) === Auth::user()->name && ($record['action'] ?? null) === 'gadai', 403);
|
||||
if (($record['state'] ?? null) === 'DONE') {
|
||||
return response()->json(['state' => 'done', 'redirect' => route('customer_info')]);
|
||||
}
|
||||
abort_unless(!empty($record->context['temporary_gadai']), 409);
|
||||
if ($record->state === 'REVIEW') {
|
||||
abort_unless(!empty($record['context']['temporary_gadai']), 409);
|
||||
if (($record['state'] ?? null) === 'REVIEW') {
|
||||
return response()->json(['state' => 'failed', 'message' => 'Penyelesaian memerlukan semakan operasi. Jangan ulang bayaran.']);
|
||||
}
|
||||
if ($record->state === 'PROCESSING') {
|
||||
if (($record['state'] ?? null) === 'PROCESSING') {
|
||||
return response()->json(['state' => 'pending']);
|
||||
}
|
||||
try {
|
||||
@@ -115,7 +95,8 @@ class ShorakaController extends Controller
|
||||
}
|
||||
return response()->json(['state' => 'pending']);
|
||||
} catch (Throwable $exception) {
|
||||
if ($record->fresh()->state === 'REVIEW') {
|
||||
$fresh = $service->local($norujukan);
|
||||
if ($fresh && ($fresh['state'] ?? null) === 'REVIEW') {
|
||||
return response()->json(['state' => 'failed', 'message' => 'Penyelesaian memerlukan semakan operasi. Jangan ulang bayaran.']);
|
||||
}
|
||||
if ($exception instanceof \Symfony\Component\HttpKernel\Exception\HttpExceptionInterface
|
||||
@@ -134,7 +115,7 @@ class ShorakaController extends Controller
|
||||
public function submit(string $norujukan, ShorakaFinancingService $service)
|
||||
{
|
||||
$record = $service->local($norujukan);
|
||||
abort_unless($record && $record->teller === Auth::user()->name, 403);
|
||||
abort_unless($record && ($record['teller'] ?? null) === Auth::user()->name, 403);
|
||||
$response = $service->api()->post($service->url($norujukan, '/submit'));
|
||||
return redirect()->route('shoraka.show', compact('norujukan'))
|
||||
->with('shoraka_message', $response->successful()
|
||||
|
||||
Reference in New Issue
Block a user