setType("解約申請"); return; } if ($model instanceof ParkingCertificateApplication) { $this->setType("車庫証明発行申請"); return; } if ($model instanceof StickerReOrderApplication) { $this->setType("シール再発行申請"); return; } if ($model instanceof ParkingUseTypeChangeOrderApplication) { $this->setType("IC定期_駐車場利用方法変更申請"); return; } if ($model instanceof SeasonTicketReOrderApplication) { $this->setType("定期券再発行申請"); return; } if ($model instanceof VehicleInfoUpdateApplication) { $this->setType("車両番号・防犯登録番号変更"); return; } if ($model instanceof UserInfoUpdateApplication) { $this->setType("利用者情報変更"); return; } if ($model instanceof UserInfoUpdateApplication) { $this->setType("振替頻度変更"); return; } if ($model instanceof BankAccountUpdateApplication) { $this->setType("口座変更申請"); return; } if ($model instanceof ChangePlanApplication) { $this->setType("プラン変更"); return; } if ($model instanceof ParkingUseTypeChangeOrderApplication) { $this->setType("IC定期_駐車場利用方法変更申請"); return; } if ($model instanceof ChangePaymentMethodCreditcardOrderApplication) { $this->setType("クレジット支払変更申請"); return; } } public function setCustomer(Customer $customer): static { $this->customer = $customer; return $this; } public function setSeasonTicketContract(SeasonTicketContract $seasonTicketContract): static { $this->seasonTicketContract = $seasonTicketContract; return $this; } public function setParking(Parking $parking): static { $this->parking = $parking; return $this; } /** * @return T */ public function makeApplication() { $this->model->applicationDatetime = DateUtil::now(); $this->model->status = "新規登録"; $this->model->applicationNo = $this->getApplicationNo(); if ($this->customer === null) { throw new LogicException("顧客未設定のため失敗"); } $this->model->customerCode = $this->customer->customerCode; if ($this->seasonTicketContract !== null) { $this->model->seasonTicketContractRecordNo = $this->seasonTicketContract->getRecordId(); } if ($this->parking !== null) { $this->model->parkingName = $this->parking->parkingName; } if ($this->model instanceof BankAccountUpdateApplication) { $this->model->applicationCustomerCode = $this->customer->customerCode; } return $this->model; } private function setType(string $type): static { $this->model->applicationType = $type; return $this; } private function getApplicationNo(): string { /** * 申請番号を発番する。重複チェックを一定回数行う。 */ for ($i = 0; $i < 10; $i++) { $no = sprintf("%s-%06d", DateUtil::now()->format('Ymd'), rand(1, 999999)); $check = GeneralApplication::getAccess()->some(GeneralApplication::getQuery()->where(GeneralApplication::FIELD_APPLICATION_NO, $no)); if ($check->isEmpty()) { return $no; } } throw new AppCommonException('申請番号取得失敗'); } }