Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

93 lines
3.3KB

  1. <?php
  2. namespace App\Kintone\Models;
  3. use App\Kintone\Models\SubTable\SeasonTicketContractPlan\CanChangePlanName;
  4. use Illuminate\Support\Collection;
  5. /**
  6. * アプリ名 定期駐車場プランマスタ
  7. * @property string planName
  8. * @property string showPlanName
  9. * @property string parkingName
  10. * @property string[] sendItem
  11. * @property string vehicleType
  12. * @property ?int taxAmount
  13. * @property ?int taxRate
  14. * @property Collection<int ,CanChangePlanName> canChangePlanNameList
  15. * @property ?int deposit
  16. * @property ?int chainGateDeposit
  17. * @property ?int cardDeposit
  18. * @property ?int totalDeposit
  19. */
  20. class SeasonTicketContractPlan extends KintoneModel
  21. {
  22. const CONFIG_KEY = "KINTONE_APP_SEASON_TICKET_CONTRACT_PLAN";
  23. const FIELD_PLAN_NAME = "key";
  24. const FIELD_SHOW_PLAN_NAME = "利用者へ表示するプラン名";
  25. const FIELD_PARKING_NAME = "定期_駐車場名";
  26. const FIELD_SEND_ITEM = "送付物";
  27. const FIELD_VEHICLE_TYPE = "種別";
  28. const FIELD_TAX_AMOUNT = "内税";
  29. const FIELD_TAX_RATE = "税率";
  30. const FIELD_DEPOSIT = "保証金";
  31. const FIELD_CHAIN_GATE_DEPOSIT = "チェーンゲート保証金";
  32. const FIELD_CARD_DEPOSIT = "パスカード保証金";
  33. const FIELD_TOTAL_DEPOSIT = "保証金合計額";
  34. const FIELD_CAN_CHANGE_PLAN_NAME_LIST = "プラン変更申請にて変更可能なプラン一覧";
  35. const FIELD_CAN_CHANGE_PLAN_NAME_LIST_PLAN_NAME = "プラン変更申請にて変更可能なプラン一覧_定期_駐車場名_月額金額_駐車場備考_プラン_種別_支払パターン";
  36. protected const FIELDS = [
  37. ...parent::FIELDS,
  38. self::FIELD_PLAN_NAME => FieldType::SINGLE_LINE_TEXT,
  39. self::FIELD_SHOW_PLAN_NAME => FieldType::SINGLE_LINE_TEXT,
  40. self::FIELD_PARKING_NAME => FieldType::SINGLE_LINE_TEXT,
  41. self::FIELD_SEND_ITEM => FieldType::CHECK_BOX,
  42. self::FIELD_VEHICLE_TYPE => FieldType::SINGLE_LINE_TEXT,
  43. self::FIELD_TAX_AMOUNT => FieldType::NUMBER,
  44. self::FIELD_TAX_RATE => FieldType::NUMBER,
  45. self::FIELD_CAN_CHANGE_PLAN_NAME_LIST => FieldType::SUBTABLE,
  46. self::FIELD_DEPOSIT => FieldType::NUMBER,
  47. self::FIELD_CHAIN_GATE_DEPOSIT => FieldType::NUMBER,
  48. self::FIELD_CARD_DEPOSIT => FieldType::NUMBER,
  49. self::FIELD_TOTAL_DEPOSIT => FieldType::NUMBER,
  50. ];
  51. protected const SUB_TABLES = [
  52. self::FIELD_CAN_CHANGE_PLAN_NAME_LIST => CanChangePlanName::class,
  53. ];
  54. protected const FIELD_NAMES = [
  55. ...parent::FIELD_NAMES,
  56. ];
  57. protected function toArrayCustom(): array
  58. {
  59. return [
  60. 'has_season_ticket' => $this->hasSeasonTicket(),
  61. 'has_sticker' => $this->hasSticker(),
  62. 'can_apply_change_plan' => $this->canApplyChangePlan(),
  63. ];
  64. }
  65. public static function findByName(string $name): static
  66. {
  67. return static::getAccess()->first(static::getQuery()->where(static::FIELD_PLAN_NAME, $name));
  68. }
  69. public function hasSeasonTicket(): bool
  70. {
  71. return in_array("定期券", $this->sendItem);
  72. }
  73. public function hasSticker(): bool
  74. {
  75. return in_array("シール", $this->sendItem);
  76. }
  77. public function canApplyChangePlan(): bool
  78. {
  79. return $this->canChangePlanNameList->isNotEmpty();
  80. }
  81. }