mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-09-30 15:13:21 -04:00
68 lines
2.2 KiB
PHP
68 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace Modules\WTIJobBoard\Console;
|
|
|
|
use Illuminate\Support\Str;
|
|
use Illuminate\Console\Command;
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
use Modules\WTIJobBoard\Entities\JobRequestShipment;
|
|
use App\Traits\SendMail;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Carbon\Carbon;
|
|
|
|
class ReceivedReminder extends Command
|
|
{
|
|
|
|
use SendMail;
|
|
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'command:received-reminders';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = "Notify creators to add received date";
|
|
|
|
/**
|
|
* Create a new command instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function handle()
|
|
{
|
|
\Modules\WTIJobBoard\Entities\JobRequest::with('track')->whereHas('category', function($query) {
|
|
$query->where('will_be_shipped', 1);
|
|
})->whereHas('tracks', function($query) {
|
|
$query->where('status_id', 3)->where('created_at', '<=', \Carbon\Carbon::now()->subDays(7)->toDateTimeString())->where('created_at', '>=', \Carbon\Carbon::now()->subDays(30)->toDateTimeString());
|
|
})->whereDoesntHave('tracks', function($query) {
|
|
$query->where('status_id', 4);
|
|
})->where('status','publish')->orderBy('id')->chunk(10, function ($job_requests) {
|
|
foreach ($job_requests as $key => $job_request) {
|
|
$diff = (\Carbon\Carbon::parse($job_request->track->created_at))->diffInDays(\Carbon\Carbon::now());
|
|
\Log::info('Asin:'.$job_request->asin.' Diff Days: '.$diff);
|
|
if($diff % 7 == 0){
|
|
$this->sendJobRequestReminder('Product Shipped',$job_request->creator, $job_request->asin);
|
|
\Log::info('Successfully sent Product Shipped Email for asin:'.$job_request->asin);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|