mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-09-29 12:13:06 -04:00
68 lines
2.4 KiB
PHP
68 lines
2.4 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 App\Traits\SendMail;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class ShippingReminder extends Command
|
|
{
|
|
|
|
use SendMail;
|
|
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'command:shipping-reminders';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = "Notify client to add shipping information";
|
|
|
|
/**
|
|
* 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', 6)->where('created_at', '<=', \Carbon\Carbon::now()->subDays(3)->toDateTimeString())->where('created_at', '>=', \Carbon\Carbon::now()->subDays(30)->toDateTimeString());
|
|
})->whereDoesntHave('tracks', function($query) {
|
|
$query->where('status_id', 3)->where('status_id', 4);
|
|
})->where('track_package_status','Creator Selected')->where('status','publish')->orderBy('id')->chunk(10, function ($job_requests) {
|
|
foreach ($job_requests as $key => $job_request) {
|
|
$diff = \Carbon\Carbon::now()->diff($job_request->track->created_at);
|
|
if($diff->days % 3 == 0){
|
|
|
|
$setting = \Modules\WTIJobBoard\Entities\JobRequestSetting::where('job_request_category_id',$job_request->type)->where('user_id',$job_request->client_id)->whereNotNull('email')->first();
|
|
$client = (object)['email' => $setting ? $setting->email : $job_request->client->email, 'first_name' => $job_request->client->first_name];
|
|
$this->sendJobRequestUpdate($client, 'Creator Selected', $job_request->asin);
|
|
Log::info('Successfully sent Shipping Info Email for asin:'.$job_request->asin);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|