скрипты, отвечающие за отправку писем - либо напрямую, либо через создание различных джоб или запуска отправки по расписанию (тестировал)
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Taxi\App\Console;
|
||||
|
||||
use Error;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use App\Console\Commands\BaseScheduleCommand;
|
||||
use App\Mail\BaseMailerObj;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\Mailer;
|
||||
use Modules\Taxi\App\Models\TaxiMain;
|
||||
use DateTime;
|
||||
|
||||
class SendOrdersToTaxiCommand extends BaseScheduleCommand
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*/
|
||||
public $signature = 'taxi:send';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*/
|
||||
public $description = 'Отправка заказов такси на сегодня агрегаторам';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->executeCommand(function () {
|
||||
$todayOrders = TaxiMain::where('cancel_rqst', 0)
|
||||
->where('taxi_date', (new DateTime())->format('Y-m-d'))
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
if (!$todayOrders) {
|
||||
Mail::send(new Mailer(
|
||||
new BaseMailerObj(
|
||||
|
||||
)
|
||||
));
|
||||
echo '<pre>'; var_dump('da'); echo'</pre>';
|
||||
} else {
|
||||
echo '<pre>'; var_dump('net'); echo'</pre>';
|
||||
}
|
||||
|
||||
throw new Error('Ошипка!');
|
||||
}, 'еще инва');
|
||||
|
||||
// try {
|
||||
// throw new Error('Ошипка!');
|
||||
// } catch (\Throwable $th) {
|
||||
// \Log::channel('schedule_err')->error($th->getFile() . ": " . $th->getMessage() . " Line: " . $th->getLine());
|
||||
// }
|
||||
|
||||
//$this->info('Daily report generated at ' . now());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*/
|
||||
protected function getArguments(): array
|
||||
{
|
||||
return [
|
||||
['example', InputArgument::REQUIRED, 'An example argument.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*/
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user