tambah function notis peringatan dalam arcc dan blast wasap dan sms

This commit is contained in:
Nur Izzati Zulkifli
2023-12-25 15:50:41 +08:00
parent 060218a6af
commit 0011b12e4d
11 changed files with 571 additions and 25 deletions
+102
View File
@@ -0,0 +1,102 @@
<?php
namespace App\Jobs;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Http;
use App\BlastSMS;
use Carbon\Carbon;
class ARCCSMSPelangganSAGLAMAbysag extends Job
{
public $nokp;
public $telefon;
public $caw_name;
public $nofoncaw;
public $kodcaw;
public $norujukan;
public $tempoh;
public $tmatang;
public $tmatang1;
public $lelong_tawarruq;
public $namapengguna;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($nokp, $telefon, $caw_name,$nofoncaw,$kodcaw,$norujukan,$tempoh,$tmatang,$tmatang1,$lelong_tawarruq,$namapengguna)
{
$this->nokp = $nokp;
$this->telefon = $telefon;
$this->caw_name = $caw_name;
$this->nofoncaw = $nofoncaw;
$this->kodcaw = $kodcaw;
$this->norujukan = $norujukan;
$this->tempoh = $tempoh;
$this->tmatang = $tmatang;
$this->tmatang1 = $tmatang1;
$this->lelong_tawarruq = $lelong_tawarruq;
$this->namapengguna = $namapengguna;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$current = Carbon::now();
$current = new Carbon();
$mobile_no = ltrim($this->telefon, '+6');
// $mobile_no = '60178916936';
// $message = 'test';
$tarikhmatang = $this->tmatang;
$tarikhmatangnew = date('d-m-Y',strtotime($tarikhmatang));
$tarikhmatang1 = $this->tmatang1;
$tarikhmatang1new = date('d-m-Y',strtotime($tarikhmatang1));
$today = $current->toDateString();
// $current_date = new Carbon($current->toDateString());
if($this->lelong_tawarruq == '1'){
if($tarikhmatang > $today){
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, '.$this->norujukan.' telah hampir tamat tempoh untuk tukar ke SAG baru, Sila perbaharui SAG anda di cawangan sebelum '.$tarikhmatangnew.'.';
}elseif($tarikhmatang < $today){
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, '.$this->norujukan.' telah tamat tempoh pada '.$tarikhmatangnew.', Sila perbaharui SAG anda di cawangan Ar-Rahn.';}
}else
if($tarikhmatang1 > $today){
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, '.$this->norujukan.' telah hampir tamat tempoh untuk tukar ke SAG baru, Sila perbaharui SAG anda di cawangan sebelum '.$tarikhmatang1new.'.';
}elseif($tarikhmatang1 <= $today){
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, '.$this->norujukan.' telah tamat tempoh pada '.$tarikhmatang1new.', Sila perbaharui SAG anda di cawangan Ar-Rahn.';}
if(env('APP_ENV') != 'production'){
$mobile_no = env('ADMIN_PHONE_NUMBER');
}
$response = Http::get(env('ONEWAYSMS_API'), [
'apiusername' => env('ONEWAYSMS_AUTH_USER'),
'apipassword' => env('ONEWAYSMS_AUTH_PASS'),
'senderid' => 'INFO',
'mobileno' => $mobile_no,
'message' => $message,
'languagetype' => 1
]);
//insert log blast sms
$logblastsms = new BlastSMS();
$logblastsms->kodcaw = $this->kodcaw;
$logblastsms->nokp = $this->nokp;
$logblastsms->notelefon = $this->telefon;
$logblastsms->norujukan = $this->norujukan;
$logblastsms->tempoh = $this->tempoh;
$logblastsms->status = $response;
$logblastsms->created_at = $current;
$logblastsms->updated_at = $current;
$logblastsms->nama = $this->namapengguna;
$logblastsms->save();
Log::info("ARCC SMS - Pelanggan ".$this->caw_name." SAG Tawarruq -".$mobile_no);
}
}
@@ -0,0 +1,101 @@
<?php
namespace App\Jobs;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Http;
use App\BlastWasap;
use App\NotisPeringatan;
use Carbon\Carbon;
class ARCCWhatsappPelangganSAGLAMAbysag extends Job
{
public $nokp;
public $telefon;
public $caw_name;
public $nofoncaw;
public $kodcaw;
public $norujukan;
public $tempoh;
public $tmatang;
public $tmatang1;
public $lelong_tawarruq;
public $namapengguna;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($nokp, $telefon, $caw_name,$nofoncaw,$kodcaw,$norujukan,$tempoh,$tmatang,$tmatang1,$lelong_tawarruq, $namapengguna)
{
$this->nokp = $nokp;
$this->telefon = $telefon;
$this->caw_name = $caw_name;
$this->nofoncaw = $nofoncaw;
$this->kodcaw = $kodcaw;
$this->norujukan = $norujukan;
$this->tempoh = $tempoh;
$this->tmatang = $tmatang;
$this->tmatang1 = $tmatang1;
$this->lelong_tawarruq = $lelong_tawarruq;
$this->namapengguna = $namapengguna;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$current = Carbon::now();
$current = new Carbon();
$mobile_no = ltrim($this->telefon, '+6');
// $mobile_no = '60178916936';
$tarikhmatang = $this->tmatang;
$tarikhmatangnew = date('d-m-Y',strtotime($tarikhmatang));
$tarikhmatang1 = $this->tmatang1;
$tarikhmatang1new = date('d-m-Y',strtotime($tarikhmatang1));
$today = $current->toDateString();
if($this->lelong_tawarruq == '1'){
if($tarikhmatang > $today){
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, *'.$this->norujukan.'* telah hampir tamat tempoh untuk tukar ke SAG baru, Sila perbaharui SAG anda di cawangan sebelum *'.$tarikhmatangnew.'*.';
}elseif($tarikhmatang <= $today){
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, *'.$this->norujukan.'* telah tamat tempoh pada *'.$tarikhmatangnew.'*, Sila perbaharui SAG anda di cawangan AR-RAHN.';}
}else
if($tarikhmatang1 > $today){
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, *'.$this->norujukan.'* telah hampir tamat tempoh untuk tukar ke SAG baru, Sila perbaharui SAG anda di cawangan sebelum *'.$tarikhmatang1new.'*.';
}elseif($tarikhmatang1 <= $today){
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, *'.$this->norujukan.'* telah tamat tempoh pada *'.$tarikhmatang1new.'*, Sila perbaharui SAG anda di cawangan Ar-Rahn.';}
if(env('APP_ENV') != 'production'){
$mobile_no = env('ADMIN_PHONE_NUMBER');
}
$response = Http::get(env('WABOT_API'), [
'number' => $mobile_no,
'type' => 'text',
'message' => $message,
'instance_id' => env('WABOT_INSTANCES_ID'),
'access_token' => env('WABOT_TOKEN_KEYS')
]);
//insert log blast wasap
$logblastwasap = new BlastWasap();
$logblastwasap->kodcaw = $this->kodcaw;
$logblastwasap->nokp = $this->nokp;
$logblastwasap->notelefon = $this->telefon;
$logblastwasap->norujukan = $this->norujukan;
$logblastwasap->tempoh = $this->tempoh;
$logblastwasap->status = $response;
$logblastwasap->nama = $this->namapengguna;
$logblastwasap->save();
Log::info("ARCC WABOT - Pelanggan SAG Tawarruq".$response);
}
}