|
- <?php
-
- namespace App\Jobs\SeasonTicketContract\Selection;
-
- use App\Codes\QueueName;
- use App\Jobs\BaseJob;
- use App\Kintone\Models\DropDown\SeasonTicketContractSelection\SelectionStatus;
- use App\Logic\SeasonTicketContractSelectionManager;
- use App\Util\LoggingUtil;
- use Exception;
- use Illuminate\Database\Eloquent\ModelNotFoundException;
-
- class SetResult extends BaseJob
- {
-
- /**
- * Create a new job instance.
- *
- * @return void
- */
- public function __construct(
- private int $recordNo
- ) {
- $this->onQueue(QueueName::JOB->value);
- }
-
- protected function handleJob()
- {
- try {
- $manager = new SeasonTicketContractSelectionManager($this->recordNo);
- $manager->makeResult()
- ->save();
-
- $selection = $manager->getSelection();
-
- // 以下ログ出力処理
- if ($selection->status === SelectionStatus::RESULT_DECISION) {
- foreach ($selection->resultList as $result) {
- info(sprintf(
- "選考結果設定 駐車場:%s 選考レコード番号:%d 締日:%s 氏名:%s 申込番号:%s",
- $selection->parkingName,
- $selection->getRecordId(),
- $selection->selectionFinalDate ? $selection->selectionFinalDate->format('Y/m/d') : "-",
- $result->name,
- $result->entryNo,
- ));
- }
- } else if ($selection->status === SelectionStatus::FAILED) {
- info(sprintf(
- "選考不調 駐車場:%s 選考レコード番号:%d 締日:%s",
- $selection->parkingName,
- $selection->getRecordId(),
- $selection->selectionFinalDate ? $selection->selectionFinalDate->format('Y/m/d') : "-",
- ));
- }
- } catch (ModelNotFoundException $e) {
- LoggingUtil::errorException($e, sprintf("データ存在なし削除 %s", self::class));
- } catch (Exception $e) {
- LoggingUtil::errorException($e, sprintf("ジョブ失敗->削除 %s", self::class));
- }
- }
- }
|