| @@ -1,90 +0,0 @@ | |||
| <?php | |||
| namespace App\Console\Commands; | |||
| use App\Jobs\SeasonTicketContract\Selection\FillCandidates; | |||
| use App\Kintone\Models\DropDown\SeasonTicketContractSelection\SelectionStatus; | |||
| use App\Kintone\Models\SeasonTicketContractSelection; | |||
| use App\Util\DBUtil; | |||
| use Exception; | |||
| class SeasonTikcetContractSelectionFillCandidates extends BaseCommand | |||
| { | |||
| const COMMAND = "season-ticket-contract-selection:fill-candidates"; | |||
| /** | |||
| * The name and signature of the console command. | |||
| * | |||
| * @var string | |||
| */ | |||
| protected $signature = self::COMMAND; | |||
| /** | |||
| * The console command description. | |||
| * | |||
| * @var string | |||
| */ | |||
| protected $description = '定期選考の候補者設定のジョブを登録する'; | |||
| static public function getCommand() | |||
| { | |||
| return self::COMMAND; | |||
| } | |||
| /** | |||
| * Create a new command instance. | |||
| * | |||
| * @return void | |||
| */ | |||
| public function __construct() | |||
| { | |||
| parent::__construct(); | |||
| $this->managers = collect(); | |||
| } | |||
| /** | |||
| * Execute the console command. | |||
| * | |||
| * @return int | |||
| */ | |||
| public function service(): int | |||
| { | |||
| try { | |||
| $db = DBUtil::instance(); | |||
| $db->beginTransaction(); | |||
| $this->getName(); | |||
| $targets = $this->getTargets(); | |||
| $this->outputInfo(sprintf("取得対象 %d件", $targets->count())); | |||
| // データハンドリング | |||
| foreach ($targets as $data) { | |||
| $this->handleData($data); | |||
| } | |||
| $db->commit(); | |||
| } catch (Exception $e) { | |||
| $db->rollBack(); | |||
| throw $e; | |||
| } | |||
| return self::RESULTCODE_SUCCESS; | |||
| } | |||
| private function getTargets() | |||
| { | |||
| $access = SeasonTicketContractSelection::getAccess(); | |||
| $query = SeasonTicketContractSelection::getQuery() | |||
| ->whereIn(SeasonTicketContractSelection::FIELD_STATUS, [SelectionStatus::START]); | |||
| return $access->all($query); | |||
| } | |||
| private function handleData(SeasonTicketContractSelection $data) | |||
| { | |||
| FillCandidates::dispatch($data->getRecordId()); | |||
| } | |||
| } | |||
| @@ -16,7 +16,6 @@ class Kernel extends ConsoleKernel | |||
| Schedules\SMBCBankAccountRegisterPoll::register($schedule); | |||
| Schedules\SMBCPaymentPoll::register($schedule); | |||
| Schedules\BankAccountRegisterRemaind::register($schedule); | |||
| Schedules\SeasonTikcetContractSelectionFillCandidates::register($schedule); | |||
| Schedules\SeasonTikcetContractSelectionSetResult::register($schedule); | |||
| Schedules\SeasonTicketContractTerminateComplete::register($schedule); | |||
| } | |||
| @@ -1,17 +0,0 @@ | |||
| <?php | |||
| namespace App\Console\Schedules; | |||
| use App\Console\Commands\SeasonTikcetContractSelectionFillCandidates as Command; | |||
| use Illuminate\Console\Scheduling\Schedule; | |||
| class SeasonTikcetContractSelectionFillCandidates extends BaseSchedule | |||
| { | |||
| static public function register(Schedule $schedule) | |||
| { | |||
| $schedule->command(Command::class) | |||
| ->everyFiveMinutes() | |||
| ->description("定期選考申込者一覧設定"); | |||
| } | |||
| } | |||
| @@ -0,0 +1,48 @@ | |||
| <?php | |||
| namespace App\Http\Controllers\Web\SeasonTicketContract\Selection; | |||
| use App\Http\Controllers\Web\FromKintoneController; | |||
| use App\Logic\SeasonTicketContractSelectionManager; | |||
| use Illuminate\Http\JsonResponse; | |||
| use Illuminate\Http\Request; | |||
| class FillCandidatesController extends FromKintoneController | |||
| { | |||
| public function name(): string | |||
| { | |||
| return "定期選考候補者設定"; | |||
| } | |||
| public function description(): string | |||
| { | |||
| return "定期選考に候補者を設定する"; | |||
| } | |||
| public function __construct(protected FillCandidatesParams $param) | |||
| { | |||
| parent::__construct(); | |||
| } | |||
| protected function run(Request $request): JsonResponse | |||
| { | |||
| $param = $this->param; | |||
| $manager = new SeasonTicketContractSelectionManager($param->recordNo); | |||
| $manager->makeCandidates() | |||
| ->save(); | |||
| $selection = $manager->getSelection(); | |||
| info(sprintf( | |||
| "候補者設定 駐車場:%s 締日:%s 候補者数:%d件", | |||
| $selection->parkingName, | |||
| $selection->selectionFinalDate ? $selection->selectionFinalDate->format('Y/m/d') : "-", | |||
| $selection->candidateList->count(), | |||
| )); | |||
| return $this->successResponse(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,20 @@ | |||
| <?php | |||
| namespace App\Http\Controllers\Web\SeasonTicketContract\Selection; | |||
| use App\Http\Controllers\Web\BaseParam; | |||
| use App\Rules\PhoneNumber; | |||
| use App\Rules\SimpleRegEx; | |||
| /** | |||
| * @property int recordNo | |||
| */ | |||
| class FillCandidatesParams extends BaseParam | |||
| { | |||
| public function rules(): array | |||
| { | |||
| return [ | |||
| 'record_no' => $this->numeric(), | |||
| ]; | |||
| } | |||
| } | |||
| @@ -1,47 +0,0 @@ | |||
| <?php | |||
| namespace App\Jobs\SeasonTicketContract\Selection; | |||
| use App\Codes\QueueName; | |||
| use App\Jobs\BaseJob; | |||
| use App\Logic\SeasonTicketContractSelectionManager; | |||
| use App\Util\LoggingUtil; | |||
| use Exception; | |||
| use Illuminate\Database\Eloquent\ModelNotFoundException; | |||
| class FillCandidates 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->makeCandidates() | |||
| ->save(); | |||
| $selection = $manager->getSelection(); | |||
| info(sprintf( | |||
| "候補者設定 駐車場:%s 締日:%s 候補者数:%d件", | |||
| $selection->parkingName, | |||
| $selection->selectionFinalDate ? $selection->selectionFinalDate->format('Y/m/d') : "-", | |||
| $selection->candidateList->count(), | |||
| )); | |||
| } catch (ModelNotFoundException $e) { | |||
| LoggingUtil::errorException($e, sprintf("データ存在なし削除 %s", self::class)); | |||
| } catch (Exception $e) { | |||
| LoggingUtil::errorException($e, sprintf("ジョブ失敗->削除 %s", self::class)); | |||
| } | |||
| } | |||
| } | |||
| @@ -231,6 +231,7 @@ class SeasonTicketContractSelectionManager | |||
| if ($this->selection->entryList->isEmpty()) { | |||
| $this->selection->status = SelectionStatus::FAILED; | |||
| $messages->push("契約希望者不在のため、選考不調"); | |||
| $this->selection->resultList = $this->selection->resultList->empty(); | |||
| return $messages; | |||
| } | |||
| @@ -15,6 +15,7 @@ use App\Util\RouteHelper; | |||
| RouteHelper::post('/email/send', App\Http\Controllers\Web\Email\EmailSendController::class); | |||
| RouteHelper::post('/season-ticket-contract-selection/notice-to-candidates', App\Http\Controllers\Web\SeasonTicketContract\Selection\NoticeToCandidatesController::class); | |||
| RouteHelper::post('/season-ticket-contract-selection/fill-candidates', App\Http\Controllers\Web\SeasonTicketContract\Selection\FillCandidatesController::class); | |||
| RouteHelper::post('/receipt/create', App\Http\Controllers\Web\Receipt\ReceiptCreateController::class); | |||