You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.3KB

  1. <?php
  2. namespace App\Jobs\SeasonTicketContract\Selection;
  3. use App\Codes\QueueName;
  4. use App\Jobs\BaseJob;
  5. use App\Logic\SeasonTicketContractSelectionManager;
  6. use App\Util\LoggingUtil;
  7. use Exception;
  8. use Illuminate\Database\Eloquent\ModelNotFoundException;
  9. class FillCandidates extends BaseJob
  10. {
  11. /**
  12. * Create a new job instance.
  13. *
  14. * @return void
  15. */
  16. public function __construct(
  17. private int $recordNo
  18. ) {
  19. $this->onQueue(QueueName::JOB->value);
  20. }
  21. protected function handleJob()
  22. {
  23. try {
  24. $manager = new SeasonTicketContractSelectionManager($this->recordNo);
  25. $manager->makeCandidates()
  26. ->save();
  27. $selection = $manager->getSelection();
  28. info(sprintf(
  29. "候補者設定 駐車場:%s 締日:%s 候補者数:%d件",
  30. $selection->parkingName,
  31. $selection->selectionFinalDate ? $selection->selectionFinalDate->format('Y/m/d') : "-",
  32. $selection->candidateList->count(),
  33. ));
  34. } catch (ModelNotFoundException $e) {
  35. LoggingUtil::errorException($e, sprintf("データ存在なし削除 %s", self::class));
  36. } catch (Exception $e) {
  37. LoggingUtil::errorException($e, sprintf("ジョブ失敗->削除 %s", self::class));
  38. }
  39. }
  40. }