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
+52 -47
View File
@@ -40,6 +40,7 @@ use Http\Client\Common\HttpMethodsClient;
use Http\Adapter\Guzzle7\Client as GuzzleHttpClient; use Http\Adapter\Guzzle7\Client as GuzzleHttpClient;
use Http\Message\MessageFactory\GuzzleMessageFactory; use Http\Message\MessageFactory\GuzzleMessageFactory;
use App\Models\LogUser; use App\Models\LogUser;
use App\Jobs\WhatsappPembidaFPXPaid;
class ApiController extends Controller class ApiController extends Controller
{ {
@@ -648,63 +649,67 @@ class ApiController extends Controller
// BillplzService.php atau ApiController.php // BillplzService.php atau ApiController.php
public function processPaidResit(array $data) public function processPaidResit(array $data)
{ {
$currentdate = Carbon::now(); $currentdate = Carbon::now();
$currentdate = $currentdate->toDateTimeString(); $currentdate = $currentdate->toDateTimeString();
$loguser = new LogUser; $loguser = new LogUser;
$loguser->user_id = User::where('name','System')->first()->id; $loguser->user_id = User::where('name','System')->first()->id;
$loguser->date = $currentdate; $loguser->date = $currentdate;
$loguser->username = 'System'; $loguser->username = 'System';
$loguser->nama_user = 'System'; $loguser->nama_user = 'System';
$loguser->norujukan = $data['billplz']['id']; $loguser->norujukan = $data['billplz']['id'];
$loguser->nota = 'Callback Resit Billplz Telah Bayar : Billplz_id -'.$data['billplz']['id']; $loguser->nota = 'Callback Resit Billplz Telah Bayar : Billplz_id -'.$data['billplz']['id'];
$loguser->save(); $loguser->save();
$resit = Resit::where('billplz_id', '=', $data['billplz']['id'])->first(); $resit = Resit::where('billplz_id', '=', $data['billplz']['id'])->first();
if (!$resit) { if (!$resit) {
return false; return false;
} }
$resit->status = 'PAID'; $resit->status = 'PAID';
$resit->paid_at = $data['billplz']['paid_at']; $resit->paid_at = $data['billplz']['paid_at'];
$resit->save(); $resit->save();
$resitoriginal = Resit::where('user_id', $resit->user_id) $resitoriginal = Resit::where('user_id', $resit->user_id)
->where('lelong_id', $resit->lelong_id) ->where('lelong_id', $resit->lelong_id)
->where('resit_type', 2) ->where('resit_type', 2)
->first(); ->first();
$payment = Payment::where('lelong_id', $resit->lelong_id) $payment = Payment::where('lelong_id', $resit->lelong_id)
->where('user_id', $resit->user_id) ->where('user_id', $resit->user_id)
->where('resit_id', $resit->id) ->where('resit_id', $resit->id)
->get(); ->get();
foreach ($payment as $index) { foreach ($payment as $index) {
$index->status = 2; $index->status = 2;
$index->remark = "BERJAYA BAYARAN ONLINE"; $index->remark = "BERJAYA BAYARAN ONLINE";
$index->update(); $index->update();
$updateTagBid = LelongBid::where('norujukan', $index->norujukan)->first(); $updateTagBid = LelongBid::where('norujukan', $index->norujukan)->first();
if ($updateTagBid) { if ($updateTagBid) {
$updateTagBid->status_payment = 2; $updateTagBid->status_payment = 2;
$updateTagBid->save(); $updateTagBid->save();
$updateTagBidder = LelongBidder::where('lelongbid_id', $updateTagBid->id) $updateTagBidder = LelongBidder::where('lelongbid_id', $updateTagBid->id)
->where('user_id', $resit->user_id)->first(); ->where('user_id', $resit->user_id)->first();
if ($updateTagBidder) { if ($updateTagBidder) {
$updateTagBidder->status_payment = 2; $updateTagBidder->status_payment = 2;
$updateTagBidder->payment_id = $index->id; $updateTagBidder->payment_id = $index->id;
$updateTagBidder->save(); $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;
}
} }
@@ -1528,6 +1528,7 @@ class PembidaController extends Controller
$data = [ $data = [
'billplz' => [ 'billplz' => [
'id' => $request->billplz_id, 'id' => $request->billplz_id,
'resit_id' => $request->resit_id,
'paid' => 'true', 'paid' => 'true',
'paid_at' => $request->paid_at ?? now()->toDateTimeString(), '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);
}
}
+164 -166
View File
@@ -5,174 +5,172 @@
<div class="col"> <div class="col">
<div class="card"> <div class="card">
<div class="card-header header-style"> <div class="card-header header-style">
<a href="javascript:window.history.go(-1);" class="header-style-icon"> <a href="javascript:window.history.go(-1);" class="header-style-icon">
<i class="fas fa-arrow-left"></i> <i class="fas fa-arrow-left"></i>
</a> </a>
<div class="header-style-title"> <div class="header-style-title">Semakan Billplz FPX</div>
Semakan Billplz FPX
</div>
</div> </div>
<div class="card-body"> <div class="card-body">
@if ($message = Session::get('success')) @if ($message = Session::get('success'))
<div class="alert alert-success"> <div class="alert alert-success">
<p>{{ $message }}</p> <p>{{ $message }}</p>
</div>
@endif
<form method="GET" action="{{ route('pembida.semakanbillplz') }}" class="mb-4">
<div class="form-inline">
<label for="date" class="mr-2">Pilih Tarikh:</label>
<input type="date" name="date" id="date" class="form-control mr-2" value="{{ $date }}">
<button type="submit" class="btn btn-primary">Semak</button>
</div>
</form>
<hr>
<h4>✅ Resit Telah Dibayar (PAID)</h4>
@if($paidResits->isEmpty())
<p>Tiada resit yang telah dibayar.</p>
@else
<table class="table table-bordered text-center">
<thead>
<tr>
<th>Nama Pembayar</th>
<th>ID Pembayar</th>
<th>Cawangan</th>
<th>Resit ID</th>
<th>Billplz ID</th>
<th>Jumlah (RM)</th>
<th>Dibayar Pada</th>
<th>Tindakan</th>
</tr>
</thead>
<tbody>
@foreach($paidResits as $resit)
<tr>
<td>{{ $resit->payer_name ?? '-' }}</td>
<td>{{ $resit->user_id }}</td>
<td>{{ $resit->cawangan_nama ?? '-' }}</td>
<td>{{ $resit->id }}</td>
<td>{{ $resit->billplz_id }}</td>
<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', ['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() }}">
<button type="submit" class="btn btn-sm btn-success">Proses</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
@endif
<hr>
<h4>❌ Resit Belum Dibayar (UNPAID)</h4>
@if($unpaidResits->isEmpty())
<p>Semua resit telah dibayar.</p>
@else
<table class="table table-bordered text-center">
<thead>
<tr>
<th>Nama Pembayar</th>
<th>ID Pembayar</th>
<th>Cawangan</th>
<th>Resit ID</th>
<th>Billplz ID</th>
<th>Jumlah (RM)</th>
<th>Tarikh Dicipta</th>
</tr>
</thead>
<tbody>
@foreach ($groupedResitsUnpaid as $resit)
<tr>
<td>{{ $resit->payer_name ?? '-' }}</td>
<td>{{ $resit->user_id }}</td>
<td>{{ $resit->cawangan_nama ?? '-' }}</td>
<td>{{ $resit->resit_id }}</td>
<td>{{ $resit->billplz_id }}</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>
</table>
@endif
<hr>
<h4>🔄 Resit Billplz yang Telah Dibayar Semula Melalui CDM</h4>
@if($billplzWithCdmResits->isEmpty())
<p>Tiada bayaran semula melalui CDM ditemui.</p>
@else
<table class="table table-bordered text-center">
<thead>
<tr>
<th>Nama Pembayar</th>
<th>ID Pembayar</th>
<th>Cawangan</th>
<th>Resit ID</th>
<th>Billplz ID</th>
<th>Jumlah (RM)</th>
<th>Tarikh Dicipta</th>
</tr>
</thead>
<tbody>
@foreach ($groupedResits as $resit)
<tr>
<td>{{ $resit->payer_name }}</td>
<td>{{ $resit->user_id }}</td>
<td>{{ $resit->cawangan_nama }}</td>
<td>{{ $resit->resit_id }}</td>
<td>{{ $resit->billplz_id }}</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>
</table>
@endif
<hr>
<h4>🕒 Resit Telah Dibayar Tetapi Dalam Proses (PENDING)</h4>
@if($processingResits->isEmpty())
<p>Tiada resit yang belum direlease.</p>
@else
<table class="table table-bordered text-center">
<thead>
<tr>
<th>Nama Pembayar</th>
<th>ID Pembayar</th>
<th>Cawangan</th>
<th>Resit ID</th>
<th>Billplz ID</th>
<th>Jumlah (RM)</th>
<th>Tarikh Dibayar</th>
</tr>
</thead>
<tbody>
@foreach($processingResits as $resit)
<tr>
<td>{{ $resit->payer_name }}</td>
<td>{{ $resit->user_id }}</td>
<td>{{ $resit->cawangan_nama ?? '-' }}</td>
<td>{{ $resit->id }}</td>
<td>{{ $resit->billplz_id }}</td>
<td>{{ number_format($resit->total_payment, 2) }}</td>
<td>{{ \Carbon\Carbon::parse($resit->paid_at)->format('d/m/Y H:i') }}</td>
</tr>
@endforeach
</tbody>
</table>
@endif
</div> </div>
@endif </div>
</div>
<form method="GET" action="{{ route('pembida.semakanbillplz') }}" class="mb-4">
<div class="form-inline">
<label for="date" class="mr-2">Pilih Tarikh:</label>
<input type="date" name="date" id="date" class="form-control mr-2" value="{{ $date }}">
<button type="submit" class="btn btn-primary">Semak</button>
</div> </div>
</form> </div>
<hr>
<h4>✅ Resit Telah Dibayar (PAID)</h4>
@if($paidResits->isEmpty())
<p>Tiada resit yang telah dibayar.</p>
@else
<table class="table table-bordered text-center">
<thead>
<tr>
<th>Nama Pembayar</th>
<th>ID Pembayar</th>
<th>Cawangan</th>
<th>Resit ID</th>
<th>Billplz ID</th>
<th>Jumlah (RM)</th>
<th>Dibayar Pada</th>
<th>Tindakan</th>
</tr>
</thead>
<tbody>
@foreach($paidResits as $resit)
<tr>
<td>{{ $resit->payer_name ?? '-' }}</td>
<td>{{ $resit->user_id }}</td>
<td>{{ $resit->cawangan_nama ?? '-' }}</td>
<td>{{ $resit->id }}</td>
<td>{{ $resit->billplz_id }}</td>
<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') }}">
@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() }}">
<button type="submit" class="btn btn-sm btn-success">Proses</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
@endif
<hr>
<h4>❌ Resit Belum Dibayar (UNPAID)</h4>
@if($unpaidResits->isEmpty())
<p>Semua resit telah dibayar.</p>
@else
<table class="table table-bordered text-center">
<thead>
<tr>
<th>Nama Pembayar</th>
<th>ID Pembayar</th>
<th>Cawangan</th>
<th>Resit ID</th>
<th>Billplz ID</th>
<th>Jumlah (RM)</th>
<th>Tarikh Dicipta</th>
</tr>
</thead>
<tbody>
@foreach ($groupedResitsUnpaid as $resit)
<tr>
<td>{{ $resit->payer_name ?? '-' }}</td>
<td>{{ $resit->user_id }}</td>
<td>{{ $resit->cawangan_nama ?? '-' }}</td>
<td>{{ $resit->resit_id }}</td>
<td>{{ $resit->billplz_id }}</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>
</table>
@endif
<hr>
<h4>🔄 Resit Billplz yang Telah Dibayar Semula Melalui CDM</h4>
@if($billplzWithCdmResits->isEmpty())
<p>Tiada bayaran semula melalui CDM ditemui.</p>
@else
<table class="table table-bordered text-center">
<thead>
<tr>
<th>Nama Pembayar</th>
<th>ID Pembayar</th>
<th>Cawangan</th>
<th>Jumlah (RM)</th>
<th>Resit ID</th>
<th>Billplz ID</th>
<th>Tarikh Dicipta</th>
</tr>
</thead>
<tbody>
@foreach ($groupedResits as $resit)
<tr>
<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>
</tr>
@endforeach
</tbody>
</table>
@endif
<hr>
<h4>🕒 Resit Telah Dibayar Tetapi Dalam Proses (PENDING)</h4>
@if($processingResits->isEmpty())
<p>Tiada resit yang belum direlease.</p>
@else
<table class="table table-bordered text-center">
<thead>
<tr>
<th>Nama Pembayar</th>
<th>ID Pembayar</th>
<th>Cawangan</th>
<th>Resit ID</th>
<th>Billplz ID</th>
<th>Jumlah (RM)</th>
<th>Tarikh Dibayar</th>
</tr>
</thead>
<tbody>
@foreach($processingResits as $resit)
<tr>
<td>{{ $resit->payer_name }}</td>
<td>{{ $resit->user_id }}</td>
<td>{{ $resit->cawangan_nama ?? '-' }}</td>
<td>{{ $resit->id }}</td>
<td>{{ $resit->billplz_id }}</td>
<td>{{ number_format($resit->total_payment, 2) }}</td>
<td>{{ \Carbon\Carbon::parse($resit->paid_at)->format('d/m/Y H:i') }}</td>
</tr>
@endforeach
</tbody>
</table>
@endif
@endsection @endsection