39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
||
|
||
namespace App\Console\Commands;
|
||
|
||
use App\Business\StoreViolationNotifier;
|
||
use Illuminate\Console\Command;
|
||
|
||
/**
|
||
* 店铺违规信息预警:P2 每日 10:00 汇总日报。
|
||
*/
|
||
class PushStoreViolationDigest extends Command
|
||
{
|
||
protected $signature = 'store-violations:push-digest';
|
||
|
||
protected $description = '推送店铺违规预警每日汇总(P2 汇总与超时未认领点名)';
|
||
|
||
public function handle(StoreViolationNotifier $notifier): int
|
||
{
|
||
if (! $notifier->enabled()) {
|
||
$this->line('推送未配置,跳过。');
|
||
|
||
return self::SUCCESS;
|
||
}
|
||
|
||
$summary = $notifier->pushDigest();
|
||
|
||
$this->info(sprintf(
|
||
'日报推送:%s;P0 %d / P1 %d / P2 %d,超时未认领 %d 条。',
|
||
$summary['sent'] ? '已发送' : '发送失败',
|
||
(int) ($summary['pending']['P0'] ?? 0),
|
||
(int) ($summary['pending']['P1'] ?? 0),
|
||
(int) ($summary['pending']['P2'] ?? 0),
|
||
(int) $summary['overdue'],
|
||
));
|
||
|
||
return self::SUCCESS;
|
||
}
|
||
}
|