|
|
|
@@ -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()); |
|
|
|
} |
|
|
|
} |