love_php/app/Console/Commands/CheckSmsComplete.php

50 lines
1.0 KiB
PHP
Raw Permalink Normal View History

2026-04-02 09:20:51 +08:00
<?php
namespace App\Console\Commands;
use App\Models\ClientMessage;
use Illuminate\Console\Command;
class CheckSmsComplete extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'checkSmsComplete';
/**
* 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 mixed
*/
public function handle()
{
$messages = ClientMessage::withCount('recive')->where('is_completed',0)->get();
foreach ($messages as $key => $value) {
$nicknames = json_decode($value->nicknames);
if($value->recive_count >= count($nicknames)){
$value->update(['is_completed'=>1]);
}
}
}
}