領収証発行サービス
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

112 rindas
3.7KB

  1. <?php
  2. namespace App\Mail\Members\Subscription;
  3. use App\Codes\ParkingUseTypeCode;
  4. use App\Codes\VehicleTypeCode;
  5. use App\Mail\Members\Member;
  6. use App\Models\Parking;
  7. use App\Models\SeasonTicketContract;
  8. use App\Models\SeasonTicketContractSubscription;
  9. use App\Models\User;
  10. use Illuminate\Support\Carbon;
  11. use LogicException;
  12. class Approve extends Member
  13. {
  14. private string $email;
  15. private string $parkName;
  16. private Carbon|null $useStartRequestDate;
  17. private VehicleTypeCode $vehicleType;
  18. private string $contractorTypeName;
  19. private int $seasonTicketSeqNo;
  20. private int|null $confirmationCode;
  21. private ParkingUseTypeCode $parkingUseType;
  22. private string $customerCode;
  23. private string $parkingManagementCode;
  24. /**
  25. * Create a new message instance.
  26. *
  27. * @return void
  28. */
  29. public function __construct(
  30. User $user,
  31. SeasonTicketContractSubscription|null $subscription,
  32. Parking $parking,
  33. SeasonTicketContract $seasonTicketContract,
  34. string $contractorTypeName
  35. ) {
  36. $this->email = $user->email;
  37. $this->parkName = $parking->park_name;
  38. $this->useStartRequestDate = $subscription ? $subscription->use_start_request_date : null;
  39. $this->vehicleType = $seasonTicketContract->vehicle_type;
  40. $this->contractorTypeName = $contractorTypeName;
  41. $this->seasonTicketSeqNo = $seasonTicketContract->season_ticket_seq_no;
  42. $this->confirmationCode = $seasonTicketContract->confirmation_code;
  43. $this->parkingUseType = $seasonTicketContract->parking_use_type;
  44. $this->customerCode = $seasonTicketContract->customer_code;
  45. $this->parkingManagementCode = $seasonTicketContract->parking_management_code;
  46. }
  47. public function getTemplateName(): string
  48. {
  49. return 'mails.members.subscription.approve';
  50. }
  51. public function getSubject(): string
  52. {
  53. return '【スマートパーキングパス】定期申し込み完了';
  54. }
  55. public function getMemberParams(): array
  56. {
  57. return [
  58. 'email' => $this->email,
  59. 'park_name' => $this->parkName,
  60. 'use_start_request_date' => $this->getUseStartRequestDate(),
  61. 'vehicle_type' => $this->getVehicleType(),
  62. 'contractor_type_name' => $this->contractorTypeName,
  63. 'how_to_use' => $this->getHowToUse(),
  64. 'season_ticket_seq_no' => $this->seasonTicketSeqNo,
  65. 'confirmation_code' => $this->confirmationCode,
  66. 'ic_card_rental_request' => $this->parkingUseType === ParkingUseTypeCode::IC_RENTAL,
  67. 'ic_self_card_request' => $this->parkingUseType === ParkingUseTypeCode::IC_SELF,
  68. 'ic_qr_code_request' => $this->parkingUseType === ParkingUseTypeCode::QR,
  69. 'my_qr_code_url' => $this->getMyQrCodeUrl(),
  70. ];
  71. }
  72. private function getUseStartRequestDate()
  73. {
  74. if ($this->useStartRequestDate === null) return "-";
  75. return $this->useStartRequestDate->format("Y年m月d日");
  76. }
  77. private function getVehicleType()
  78. {
  79. return VehicleTypeCode::getName($this->vehicleType);
  80. }
  81. private function getHowToUse()
  82. {
  83. switch ($this->parkingUseType) {
  84. case ParkingUseTypeCode::IC_RENTAL:
  85. return "貸与ICカード";
  86. case ParkingUseTypeCode::IC_SELF:
  87. return "個人ICカード";
  88. case ParkingUseTypeCode::QR:
  89. return "QRコード";
  90. }
  91. throw new LogicException(sprintf("不適切な駐車場利用方法 %d", $this->parkingUseType->value));
  92. }
  93. private function getMyQrCodeUrl()
  94. {
  95. return $this->getAppUrl(['app', 'qrcode', 'detail', $this->customerCode, $this->parkingManagementCode]);
  96. }
  97. }