update
This commit is contained in:
@@ -0,0 +1,164 @@
|
||||
<?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 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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// $user = Auth::user();
|
||||
$caw = Cawangan::where('caw_code', '=', $this->user_kodcaw)->first();
|
||||
|
||||
$currentdate = Carbon::now();
|
||||
|
||||
$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();
|
||||
|
||||
$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) {
|
||||
if ($item->kpbaru != '') {
|
||||
return $item->kpbaru;
|
||||
} else 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;
|
||||
}
|
||||
|
||||
}
|
||||
// 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';
|
||||
|
||||
$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')
|
||||
]);
|
||||
|
||||
Log::info("WABOT - Notis Lelongan Fasa 1" . $response);
|
||||
}
|
||||
sleep(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
<?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 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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// $user = Auth::user();
|
||||
$caw = Cawangan::where('caw_code', '=', $this->user_kodcaw)->first();
|
||||
|
||||
$currentdate = Carbon::now();
|
||||
|
||||
$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();
|
||||
|
||||
$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) {
|
||||
if ($item->kpbaru != '') {
|
||||
return $item->kpbaru;
|
||||
} else 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;
|
||||
}
|
||||
|
||||
}
|
||||
// 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';
|
||||
|
||||
$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')
|
||||
]);
|
||||
|
||||
Log::info("WABOT - Notis Lelongan Fasa 2" . $response);
|
||||
}
|
||||
sleep(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user