42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
||
|
||
namespace App\Console\Commands;
|
||
|
||
use App\Business\StoreViolationNotifier;
|
||
use Illuminate\Console\Command;
|
||
|
||
/**
|
||
* 店铺违规信息预警:P0/P1 即时推送(每天 09:00 起由生产 cron 每 5 分钟触发)。
|
||
*/
|
||
class PushStoreViolationAlerts extends Command
|
||
{
|
||
protected $signature = 'store-violations:push-instant
|
||
{--limit=200 : 单轮最多推送条数}
|
||
{--retry-failed : 同时重试推送失败的记录}';
|
||
|
||
protected $description = '推送店铺违规预警即时消息(P0/P1,含责任人@与去认领链接)';
|
||
|
||
public function handle(StoreViolationNotifier $notifier): int
|
||
{
|
||
if (! $notifier->enabled()) {
|
||
$this->line('推送未配置,跳过。');
|
||
|
||
return self::SUCCESS;
|
||
}
|
||
|
||
$summary = $notifier->pushInstant(
|
||
max((int) $this->option('limit'), 1),
|
||
(bool) $this->option('retry-failed'),
|
||
);
|
||
|
||
$this->info(sprintf(
|
||
'即时推送:待推 %d 条,成功 %d 条,失败 %d 条。',
|
||
$summary['attempted'],
|
||
$summary['succeeded'],
|
||
$summary['failed'],
|
||
));
|
||
|
||
return self::SUCCESS;
|
||
}
|
||
}
|