DONE: add notification for gadaian and pendahuluan

This commit is contained in:
ISMAIL MASSERAN
2026-09-21 14:30:20 +08:00
parent 676600cf84
commit 6f1dfed9ee
2 changed files with 96 additions and 11 deletions
+45
View File
@@ -13,6 +13,7 @@ use App\Vault;
use Auth0\SDK\API\Management\Users;
use Illuminate\Http\Request;
use Carbon\Carbon;
use App\Services\StaffNotificationClient;
use Illuminate\Support\Facades\Log;
class TunaiController extends Controller
{
@@ -476,10 +477,54 @@ class TunaiController extends Controller
$audit->updated_at = $current;
$audit->save();
$this->notifyKhazanahAliranTunai($kodcaw, $request, $reqteller);
return response()->json($reqteller,200);
}
/**
* Inbox for PC/PPC at the branch. Failures must not block the request.
*
* @param string $kodcaw
* @param \Illuminate\Http\Request $request
* @param \App\RequestTeller $reqteller
* @return void
*/
protected function notifyKhazanahAliranTunai($kodcaw, Request $request, $reqteller)
{
try {
$cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $kodcaw)->first();
$namaCaw = $kodcaw;
if ($cawangan) {
$nama = trim((string) $cawangan->nama_cawangan);
if ($nama !== '') {
$namaCaw = $nama;
}
}
$modal = (float) $request->modal;
$serahan = (float) $request->serahan;
app(StaffNotificationClient::class)->notify([
'type' => 'aliran_tunai.pending_khazanah',
'cawangan' => $kodcaw,
'audience' => ['role' => 'pc'],
'data' => [
'request_no' => isset($reqteller->no) ? $reqteller->no : null,
'kodlaluan' => $request->kodlaluan,
'modal' => $modal,
'serahan' => $serahan,
'cawangan_nama' => $namaCaw,
],
]);
} catch (\Throwable $e) {
Log::warning('Aliran tunai khazanah notification failed: '.$e->getMessage(), [
'kodcaw' => $kodcaw,
'kodlaluan' => $request->kodlaluan,
]);
}
}
public function getTunaiSemalam($kodcaw)
{
$current = new Carbon();