Add feat unsold commodity notifications
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Setting;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class WhatsappUnsoldCommodityScanner extends Job
|
||||
{
|
||||
public $status;
|
||||
public $start_time;
|
||||
public $end_time;
|
||||
public $message;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$settings = Setting::on()->where('group', 'unsold_commodity_notifications')->get();
|
||||
|
||||
$this->status = $settings->where('key', 'status')->first()->value;
|
||||
|
||||
$this->start_time = $settings->where('key', 'start_time')->first()->value;
|
||||
|
||||
$this->end_time = $settings->where('key', 'end_time')->first()->value;
|
||||
|
||||
$this->message = $settings->where('key', 'message')->first()->value;
|
||||
|
||||
if ($this->status === '0') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Carbon::parse($this->start_time) > Carbon::now()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Carbon::parse($this->end_time) < Carbon::now()) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch((new WhatsappUnsoldCommodityNotification($this->message))->delay(Carbon::parse($this->start_time)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user