tambah notifikasi wasap pembida billplz paid

This commit is contained in:
BTMS2
2025-05-06 16:13:34 +08:00
parent 791ca8dd84
commit 2c579e4327
4 changed files with 276 additions and 213 deletions
+5
View File
@@ -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
{
@@ -702,6 +703,10 @@ public function processPaidResit(array $data)
}
event(new PaymentNotify('PAID', $resit->user_id, $payment));
//notifikasi wasap kepada pembida//
WhatsappPembidaFPXPaid::dispatch($resit->user_id,
$resit->id,
$resit->total_payment);
return true;
}
@@ -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(),
]
+59
View File
@@ -0,0 +1,59 @@
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Carbon\Carbon;
use App\Models\User;
use App\Models\LogUser;
class WhatsappPembidaFPXPaid implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $userId, $resitId, $amount;
public function __construct($userId, $resitId, $amount)
{
$this->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);
}
}
@@ -8,10 +8,9 @@
<a href="javascript:window.history.go(-1);" class="header-style-icon">
<i class="fas fa-arrow-left"></i>
</a>
<div class="header-style-title">
Semakan Billplz FPX
</div>
<div class="header-style-title">Semakan Billplz FPX</div>
</div>
<div class="card-body">
@if ($message = Session::get('success'))
<div class="alert alert-success">
@@ -27,9 +26,7 @@
</div>
</form>
<hr>
<h4>✅ Resit Telah Dibayar (PAID)</h4>
@if($paidResits->isEmpty())
<p>Tiada resit yang telah dibayar.</p>
@@ -58,7 +55,7 @@
<td>{{ number_format($resit->total_payment, 2) }}</td>
<td>{{ \Carbon\Carbon::parse($resit->paid_at)->format('d/m/Y H:i') }}</td>
<td>
<form method="POST" action="{{ route('pembida.prosesBillplz') }}">
<form method="POST" action="{{ route('pembida.prosesBillplz', ['resit_id' => $resit->id, 'billplz_id' => $resit->billplz_id]) }}">
@csrf
<input type="hidden" name="billplz_id" value="{{ $resit->billplz_id }}">
<input type="hidden" name="paid_at" value="{{ \Carbon\Carbon::parse($resit->paid_at)->toDateTimeString() }}">
@@ -116,9 +113,9 @@
<th>Nama Pembayar</th>
<th>ID Pembayar</th>
<th>Cawangan</th>
<th>Jumlah (RM)</th>
<th>Resit ID</th>
<th>Billplz ID</th>
<th>Jumlah (RM)</th>
<th>Tarikh Dicipta</th>
</tr>
</thead>
@@ -128,10 +125,10 @@
<td>{{ $resit->payer_name }}</td>
<td>{{ $resit->user_id }}</td>
<td>{{ $resit->cawangan_nama }}</td>
<td>{{ number_format($resit->jumlah_bayaran, 2) }}</td>
<td>{{ $resit->resit_id }}</td>
<td>{{ $resit->billplz_id }}</td>
<td>{{ \Carbon\Carbon::parse($resit->created_at)->format('Y-m-d') }}</td>
<td>{{ number_format($resit->jumlah_bayaran, 2) }}</td>
<td>{{ \Carbon\Carbon::parse($resit->created_at)->format('d/m/Y H:i') }}</td>
</tr>
@endforeach
</tbody>
@@ -171,8 +168,9 @@
</table>
@endif
</div>
</div>
</div>
</div>
</div>
@endsection