Bugfix/list clickup issue (#5)
Reviewed-on: #5 Co-authored-by: ISMAIL MASSERAN <ismail@koppkb.com> Co-committed-by: ISMAIL MASSERAN <ismail@koppkb.com>
This commit was merged in pull request #5.
This commit is contained in:
@@ -2,23 +2,20 @@
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Events\LelongNotify;
|
||||
use App\Models\Cart;
|
||||
use App\Models\CawanganLelong;
|
||||
use App\Models\Lelong;
|
||||
use App\Models\LogUser;
|
||||
use App\Models\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Models\Lelong;
|
||||
use Illuminate\Support\Carbon;
|
||||
use App\Events\LelongNotify;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Models\LogUser;
|
||||
use App\Models\User;
|
||||
use App\Models\CawanganLelong;
|
||||
use App\Models\Cart;
|
||||
|
||||
|
||||
|
||||
class AutoTamatLelong implements ShouldQueue
|
||||
{
|
||||
@@ -43,57 +40,55 @@ class AutoTamatLelong implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$dt = Carbon::now();
|
||||
$timeloni = $dt->toTimeString();
|
||||
$tarikhlelong = $dt->toDateString();
|
||||
|
||||
event(new LelongNotify('stop'));
|
||||
$updatestatus = Lelong::where('sts_lelong',1)
|
||||
->where('tarikh_lelong',$tarikhlelong)
|
||||
->update(['sts_lelong' => 2]);
|
||||
$dt = Carbon::now();
|
||||
$timeloni = $dt->toTimeString();
|
||||
$tarikhlelong = $dt->toDateString();
|
||||
|
||||
$cawlelong = CawanganLelong::where('lelong_id','=',$this->id)->get();
|
||||
foreach($cawlelong as $cawlel) //save old harga asas
|
||||
{
|
||||
// $cawlel->masatamat_lelong = $currenttime;
|
||||
$cawlel->status_online = 0; //start lelong
|
||||
$cawlel->save();
|
||||
}
|
||||
event(new LelongNotify('stop'));
|
||||
$updatestatus = Lelong::where('sts_lelong', 1)
|
||||
->where('tarikh_lelong', $tarikhlelong)
|
||||
->update(['sts_lelong' => 2]);
|
||||
|
||||
$hapuscart = Cart::truncate();
|
||||
$cawlelong = CawanganLelong::where('lelong_id', '=', $this->id)->get();
|
||||
foreach ($cawlelong as $cawlel) { // save old harga asas
|
||||
// $cawlel->masatamat_lelong = $currenttime;
|
||||
$cawlel->status_online = 0; // start lelong
|
||||
$cawlel->save();
|
||||
}
|
||||
|
||||
|
||||
$hapuscart = Cart::truncate();
|
||||
|
||||
$getnoajk = User::where('user_type', 3)->get();
|
||||
foreach($getnoajk as $notifikasi){
|
||||
$mobile_no = '6'.$notifikasi->notelbimbit;
|
||||
$response = null;
|
||||
$getnoajk = User::where('user_type', 3)->get();
|
||||
foreach ($getnoajk as $notifikasi) {
|
||||
$mobile_no = '6'.$notifikasi->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' => 'Lelongan Telah Tamat, Sila Jana Pemenang',
|
||||
'instance_id' => config('app.wabot_instances_id'),
|
||||
'access_token' => config('app.wabot_token_keys')
|
||||
]);
|
||||
}
|
||||
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' => 'Lelongan Telah Tamat, Sila Jana Pemenang',
|
||||
'instance_id' => config('app.wabot_instances_id'),
|
||||
'access_token' => config('app.wabot_token_keys'),
|
||||
]);
|
||||
}
|
||||
|
||||
//insert loguser
|
||||
$loguser = new LogUser;
|
||||
// $loguser->user_id = $user->id;
|
||||
$loguser->date = $dt;
|
||||
$loguser->username = 'System';
|
||||
$loguser->nama_user = 'System';
|
||||
// $loguser->norujukan = $data['norujukan'];
|
||||
$loguser->nota = 'Lelongan Tamat';
|
||||
$loguser->save();
|
||||
|
||||
Log::info("Lelongan Telah Tamat" . $response);
|
||||
// }
|
||||
|
||||
// event(new LelongNotify('stop'));
|
||||
// insert loguser
|
||||
$loguser = new LogUser;
|
||||
// $loguser->user_id = $user->id;
|
||||
$loguser->date = $dt;
|
||||
$loguser->username = 'System';
|
||||
$loguser->nama_user = 'System';
|
||||
// $loguser->norujukan = $data['norujukan'];
|
||||
$loguser->nota = 'Lelongan Tamat';
|
||||
$loguser->save();
|
||||
|
||||
Log::info('Lelongan Telah Tamat', ['response' => $response]);
|
||||
// }
|
||||
|
||||
// event(new LelongNotify('stop'));
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Concerns;
|
||||
|
||||
use App\Models\LelongBid;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
trait ResolvesJanaNotisJumlah
|
||||
{
|
||||
/**
|
||||
* Resolve total amount (jumlah) for a SAG, matching PDF jananotis calculation.
|
||||
*
|
||||
* @return string|null Formatted amount e.g. "1,234.56"
|
||||
*/
|
||||
protected function resolveJanaNotisJumlah($kodcaw, $lelongId, $suratnotis)
|
||||
{
|
||||
$lelongBid = LelongBid::where('lelong_id', $lelongId)
|
||||
->where('norujukan', $suratnotis->norujukan)
|
||||
->first();
|
||||
|
||||
if (! $lelongBid) {
|
||||
Log::warning('Jana notis jumlah: lelong bid not found', [
|
||||
'lelong_id' => $lelongId,
|
||||
'norujukan' => $suratnotis->norujukan,
|
||||
]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$tagbaru = (string) $suratnotis->tagbaru;
|
||||
$jeniskeuntungan = $tagbaru === '1' ? 'onepercent' : 'asal';
|
||||
|
||||
$api = Http::get(config('app.api_ujrah_url').'get/upahtawarruqbytarikh', [
|
||||
'kodcaw' => $kodcaw,
|
||||
'norujukan' => $suratnotis->norujukan,
|
||||
'tarikh' => $lelongBid->t_lelong,
|
||||
'jeniskeuntungan' => $jeniskeuntungan,
|
||||
])->json();
|
||||
|
||||
if (! is_array($api)) {
|
||||
Log::warning('Jana notis jumlah: API returned null', [
|
||||
'norujukan' => $suratnotis->norujukan,
|
||||
'jeniskeuntungan' => $jeniskeuntungan,
|
||||
]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$nilaipembiayaan = (float) $lelongBid->pinjaman;
|
||||
|
||||
if ($tagbaru === '1') {
|
||||
$jumlah = $nilaipembiayaan + (float) ($api['pendapatan'] ?? 0);
|
||||
} else {
|
||||
$jumlah = $nilaipembiayaan + (float) ($api['upahsemasa'] ?? 0);
|
||||
}
|
||||
|
||||
return number_format($jumlah, 2, '.', ',');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Cawangan;
|
||||
use App\Models\Customer;
|
||||
use App\Models\Gadai;
|
||||
use App\Models\JanaNotisExport;
|
||||
use App\Models\Lelong;
|
||||
use App\Models\LelongBid;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
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 Illuminate\Support\Facades\Storage;
|
||||
use PDF;
|
||||
use Throwable;
|
||||
|
||||
class GenerateJanaNotisPdf implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $timeout = 600;
|
||||
|
||||
public $tries = 1;
|
||||
|
||||
protected $exportId;
|
||||
|
||||
public function __construct($exportId)
|
||||
{
|
||||
$this->exportId = $exportId;
|
||||
$this->onQueue('jana-notis');
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
ini_set('memory_limit', '2048M');
|
||||
|
||||
$export = JanaNotisExport::find($this->exportId);
|
||||
if (! $export) {
|
||||
return;
|
||||
}
|
||||
|
||||
$export->update([
|
||||
'status' => JanaNotisExport::STATUS_PROCESSING,
|
||||
'error_message' => null,
|
||||
]);
|
||||
|
||||
$user = User::find($export->user_id);
|
||||
$caw = Cawangan::where('caw_code', $export->kodcaw)->first();
|
||||
$lelong_id = $export->lelong_id;
|
||||
$fasa = (int) $export->fasa;
|
||||
|
||||
Log::info("Jana notis fasa {$fasa} (queued): {$export->kodcaw}, ".($user->name ?? 'unknown'));
|
||||
|
||||
$tarikh_cetak = Carbon::now()->toDateString();
|
||||
$lelongid = Lelong::find($lelong_id);
|
||||
|
||||
$arraynorujukan = LelongBid::where('lelong_id', $lelong_id)
|
||||
->where('kodcaw', $caw->caw_code)
|
||||
->pluck('norujukan');
|
||||
|
||||
$marhuns = Gadai::on($caw->caw_code)
|
||||
->whereIn('norujukan', $arraynorujukan)
|
||||
->select('nokp', 'norujukan', 'bakipjm', 'tagbaru')
|
||||
->orderBy('nokp', 'asc')
|
||||
->get();
|
||||
|
||||
$customers = Customer::whereIn('kpbaru', $marhuns->pluck('nokp'))
|
||||
->orWhereIn('kplama', $marhuns->pluck('nokp'))
|
||||
->join('poskod', 'customer.poskod', '=', 'poskod.poskod')
|
||||
->join('daerah', 'poskod.koddaerah', '=', 'daerah.koddaerah')
|
||||
->join('negeri', 'poskod.kodnegeri', '=', 'negeri.kodnegeri')
|
||||
->get();
|
||||
|
||||
$customers_keyBy_noKp = $customers->keyBy(function ($item) {
|
||||
if ($item->kpbaru != '') {
|
||||
return $item->kpbaru;
|
||||
}
|
||||
if ($item->kplama != '') {
|
||||
return $item->kplama;
|
||||
}
|
||||
});
|
||||
|
||||
foreach ($marhuns as $index => $marhun) {
|
||||
if (isset($customers_keyBy_noKp[$marhun->nokp])) {
|
||||
$marhuns[$index]['nama'] = $customers_keyBy_noKp[$marhun->nokp];
|
||||
}
|
||||
|
||||
$getdatalelongbid = LelongBid::where('lelong_id', $lelong_id)
|
||||
->where('norujukan', $marhun->norujukan)
|
||||
->first();
|
||||
|
||||
$tagbaru = $marhun->tagbaru;
|
||||
if ($tagbaru == '0') {
|
||||
$getkeuntunganhinggatarikhlelong = Http::get(config('app.api_ujrah_url').'get/upahtawarruqbytarikh', [
|
||||
'kodcaw' => $export->kodcaw,
|
||||
'norujukan' => $marhun->norujukan,
|
||||
'tarikh' => $getdatalelongbid['t_lelong'],
|
||||
'jeniskeuntungan' => 'asal',
|
||||
])->json();
|
||||
|
||||
$nilaitebus = (float) $getkeuntunganhinggatarikhlelong['harga_tebus'];
|
||||
$nilaipembiayaan = (float) $getdatalelongbid['pinjaman'];
|
||||
$nilaikeuntungan = (float) $getkeuntunganhinggatarikhlelong['upahsemasa'];
|
||||
$jumlah = $nilaipembiayaan + $nilaikeuntungan;
|
||||
|
||||
$marhuns[$index]['nilaitebus'] = $nilaitebus;
|
||||
$marhuns[$index]['nilaipembiayaan'] = $nilaipembiayaan;
|
||||
$marhuns[$index]['nilaikeuntungan'] = $nilaikeuntungan;
|
||||
$marhuns[$index]['jumlah'] = $jumlah;
|
||||
} elseif ($tagbaru == '1') {
|
||||
$getkeuntunganhinggatarikhlelong = Http::get(config('app.api_ujrah_url').'get/upahtawarruqbytarikh', [
|
||||
'kodcaw' => $export->kodcaw,
|
||||
'norujukan' => $marhun->norujukan,
|
||||
'tarikh' => $getdatalelongbid['t_lelong'],
|
||||
'jeniskeuntungan' => 'onepercent',
|
||||
])->json();
|
||||
|
||||
$nilaitebus = (float) $getkeuntunganhinggatarikhlelong['harga_tebus'];
|
||||
$nilaipembiayaan = (float) $getdatalelongbid['pinjaman'];
|
||||
$nilaipendapatan = (float) $getkeuntunganhinggatarikhlelong['pendapatan'];
|
||||
$nilaikeuntungan = (float) $getkeuntunganhinggatarikhlelong['keuntungan'];
|
||||
$nilaiujrah = (float) $getkeuntunganhinggatarikhlelong['ujrah'];
|
||||
$jumlah = $nilaipembiayaan + $nilaipendapatan;
|
||||
|
||||
$marhuns[$index]['nilaitebus'] = $nilaitebus;
|
||||
$marhuns[$index]['nilaipembiayaan'] = $nilaipembiayaan;
|
||||
$marhuns[$index]['nilaikeuntungan'] = $nilaikeuntungan;
|
||||
$marhuns[$index]['nilaiujrah'] = $nilaiujrah;
|
||||
$marhuns[$index]['jumlah'] = $jumlah;
|
||||
}
|
||||
}
|
||||
|
||||
$view = $fasa === 2 ? 'pdf.jananotisfasa2_new' : 'pdf.jananotis_new';
|
||||
$fileName = 'Penjanaan Notis Fasa '.$fasa.':Batch Lelong '.$lelong_id.'.pdf';
|
||||
$relativePath = 'jana_notis/'.$export->kodcaw.'/'.$lelong_id.'_fasa'.$fasa.'_'.$export->id.'.pdf';
|
||||
|
||||
$pdf = PDF::loadView($view, compact('marhuns', 'lelongid', 'caw', 'tarikh_cetak'))
|
||||
->setPaper('a4', 'potrait');
|
||||
|
||||
Storage::disk('local')->put($relativePath, $pdf->output());
|
||||
|
||||
$export->update([
|
||||
'status' => JanaNotisExport::STATUS_COMPLETED,
|
||||
'file_path' => $relativePath,
|
||||
'file_name' => $fileName,
|
||||
'error_message' => null,
|
||||
]);
|
||||
|
||||
if ($fasa === 2) {
|
||||
WhatsappNotisLelongFasa2::dispatch($export->user_id, $export->kodcaw, $export->lelong_id);
|
||||
} else {
|
||||
WhatsappNotisLelongFasa1::dispatch($export->user_id, $export->kodcaw, $export->lelong_id);
|
||||
}
|
||||
|
||||
Log::info("Queued WhatsApp Jana Notis fasa {$fasa} for lelong {$export->lelong_id}");
|
||||
}
|
||||
|
||||
public function failed(Throwable $exception)
|
||||
{
|
||||
$export = JanaNotisExport::find($this->exportId);
|
||||
if ($export) {
|
||||
$export->update([
|
||||
'status' => JanaNotisExport::STATUS_FAILED,
|
||||
'error_message' => $exception->getMessage(),
|
||||
]);
|
||||
}
|
||||
|
||||
Log::error('GenerateJanaNotisPdf failed: '.$exception->getMessage(), [
|
||||
'export_id' => $this->exportId,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -2,24 +2,24 @@
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Mail\Pemenang;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\Pemenang;
|
||||
|
||||
class HantarMail implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $user_email;
|
||||
|
||||
public $user_name;
|
||||
|
||||
protected $total_bid_win_converted;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
|
||||
@@ -3,14 +3,11 @@
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Mail\NotifyAdmin;
|
||||
use App\Mail\NotifyJanaNotis as MailNotifyJanaNotis;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class NotifyJanaNotis implements ShouldQueue
|
||||
@@ -18,9 +15,13 @@ class NotifyJanaNotis implements ShouldQueue
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $user_id;
|
||||
|
||||
public $user_kodcaw;
|
||||
|
||||
private $user_name;
|
||||
|
||||
private $description;
|
||||
|
||||
private $date_time;
|
||||
|
||||
/**
|
||||
@@ -53,7 +54,7 @@ class NotifyJanaNotis implements ShouldQueue
|
||||
|
||||
$admin_emails = explode(',', config('app.admin_email'));
|
||||
|
||||
foreach($admin_emails as $email) {
|
||||
foreach ($admin_emails as $email) {
|
||||
Mail::to($email)->send(new NotifyAdmin($content_collection));
|
||||
}
|
||||
|
||||
|
||||
@@ -2,166 +2,143 @@
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Jobs\Concerns\ResolvesJanaNotisJumlah;
|
||||
use App\Models\Cawangan;
|
||||
use App\Models\Customer;
|
||||
use App\Models\Gadai;
|
||||
use App\Models\Lelong;
|
||||
use App\Models\LelongBid;
|
||||
use App\Services\WhatsAppCloudService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use App\Models\Cawangan;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Lelong;
|
||||
use App\Models\LelongCawangan;
|
||||
use App\Models\LelongBid;
|
||||
use App\Models\Gadai;
|
||||
use App\Models\Customer;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Models\CawanganLelong;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use DateTime;
|
||||
|
||||
class WhatsappNotisLelongFasa1 implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
use Dispatchable, InteractsWithQueue, Queueable, ResolvesJanaNotisJumlah, SerializesModels;
|
||||
|
||||
public $timeout = 600;
|
||||
|
||||
public $tries = 1;
|
||||
|
||||
public $user_id;
|
||||
|
||||
public $user_kodcaw;
|
||||
|
||||
protected $lelong_id;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function __construct($user_id, $user_kodcaw, $lelong_id)
|
||||
{
|
||||
$this->user_id = $user_id;
|
||||
$this->user_kodcaw = $user_kodcaw;
|
||||
$this->lelong_id = $lelong_id;
|
||||
$this->onQueue('default');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(WhatsAppCloudService $whatsapp)
|
||||
{
|
||||
// $user = Auth::user();
|
||||
$caw = Cawangan::where('caw_code', '=', $this->user_kodcaw)->first();
|
||||
if (! $whatsapp->isEnabled()) {
|
||||
Log::warning('WhatsappNotisLelongFasa1 skipped: WhatsApp Cloud API not enabled.');
|
||||
|
||||
$currentdate = Carbon::now();
|
||||
return;
|
||||
}
|
||||
|
||||
$lel = Lelong::with('cawangan')->find($this->lelong_id);
|
||||
// dd($lel->tarikh_lelong);
|
||||
|
||||
$cawanganDetail = $lel->cawangan->find($caw->id);
|
||||
$lelong_id = $this->lelong_id;
|
||||
$cawangan = Cawangan::with(["lelongBid" => function($q) use ($lelong_id){
|
||||
$q->where('lelong_id', '=', $lelong_id)->select('id','caw_id','kodcaw','norujukan','pinjaman','bakiupah','hargaasas','nilaimarhun','cajlelong','baki','t_lelong');
|
||||
}])
|
||||
->where('caw_code','=',$cawanganDetail->caw_code)->first();
|
||||
$lelongbid_data_pluck_norujukan = $cawangan->lelongBid->pluck('norujukan')->toArray();
|
||||
$gadai_all = Gadai::on($cawanganDetail->caw_code)->whereIn('gadai.norujukan', $lelongbid_data_pluck_norujukan)
|
||||
->orderBy('nokp', 'asc')
|
||||
->orderBy('norujukan','ASC')
|
||||
->get();
|
||||
$caw = Cawangan::where('caw_code', $this->user_kodcaw)->first();
|
||||
if (! $caw) {
|
||||
Log::error('WhatsappNotisLelongFasa1: cawangan not found', ['kodcaw' => $this->user_kodcaw]);
|
||||
|
||||
$customers_list = $gadai_all->pluck('nokp')->unique();
|
||||
$customers = Customer::whereIn('kpbaru', $customers_list)
|
||||
->orWhereIn('kplama', $customers_list)
|
||||
->select('id','kpbaru','kplama' ,'nama', 'telefon')
|
||||
->get()->keyBy('id');
|
||||
|
||||
$customers_keyBy_noKp = $customers->keyBy(function ($item) {
|
||||
return;
|
||||
}
|
||||
|
||||
$lel = Lelong::find($this->lelong_id);
|
||||
if (! $lel) {
|
||||
Log::error('WhatsappNotisLelongFasa1: lelong not found', ['lelong_id' => $this->lelong_id]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$arraynorujukan = LelongBid::where('lelong_id', $this->lelong_id)
|
||||
->where('kodcaw', $caw->caw_code)
|
||||
->pluck('norujukan');
|
||||
|
||||
$gadaiAll = Gadai::on($caw->caw_code)
|
||||
->whereIn('norujukan', $arraynorujukan)
|
||||
->orderBy('nokp', 'asc')
|
||||
->orderBy('norujukan', 'asc')
|
||||
->get();
|
||||
|
||||
$customers = Customer::whereIn('kpbaru', $gadaiAll->pluck('nokp'))
|
||||
->orWhereIn('kplama', $gadaiAll->pluck('nokp'))
|
||||
->select('id', 'kpbaru', 'kplama', 'nama', 'telefon')
|
||||
->get();
|
||||
|
||||
$customersByKp = $customers->keyBy(function ($item) {
|
||||
if ($item->kpbaru != '') {
|
||||
return $item->kpbaru;
|
||||
} else if ($item->kplama != '') {
|
||||
}
|
||||
if ($item->kplama != '') {
|
||||
return $item->kplama;
|
||||
}
|
||||
});
|
||||
|
||||
$customers_pluck_notel = $customers_keyBy_noKp->pluck('telefon');
|
||||
// dd($customers_pluck_notel);
|
||||
foreach($customers_pluck_notel as $index1 =>$custphone) {
|
||||
// dd($custphone);
|
||||
$special = preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $custphone);
|
||||
// dump($special);
|
||||
if($special == 0){
|
||||
if($custphone == ''){
|
||||
$newtel = '';
|
||||
}elseif($custphone <> ''){
|
||||
$newtel = '6'.$custphone;
|
||||
}
|
||||
}
|
||||
elseif($special == 1){
|
||||
if($custphone == ''){
|
||||
$newtel = '';
|
||||
}elseif($custphone <> ''){
|
||||
$newtel = '6'.str_replace( array( '-' ), '', $custphone);
|
||||
}
|
||||
}
|
||||
// dump($newtel);
|
||||
|
||||
}
|
||||
$lelong_bid_all_groupby_norujukan = $cawangan->lelongBid->groupBy('norujukan');
|
||||
$lelong_all_keyBy_norujukan = $gadai_all->keyBy('norujukan');
|
||||
foreach($lelong_bid_all_groupby_norujukan as $index7=>$lelongbid){
|
||||
// dd($notis_all_keyBy_norujukan);
|
||||
if($lelong_all_keyBy_norujukan[$index7]){
|
||||
|
||||
$gadai_true = $lelong_all_keyBy_norujukan[$index7];
|
||||
$gadai_true['data_lelongbid'] = $lelongbid;
|
||||
|
||||
$tarikhLelong = Carbon::parse($lel->tarikh_lelong)->format('d-m-Y');
|
||||
$tarikhSebelum = Carbon::parse($lel->tarikh_lelong)->subDays(3)->format('d-m-Y');
|
||||
$template = config('whatsapp.jana_notis_template');
|
||||
$lang = config('whatsapp.jana_notis_template_lang');
|
||||
|
||||
foreach ($gadaiAll as $suratnotis) {
|
||||
if (! isset($customersByKp[$suratnotis->nokp])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
// dd($gadai_all);
|
||||
foreach ($gadai_all as $index => $suratnotis) {
|
||||
$datanotisbid = $suratnotis['data_lelongbid'][0]->fasa;
|
||||
// dd($suratnotis);
|
||||
if($customers_keyBy_noKp[$suratnotis->nokp])
|
||||
{
|
||||
$mobile_no = '60178916936';
|
||||
// $mobile_no = $newtel;
|
||||
$user_true = $customers_keyBy_noKp[$suratnotis->nokp];
|
||||
$nama = $user_true->nama;
|
||||
$t_lelong = Carbon::parse($lel->tarikh_lelong);
|
||||
$t_lelongf1 = $t_lelong->format('d-m-Y');
|
||||
$cawname = $caw->caw_name;
|
||||
$para2blast = $caw->para2blast;
|
||||
$myDateTime = DateTime::createFromFormat('Y-m-d', $lel->tarikh_lelong );
|
||||
$datez = $myDateTime->modify('-3 day')->format('d-m-Y');
|
||||
// dd($t_matang1);
|
||||
$message = '*LELONGAN AWAM BARANG GADAIAN PADA '.$t_lelongf1.'*
|
||||
|
||||
Nama: *'.$nama.'*
|
||||
No.KP: *'.$suratnotis->nokp.'*'.'
|
||||
No.Rujukan: *'.$suratnotis->norujukan.'*
|
||||
Cawangan: *'.$cawname.'*
|
||||
Waktu Lelong: *10.30Pagi*
|
||||
|
||||
Tuan/Puan adalah dikehendaki untuk membuat urusan berikut dikaunter cawangan pada atau sebelum *'.$datez.'*:-
|
||||
|
||||
'.$para2blast.'.
|
||||
|
||||
Terima Kasih';
|
||||
|
||||
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')
|
||||
$customer = $customersByKp[$suratnotis->nokp];
|
||||
$recipient = $whatsapp->resolveRecipient($customer->telefon);
|
||||
if (! $recipient) {
|
||||
Log::warning('WhatsappNotisLelongFasa1: invalid phone', [
|
||||
'nokp' => $suratnotis->nokp,
|
||||
'norujukan' => $suratnotis->norujukan,
|
||||
]);
|
||||
|
||||
Log::info("WABOT - Notis Lelongan Fasa 1" . $response);
|
||||
continue;
|
||||
}
|
||||
sleep(2);
|
||||
|
||||
$jumlah = $this->resolveJanaNotisJumlah($caw->caw_code, $this->lelong_id, $suratnotis);
|
||||
if ($jumlah === null) {
|
||||
Log::warning('WhatsappNotisLelongFasa1: skip send, jumlah unavailable', [
|
||||
'norujukan' => $suratnotis->norujukan,
|
||||
]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (empty($caw->notel)) {
|
||||
Log::warning('WhatsappNotisLelongFasa1: skip send, cawangan phone missing', [
|
||||
'kodcaw' => $caw->caw_code,
|
||||
'norujukan' => $suratnotis->norujukan,
|
||||
]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// {{1}} nama, {{2}} norujukan, {{3}} jumlah, {{4}} tarikh lelong,
|
||||
// {{5}} tarikh akhir bayaran, {{6}} telefon cawangan, {{7}} cawangan
|
||||
$bodyParams = [
|
||||
$customer->nama,
|
||||
$suratnotis->norujukan,
|
||||
$jumlah,
|
||||
$tarikhLelong,
|
||||
$tarikhSebelum,
|
||||
$caw->notel,
|
||||
$caw->caw_name,
|
||||
];
|
||||
|
||||
$whatsapp->sendTemplate($recipient, $template, $bodyParams, $lang);
|
||||
|
||||
usleep(300000); // 0.3s soft rate-limit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,166 +2,143 @@
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Jobs\Concerns\ResolvesJanaNotisJumlah;
|
||||
use App\Models\Cawangan;
|
||||
use App\Models\Customer;
|
||||
use App\Models\Gadai;
|
||||
use App\Models\Lelong;
|
||||
use App\Models\LelongBid;
|
||||
use App\Services\WhatsAppCloudService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use App\Models\Cawangan;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Lelong;
|
||||
use App\Models\LelongCawangan;
|
||||
use App\Models\LelongBid;
|
||||
use App\Models\Gadai;
|
||||
use App\Models\Customer;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Models\CawanganLelong;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use DateTime;
|
||||
|
||||
class WhatsappNotisLelongFasa2 implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
use Dispatchable, InteractsWithQueue, Queueable, ResolvesJanaNotisJumlah, SerializesModels;
|
||||
|
||||
public $timeout = 600;
|
||||
|
||||
public $tries = 1;
|
||||
|
||||
public $user_id;
|
||||
|
||||
public $user_kodcaw;
|
||||
|
||||
protected $lelong_id;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function __construct($user_id, $user_kodcaw, $lelong_id)
|
||||
{
|
||||
$this->user_id = $user_id;
|
||||
$this->user_kodcaw = $user_kodcaw;
|
||||
$this->lelong_id = $lelong_id;
|
||||
$this->onQueue('default');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(WhatsAppCloudService $whatsapp)
|
||||
{
|
||||
// $user = Auth::user();
|
||||
$caw = Cawangan::where('caw_code', '=', $this->user_kodcaw)->first();
|
||||
if (! $whatsapp->isEnabled()) {
|
||||
Log::warning('WhatsappNotisLelongFasa2 skipped: WhatsApp Cloud API not enabled.');
|
||||
|
||||
$currentdate = Carbon::now();
|
||||
return;
|
||||
}
|
||||
|
||||
$lel = Lelong::with('cawangan')->find($this->lelong_id);
|
||||
// dd($lel->tarikh_lelong);
|
||||
|
||||
$cawanganDetail = $lel->cawangan->find($caw->id);
|
||||
$lelong_id = $this->lelong_id;
|
||||
$cawangan = Cawangan::with(["lelongBid" => function($q) use ($lelong_id){
|
||||
$q->where('lelong_id', '=', $lelong_id)->select('id','caw_id','kodcaw','norujukan','pinjaman','bakiupah','hargaasas','nilaimarhun','cajlelong','baki','t_lelong');
|
||||
}])
|
||||
->where('caw_code','=',$cawanganDetail->caw_code)->first();
|
||||
$lelongbid_data_pluck_norujukan = $cawangan->lelongBid->pluck('norujukan')->toArray();
|
||||
$gadai_all = Gadai::on($cawanganDetail->caw_code)->whereIn('gadai.norujukan', $lelongbid_data_pluck_norujukan)
|
||||
->orderBy('nokp', 'asc')
|
||||
->orderBy('norujukan','ASC')
|
||||
->get();
|
||||
$caw = Cawangan::where('caw_code', $this->user_kodcaw)->first();
|
||||
if (! $caw) {
|
||||
Log::error('WhatsappNotisLelongFasa2: cawangan not found', ['kodcaw' => $this->user_kodcaw]);
|
||||
|
||||
$customers_list = $gadai_all->pluck('nokp')->unique();
|
||||
$customers = Customer::whereIn('kpbaru', $customers_list)
|
||||
->orWhereIn('kplama', $customers_list)
|
||||
->select('id','kpbaru','kplama' ,'nama', 'telefon')
|
||||
->get()->keyBy('id');
|
||||
|
||||
$customers_keyBy_noKp = $customers->keyBy(function ($item) {
|
||||
return;
|
||||
}
|
||||
|
||||
$lel = Lelong::find($this->lelong_id);
|
||||
if (! $lel) {
|
||||
Log::error('WhatsappNotisLelongFasa2: lelong not found', ['lelong_id' => $this->lelong_id]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$arraynorujukan = LelongBid::where('lelong_id', $this->lelong_id)
|
||||
->where('kodcaw', $caw->caw_code)
|
||||
->pluck('norujukan');
|
||||
|
||||
$gadaiAll = Gadai::on($caw->caw_code)
|
||||
->whereIn('norujukan', $arraynorujukan)
|
||||
->orderBy('nokp', 'asc')
|
||||
->orderBy('norujukan', 'asc')
|
||||
->get();
|
||||
|
||||
$customers = Customer::whereIn('kpbaru', $gadaiAll->pluck('nokp'))
|
||||
->orWhereIn('kplama', $gadaiAll->pluck('nokp'))
|
||||
->select('id', 'kpbaru', 'kplama', 'nama', 'telefon')
|
||||
->get();
|
||||
|
||||
$customersByKp = $customers->keyBy(function ($item) {
|
||||
if ($item->kpbaru != '') {
|
||||
return $item->kpbaru;
|
||||
} else if ($item->kplama != '') {
|
||||
}
|
||||
if ($item->kplama != '') {
|
||||
return $item->kplama;
|
||||
}
|
||||
});
|
||||
|
||||
$customers_pluck_notel = $customers_keyBy_noKp->pluck('telefon');
|
||||
// dd($customers_pluck_notel);
|
||||
foreach($customers_pluck_notel as $index1 =>$custphone) {
|
||||
// dd($custphone);
|
||||
$special = preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $custphone);
|
||||
// dump($special);
|
||||
if($special == 0){
|
||||
if($custphone == ''){
|
||||
$newtel = '';
|
||||
}elseif($custphone <> ''){
|
||||
$newtel = '6'.$custphone;
|
||||
}
|
||||
}
|
||||
elseif($special == 1){
|
||||
if($custphone == ''){
|
||||
$newtel = '';
|
||||
}elseif($custphone <> ''){
|
||||
$newtel = '6'.str_replace( array( '-' ), '', $custphone);
|
||||
}
|
||||
}
|
||||
// dump($newtel);
|
||||
|
||||
}
|
||||
$lelong_bid_all_groupby_norujukan = $cawangan->lelongBid->groupBy('norujukan');
|
||||
$lelong_all_keyBy_norujukan = $gadai_all->keyBy('norujukan');
|
||||
foreach($lelong_bid_all_groupby_norujukan as $index7=>$lelongbid){
|
||||
// dd($notis_all_keyBy_norujukan);
|
||||
if($lelong_all_keyBy_norujukan[$index7]){
|
||||
|
||||
$gadai_true = $lelong_all_keyBy_norujukan[$index7];
|
||||
$gadai_true['data_lelongbid'] = $lelongbid;
|
||||
|
||||
$tarikhLelong = Carbon::parse($lel->tarikh_lelong)->format('d-m-Y');
|
||||
$tarikhSebelum = Carbon::parse($lel->tarikh_lelong)->subDays(3)->format('d-m-Y');
|
||||
$template = config('whatsapp.jana_notis_template');
|
||||
$lang = config('whatsapp.jana_notis_template_lang');
|
||||
|
||||
foreach ($gadaiAll as $suratnotis) {
|
||||
if (! isset($customersByKp[$suratnotis->nokp])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
// dd($gadai_all);
|
||||
foreach ($gadai_all as $index => $suratnotis) {
|
||||
$datanotisbid = $suratnotis['data_lelongbid'][0]->fasa;
|
||||
// dd($suratnotis);
|
||||
if($customers_keyBy_noKp[$suratnotis->nokp])
|
||||
{
|
||||
$mobile_no = '60178916936';
|
||||
// $mobile_no = $newtel;
|
||||
$user_true = $customers_keyBy_noKp[$suratnotis->nokp];
|
||||
$nama = $user_true->nama;
|
||||
$t_lelong = Carbon::parse($lel->tarikh_lelong);
|
||||
$t_lelongf1 = $t_lelong->format('d-m-Y');
|
||||
$cawname = $caw->caw_name;
|
||||
$para2blast = $caw->para3blast;
|
||||
$myDateTime = DateTime::createFromFormat('Y-m-d', $lel->tarikh_lelong );
|
||||
$datez = $myDateTime->modify('-3 day')->format('d-m-Y');
|
||||
// dd($t_matang1);
|
||||
$message = '*LELONGAN AWAM BARANG GADAIAN PADA '.$t_lelongf1.'*
|
||||
|
||||
Nama: *'.$nama.'*
|
||||
No.KP: *'.$suratnotis->nokp.'*'.'
|
||||
No.Rujukan: *'.$suratnotis->norujukan.'*
|
||||
Cawangan: *'.$cawname.'*
|
||||
Waktu Lelong: *10.30Pagi*
|
||||
|
||||
Tuan/Puan adalah dikehendaki untuk membuat urusan berikut dikaunter cawangan pada atau sebelum *'.$datez.'*:-
|
||||
|
||||
'.$para2blast.'.
|
||||
|
||||
Terima Kasih';
|
||||
|
||||
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')
|
||||
$customer = $customersByKp[$suratnotis->nokp];
|
||||
$recipient = $whatsapp->resolveRecipient($customer->telefon);
|
||||
if (! $recipient) {
|
||||
Log::warning('WhatsappNotisLelongFasa2: invalid phone', [
|
||||
'nokp' => $suratnotis->nokp,
|
||||
'norujukan' => $suratnotis->norujukan,
|
||||
]);
|
||||
|
||||
Log::info("WABOT - Notis Lelongan Fasa 2" . $response);
|
||||
continue;
|
||||
}
|
||||
sleep(2);
|
||||
|
||||
$jumlah = $this->resolveJanaNotisJumlah($caw->caw_code, $this->lelong_id, $suratnotis);
|
||||
if ($jumlah === null) {
|
||||
Log::warning('WhatsappNotisLelongFasa2: skip send, jumlah unavailable', [
|
||||
'norujukan' => $suratnotis->norujukan,
|
||||
]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (empty($caw->notel)) {
|
||||
Log::warning('WhatsappNotisLelongFasa2: skip send, cawangan phone missing', [
|
||||
'kodcaw' => $caw->caw_code,
|
||||
'norujukan' => $suratnotis->norujukan,
|
||||
]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// {{1}} nama, {{2}} norujukan, {{3}} jumlah, {{4}} tarikh lelong,
|
||||
// {{5}} tarikh akhir bayaran, {{6}} telefon cawangan, {{7}} cawangan
|
||||
$bodyParams = [
|
||||
$customer->nama,
|
||||
$suratnotis->norujukan,
|
||||
$jumlah,
|
||||
$tarikhLelong,
|
||||
$tarikhSebelum,
|
||||
$caw->notel,
|
||||
$caw->caw_name,
|
||||
];
|
||||
|
||||
$whatsapp->sendTemplate($recipient, $template, $bodyParams, $lang);
|
||||
|
||||
usleep(300000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,39 +2,38 @@
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Cawangan;
|
||||
use App\Models\Customer;
|
||||
use App\Models\Gadai;
|
||||
use App\Models\Notis;
|
||||
use App\Models\NotisBid;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use App\Models\Cawangan;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Notis;
|
||||
use App\Models\NotisBid;
|
||||
use App\Models\Gadai;
|
||||
use App\Models\Customer;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Models\CawanganNotis;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class WhatsappNotisPeringatanKedua implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $user_id;
|
||||
|
||||
public $user_kodcaw;
|
||||
|
||||
protected $notisid;
|
||||
|
||||
protected $cawid;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($user_id, $user_kodcaw, $notisid,$cawid)
|
||||
public function __construct($user_id, $user_kodcaw, $notisid, $cawid)
|
||||
{
|
||||
$this->user_id = $user_id;
|
||||
$this->user_kodcaw = $user_kodcaw;
|
||||
@@ -57,66 +56,64 @@ class WhatsappNotisPeringatanKedua implements ShouldQueue
|
||||
|
||||
$notis = Notis::find($this->notisid);
|
||||
// dd($notis->tarikh_notis);
|
||||
$notis_bid_all = NotisBid::select('id','nokp','norujukan','jbg','pinjaman','fasa')->where('notis_id', $this->notisid)->where('kodcaw', $caw->caw_code)->get();
|
||||
$notis_bid_all = NotisBid::select('id', 'nokp', 'norujukan', 'jbg', 'pinjaman', 'fasa')->where('notis_id', $this->notisid)->where('kodcaw', $caw->caw_code)->get();
|
||||
$arraynorujukan_notis_bid_all = NotisBid::where('notis_id', $this->notisid)->where('kodcaw', $caw->caw_code)->pluck('norujukan');
|
||||
|
||||
|
||||
$arraynorujukan = NotisBid::where('notis_id', $this->notisid)->where('kodcaw', $caw->caw_code)->pluck('norujukan');
|
||||
$gadai_all = Gadai::on($caw->caw_code)->whereIn('norujukan', $arraynorujukan)->select('nokp', 'norujukan','bakipjm','t_matang','t_matang1','tempoh')->orderBy('nokp', 'asc')->get();
|
||||
|
||||
$gadai_all = Gadai::on($caw->caw_code)->whereIn('norujukan', $arraynorujukan)->select('nokp', 'norujukan', 'bakipjm', 't_matang', 't_matang1', 'tempoh')->orderBy('nokp', 'asc')->get();
|
||||
|
||||
$customers_list = $gadai_all->pluck('nokp')->unique();
|
||||
$customers = Customer::whereIn('kpbaru', $customers_list)
|
||||
->orWhereIn('kplama', $customers_list)
|
||||
->select('id','kpbaru','kplama' ,'nama', 'telefon')
|
||||
->get()->keyBy('id');
|
||||
|
||||
->orWhereIn('kplama', $customers_list)
|
||||
->select('id', 'kpbaru', 'kplama', 'nama', 'telefon')
|
||||
->get()->keyBy('id');
|
||||
|
||||
$customers_keyBy_noKp = $customers->keyBy(function ($item) {
|
||||
if ($item->kpbaru != '') {
|
||||
return $item->kpbaru;
|
||||
} else if ($item->kplama != '') {
|
||||
} elseif ($item->kplama != '') {
|
||||
return $item->kplama;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$customers_pluck_notel = $customers_keyBy_noKp->pluck('telefon');
|
||||
// dd($customers_pluck_notel);
|
||||
foreach($customers_pluck_notel as $index1 =>$custphone) {
|
||||
foreach ($customers_pluck_notel as $index1 => $custphone) {
|
||||
// dd($custphone);
|
||||
$special = preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $custphone);
|
||||
// dump($special);
|
||||
if($special == 0){
|
||||
if($custphone == ''){
|
||||
$newtel = '';
|
||||
}elseif($custphone <> ''){
|
||||
$newtel = '6'.$custphone;
|
||||
}
|
||||
// dump($special);
|
||||
if ($special == 0) {
|
||||
if ($custphone == '') {
|
||||
$newtel = '';
|
||||
} elseif ($custphone != '') {
|
||||
$newtel = '6'.$custphone;
|
||||
}
|
||||
elseif($special == 1){
|
||||
if($custphone == ''){
|
||||
$newtel = '';
|
||||
}elseif($custphone <> ''){
|
||||
$newtel = '6'.str_replace( array( '-' ), '', $custphone);
|
||||
}
|
||||
} elseif ($special == 1) {
|
||||
if ($custphone == '') {
|
||||
$newtel = '';
|
||||
} elseif ($custphone != '') {
|
||||
$newtel = '6'.str_replace(['-'], '', $custphone);
|
||||
}
|
||||
// dump($newtel);
|
||||
|
||||
}
|
||||
// dump($newtel);
|
||||
|
||||
}
|
||||
$notis_bid_all_groupby_norujukan = $notis_bid_all->groupBy('norujukan');
|
||||
$notis_all_keyBy_norujukan = $gadai_all->keyBy('norujukan');
|
||||
foreach($notis_bid_all_groupby_norujukan as $index7=>$notisbid){
|
||||
foreach ($notis_bid_all_groupby_norujukan as $index7 => $notisbid) {
|
||||
// dd($notis_all_keyBy_norujukan);
|
||||
if($notis_all_keyBy_norujukan[$index7]){
|
||||
|
||||
if ($notis_all_keyBy_norujukan[$index7]) {
|
||||
|
||||
$gadai_true = $notis_all_keyBy_norujukan[$index7];
|
||||
$gadai_true['data_notisbid'] = $notisbid;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// dd($gadai_all);
|
||||
foreach ($gadai_all as $index => $suratnotis) {
|
||||
$datanotisbid = $suratnotis['data_notisbid'][0]->fasa;
|
||||
// dd($suratnotis);
|
||||
if($customers_keyBy_noKp[$suratnotis->nokp])
|
||||
{
|
||||
if ($customers_keyBy_noKp[$suratnotis->nokp]) {
|
||||
$mobile_no = '60178916936';
|
||||
// $mobile_no = $newtel;
|
||||
$user_true = $customers_keyBy_noKp[$suratnotis->nokp];
|
||||
@@ -128,7 +125,7 @@ class WhatsappNotisPeringatanKedua implements ShouldQueue
|
||||
$t_matangf2 = $t_matang1->format('d-m-Y');
|
||||
$cawname = $caw->caw_name;
|
||||
// dd($t_matang1);
|
||||
if( $datanotisbid == '1'){
|
||||
if ($datanotisbid == '1') {
|
||||
$message = '*NOTIS PEMBERITAHUAN*
|
||||
|
||||
Nama: *'.$nama.'*
|
||||
@@ -140,8 +137,7 @@ Tempoh: *'.$suratnotis->tempoh.' bulan*
|
||||
|
||||
Tuan/puan atau wakil adalah dikehendaki menebus/membayar *KOS KEUNTUNGAN* tersebut secepat mungkin. Jika pihak tuan/puan menghadapi sebarang masalah, sila hubungi kami sebagaimana alamat di dalam *Surat Akaun Gadaian* ATAU datang sendiri ke *'.$cawname.'* dengan membawa bersama salinan asal Surat Akaun Gadaian tuan/puan.
|
||||
Sekian, terima kasih.';
|
||||
}
|
||||
else if( $datanotisbid == '2'){
|
||||
} elseif ($datanotisbid == '2') {
|
||||
$message = '*NOTIS PEMBERITAHUAN*
|
||||
|
||||
Nama: *'.$nama.'*
|
||||
@@ -154,20 +150,19 @@ Tempoh: *'.$suratnotis->tempoh.' bulan*.
|
||||
Tuan/puan atau wakil adalah dikehendaki menebus/tukar surat di premis kami dengan kadar yang segera. Jika pihak tuan/puan menghadapi sebarang masalah, sila hubungi kami sebagaimana alamat di dalam *Surat Akaun Gadaian* ATAU datang sendiri ke *'.$cawname.'* dengan membawa bersama salinan asal Surat Akaun Gadaian tuan/puan.
|
||||
Sekian, terima kasih.';
|
||||
|
||||
|
||||
}
|
||||
if(config('app.env') != 'production'){
|
||||
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,
|
||||
'message' => $message,
|
||||
'instance_id' => config('app.wabot_instances_id'),
|
||||
'access_token' => config('app.wabot_token_keys')
|
||||
'access_token' => config('app.wabot_token_keys'),
|
||||
]);
|
||||
|
||||
Log::info("WABOT - notis peringatan kedua " . $response);
|
||||
Log::info('WABOT - notis peringatan kedua '.$response);
|
||||
}
|
||||
sleep(2);
|
||||
}
|
||||
|
||||
@@ -2,40 +2,37 @@
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Cawangan;
|
||||
use App\Models\Customer;
|
||||
use App\Models\Lelong;
|
||||
use App\Models\LelongCawangan;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use App\Models\Cawangan;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Lelong;
|
||||
use App\Models\LelongCawangan;
|
||||
use App\Models\LelongBid;
|
||||
use App\Models\Gadai;
|
||||
use App\Models\Customer;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Models\CawanganLelong;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class WhatsappNotisTuntutBaki implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $user_id;
|
||||
|
||||
public $user_kodcaw;
|
||||
|
||||
protected $lelong_id;
|
||||
|
||||
protected $caw_id;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($user_id, $user_kodcaw, $lelong_id,$caw_id)
|
||||
public function __construct($user_id, $user_kodcaw, $lelong_id, $caw_id)
|
||||
{
|
||||
$this->user_id = $user_id;
|
||||
$this->user_kodcaw = $user_kodcaw;
|
||||
@@ -56,77 +53,75 @@ class WhatsappNotisTuntutBaki implements ShouldQueue
|
||||
$currentdate = Carbon::now();
|
||||
|
||||
$lel = Lelong::with('cawangan')->find($this->lelong_id);
|
||||
|
||||
|
||||
$cawanganDetail = $lel->cawangan->find($this->caw_id);
|
||||
$lelong_id = $this->lelong_id;
|
||||
$cawangan = Cawangan::with(["lelongBid" => function($q) use ($lelong_id){
|
||||
$q->where('lelong_id', '=', $lelong_id)->select('id','caw_id','kodcaw','norujukan','pinjaman','bakiupah','hargaasas','nilaimarhun','cajlelong','baki');
|
||||
$cawangan = Cawangan::with(['lelongBid' => function ($q) use ($lelong_id) {
|
||||
$q->where('lelong_id', '=', $lelong_id)->select('id', 'caw_id', 'kodcaw', 'norujukan', 'pinjaman', 'bakiupah', 'hargaasas', 'nilaimarhun', 'cajlelong', 'baki');
|
||||
}])
|
||||
->where('caw_code','=',$cawanganDetail->caw_code)->first();
|
||||
->where('caw_code', '=', $cawanganDetail->caw_code)->first();
|
||||
$lelongbid_data_pluck_norujukan = $cawangan->lelongBid->pluck('norujukan')->toArray();
|
||||
$gadai_all = LelongCawangan::on($cawanganDetail->caw_code)->whereIn('lelong.norujukan', $lelongbid_data_pluck_norujukan)
|
||||
->join('gadai','gadai.norujukan','=','lelong.norujukan')
|
||||
->where('trkhtuntut','=',null)
|
||||
->where('baki','>', '0.00')
|
||||
->select('nokp', 'lelong.norujukan','lelong.t_lelong AS tarikhlelong','lelong.hargajual','lelong.gst_hj','gadai.bakipjm','lelong.bakiupah','lelong.cajlelong','lelong.gst_cl','lelong.cajlain','lelong.baki')
|
||||
->orderBy('nokp', 'asc')
|
||||
->orderBy('lelong.norujukan','ASC')
|
||||
->get();
|
||||
->join('gadai', 'gadai.norujukan', '=', 'lelong.norujukan')
|
||||
->where('trkhtuntut', '=', null)
|
||||
->where('baki', '>', '0.00')
|
||||
->select('nokp', 'lelong.norujukan', 'lelong.t_lelong AS tarikhlelong', 'lelong.hargajual', 'lelong.gst_hj', 'gadai.bakipjm', 'lelong.bakiupah', 'lelong.cajlelong', 'lelong.gst_cl', 'lelong.cajlain', 'lelong.baki')
|
||||
->orderBy('nokp', 'asc')
|
||||
->orderBy('lelong.norujukan', 'ASC')
|
||||
->get();
|
||||
|
||||
$customers_list = $gadai_all->pluck('nokp')->unique();
|
||||
$customers = Customer::whereIn('kpbaru', $customers_list)
|
||||
->orWhereIn('kplama', $customers_list)
|
||||
->select('id','kpbaru','kplama' ,'nama', 'telefon')
|
||||
->get()->keyBy('id');
|
||||
|
||||
->orWhereIn('kplama', $customers_list)
|
||||
->select('id', 'kpbaru', 'kplama', 'nama', 'telefon')
|
||||
->get()->keyBy('id');
|
||||
|
||||
$customers_keyBy_noKp = $customers->keyBy(function ($item) {
|
||||
if ($item->kpbaru != '') {
|
||||
return $item->kpbaru;
|
||||
} else if ($item->kplama != '') {
|
||||
} elseif ($item->kplama != '') {
|
||||
return $item->kplama;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$customers_pluck_notel = $customers_keyBy_noKp->pluck('telefon');
|
||||
// dd($customers_pluck_notel);
|
||||
foreach($customers_pluck_notel as $index1 =>$custphone) {
|
||||
foreach ($customers_pluck_notel as $index1 => $custphone) {
|
||||
// dd($custphone);
|
||||
$special = preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $custphone);
|
||||
// dump($special);
|
||||
if($special == 0){
|
||||
if($custphone == ''){
|
||||
$newtel = '';
|
||||
}elseif($custphone <> ''){
|
||||
$newtel = '6'.$custphone;
|
||||
}
|
||||
// dump($special);
|
||||
if ($special == 0) {
|
||||
if ($custphone == '') {
|
||||
$newtel = '';
|
||||
} elseif ($custphone != '') {
|
||||
$newtel = '6'.$custphone;
|
||||
}
|
||||
elseif($special == 1){
|
||||
if($custphone == ''){
|
||||
$newtel = '';
|
||||
}elseif($custphone <> ''){
|
||||
$newtel = '6'.str_replace( array( '-' ), '', $custphone);
|
||||
}
|
||||
} elseif ($special == 1) {
|
||||
if ($custphone == '') {
|
||||
$newtel = '';
|
||||
} elseif ($custphone != '') {
|
||||
$newtel = '6'.str_replace(['-'], '', $custphone);
|
||||
}
|
||||
// dump($newtel);
|
||||
|
||||
}
|
||||
// dump($newtel);
|
||||
|
||||
}
|
||||
$lelong_bid_all_groupby_norujukan = $gadai_all->groupBy('norujukan');
|
||||
$lelong_all_keyBy_norujukan = $gadai_all->keyBy('norujukan');
|
||||
foreach($lelong_bid_all_groupby_norujukan as $index7=>$lelongbid){
|
||||
foreach ($lelong_bid_all_groupby_norujukan as $index7 => $lelongbid) {
|
||||
// dd($notis_all_keyBy_norujukan);
|
||||
if($lelong_all_keyBy_norujukan[$index7]){
|
||||
|
||||
if ($lelong_all_keyBy_norujukan[$index7]) {
|
||||
|
||||
$gadai_true = $lelong_all_keyBy_norujukan[$index7];
|
||||
$gadai_true['data_lelongbid'] = $lelongbid;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// dd($gadai_all);
|
||||
foreach ($gadai_all as $index => $suratnotis) {
|
||||
$datanotisbid = $suratnotis['data_lelongbid'][0]->fasa;
|
||||
// dd($suratnotis);
|
||||
if($customers_keyBy_noKp[$suratnotis->nokp])
|
||||
{
|
||||
if ($customers_keyBy_noKp[$suratnotis->nokp]) {
|
||||
$mobile_no = '60178916936';
|
||||
// $mobile_no = $newtel;
|
||||
$user_true = $customers_keyBy_noKp[$suratnotis->nokp];
|
||||
@@ -137,7 +132,7 @@ class WhatsappNotisTuntutBaki implements ShouldQueue
|
||||
$cawname = $caw->caw_name;
|
||||
$parabaki2 = $caw->parabaki2;
|
||||
// dd($t_matang1);
|
||||
$message = '*NOTIS MAKLUMAN LEBIHAN WANG LELONGAN BARANGAN*
|
||||
$message = '*NOTIS MAKLUMAN LEBIHAN WANG LELONGAN BARANGAN*
|
||||
|
||||
Nama: *'.$nama.'*
|
||||
No.KP: *'.$suratnotis->nokp.'*'.'
|
||||
@@ -145,22 +140,22 @@ No.Rujukan: *'.$suratnotis->norujukan.'*
|
||||
Tarikh Lelong: *'.$t_jualf1.'*
|
||||
Wang Lebihan: *RM'.$baki.'*'.'
|
||||
|
||||
'.$parabaki2. ' *'.$cawname.'*.
|
||||
'.$parabaki2.' *'.$cawname.'*.
|
||||
|
||||
Terima Kasih';
|
||||
|
||||
if(config('app.env') != 'production'){
|
||||
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,
|
||||
'message' => $message,
|
||||
'instance_id' => config('app.wabot_instances_id'),
|
||||
'access_token' => config('app.wabot_token_keys')
|
||||
'access_token' => config('app.wabot_token_keys'),
|
||||
]);
|
||||
|
||||
Log::info("WABOT - Notis Tuntutan Baki Lelong" . $response);
|
||||
Log::info('WABOT - Notis Tuntutan Baki Lelong'.$response);
|
||||
}
|
||||
sleep(2);
|
||||
}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
@@ -2,66 +2,52 @@
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Services\WhatsAppCloudService;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use App\Models\Cawangan;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Notis;
|
||||
use App\Models\NotisBid;
|
||||
use App\Models\Gadai;
|
||||
use App\Models\Customer;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Models\CawanganNotis;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class WhatsappPemenang implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $user_notelbimbit;
|
||||
|
||||
public $total_bid_win_converted;
|
||||
// protected $notisid;
|
||||
// protected $cawid;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function __construct($user_notelbimbit, $total_bid_win_converted)
|
||||
{
|
||||
$this->user_notelbimbit = $user_notelbimbit;
|
||||
$this->total_bid_win_converted = $total_bid_win_converted;
|
||||
// $this->notisid = $notisid;
|
||||
// $this->cawid = $cawid;
|
||||
$this->onQueue('default');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(WhatsAppCloudService $whatsapp)
|
||||
{
|
||||
$mobile_no = ltrim($this->user_notelbimbit, '+');
|
||||
$message = 'AR-RAHN PKB: Tahniah Anda Menang Bidaan Sebanyak RM' . $this->total_bid_win_converted . '. Sila Semak Melalui Sistem ArrahnBid. Terima Kasih.';
|
||||
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')
|
||||
]);
|
||||
if (! $whatsapp->isEnabled()) {
|
||||
Log::warning('WhatsappPemenang skipped: WhatsApp Cloud API not enabled.');
|
||||
|
||||
Log::info("WABOT - menang bidaan " . $response);
|
||||
return;
|
||||
}
|
||||
|
||||
$recipient = $whatsapp->resolveRecipient($this->user_notelbimbit);
|
||||
if (! $recipient) {
|
||||
Log::warning('WhatsappPemenang: invalid phone', [
|
||||
'notelbimbit' => $this->user_notelbimbit,
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// {{1}} jumlah bidaan menang (formatted, without RM)
|
||||
$whatsapp->sendTemplate(
|
||||
$recipient,
|
||||
config('whatsapp.pemenang_template'),
|
||||
[$this->total_bid_win_converted],
|
||||
config('whatsapp.pemenang_template_lang')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use App\Models\Cawangan;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class WhatsappPengesahanPembida implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $user_notelbimbit;
|
||||
public $user_namapembida;
|
||||
public $user_cawname;
|
||||
|
||||
// protected $notisid;
|
||||
// protected $cawid;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($user_notelbimbit,$user_namapembida,$user_cawname)
|
||||
{
|
||||
$this->user_notelbimbit = $user_notelbimbit;
|
||||
$this->user_namapembida = $user_namapembida;
|
||||
$this->user_cawname = $user_cawname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$mobile_no = ltrim($this->user_notelbimbit, '+');
|
||||
$message = 'AR-RAHN PKB: Terima Kasih '.$this->user_namapembida .', Pembayaran Bidaan Anda Untuk Cawangan *'.$this->user_cawname.'* Telah Disahkan, Sila Ke Cawangan Berkenaan Untuk Tuntutan Barang Bidaan Anda Hari Ini.';
|
||||
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')
|
||||
]);
|
||||
|
||||
Log::info("WABOT - Akaun Telah Sahkan Pembayaran: ".$this->user_namapembida .'' . $response);
|
||||
}
|
||||
}
|
||||
@@ -2,19 +2,14 @@
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use App\Models\LogUser;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
|
||||
|
||||
class WhatsappTidakSahBayaran implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
@@ -38,21 +33,20 @@ class WhatsappTidakSahBayaran implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$getnoajk = User::where('user_type', 3)->get();
|
||||
foreach($getnoajk as $notifikasi){
|
||||
$mobile_no = '6'.$notifikasi->notelbimbit;
|
||||
$getnoajk = User::where('user_type', 3)->get();
|
||||
foreach ($getnoajk as $notifikasi) {
|
||||
$mobile_no = '6'.$notifikasi->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' => 'Bayaran Pembida yang bernama *'.$this->user_namapembida.'* Adalah *Tidak Sah*, Mohon Pihak AJK Lelong Untuk Buat Semakan, Terima Kasih.' ,
|
||||
'instance_id' => config('app.wabot_instances_id'),
|
||||
'access_token' => config('app.wabot_token_keys')
|
||||
]);
|
||||
}
|
||||
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' => 'Bayaran Pembida yang bernama *'.$this->user_namapembida.'* Adalah *Tidak Sah*, Mohon Pihak AJK Lelong Untuk Buat Semakan, Terima Kasih.',
|
||||
'instance_id' => config('app.wabot_instances_id'),
|
||||
'access_token' => config('app.wabot_token_keys'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user