109 lines
3.5 KiB
PHP
109 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\Log;
|
|
use App\Services\ShjThreeService;
|
|
|
|
/**
|
|
* SHJ-3 定期更新リマインダー処理コマンド
|
|
*
|
|
* 駐輪場の定期契約更新対象者に対するリマインダー処理を実行する
|
|
* バックグラウンドで実行される定期バッチ処理
|
|
*/
|
|
class ShjThreeCommand extends Command
|
|
{
|
|
/**
|
|
* コンソールコマンドの名前とシグネチャ
|
|
*
|
|
* 引数なし - 全ての駐輪場を対象に処理を実行
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'shj:3';
|
|
|
|
/**
|
|
* コンソールコマンドの説明
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'SHJ-3 定期更新リマインダー処理 - 定期契約更新対象者へのリマインダー送信を実行';
|
|
|
|
/**
|
|
* SHJ-3サービスクラス
|
|
*
|
|
* @var ShjThreeService
|
|
*/
|
|
protected $shjThreeService;
|
|
|
|
/**
|
|
* コンストラクタ
|
|
*
|
|
* @param ShjThreeService $shjThreeService
|
|
*/
|
|
public function __construct(ShjThreeService $shjThreeService)
|
|
{
|
|
parent::__construct();
|
|
$this->shjThreeService = $shjThreeService;
|
|
}
|
|
|
|
/**
|
|
* コンソールコマンドを実行
|
|
*
|
|
* 処理フロー:
|
|
* 1. 駐輪場マスタ情報取得
|
|
* 2. 各駐輪場の実行タイミングチェック
|
|
* 3. 定期更新対象者取得とリマインダー送信
|
|
* 4. バッチログ作成
|
|
* 5. 処理結果返却
|
|
*
|
|
* @return int
|
|
*/
|
|
public function handle()
|
|
{
|
|
try {
|
|
// 開始ログ出力
|
|
$startTime = now();
|
|
$this->info('SHJ-3 定期更新リマインダー処理を開始します。');
|
|
|
|
Log::info('SHJ-3 定期更新リマインダー処理開始', [
|
|
'start_time' => $startTime
|
|
]);
|
|
|
|
// SHJ-3メイン処理実行
|
|
$result = $this->shjThreeService->executeReminderProcess();
|
|
|
|
$endTime = now();
|
|
$this->info('SHJ-3 定期更新リマインダー処理が完了しました。');
|
|
$this->info("処理時間: {$startTime->diffInSeconds($endTime)}秒");
|
|
|
|
// 処理結果表示
|
|
$this->line('=== 処理結果 ===');
|
|
$this->line("対象駐輪場数: {$result['processed_parks_count']}");
|
|
$this->line("対象者総数: {$result['total_target_users']}");
|
|
$this->line("メール送信成功: {$result['mail_success_count']}件");
|
|
$this->line("メール送信失敗: {$result['mail_error_count']}件");
|
|
$this->line("オペレーターキュー追加: {$result['operator_queue_count']}件");
|
|
|
|
Log::info('SHJ-3 定期更新リマインダー処理完了', [
|
|
'end_time' => $endTime,
|
|
'duration_seconds' => $startTime->diffInSeconds($endTime),
|
|
'result' => $result
|
|
]);
|
|
|
|
return $result['success'] ? self::SUCCESS : self::FAILURE;
|
|
|
|
} catch (\Exception $e) {
|
|
$this->error('SHJ-3 定期更新リマインダー処理で予期しないエラーが発生しました: ' . $e->getMessage());
|
|
|
|
Log::error('SHJ-3 定期更新リマインダー処理例外エラー', [
|
|
'exception' => $e->getMessage(),
|
|
'trace' => $e->getTraceAsString()
|
|
]);
|
|
|
|
return self::FAILURE;
|
|
}
|
|
}
|
|
}
|