app/Console/Commands/ShjTwelveCommand.php を削除
All checks were successful
Deploy main / deploy (push) Successful in 21s
All checks were successful
Deploy main / deploy (push) Successful in 21s
This commit is contained in:
parent
cb0c5c8cc5
commit
45acbff97f
@ -1,177 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Services\ShjTwelveService;
|
||||
|
||||
/**
|
||||
* SHJ-12 未払い者通知処理コマンド
|
||||
*
|
||||
* 定期契約マスタより未払い者を取得し、通知処理またはオペレーターキュー追加を実行する
|
||||
* バックグラウンドで実行される定期バッチ処理
|
||||
*/
|
||||
class ShjTwelveCommand extends Command
|
||||
{
|
||||
/**
|
||||
* コンソールコマンドの名前とシグネチャ
|
||||
*
|
||||
* 引数: なし
|
||||
* オプション: なし
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'shj:12';
|
||||
|
||||
/**
|
||||
* コンソールコマンドの説明
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'SHJ-12 未払い者通知処理 - 定期契約マスタより未払い者を取得し通知処理を実行';
|
||||
|
||||
/**
|
||||
* SHJ-12サービスクラス
|
||||
*
|
||||
* @var ShjTwelveService
|
||||
*/
|
||||
protected $shjTwelveService;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
*
|
||||
* @param ShjTwelveService $shjTwelveService
|
||||
*/
|
||||
public function __construct(ShjTwelveService $shjTwelveService)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->shjTwelveService = $shjTwelveService;
|
||||
}
|
||||
|
||||
/**
|
||||
* コンソールコマンドを実行
|
||||
*
|
||||
* 処理フロー:
|
||||
* 1. 定期契約マスタより未払い者を取得する
|
||||
* 2. 取得件数判定
|
||||
* 3. 未払い者への通知、またはオペレーターキュー追加処理
|
||||
* 4. バッチ処理ログを作成する
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
// 開始ログ出力
|
||||
$startTime = now();
|
||||
$this->info('SHJ-12 未払い者通知処理を開始します。');
|
||||
Log::info('SHJ-12 未払い者通知処理開始', [
|
||||
'start_time' => $startTime
|
||||
]);
|
||||
|
||||
// 【処理1】定期契約マスタより未払い者を取得する
|
||||
$this->info('【処理1】定期契約マスタより未払い者を取得しています...');
|
||||
$unpaidUsers = $this->shjTwelveService->getUnpaidUsers();
|
||||
|
||||
// 【判断1】取得件数判定
|
||||
$unpaidCount = count($unpaidUsers);
|
||||
$this->info("取得件数: {$unpaidCount}件");
|
||||
|
||||
if ($unpaidCount === 0) {
|
||||
// 未払い者対象なしの結果を設定する
|
||||
$this->info('未払い者対象なしのため処理を終了します。');
|
||||
|
||||
// バッチ処理ログを作成
|
||||
$this->shjTwelveService->createBatchLog(
|
||||
'success',
|
||||
[],
|
||||
'未払い者対象なし',
|
||||
0,
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
Log::info('SHJ-12 未払い者通知処理完了(対象なし)', [
|
||||
'end_time' => now(),
|
||||
'duration_seconds' => $startTime->diffInSeconds(now())
|
||||
]);
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
// 【処理2】未払い者への通知、またはオペレーターキュー追加処理
|
||||
$this->info('【処理2】未払い者への通知処理を実行しています...');
|
||||
$processResult = $this->shjTwelveService->processUnpaidUserNotifications($unpaidUsers);
|
||||
|
||||
// 処理結果確認
|
||||
if ($processResult['success']) {
|
||||
$endTime = now();
|
||||
$this->info('SHJ-12 未払い者通知処理が正常に完了しました。');
|
||||
$this->info("処理時間: {$startTime->diffInSeconds($endTime)}秒");
|
||||
$this->info("処理対象件数: {$unpaidCount}件");
|
||||
$this->info("通知送信件数: {$processResult['notification_count']}件");
|
||||
$this->info("オペレーターキュー追加件数: {$processResult['queue_count']}件");
|
||||
|
||||
// 【処理3】バッチ処理ログを作成する
|
||||
$this->shjTwelveService->createBatchLog(
|
||||
'success',
|
||||
$processResult['parameters'],
|
||||
'未払い者通知処理完了',
|
||||
$unpaidCount,
|
||||
$processResult['notification_count'] + $processResult['queue_count'],
|
||||
0
|
||||
);
|
||||
|
||||
Log::info('SHJ-12 未払い者通知処理完了', [
|
||||
'end_time' => $endTime,
|
||||
'duration_seconds' => $startTime->diffInSeconds($endTime),
|
||||
'processed_count' => $unpaidCount,
|
||||
'notification_count' => $processResult['notification_count'],
|
||||
'queue_count' => $processResult['queue_count']
|
||||
]);
|
||||
|
||||
return self::SUCCESS;
|
||||
} else {
|
||||
$this->error('SHJ-12 未払い者通知処理でエラーが発生しました: ' . $processResult['message']);
|
||||
|
||||
// エラー時のバッチログ作成
|
||||
$this->shjTwelveService->createBatchLog(
|
||||
'error',
|
||||
$processResult['parameters'] ?? [],
|
||||
$processResult['message'],
|
||||
$unpaidCount,
|
||||
$processResult['notification_count'] ?? 0,
|
||||
1
|
||||
);
|
||||
|
||||
Log::error('SHJ-12 未払い者通知処理エラー', [
|
||||
'error' => $processResult['message'],
|
||||
'details' => $processResult['details'] ?? null
|
||||
]);
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$this->error('SHJ-12 未払い者通知処理で予期しないエラーが発生しました: ' . $e->getMessage());
|
||||
|
||||
// 例外時のバッチログ作成
|
||||
$this->shjTwelveService->createBatchLog(
|
||||
'error',
|
||||
[],
|
||||
'システムエラー: ' . $e->getMessage(),
|
||||
0,
|
||||
0,
|
||||
1
|
||||
);
|
||||
|
||||
Log::error('SHJ-12 未払い者通知処理例外エラー', [
|
||||
'exception' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString()
|
||||
]);
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user