61 lines
1.4 KiB
PHP
61 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use Carbon\Carbon;
|
|
use App\Models\{Order, ReserveEditLog};
|
|
use App\Jobs\SendReserveNotice;
|
|
|
|
class SendNoticeMessage extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'milk-tea:send_notice_message';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = '发送过时的取餐超时提醒';
|
|
|
|
/**
|
|
* Create a new command instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function handle()
|
|
{
|
|
|
|
$list = Order::with(['user', 'goods'])->where([
|
|
'is_reserve'=>1,
|
|
'order_status'=>1,
|
|
'pay_status'=>1,
|
|
])->where('reserve_time', Carbon::now()->subDays(1)->startOfDay())
|
|
->whereNull('order_number')->get();
|
|
|
|
foreach($list as $order){
|
|
//如果已经有修改记录则不用发送通知;
|
|
if(!ReserveEditLog::where('order_sn', $order->order_sn)->exists()){
|
|
SendReserveNotice::dispatch($order);
|
|
}
|
|
}
|
|
|
|
$this->info('发送成功!');
|
|
}
|
|
}
|