| @@ -0,0 +1,12 @@ | |||||
| <?php | |||||
| namespace App\Codes; | |||||
| enum Email: string | |||||
| { | |||||
| case TERMINATE_ORDER_APPROVE = '解約承認'; | |||||
| case VEHICLE_INFO_UPDATE_ORDER_APPROVE = '車両番号・防犯登録番号変更完了'; | |||||
| case USER_INFO_UPDATE_ORDER_APPROVE = '利用者情報変更完了'; | |||||
| case ENTRY_APPROVE = '申込受付'; | |||||
| case ENTRY_PAYMENT_COMPLETE = '申込承認'; | |||||
| } | |||||
| @@ -2,42 +2,45 @@ | |||||
| namespace App\Email\Members; | namespace App\Email\Members; | ||||
| use App\Kintone\Models\Customer; | |||||
| use App\Kintone\Models\SeasonTicketContract; | |||||
| use App\Kintone\Models\Parking; | |||||
| use App\Kintone\Models\SeasonTicketContractEntry; | |||||
| class EntryApprove extends Members | class EntryApprove extends Members | ||||
| { | { | ||||
| public function __construct( | public function __construct( | ||||
| protected Customer $customer, | |||||
| private SeasonTicketContract $seasonTicketContract, | |||||
| private Parking $parking, | |||||
| private SeasonTicketContractEntry $entry, | |||||
| ) { | ) { | ||||
| parent::__construct($customer); | |||||
| $this->setEmail($entry->email); | |||||
| parent::__construct(null); | |||||
| } | } | ||||
| public function getTemplateName(): string | public function getTemplateName(): string | ||||
| { | { | ||||
| return 'emails.members.vehicle_info_update_order_notice'; | |||||
| return 'emails.members.entry_approve'; | |||||
| } | } | ||||
| public function getSubject(): string | public function getSubject(): string | ||||
| { | { | ||||
| return "車両番号・防犯登録番号変更受付のお知らせ"; | |||||
| return "【利用確認事項】申込受付 月極定期駐車場ナビ"; | |||||
| } | } | ||||
| public function getMemberParams(): array | public function getMemberParams(): array | ||||
| { | { | ||||
| return [ | return [ | ||||
| 'customer_name_kana' => $this->customer->customerNameKana, | |||||
| 'parking_name' => '##TODO##', | |||||
| 'customer_name' => $this->entry->customerName, | |||||
| 'customer_name_kana' => $this->entry->customerNameKana, | |||||
| 'parking_name' => $this->entry->parkingName, | |||||
| 'type_name' => '##TODO##', | 'type_name' => '##TODO##', | ||||
| 'season_ticket_select' => '##TODO##', | |||||
| 'plan_name' => '##TODO##', | 'plan_name' => '##TODO##', | ||||
| 'vehicle_no' => '##TODO##', | |||||
| 'use_start_date' => '##TODO##', | |||||
| 'payment_method' => '##TODO##', | |||||
| 'vehicle_no' => $this->entry->vehicleNo, | |||||
| 'use_start_date' => $this->entry->useStartDate->format('Y/m/d'), | |||||
| 'payment_method' => $this->entry->paymentMethod, | |||||
| 'amount' => '##TODO##', | 'amount' => '##TODO##', | ||||
| 'can_terminate_15' => true, | |||||
| 'can_terminate_end_of_month' => true, | |||||
| 'can_terminate_15' => in_array(Parking::ELEMENT_CAN_TERMINATE_DATE_15, $this->parking->canTerminateDate), | |||||
| 'can_terminate_end_of_month' => in_array(Parking::ELEMENT_CAN_TERMINATE_DATE_END_OF_MONTH, $this->parking->canTerminateDate), | |||||
| ]; | ]; | ||||
| } | } | ||||
| } | } | ||||
| @@ -2,17 +2,18 @@ | |||||
| namespace App\Email\Members; | namespace App\Email\Members; | ||||
| use App\Kintone\Models\Customer; | |||||
| use App\Kintone\Models\SeasonTicketContract; | |||||
| use App\Kintone\Models\Parking; | |||||
| use App\Kintone\Models\SeasonTicketContractEntry; | |||||
| class EntryPaymentComplete extends Members | class EntryPaymentComplete extends Members | ||||
| { | { | ||||
| public function __construct( | public function __construct( | ||||
| protected Customer $customer, | |||||
| private SeasonTicketContract $seasonTicketContract, | |||||
| private Parking $parking, | |||||
| private SeasonTicketContractEntry $entry, | |||||
| ) { | ) { | ||||
| parent::__construct($customer); | |||||
| $this->setEmail($entry->email); | |||||
| parent::__construct(null); | |||||
| } | } | ||||
| public function getTemplateName(): string | public function getTemplateName(): string | ||||
| @@ -28,16 +29,18 @@ class EntryPaymentComplete extends Members | |||||
| public function getMemberParams(): array | public function getMemberParams(): array | ||||
| { | { | ||||
| return [ | return [ | ||||
| 'customer_name_kana' => $this->customer->customerNameKana, | |||||
| 'parking_name' => '##TODO##', | |||||
| 'customer_name' => $this->entry->customerName, | |||||
| 'customer_name_kana' => $this->entry->customerNameKana, | |||||
| 'parking_name' => $this->entry->parkingName, | |||||
| 'type_name' => '##TODO##', | 'type_name' => '##TODO##', | ||||
| 'season_ticket_select' => '##TODO##', | |||||
| 'plan_name' => '##TODO##', | 'plan_name' => '##TODO##', | ||||
| 'vehicle_no' => '##TODO##', | |||||
| 'use_start_date' => '##TODO##', | |||||
| 'payment_method' => '##TODO##', | |||||
| 'vehicle_no' => $this->entry->vehicleNo, | |||||
| 'use_start_date' => $this->entry->useStartDate->format('Y/m/d'), | |||||
| 'payment_method' => $this->entry->paymentMethod, | |||||
| 'amount' => '##TODO##', | 'amount' => '##TODO##', | ||||
| 'can_terminate_15' => true, | |||||
| 'can_terminate_end_of_month' => true, | |||||
| 'can_terminate_15' => in_array(Parking::ELEMENT_CAN_TERMINATE_DATE_15, $this->parking->canTerminateDate), | |||||
| 'can_terminate_end_of_month' => in_array(Parking::ELEMENT_CAN_TERMINATE_DATE_END_OF_MONTH, $this->parking->canTerminateDate), | |||||
| ]; | ]; | ||||
| } | } | ||||
| } | } | ||||
| @@ -8,16 +8,18 @@ use App\Kintone\Models\Customer; | |||||
| abstract class Members extends BaseEmailer | abstract class Members extends BaseEmailer | ||||
| { | { | ||||
| public function __construct(protected Customer $customer) | |||||
| public function __construct(protected ?Customer $customer) | |||||
| { | { | ||||
| $this->setEmail($customer->email); | |||||
| if ($customer !== null) { | |||||
| $this->setEmail($customer->email); | |||||
| } | |||||
| } | } | ||||
| public function getParams(): array | public function getParams(): array | ||||
| { | { | ||||
| return array_merge($this->getMemberParams(), [ | |||||
| 'customer_name' => $this->customer->customerName | |||||
| ]); | |||||
| return array_merge([ | |||||
| 'customer_name' => $this->customer ? $this->customer->customerName : "", | |||||
| ], $this->getMemberParams()); | |||||
| } | } | ||||
| abstract public function getMemberParams(): array; | abstract public function getMemberParams(): array; | ||||
| @@ -10,10 +10,13 @@ class ParkingCertificateOrderNotice extends Members | |||||
| { | { | ||||
| public function __construct( | public function __construct( | ||||
| protected Customer $customer, | |||||
| private SeasonTicketContract $seasonTicketContract, | private SeasonTicketContract $seasonTicketContract, | ||||
| private ParkingCertificateApplication $app | |||||
| private ParkingCertificateApplication $app, | |||||
| protected ?Customer $customer = null, | |||||
| ) { | ) { | ||||
| if ($customer === null) { | |||||
| $customer = $app->getCustomer(); | |||||
| } | |||||
| parent::__construct($customer); | parent::__construct($customer); | ||||
| } | } | ||||
| @@ -10,10 +10,13 @@ class SeasonTicketReOrderNotice extends Members | |||||
| { | { | ||||
| public function __construct( | public function __construct( | ||||
| protected Customer $customer, | |||||
| private SeasonTicketContract $seasonTicketContract, | private SeasonTicketContract $seasonTicketContract, | ||||
| private SeasonTicketReOrderApplication $app | |||||
| private SeasonTicketReOrderApplication $app, | |||||
| protected ?Customer $customer = null, | |||||
| ) { | ) { | ||||
| if ($customer === null) { | |||||
| $customer = $app->getCustomer(); | |||||
| } | |||||
| parent::__construct($customer); | parent::__construct($customer); | ||||
| } | } | ||||
| @@ -10,10 +10,13 @@ class StickerReOrderNotice extends Members | |||||
| { | { | ||||
| public function __construct( | public function __construct( | ||||
| protected Customer $customer, | |||||
| private SeasonTicketContract $seasonTicketContract, | private SeasonTicketContract $seasonTicketContract, | ||||
| private StickerReOrderApplication $app | |||||
| private StickerReOrderApplication $app, | |||||
| protected ?Customer $customer = null, | |||||
| ) { | ) { | ||||
| if ($customer === null) { | |||||
| $customer = $app->getCustomer(); | |||||
| } | |||||
| parent::__construct($customer); | parent::__construct($customer); | ||||
| } | } | ||||
| @@ -10,10 +10,13 @@ class TerminateOrderApprove extends Members | |||||
| { | { | ||||
| public function __construct( | public function __construct( | ||||
| protected Customer $customer, | |||||
| private SeasonTicketContract $seasonTicketContract, | private SeasonTicketContract $seasonTicketContract, | ||||
| private TerminateApplication $app | |||||
| private TerminateApplication $app, | |||||
| protected ?Customer $customer = null, | |||||
| ) { | ) { | ||||
| if ($customer === null) { | |||||
| $customer = $app->getCustomer(); | |||||
| } | |||||
| parent::__construct($customer); | parent::__construct($customer); | ||||
| } | } | ||||
| @@ -10,10 +10,13 @@ class TerminateOrderComplete extends Members | |||||
| { | { | ||||
| public function __construct( | public function __construct( | ||||
| protected Customer $customer, | |||||
| private SeasonTicketContract $seasonTicketContract, | private SeasonTicketContract $seasonTicketContract, | ||||
| private TerminateApplication $app | |||||
| private TerminateApplication $app, | |||||
| protected ?Customer $customer = null, | |||||
| ) { | ) { | ||||
| if ($customer === null) { | |||||
| $customer = $app->getCustomer(); | |||||
| } | |||||
| parent::__construct($customer); | parent::__construct($customer); | ||||
| } | } | ||||
| @@ -10,10 +10,13 @@ class TerminateOrderNotice extends Members | |||||
| { | { | ||||
| public function __construct( | public function __construct( | ||||
| protected Customer $customer, | |||||
| private SeasonTicketContract $seasonTicketContract, | private SeasonTicketContract $seasonTicketContract, | ||||
| private TerminateApplication $app | |||||
| private TerminateApplication $app, | |||||
| protected ?Customer $customer = null, | |||||
| ) { | ) { | ||||
| if ($customer === null) { | |||||
| $customer = $app->getCustomer(); | |||||
| } | |||||
| parent::__construct($customer); | parent::__construct($customer); | ||||
| } | } | ||||
| @@ -10,10 +10,13 @@ class UserInfoUpdateOrderApprove extends Members | |||||
| { | { | ||||
| public function __construct( | public function __construct( | ||||
| protected Customer $customer, | |||||
| private SeasonTicketContract $seasonTicketContract, | private SeasonTicketContract $seasonTicketContract, | ||||
| private UserInfoUpdateApplication $app | |||||
| private UserInfoUpdateApplication $app, | |||||
| protected ?Customer $customer = null, | |||||
| ) { | ) { | ||||
| if ($customer === null) { | |||||
| $customer = $app->getCustomer(); | |||||
| } | |||||
| parent::__construct($customer); | parent::__construct($customer); | ||||
| } | } | ||||
| @@ -9,9 +9,12 @@ class UserInfoUpdateOrderNotice extends Members | |||||
| { | { | ||||
| public function __construct( | public function __construct( | ||||
| protected Customer $customer, | |||||
| private UserInfoUpdateApplication $app | |||||
| private UserInfoUpdateApplication $app, | |||||
| protected ?Customer $customer = null, | |||||
| ) { | ) { | ||||
| if ($customer === null) { | |||||
| $customer = $app->getCustomer(); | |||||
| } | |||||
| parent::__construct($customer); | parent::__construct($customer); | ||||
| } | } | ||||
| @@ -10,10 +10,13 @@ class VehicleInfoUpdateOrderApprove extends Members | |||||
| { | { | ||||
| public function __construct( | public function __construct( | ||||
| protected Customer $customer, | |||||
| private SeasonTicketContract $seasonTicketContract, | private SeasonTicketContract $seasonTicketContract, | ||||
| private VehicleInfoUpdateApplication $app | |||||
| private VehicleInfoUpdateApplication $app, | |||||
| protected ?Customer $customer = null, | |||||
| ) { | ) { | ||||
| if ($customer === null) { | |||||
| $customer = $app->getCustomer(); | |||||
| } | |||||
| parent::__construct($customer); | parent::__construct($customer); | ||||
| } | } | ||||
| @@ -10,10 +10,13 @@ class VehicleInfoUpdateOrderNotice extends Members | |||||
| { | { | ||||
| public function __construct( | public function __construct( | ||||
| protected Customer $customer, | |||||
| private SeasonTicketContract $seasonTicketContract, | private SeasonTicketContract $seasonTicketContract, | ||||
| private VehicleInfoUpdateApplication $app | |||||
| private VehicleInfoUpdateApplication $app, | |||||
| protected ?Customer $customer = null, | |||||
| ) { | ) { | ||||
| if ($customer === null) { | |||||
| $customer = $app->getCustomer(); | |||||
| } | |||||
| parent::__construct($customer); | parent::__construct($customer); | ||||
| } | } | ||||
| @@ -0,0 +1,141 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\Email; | |||||
| use App\Codes\Email; | |||||
| use App\Email\BaseEmailer; | |||||
| use App\Email\Members\EntryApprove; | |||||
| use App\Email\Members\EntryPaymentComplete; | |||||
| use App\Email\Members\TerminateOrderApprove; | |||||
| use App\Email\Members\UserInfoUpdateOrderApprove; | |||||
| use App\Email\Members\VehicleInfoUpdateOrderApprove; | |||||
| use App\Http\Controllers\Web\WebController; | |||||
| use App\Kintone\Models\SeasonTicketContract; | |||||
| use App\Kintone\Models\SeasonTicketContractEntry; | |||||
| use App\Kintone\Models\TerminateApplication; | |||||
| use App\Kintone\Models\UserInfoUpdateApplication; | |||||
| use App\Kintone\Models\VehicleInfoUpdateApplication; | |||||
| use App\Logic\EmailManager; | |||||
| use Exception; | |||||
| use Illuminate\Http\JsonResponse; | |||||
| use Illuminate\Http\Request; | |||||
| use LogicException; | |||||
| class EmailSendController extends WebController | |||||
| { | |||||
| private BaseEmailer|null $email = null; | |||||
| private EmailManager|null $emailManager = null; | |||||
| public function name(): string | |||||
| { | |||||
| return "メール送信依頼"; | |||||
| } | |||||
| public function description(): string | |||||
| { | |||||
| return "メール送信依頼を登録する"; | |||||
| } | |||||
| public function __construct(protected EmailSendParam $param) | |||||
| { | |||||
| parent::__construct(); | |||||
| } | |||||
| protected function run(Request $request): JsonResponse | |||||
| { | |||||
| try { | |||||
| // トークンチェック | |||||
| $this->checkToken(); | |||||
| // メール作成 | |||||
| $this->getEmail(); | |||||
| // 送信 | |||||
| if ($this->emailManager === null) { | |||||
| throw new LogicException("EmailManager不正"); | |||||
| } | |||||
| $this->emailManager->confirm(); | |||||
| } catch (Exception $e) { | |||||
| logger($e->getMessage()); | |||||
| logger($e->getFile()); | |||||
| logger($e->getLine()); | |||||
| return $this->failed(); | |||||
| } | |||||
| return $this->success(); | |||||
| } | |||||
| private function success() | |||||
| { | |||||
| return response()->json([ | |||||
| 'result' => 'SUCCESS' | |||||
| ]); | |||||
| } | |||||
| private function failed() | |||||
| { | |||||
| return response()->json([ | |||||
| 'result' => 'FAILED' | |||||
| ]); | |||||
| } | |||||
| private function checkToken() | |||||
| { | |||||
| $currectToken = config('mail.emailSendOrderToken'); | |||||
| if ($this->param->token !== $currectToken) { | |||||
| logs()->warning("Email送信依頼トークン不正"); | |||||
| throw new Exception("Email送信依頼トークン不正"); | |||||
| } | |||||
| } | |||||
| private function getEmail() | |||||
| { | |||||
| $emailId = $this->param->emailId; | |||||
| if ($emailId === Email::TERMINATE_ORDER_APPROVE) { | |||||
| $application = TerminateApplication::findByApplicationNo($this->param->applicationNo); | |||||
| $seasonTicketContract = SeasonTicketContract::find($application->seasonTicketContractRecordNo); | |||||
| $this->setEmail(new TerminateOrderApprove($seasonTicketContract, $application)); | |||||
| return; | |||||
| } | |||||
| if ($emailId === Email::VEHICLE_INFO_UPDATE_ORDER_APPROVE) { | |||||
| $application = VehicleInfoUpdateApplication::findByApplicationNo($this->param->applicationNo); | |||||
| $seasonTicketContract = SeasonTicketContract::find($application->seasonTicketContractRecordNo); | |||||
| $this->setEmail(new VehicleInfoUpdateOrderApprove($seasonTicketContract, $application)); | |||||
| return; | |||||
| } | |||||
| if ($emailId === Email::USER_INFO_UPDATE_ORDER_APPROVE) { | |||||
| $application = UserInfoUpdateApplication::findByApplicationNo($this->param->applicationNo); | |||||
| $seasonTicketContract = SeasonTicketContract::find($application->seasonTicketContractRecordNo); | |||||
| $this->setEmail(new UserInfoUpdateOrderApprove($seasonTicketContract, $application)); | |||||
| return; | |||||
| } | |||||
| if ($emailId === Email::ENTRY_APPROVE) { | |||||
| $entry = SeasonTicketContractEntry::find($this->param->seasonTicketContractEntryRecordNo); | |||||
| $parking = $entry->getParking(); | |||||
| $this->setEmail(new EntryApprove($parking, $entry)); | |||||
| return; | |||||
| } | |||||
| if ($emailId === Email::ENTRY_PAYMENT_COMPLETE) { | |||||
| $entry = SeasonTicketContractEntry::find($this->param->seasonTicketContractEntryRecordNo); | |||||
| $parking = $entry->getParking(); | |||||
| $this->setEmail(new EntryPaymentComplete($parking, $entry)); | |||||
| return; | |||||
| } | |||||
| if ($this->email === null || $this->emailManager === null) { | |||||
| throw new LogicException("setEmail不正"); | |||||
| } | |||||
| } | |||||
| private function setEmail(BaseEmailer $email) | |||||
| { | |||||
| $this->email = $email; | |||||
| $this->emailManager = new EmailManager($email); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,26 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\Email; | |||||
| use App\Codes\Email; | |||||
| use App\Http\Controllers\Web\BaseParam; | |||||
| use Illuminate\Validation\Rules\Enum; | |||||
| /** | |||||
| * @property Email emailId | |||||
| * @property ?string token | |||||
| * @property ?string seasonTicketContractEntryRecordNo | |||||
| * @property ?string applicationNo | |||||
| */ | |||||
| class EmailSendParam extends BaseParam | |||||
| { | |||||
| public function rules(): array | |||||
| { | |||||
| return [ | |||||
| 'email_id' => $this->enum([new Enum(Email::class)]), | |||||
| 'token' => $this->str(true), | |||||
| 'season_ticket_contract_entry_record_no' => $this->str(true), | |||||
| 'application_no' => $this->str(true), | |||||
| ]; | |||||
| } | |||||
| } | |||||
| @@ -65,7 +65,7 @@ class ParkingCertificateOrderController extends WebController | |||||
| $application->memo = $param->memo; | $application->memo = $param->memo; | ||||
| // メール送信 | // メール送信 | ||||
| $email = new ParkingCertificateOrderNotice($customer, $seasonTicketContract, $application); | |||||
| $email = new ParkingCertificateOrderNotice($seasonTicketContract, $application, $customer); | |||||
| $email->setUser(Auth::user()); | $email->setUser(Auth::user()); | ||||
| $emailMmanager = new EmailManager($email); | $emailMmanager = new EmailManager($email); | ||||
| $emailMmanager->confirm(); | $emailMmanager->confirm(); | ||||
| @@ -54,7 +54,7 @@ class SeasonTicketReOrderController extends WebController | |||||
| $application->memo = $param->memo; | $application->memo = $param->memo; | ||||
| // メール送信 | // メール送信 | ||||
| $email = new SeasonTicketReOrderNotice($customer, $seasonTicketContract, $application); | |||||
| $email = new SeasonTicketReOrderNotice($seasonTicketContract, $application, $customer); | |||||
| $email->setUser(Auth::user()); | $email->setUser(Auth::user()); | ||||
| $emailMmanager = new EmailManager($email); | $emailMmanager = new EmailManager($email); | ||||
| $emailMmanager->confirm(); | $emailMmanager->confirm(); | ||||
| @@ -55,7 +55,7 @@ class StickerReOrderController extends WebController | |||||
| $application->memo = $param->memo; | $application->memo = $param->memo; | ||||
| // メール送信 | // メール送信 | ||||
| $email = new StickerReOrderNotice($customer, $seasonTicketContract, $application); | |||||
| $email = new StickerReOrderNotice($seasonTicketContract, $application, $customer); | |||||
| $email->setUser(Auth::user()); | $email->setUser(Auth::user()); | ||||
| $emailMmanager = new EmailManager($email); | $emailMmanager = new EmailManager($email); | ||||
| $emailMmanager->confirm(); | $emailMmanager->confirm(); | ||||
| @@ -57,7 +57,7 @@ class TerminationOrderController extends WebController | |||||
| $application->memo = $param->memo; | $application->memo = $param->memo; | ||||
| // メール送信 | // メール送信 | ||||
| $email = new TerminateOrderNotice($customer, $seasonTicketContract, $application); | |||||
| $email = new TerminateOrderNotice($seasonTicketContract, $application, $customer); | |||||
| $email->setUser(Auth::user()); | $email->setUser(Auth::user()); | ||||
| $emailMmanager = new EmailManager($email); | $emailMmanager = new EmailManager($email); | ||||
| $emailMmanager->confirm(); | $emailMmanager->confirm(); | ||||
| @@ -3,6 +3,7 @@ | |||||
| namespace App\Http\Controllers\Web\SeasonTicketContract; | namespace App\Http\Controllers\Web\SeasonTicketContract; | ||||
| use App\Http\Controllers\Web\WebController; | use App\Http\Controllers\Web\WebController; | ||||
| use App\Kintone\Models\SeasonTicketContract; | |||||
| use App\Util\DateUtil; | use App\Util\DateUtil; | ||||
| use Illuminate\Http\JsonResponse; | use Illuminate\Http\JsonResponse; | ||||
| use Illuminate\Http\Request; | use Illuminate\Http\Request; | ||||
| @@ -33,6 +34,15 @@ class TerminationOrderOptionsController extends WebController | |||||
| $monthes = []; | $monthes = []; | ||||
| // $seasonTicketContract = SeasonTicketContract::find($param->seasonTicketContractRecordNo); | |||||
| // $parking = $seasonTicketContract->getParking(); | |||||
| // $today = DateUtil::now(); | |||||
| // $canEndOfMonth = $parking-> | |||||
| foreach (range(0, 3) as $m) { | foreach (range(0, 3) as $m) { | ||||
| $target = DateUtil::now()->addMonth($m)->endOfMonth(); | $target = DateUtil::now()->addMonth($m)->endOfMonth(); | ||||
| $monthes[] = $target->format('Y/m/d'); | $monthes[] = $target->format('Y/m/d'); | ||||
| @@ -58,7 +58,7 @@ class UpdateVehicleInfoOrderController extends WebController | |||||
| $application->memo = $param->memo; | $application->memo = $param->memo; | ||||
| // メール送信 | // メール送信 | ||||
| $email = new VehicleInfoUpdateOrderNotice($customer, $seasonTicketContract, $application); | |||||
| $email = new VehicleInfoUpdateOrderNotice($seasonTicketContract, $application, $customer); | |||||
| $email->setUser(Auth::user()); | $email->setUser(Auth::user()); | ||||
| $emailMmanager = new EmailManager($email); | $emailMmanager = new EmailManager($email); | ||||
| $emailMmanager->confirm(); | $emailMmanager->confirm(); | ||||
| @@ -19,6 +19,7 @@ class KintoneAccess | |||||
| { | { | ||||
| private string $appName; | private string $appName; | ||||
| private ?string $modelName; | |||||
| private string $host; | private string $host; | ||||
| private string $apiToken = ""; | private string $apiToken = ""; | ||||
| private int $appId; | private int $appId; | ||||
| @@ -43,9 +44,10 @@ class KintoneAccess | |||||
| private const URL_APP_FORM_FIELDS = "/k/v1/app/form/fields.json"; | private const URL_APP_FORM_FIELDS = "/k/v1/app/form/fields.json"; | ||||
| public function __construct(string $appName) | |||||
| public function __construct(string $appName, ?string $modelName) | |||||
| { | { | ||||
| $this->appName = $appName; | $this->appName = $appName; | ||||
| $this->modelName = $modelName; | |||||
| $key = "kintone.host"; | $key = "kintone.host"; | ||||
| $host = config($key); | $host = config($key); | ||||
| @@ -118,7 +120,7 @@ class KintoneAccess | |||||
| throw $e; | throw $e; | ||||
| } | } | ||||
| } | } | ||||
| $result = new $this->appName(); | |||||
| $result = $this->modelName ? new $this->modelName() : new $this->appName(); | |||||
| $result->setDataFromRecordResponse($response['record']); | $result->setDataFromRecordResponse($response['record']); | ||||
| return $result; | return $result; | ||||
| @@ -157,7 +159,7 @@ class KintoneAccess | |||||
| /** | /** | ||||
| * @var KintoneModel $model | * @var KintoneModel $model | ||||
| */ | */ | ||||
| $model = new $this->appName(); | |||||
| $model = $this->modelName ? new $this->modelName() : new $this->appName(); | |||||
| $model->setDataFromRecordResponse($data); | $model->setDataFromRecordResponse($data); | ||||
| $ret->put($model->getRecordId(), $model); | $ret->put($model->getRecordId(), $model); | ||||
| @@ -51,4 +51,9 @@ class Customer extends KintoneModel | |||||
| { | { | ||||
| return static::getAccess()->find(Auth::user()->kintone_id); | return static::getAccess()->find(Auth::user()->kintone_id); | ||||
| } | } | ||||
| public static function findByCustomerCode(string $customerCode) | |||||
| { | |||||
| return static::getAccess()->first(static::getQuery()->where(self::FIELD_CUSTOMER_CODE, $customerCode)); | |||||
| } | |||||
| } | } | ||||
| @@ -48,4 +48,14 @@ abstract class GeneralApplication extends KintoneModel | |||||
| SeasonTicketContract::class, | SeasonTicketContract::class, | ||||
| Customer::class, | Customer::class, | ||||
| ]; | ]; | ||||
| public static function findByApplicationNo(string $applicationNo): static | |||||
| { | |||||
| return static::getAccess()->first(static::getQuery()->where(static::FIELD_APPLICATION_NO, $applicationNo)); | |||||
| } | |||||
| public function getCustomer(): Customer | |||||
| { | |||||
| return Customer::findByCustomerCode($this->customerCode); | |||||
| } | |||||
| } | } | ||||
| @@ -62,7 +62,7 @@ abstract class KintoneModel | |||||
| return $store->get($target); | return $store->get($target); | ||||
| } | } | ||||
| $access = new KintoneAccess($target); | |||||
| $access = new KintoneAccess($target, static::class); | |||||
| $access->setFields(array_keys(static::FIELDS)); | $access->setFields(array_keys(static::FIELDS)); | ||||
| foreach (static::RELATIONS as $relation) { | foreach (static::RELATIONS as $relation) { | ||||
| @@ -2,19 +2,35 @@ | |||||
| namespace App\Kintone\Models; | namespace App\Kintone\Models; | ||||
| use App\Util\DateUtil; | |||||
| use Illuminate\Support\Carbon; | |||||
| /** | /** | ||||
| * アプリ名 定期駐車場マスタ | * アプリ名 定期駐車場マスタ | ||||
| * @property string $parkingName | |||||
| * @property string parkingName | |||||
| * @property array canTerminateDate | |||||
| * @property array canTerminateRule | |||||
| */ | */ | ||||
| class Parking extends KintoneModel | class Parking extends KintoneModel | ||||
| { | { | ||||
| const CONFIG_KEY = "KINTONE_APP_PARKING"; | const CONFIG_KEY = "KINTONE_APP_PARKING"; | ||||
| const FIELD_PARKING_NAME = "駐車場名"; | const FIELD_PARKING_NAME = "駐車場名"; | ||||
| const FIELD_CAN_TERMINATE_DATE = "解約可能日"; | |||||
| const FIELD_CAN_TERMINATE_RULE = "解約ルール"; | |||||
| const ELEMENT_CAN_TERMINATE_DATE_END_OF_MONTH = "末日"; | |||||
| const ELEMENT_CAN_TERMINATE_DATE_15 = "15日"; | |||||
| const ELEMENT_CAN_TERMINATE_RULE_UNTIL_10 = "10日まで申込は当月可"; | |||||
| const ELEMENT_CAN_TERMINATE_RULE_TODAY = "当日解約可"; | |||||
| protected const FIELDS = [ | protected const FIELDS = [ | ||||
| ...parent::FIELDS, | ...parent::FIELDS, | ||||
| self::FIELD_PARKING_NAME => FieldType::SINGLE_LINE_TEXT, | self::FIELD_PARKING_NAME => FieldType::SINGLE_LINE_TEXT, | ||||
| self::FIELD_CAN_TERMINATE_DATE => FieldType::CHECK_BOX, | |||||
| self::FIELD_CAN_TERMINATE_RULE => FieldType::CHECK_BOX, | |||||
| ]; | ]; | ||||
| protected const FIELD_NAMES = [ | protected const FIELD_NAMES = [ | ||||
| @@ -26,4 +42,13 @@ class Parking extends KintoneModel | |||||
| { | { | ||||
| return static::getAccess()->first(static::getQuery()->where(static::FIELD_PARKING_NAME, $parkingName)); | return static::getAccess()->first(static::getQuery()->where(static::FIELD_PARKING_NAME, $parkingName)); | ||||
| } | } | ||||
| public function canTerminateDateEndOfMonth(): bool | |||||
| { | |||||
| return in_array(self::ELEMENT_CAN_TERMINATE_DATE_END_OF_MONTH, $this->canTerminateDate); | |||||
| } | |||||
| public function canTerminateDate15(): bool | |||||
| { | |||||
| return in_array(self::ELEMENT_CAN_TERMINATE_DATE_15, $this->canTerminateDate); | |||||
| } | |||||
| } | } | ||||
| @@ -6,7 +6,9 @@ use LogicException; | |||||
| /** | /** | ||||
| * アプリ名 車室情報管理 | * アプリ名 車室情報管理 | ||||
| * @property string customerCode | |||||
| * @property string seasonTicketSeqNo | * @property string seasonTicketSeqNo | ||||
| * @property string parkingName | |||||
| * @property string vehicleNo | * @property string vehicleNo | ||||
| * @property string registerNo | * @property string registerNo | ||||
| */ | */ | ||||
| @@ -59,4 +61,14 @@ class SeasonTicketContract extends KintoneModel | |||||
| self::FIELD_STUDENT_LICENSE_IMAGES_UPLOAD_DATETIME => 'student_license_images_upload_datetime', | self::FIELD_STUDENT_LICENSE_IMAGES_UPLOAD_DATETIME => 'student_license_images_upload_datetime', | ||||
| self::FIELD_OTHER_LICENSE_IMAGES_UPLOAD_DATETIME => 'other_license_images_upload_datetime', | self::FIELD_OTHER_LICENSE_IMAGES_UPLOAD_DATETIME => 'other_license_images_upload_datetime', | ||||
| ]; | ]; | ||||
| public function getParking(): Parking | |||||
| { | |||||
| return Parking::findByParkingName($this->parkingName); | |||||
| } | |||||
| public function getCustomer(): Customer | |||||
| { | |||||
| return Customer::findByCustomerCode($this->customerCode); | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,54 @@ | |||||
| <?php | |||||
| namespace App\Kintone\Models; | |||||
| use Illuminate\Support\Carbon; | |||||
| /** | |||||
| * アプリ名 定期申込・予約 | |||||
| * @property string parkingName | |||||
| * @property string customerName | |||||
| * @property string customerNameKana | |||||
| * @property string phoneNo | |||||
| * @property string address | |||||
| * @property string email | |||||
| * @property Carbon useStartDate | |||||
| * @property string vehicleNo | |||||
| * @property string paymentMethod | |||||
| */ | |||||
| class SeasonTicketContractEntry extends KintoneModel | |||||
| { | |||||
| const CONFIG_KEY = "KINTONE_APP_SEASON_TICEKT_CONTRACT_ENTRY"; | |||||
| const FIELD_PARKING_NAME = "駐車場"; | |||||
| const FIELD_CUSTOMER_NAME = "氏名"; | |||||
| const FIELD_CUSTOMER_NAME_KANA = "フリガナ"; | |||||
| const FIELD_PHONE_NO = "電話番号"; | |||||
| const FIELD_ADDRESS = "住所"; | |||||
| const FIELD_EMAIL = "メールアドレス"; | |||||
| const FIELD_USE_START_DATE = "利用開始希望日"; | |||||
| const FIELD_VEHICLE_NO = "車両番号"; | |||||
| const FIELD_PAYMENT_METHOD = "支払方法"; | |||||
| protected const FIELDS = [ | |||||
| ...parent::FIELDS, | |||||
| self::FIELD_PARKING_NAME => FieldType::SINGLE_LINE_TEXT, | |||||
| self::FIELD_CUSTOMER_NAME => FieldType::SINGLE_LINE_TEXT, | |||||
| self::FIELD_CUSTOMER_NAME_KANA => FieldType::SINGLE_LINE_TEXT, | |||||
| self::FIELD_PHONE_NO => FieldType::SINGLE_LINE_TEXT, | |||||
| self::FIELD_ADDRESS => FieldType::SINGLE_LINE_TEXT, | |||||
| self::FIELD_EMAIL => FieldType::SINGLE_LINE_TEXT, | |||||
| self::FIELD_USE_START_DATE => FieldType::DATE, | |||||
| self::FIELD_VEHICLE_NO => FieldType::SINGLE_LINE_TEXT, | |||||
| self::FIELD_PAYMENT_METHOD => FieldType::DROP_DOWN, | |||||
| ]; | |||||
| protected const FIELD_NAMES = [ | |||||
| ...parent::FIELD_NAMES, | |||||
| ]; | |||||
| public function getParking(): Parking | |||||
| { | |||||
| return Parking::findByParkingName($this->parkingName); | |||||
| } | |||||
| } | |||||
| @@ -30,6 +30,9 @@ class RouteServiceProvider extends ServiceProvider | |||||
| Route::middleware('web') | Route::middleware('web') | ||||
| ->prefix('api') | ->prefix('api') | ||||
| ->group(base_path('routes/api.php')); | ->group(base_path('routes/api.php')); | ||||
| Route::middleware('api') | |||||
| ->prefix('api-email') | |||||
| ->group(base_path('routes/api_email.php')); | |||||
| Route::middleware('web') | Route::middleware('web') | ||||
| ->group(base_path('routes/web.php')); | ->group(base_path('routes/web.php')); | ||||
| @@ -29,6 +29,7 @@ return [ | |||||
| ...App\Kintone\Models\Customer::setConfig(), | ...App\Kintone\Models\Customer::setConfig(), | ||||
| ...App\Kintone\Models\Parking::setConfig(), | ...App\Kintone\Models\Parking::setConfig(), | ||||
| ...App\Kintone\Models\SeasonTicketContract::setConfig(), | ...App\Kintone\Models\SeasonTicketContract::setConfig(), | ||||
| ...App\Kintone\Models\SeasonTicketContractEntry::setConfig(), | |||||
| ...App\Kintone\Models\PaymentPlan::setConfig(), | ...App\Kintone\Models\PaymentPlan::setConfig(), | ||||
| ...App\Kintone\Models\GeneralApplication::setConfig(), | ...App\Kintone\Models\GeneralApplication::setConfig(), | ||||
| ...App\Kintone\Models\FAQ::setConfig(), | ...App\Kintone\Models\FAQ::setConfig(), | ||||
| @@ -123,6 +123,8 @@ return [ | |||||
| ], | ], | ||||
| ], | ], | ||||
| 'developmentEmail' => env('MAIL_ADDRESS_DEVELOPMENT') | |||||
| 'developmentEmail' => env('MAIL_ADDRESS_DEVELOPMENT'), | |||||
| 'emailSendOrderToken' => env('MAIL_SEND_ORDER_TOKEN'), | |||||
| ]; | ]; | ||||
| @@ -1,4 +1,4 @@ | |||||
| @extends('emails.layouts.members') | |||||
| @extends('emails.layouts.member') | |||||
| @section('contents') | @section('contents') | ||||
| 定期利用取扱事項を同意のうえ、定期利用申込みを頂き誠にありがとうございます。 | 定期利用取扱事項を同意のうえ、定期利用申込みを頂き誠にありがとうございます。 | ||||
| @@ -0,0 +1,16 @@ | |||||
| <?php | |||||
| use App\Util\RouteHelper; | |||||
| /* | |||||
| |-------------------------------------------------------------------------- | |||||
| | API Routes | |||||
| |-------------------------------------------------------------------------- | |||||
| | | |||||
| | Here is where you can register API routes for your application. These | |||||
| | routes are loaded by the RouteServiceProvider and all of them will | |||||
| | be assigned to the "api" middleware group. Make something great! | |||||
| | | |||||
| */ | |||||
| RouteHelper::post('/send', App\Http\Controllers\Web\Email\EmailSendController::class); | |||||