diff --git a/app/Http/Controllers/ApiController.php b/app/Http/Controllers/ApiController.php index c3a641dc..2a6a4ce9 100644 --- a/app/Http/Controllers/ApiController.php +++ b/app/Http/Controllers/ApiController.php @@ -40,6 +40,7 @@ use Http\Client\Common\HttpMethodsClient; use Http\Adapter\Guzzle7\Client as GuzzleHttpClient; use Http\Message\MessageFactory\GuzzleMessageFactory; use App\Models\LogUser; +use App\Jobs\WhatsappPembidaFPXPaid; class ApiController extends Controller { @@ -648,63 +649,67 @@ class ApiController extends Controller // BillplzService.php atau ApiController.php -public function processPaidResit(array $data) -{ - $currentdate = Carbon::now(); - $currentdate = $currentdate->toDateTimeString(); - $loguser = new LogUser; - $loguser->user_id = User::where('name','System')->first()->id; - $loguser->date = $currentdate; - $loguser->username = 'System'; - $loguser->nama_user = 'System'; - $loguser->norujukan = $data['billplz']['id']; - $loguser->nota = 'Callback Resit Billplz Telah Bayar : Billplz_id -'.$data['billplz']['id']; - $loguser->save(); - - $resit = Resit::where('billplz_id', '=', $data['billplz']['id'])->first(); + public function processPaidResit(array $data) + { + $currentdate = Carbon::now(); + $currentdate = $currentdate->toDateTimeString(); + $loguser = new LogUser; + $loguser->user_id = User::where('name','System')->first()->id; + $loguser->date = $currentdate; + $loguser->username = 'System'; + $loguser->nama_user = 'System'; + $loguser->norujukan = $data['billplz']['id']; + $loguser->nota = 'Callback Resit Billplz Telah Bayar : Billplz_id -'.$data['billplz']['id']; + $loguser->save(); + + $resit = Resit::where('billplz_id', '=', $data['billplz']['id'])->first(); - if (!$resit) { - return false; - } + if (!$resit) { + return false; + } - $resit->status = 'PAID'; - $resit->paid_at = $data['billplz']['paid_at']; - $resit->save(); + $resit->status = 'PAID'; + $resit->paid_at = $data['billplz']['paid_at']; + $resit->save(); - $resitoriginal = Resit::where('user_id', $resit->user_id) - ->where('lelong_id', $resit->lelong_id) - ->where('resit_type', 2) - ->first(); + $resitoriginal = Resit::where('user_id', $resit->user_id) + ->where('lelong_id', $resit->lelong_id) + ->where('resit_type', 2) + ->first(); - $payment = Payment::where('lelong_id', $resit->lelong_id) - ->where('user_id', $resit->user_id) - ->where('resit_id', $resit->id) - ->get(); + $payment = Payment::where('lelong_id', $resit->lelong_id) + ->where('user_id', $resit->user_id) + ->where('resit_id', $resit->id) + ->get(); - foreach ($payment as $index) { - $index->status = 2; - $index->remark = "BERJAYA BAYARAN ONLINE"; - $index->update(); + foreach ($payment as $index) { + $index->status = 2; + $index->remark = "BERJAYA BAYARAN ONLINE"; + $index->update(); - $updateTagBid = LelongBid::where('norujukan', $index->norujukan)->first(); - if ($updateTagBid) { - $updateTagBid->status_payment = 2; - $updateTagBid->save(); + $updateTagBid = LelongBid::where('norujukan', $index->norujukan)->first(); + if ($updateTagBid) { + $updateTagBid->status_payment = 2; + $updateTagBid->save(); - $updateTagBidder = LelongBidder::where('lelongbid_id', $updateTagBid->id) - ->where('user_id', $resit->user_id)->first(); - if ($updateTagBidder) { - $updateTagBidder->status_payment = 2; - $updateTagBidder->payment_id = $index->id; - $updateTagBidder->save(); + $updateTagBidder = LelongBidder::where('lelongbid_id', $updateTagBid->id) + ->where('user_id', $resit->user_id)->first(); + if ($updateTagBidder) { + $updateTagBidder->status_payment = 2; + $updateTagBidder->payment_id = $index->id; + $updateTagBidder->save(); + } } } + + event(new PaymentNotify('PAID', $resit->user_id, $payment)); + //notifikasi wasap kepada pembida// + WhatsappPembidaFPXPaid::dispatch($resit->user_id, + $resit->id, + $resit->total_payment); + + return true; } - event(new PaymentNotify('PAID', $resit->user_id, $payment)); - - return true; -} - } \ No newline at end of file diff --git a/app/Http/Controllers/PembidaController.php b/app/Http/Controllers/PembidaController.php index 57fab8a2..d76d8240 100644 --- a/app/Http/Controllers/PembidaController.php +++ b/app/Http/Controllers/PembidaController.php @@ -1528,6 +1528,7 @@ class PembidaController extends Controller $data = [ 'billplz' => [ 'id' => $request->billplz_id, + 'resit_id' => $request->resit_id, 'paid' => 'true', 'paid_at' => $request->paid_at ?? now()->toDateTimeString(), ] diff --git a/app/Jobs/WhatsappPembidaFPXPaid.php b/app/Jobs/WhatsappPembidaFPXPaid.php new file mode 100644 index 00000000..4ba3ce9d --- /dev/null +++ b/app/Jobs/WhatsappPembidaFPXPaid.php @@ -0,0 +1,59 @@ +userId = $userId; + $this->resitId = $resitId; + $this->amount = $amount; + } + + public function handle(): void + { + $dt = Carbon::now(); + $user = User::find($this->userId); + if (!$user || !$user->notelbimbit) return; + + $message = "Assalamualaikum {$user->name}, bayaran FPX anda sebanyak RM " . number_format($this->amount, 2) . " telah berjaya direkodkan. Resit ID: {$this->resitId}. Terima kasih."; + + $mobile_no = '6' . $user->notelbimbit; + if (config('app.env') != 'production') { + $mobile_no = config('app.admin_phone_number'); + } + + $response = Http::get(config('app.wabot_api'), [ + 'number' => $mobile_no, + 'type' => 'text', + 'message' => $message, + 'instance_id' => config('app.wabot_instances_id'), + 'access_token' => config('app.wabot_token_keys') + ]); + + $loguser = new LogUser; + $loguser->date = $dt; + $loguser->username = 'Operasi'; + $loguser->nama_user = 'System'; + $loguser->nota = 'Notifikasi Pembayaran Billplz Berjaya'; + $loguser->save(); + + Log::info("Notifikasi Pembayaran Billplz Berjaya: " . $response); + } +} diff --git a/resources/views/pembida/semakanbillplz.blade.php b/resources/views/pembida/semakanbillplz.blade.php index daa85675..4b3133ee 100644 --- a/resources/views/pembida/semakanbillplz.blade.php +++ b/resources/views/pembida/semakanbillplz.blade.php @@ -5,174 +5,172 @@
- - - -
- Semakan Billplz FPX -
+ + + +
Semakan Billplz FPX
+
- @if ($message = Session::get('success')) -
-

{{ $message }}

+ @if ($message = Session::get('success')) +
+

{{ $message }}

+
+ @endif + +
+
+ + + +
+
+ +
+

✅ Resit Telah Dibayar (PAID)

+ @if($paidResits->isEmpty()) +

Tiada resit yang telah dibayar.

+ @else + + + + + + + + + + + + + + + @foreach($paidResits as $resit) + + + + + + + + + + + @endforeach + +
Nama PembayarID PembayarCawanganResit IDBillplz IDJumlah (RM)Dibayar PadaTindakan
{{ $resit->payer_name ?? '-' }}{{ $resit->user_id }}{{ $resit->cawangan_nama ?? '-' }}{{ $resit->id }}{{ $resit->billplz_id }}{{ number_format($resit->total_payment, 2) }}{{ \Carbon\Carbon::parse($resit->paid_at)->format('d/m/Y H:i') }} +
+ @csrf + + + +
+
+ @endif + +
+ +

❌ Resit Belum Dibayar (UNPAID)

+ @if($unpaidResits->isEmpty()) +

Semua resit telah dibayar.

+ @else + + + + + + + + + + + + + + @foreach ($groupedResitsUnpaid as $resit) + + + + + + + + + + @endforeach + +
Nama PembayarID PembayarCawanganResit IDBillplz IDJumlah (RM)Tarikh Dicipta
{{ $resit->payer_name ?? '-' }}{{ $resit->user_id }}{{ $resit->cawangan_nama ?? '-' }}{{ $resit->resit_id }}{{ $resit->billplz_id }}{{ number_format($resit->jumlah_bayaran, 2) }}{{ \Carbon\Carbon::parse($resit->created_at)->format('d/m/Y H:i') }}
+ @endif + +
+

🔄 Resit Billplz yang Telah Dibayar Semula Melalui CDM

+ @if($billplzWithCdmResits->isEmpty()) +

Tiada bayaran semula melalui CDM ditemui.

+ @else + + + + + + + + + + + + + + @foreach ($groupedResits as $resit) + + + + + + + + + + @endforeach + +
Nama PembayarID PembayarCawanganResit IDBillplz IDJumlah (RM)Tarikh Dicipta
{{ $resit->payer_name }}{{ $resit->user_id }}{{ $resit->cawangan_nama }}{{ $resit->resit_id }}{{ $resit->billplz_id }}{{ number_format($resit->jumlah_bayaran, 2) }}{{ \Carbon\Carbon::parse($resit->created_at)->format('d/m/Y H:i') }}
+ @endif + +
+

🕒 Resit Telah Dibayar Tetapi Dalam Proses (PENDING)

+ @if($processingResits->isEmpty()) +

Tiada resit yang belum direlease.

+ @else + + + + + + + + + + + + + + @foreach($processingResits as $resit) + + + + + + + + + + @endforeach + +
Nama PembayarID PembayarCawanganResit IDBillplz IDJumlah (RM)Tarikh Dibayar
{{ $resit->payer_name }}{{ $resit->user_id }}{{ $resit->cawangan_nama ?? '-' }}{{ $resit->id }}{{ $resit->billplz_id }}{{ number_format($resit->total_payment, 2) }}{{ \Carbon\Carbon::parse($resit->paid_at)->format('d/m/Y H:i') }}
+ @endif +
- @endif - -
-
- - - +
+
- - - -
- -

✅ Resit Telah Dibayar (PAID)

-@if($paidResits->isEmpty()) -

Tiada resit yang telah dibayar.

-@else - - - - - - - - - - - - - - - @foreach($paidResits as $resit) - - - - - - - - - - - @endforeach - -
Nama PembayarID PembayarCawanganResit IDBillplz IDJumlah (RM)Dibayar PadaTindakan
{{ $resit->payer_name ?? '-' }}{{ $resit->user_id }}{{ $resit->cawangan_nama ?? '-' }}{{ $resit->id }}{{ $resit->billplz_id }}{{ number_format($resit->total_payment, 2) }}{{ \Carbon\Carbon::parse($resit->paid_at)->format('d/m/Y H:i') }} -
- @csrf - - - -
-
-@endif - -
- -

❌ Resit Belum Dibayar (UNPAID)

-@if($unpaidResits->isEmpty()) -

Semua resit telah dibayar.

-@else - - - - - - - - - - - - - - @foreach ($groupedResitsUnpaid as $resit) - - - - - - - - - - @endforeach - -
Nama PembayarID PembayarCawanganResit IDBillplz IDJumlah (RM)Tarikh Dicipta
{{ $resit->payer_name ?? '-' }}{{ $resit->user_id }}{{ $resit->cawangan_nama ?? '-' }}{{ $resit->resit_id }}{{ $resit->billplz_id }}{{ number_format($resit->jumlah_bayaran, 2) }}{{ \Carbon\Carbon::parse($resit->created_at)->format('d/m/Y H:i') }}
-@endif - -
-

🔄 Resit Billplz yang Telah Dibayar Semula Melalui CDM

-@if($billplzWithCdmResits->isEmpty()) -

Tiada bayaran semula melalui CDM ditemui.

-@else - - - - - - - - - - - - - - @foreach ($groupedResits as $resit) - - - - - - - - - - @endforeach - -
Nama PembayarID PembayarCawanganJumlah (RM)Resit IDBillplz IDTarikh Dicipta
{{ $resit->payer_name }}{{ $resit->user_id }}{{ $resit->cawangan_nama }}{{ number_format($resit->jumlah_bayaran, 2) }}{{ $resit->resit_id }}{{ $resit->billplz_id }}{{ \Carbon\Carbon::parse($resit->created_at)->format('Y-m-d') }}
-@endif - -
-

🕒 Resit Telah Dibayar Tetapi Dalam Proses (PENDING)

-@if($processingResits->isEmpty()) -

Tiada resit yang belum direlease.

-@else - - - - - - - - - - - - - - @foreach($processingResits as $resit) - - - - - - - - - - @endforeach - -
Nama PembayarID PembayarCawanganResit IDBillplz IDJumlah (RM)Tarikh Dibayar
{{ $resit->payer_name }}{{ $resit->user_id }}{{ $resit->cawangan_nama ?? '-' }}{{ $resit->id }}{{ $resit->billplz_id }}{{ number_format($resit->total_payment, 2) }}{{ \Carbon\Carbon::parse($resit->paid_at)->format('d/m/Y H:i') }}
-@endif - - - - - +
@endsection \ No newline at end of file