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\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;
}
}
@@ -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);
}
}