您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

103 行
3.7KB

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