| @@ -1,33 +0,0 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\SeasonTicketContract; | |||||
| use App\Http\Controllers\Web\WebController; | |||||
| use Illuminate\Http\JsonResponse; | |||||
| use Illuminate\Http\Request; | |||||
| class ChangePaymentIntervalOrderController extends WebController | |||||
| { | |||||
| public function name(): string | |||||
| { | |||||
| return "振替頻度変更依頼"; | |||||
| } | |||||
| public function description(): string | |||||
| { | |||||
| return "振替頻度依頼を登録する"; | |||||
| } | |||||
| public function __construct(protected ChangePaymentIntervalOrderParam $param) | |||||
| { | |||||
| parent::__construct(); | |||||
| $this->middleware('auth:sanctum'); | |||||
| } | |||||
| protected function run(Request $request): JsonResponse | |||||
| { | |||||
| return $this->successResponse(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,69 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\SeasonTicketContract; | |||||
| use App\Email\Members\StickerReOrderNotice; | |||||
| use App\Http\Controllers\Web\WebController; | |||||
| use App\Kintone\Models\ChangePlanApplication; | |||||
| use App\Kintone\Models\Customer; | |||||
| use App\Kintone\Models\Parking; | |||||
| use App\Kintone\Models\SeasonTicketContract; | |||||
| use App\Kintone\Models\SeasonTicketReOrderApplication; | |||||
| use App\Kintone\Models\StickerReOrderApplication; | |||||
| use App\Logic\EmailManager; | |||||
| use App\Logic\GeneralApplicationManager; | |||||
| use Illuminate\Http\JsonResponse; | |||||
| use Illuminate\Http\Request; | |||||
| use Illuminate\Support\Facades\Auth; | |||||
| class ChangePlanOrderController extends WebController | |||||
| { | |||||
| public function name(): string | |||||
| { | |||||
| return "プラン変更申請"; | |||||
| } | |||||
| public function description(): string | |||||
| { | |||||
| return "プラン変更申請を登録する"; | |||||
| } | |||||
| public function __construct(protected ChangePlanOrderParams $param) | |||||
| { | |||||
| parent::__construct(); | |||||
| $this->middleware('auth:sanctum'); | |||||
| } | |||||
| protected function run(Request $request): JsonResponse | |||||
| { | |||||
| $param = $this->param; | |||||
| $customer = Customer::getSelf(); | |||||
| $seasonTicketContract = SeasonTicketContract::find($param->seasonTicketContractRecordNo); | |||||
| $parking = $seasonTicketContract->getParking(); | |||||
| $application = new ChangePlanApplication(); | |||||
| $manager = new GeneralApplicationManager($application); | |||||
| $manager | |||||
| ->setCustomer($customer) | |||||
| ->setSeasonTicketContract($seasonTicketContract) | |||||
| ->setParking($parking) | |||||
| ->makeApplication(); | |||||
| $application->planNameBefore = $seasonTicketContract->planName; | |||||
| $application->planNameAfter = $param->planName; | |||||
| $application->memo = $param->memo; | |||||
| // メール送信 | |||||
| // $email = new StickerReOrderNotice($seasonTicketContract, $application, $customer); | |||||
| // $email->setUser(Auth::user()); | |||||
| // $emailMmanager = new EmailManager($email); | |||||
| // $emailMmanager->confirm(); | |||||
| $application->save(); | |||||
| return $this->successResponse(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,55 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\SeasonTicketContract; | |||||
| use App\Email\Members\StickerReOrderNotice; | |||||
| use App\Http\Controllers\Web\WebController; | |||||
| use App\Kintone\Models\ChangePlanApplication; | |||||
| use App\Kintone\Models\Customer; | |||||
| use App\Kintone\Models\Parking; | |||||
| use App\Kintone\Models\SeasonTicketContract; | |||||
| use App\Kintone\Models\SeasonTicketContractPlan; | |||||
| use App\Kintone\Models\SeasonTicketReOrderApplication; | |||||
| use App\Kintone\Models\StickerReOrderApplication; | |||||
| use App\Logic\EmailManager; | |||||
| use App\Logic\GeneralApplicationManager; | |||||
| use Illuminate\Http\JsonResponse; | |||||
| use Illuminate\Http\Request; | |||||
| use Illuminate\Support\Facades\Auth; | |||||
| class ChangePlanOrderOptionsController extends WebController | |||||
| { | |||||
| public function name(): string | |||||
| { | |||||
| return "プラン変更申請オプション取得"; | |||||
| } | |||||
| public function description(): string | |||||
| { | |||||
| return "プラン変更申請のオプションする"; | |||||
| } | |||||
| public function __construct(protected ChangePlanOrderOptionsParams $param) | |||||
| { | |||||
| parent::__construct(); | |||||
| $this->middleware('auth:sanctum'); | |||||
| } | |||||
| protected function run(Request $request): JsonResponse | |||||
| { | |||||
| $param = $this->param; | |||||
| $seasonTicketContract = SeasonTicketContract::find($param->seasonTicketContractRecordNo); | |||||
| $plan = SeasonTicketContractPlan::findByName($seasonTicketContract->planName); | |||||
| $ret = []; | |||||
| foreach ($plan->canChangePlanNameList as $planName) { | |||||
| $ret[] = $planName->planName; | |||||
| } | |||||
| return $this->successResponse($ret); | |||||
| } | |||||
| } | |||||
| @@ -3,12 +3,11 @@ | |||||
| namespace App\Http\Controllers\Web\SeasonTicketContract; | namespace App\Http\Controllers\Web\SeasonTicketContract; | ||||
| use App\Http\Controllers\Web\BaseParam; | use App\Http\Controllers\Web\BaseParam; | ||||
| use App\Kintone\Models\GeneralApplication; | |||||
| /** | /** | ||||
| * @property string $seasonTicketContractRecordNo | * @property string $seasonTicketContractRecordNo | ||||
| */ | */ | ||||
| class ChangePaymentIntervalOrderParam extends BaseParam | |||||
| class ChangePlanOrderOptionsParams extends BaseParam | |||||
| { | { | ||||
| public function rules(): array | public function rules(): array | ||||
| { | { | ||||
| @@ -0,0 +1,22 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\SeasonTicketContract; | |||||
| use App\Http\Controllers\Web\BaseParam; | |||||
| /** | |||||
| * @property string $seasonTicketContractRecordNo | |||||
| * @property string planName | |||||
| * @property ?string memo | |||||
| */ | |||||
| class ChangePlanOrderParams extends BaseParam | |||||
| { | |||||
| public function rules(): array | |||||
| { | |||||
| return [ | |||||
| 'season_ticket_contract_record_no' => $this->str(), | |||||
| 'plan_name' => $this->str(), | |||||
| 'memo' => $this->str(true), | |||||
| ]; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,27 @@ | |||||
| <?php | |||||
| namespace App\Kintone\Models; | |||||
| /** | |||||
| * アプリ名 各種申請 [プラン変更申請] | |||||
| * @property string planNameBefore | |||||
| * @property string planNameAfter | |||||
| * @property string memo | |||||
| */ | |||||
| class ChangePlanApplication extends GeneralApplication | |||||
| { | |||||
| const FIELD_PLAN_NAME_BEFORE = "プラン変更申請_変更前_プラン名"; | |||||
| const FIELD_PLAN_NAME_AFTER = "プラン変更申請_変更後_プラン名"; | |||||
| const FIELD_MEMO = "プラン変更申請_備考"; | |||||
| protected const FIELDS = [ | |||||
| ...parent::FIELDS, | |||||
| self::FIELD_PLAN_NAME_BEFORE => FieldType::SINGLE_LINE_TEXT, | |||||
| self::FIELD_PLAN_NAME_AFTER => FieldType::SINGLE_LINE_TEXT, | |||||
| self::FIELD_MEMO => FieldType::MULTI_LINE_TEXT, | |||||
| ]; | |||||
| protected const FIELD_NAMES = [ | |||||
| ...parent::FIELD_NAMES, | |||||
| ]; | |||||
| } | |||||
| @@ -46,6 +46,7 @@ abstract class GeneralApplication extends KintoneModel | |||||
| protected const RELATIONS = [ | protected const RELATIONS = [ | ||||
| SeasonTicketContract::class, | SeasonTicketContract::class, | ||||
| SeasonTicketContractPlan::class, | |||||
| Customer::class, | Customer::class, | ||||
| Bank::class, | Bank::class, | ||||
| ]; | ]; | ||||
| @@ -2,6 +2,8 @@ | |||||
| namespace App\Kintone\Models; | namespace App\Kintone\Models; | ||||
| use App\Util\DateUtil; | |||||
| use Illuminate\Support\Carbon; | |||||
| use LogicException; | use LogicException; | ||||
| /** | /** | ||||
| @@ -12,6 +14,8 @@ use LogicException; | |||||
| * @property string planName | * @property string planName | ||||
| * @property string vehicleNo | * @property string vehicleNo | ||||
| * @property string registerNo | * @property string registerNo | ||||
| * @property ?Carbon contractStartDate | |||||
| * @property ?Carbon contractEndDate | |||||
| */ | */ | ||||
| class SeasonTicketContract extends KintoneModel | class SeasonTicketContract extends KintoneModel | ||||
| { | { | ||||
| @@ -69,6 +73,13 @@ class SeasonTicketContract extends KintoneModel | |||||
| self::FIELD_OTHER_LICENSE_IMAGES_UPLOAD_DATETIME => 'other_license_images_upload_datetime', | self::FIELD_OTHER_LICENSE_IMAGES_UPLOAD_DATETIME => 'other_license_images_upload_datetime', | ||||
| ]; | ]; | ||||
| protected function toArrayCustom(): array | |||||
| { | |||||
| return [ | |||||
| 'can_some_apply' => $this->canSomeApply(), | |||||
| ]; | |||||
| } | |||||
| public function getParking(): Parking | public function getParking(): Parking | ||||
| { | { | ||||
| return Parking::findByParkingName($this->parkingName); | return Parking::findByParkingName($this->parkingName); | ||||
| @@ -78,4 +89,14 @@ class SeasonTicketContract extends KintoneModel | |||||
| { | { | ||||
| return Customer::findByCustomerCode($this->customerCode); | return Customer::findByCustomerCode($this->customerCode); | ||||
| } | } | ||||
| /** | |||||
| * 各種申請を行うことができるか判定する | |||||
| * | |||||
| * @return boolean | |||||
| */ | |||||
| public function canSomeApply(): bool | |||||
| { | |||||
| return $this->contractEndDate instanceof Carbon ? DateUtil::now() <= $this->contractEndDate : false; | |||||
| } | |||||
| } | } | ||||
| @@ -2,6 +2,8 @@ | |||||
| namespace App\Kintone\Models; | namespace App\Kintone\Models; | ||||
| use App\Kintone\Models\SubTable\SeasonTicketContractPlan\CanChangePlanName; | |||||
| use Illuminate\Support\Collection; | |||||
| /** | /** | ||||
| * アプリ名 定期駐車場プランマスタ | * アプリ名 定期駐車場プランマスタ | ||||
| @@ -11,6 +13,7 @@ namespace App\Kintone\Models; | |||||
| * @property string vehicleType | * @property string vehicleType | ||||
| * @property ?int taxAmount | * @property ?int taxAmount | ||||
| * @property ?int taxRate | * @property ?int taxRate | ||||
| * @property Collection<int ,CanChangePlanName> canChangePlanNameList | |||||
| */ | */ | ||||
| class SeasonTicketContractPlan extends KintoneModel | class SeasonTicketContractPlan extends KintoneModel | ||||
| { | { | ||||
| @@ -23,6 +26,9 @@ class SeasonTicketContractPlan extends KintoneModel | |||||
| const FIELD_TAX_AMOUNT = "内税"; | const FIELD_TAX_AMOUNT = "内税"; | ||||
| const FIELD_TAX_RATE = "税率"; | const FIELD_TAX_RATE = "税率"; | ||||
| const FIELD_CAN_CHANGE_PLAN_NAME_LIST = "プラン変更申請にて変更可能なプラン一覧"; | |||||
| const FIELD_CAN_CHANGE_PLAN_NAME_LIST_PLAN_NAME = "プラン変更申請にて変更可能なプラン一覧_定期_駐車場名_月額金額_駐車場備考_プラン_種別_支払パターン"; | |||||
| 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, | ||||
| @@ -30,6 +36,11 @@ class SeasonTicketContractPlan extends KintoneModel | |||||
| self::FIELD_VEHICLE_TYPE => FieldType::SINGLE_LINE_TEXT, | self::FIELD_VEHICLE_TYPE => FieldType::SINGLE_LINE_TEXT, | ||||
| self::FIELD_TAX_AMOUNT => FieldType::NUMBER, | self::FIELD_TAX_AMOUNT => FieldType::NUMBER, | ||||
| self::FIELD_TAX_RATE => FieldType::NUMBER, | self::FIELD_TAX_RATE => FieldType::NUMBER, | ||||
| self::FIELD_CAN_CHANGE_PLAN_NAME_LIST => FieldType::SUBTABLE, | |||||
| ]; | |||||
| protected const SUB_TABLES = [ | |||||
| self::FIELD_CAN_CHANGE_PLAN_NAME_LIST => CanChangePlanName::class, | |||||
| ]; | ]; | ||||
| protected const FIELD_NAMES = [ | protected const FIELD_NAMES = [ | ||||
| @@ -38,10 +49,10 @@ class SeasonTicketContractPlan extends KintoneModel | |||||
| protected function toArrayCustom(): array | protected function toArrayCustom(): array | ||||
| { | { | ||||
| $item = $this->sendItem; | |||||
| return [ | return [ | ||||
| 'has_season_ticket' => in_array("定期券", $item), | |||||
| 'has_sticker' => in_array("シール", $item), | |||||
| 'has_season_ticket' => $this->hasSeasonTicket(), | |||||
| 'has_sticker' => $this->hasSticker(), | |||||
| 'can_apply_change_plan' => $this->canApplyChangePlan(), | |||||
| ]; | ]; | ||||
| } | } | ||||
| @@ -49,4 +60,17 @@ class SeasonTicketContractPlan extends KintoneModel | |||||
| { | { | ||||
| return static::getAccess()->first(static::getQuery()->where(static::FIELD_PLAN_NAME, $name)); | return static::getAccess()->first(static::getQuery()->where(static::FIELD_PLAN_NAME, $name)); | ||||
| } | } | ||||
| public function hasSeasonTicket(): bool | |||||
| { | |||||
| return in_array("定期券", $this->sendItem); | |||||
| } | |||||
| public function hasSticker(): bool | |||||
| { | |||||
| return in_array("シール", $this->sendItem); | |||||
| } | |||||
| public function canApplyChangePlan(): bool | |||||
| { | |||||
| return $this->canChangePlanNameList->isNotEmpty(); | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,27 @@ | |||||
| <?php | |||||
| namespace App\Kintone\Models\SubTable\SeasonTicketContractPlan; | |||||
| use App\Kintone\Models\SeasonTicketContractPlan; | |||||
| use App\Kintone\Models\SubTable\SubTableData; | |||||
| class CanChangePlanName extends SubTableData | |||||
| { | |||||
| public string $planName; | |||||
| public function __construct(array $data = []) | |||||
| { | |||||
| $this->planName = data_get($data, SeasonTicketContractPlan::FIELD_CAN_CHANGE_PLAN_NAME_LIST_PLAN_NAME, ""); | |||||
| parent::__construct($data); | |||||
| } | |||||
| public function toArray(): array | |||||
| { | |||||
| return [ | |||||
| SeasonTicketContractPlan::FIELD_CAN_CHANGE_PLAN_NAME_LIST_PLAN_NAME => $this->planName | |||||
| ]; | |||||
| } | |||||
| } | |||||
| @@ -4,6 +4,7 @@ namespace App\Logic; | |||||
| use App\Exceptions\AppCommonException; | use App\Exceptions\AppCommonException; | ||||
| use App\Kintone\Models\BankAccountUpdateApplication; | use App\Kintone\Models\BankAccountUpdateApplication; | ||||
| use App\Kintone\Models\ChangePlanApplication; | |||||
| use App\Kintone\Models\Customer; | use App\Kintone\Models\Customer; | ||||
| use App\Kintone\Models\GeneralApplication; | use App\Kintone\Models\GeneralApplication; | ||||
| use App\Kintone\Models\Parking; | use App\Kintone\Models\Parking; | ||||
| @@ -66,6 +67,10 @@ class GeneralApplicationManager | |||||
| $this->setType("口座変更申請"); | $this->setType("口座変更申請"); | ||||
| return; | return; | ||||
| } | } | ||||
| if ($model instanceof ChangePlanApplication) { | |||||
| $this->setType("プラン変更"); | |||||
| return; | |||||
| } | |||||
| } | } | ||||
| public function setCustomer(Customer $customer): static | public function setCustomer(Customer $customer): static | ||||
| @@ -22,11 +22,12 @@ RouteHelper::get('/season-ticket-contracts', App\Http\Controllers\Web\SeasonTick | |||||
| RouteHelper::get('/season-ticket-contract/payment-plans', App\Http\Controllers\Web\SeasonTicketContract\PaymentPlansController::class); | RouteHelper::get('/season-ticket-contract/payment-plans', App\Http\Controllers\Web\SeasonTicketContract\PaymentPlansController::class); | ||||
| RouteHelper::post('/season-ticket-contract/season-ticket-re-order', App\Http\Controllers\Web\SeasonTicketContract\SeasonTicketReOrderController::class); | RouteHelper::post('/season-ticket-contract/season-ticket-re-order', App\Http\Controllers\Web\SeasonTicketContract\SeasonTicketReOrderController::class); | ||||
| RouteHelper::post('/season-ticket-contract/sticker-re-order', App\Http\Controllers\Web\SeasonTicketContract\StickerReOrderController::class); | RouteHelper::post('/season-ticket-contract/sticker-re-order', App\Http\Controllers\Web\SeasonTicketContract\StickerReOrderController::class); | ||||
| RouteHelper::post('/season-ticket-contract/change-plan-order', App\Http\Controllers\Web\SeasonTicketContract\ChangePlanOrderController::class); | |||||
| RouteHelper::get('/season-ticket-contract/change-plan-order-params', App\Http\Controllers\Web\SeasonTicketContract\ChangePlanOrderOptionsController::class); | |||||
| RouteHelper::post('/season-ticket-contract/parking-certificate-order', App\Http\Controllers\Web\SeasonTicketContract\ParkingCertificateOrderController::class); | RouteHelper::post('/season-ticket-contract/parking-certificate-order', App\Http\Controllers\Web\SeasonTicketContract\ParkingCertificateOrderController::class); | ||||
| RouteHelper::post('/season-ticket-contract/termination-order', App\Http\Controllers\Web\SeasonTicketContract\TerminationOrderController::class); | RouteHelper::post('/season-ticket-contract/termination-order', App\Http\Controllers\Web\SeasonTicketContract\TerminationOrderController::class); | ||||
| RouteHelper::get('/season-ticket-contract/termination-order/options', App\Http\Controllers\Web\SeasonTicketContract\TerminationOrderOptionsController::class); | RouteHelper::get('/season-ticket-contract/termination-order/options', App\Http\Controllers\Web\SeasonTicketContract\TerminationOrderOptionsController::class); | ||||
| RouteHelper::post('/season-ticket-contract/update-vehicle-info-order', App\Http\Controllers\Web\SeasonTicketContract\UpdateVehicleInfoOrderController::class); | RouteHelper::post('/season-ticket-contract/update-vehicle-info-order', App\Http\Controllers\Web\SeasonTicketContract\UpdateVehicleInfoOrderController::class); | ||||
| RouteHelper::post('/season-ticket-contract/change-payment-interval-order', App\Http\Controllers\Web\SeasonTicketContract\ChangePaymentIntervalOrderController::class); | |||||
| RouteHelper::post('/upload/student-license-images', App\Http\Controllers\Web\SeasonTicketContract\UploadStudentLicenseImagesController::class); | RouteHelper::post('/upload/student-license-images', App\Http\Controllers\Web\SeasonTicketContract\UploadStudentLicenseImagesController::class); | ||||
| RouteHelper::post('/upload/other-license-images', App\Http\Controllers\Web\SeasonTicketContract\UploadOtherLicenseImagesController::class); | RouteHelper::post('/upload/other-license-images', App\Http\Controllers\Web\SeasonTicketContract\UploadOtherLicenseImagesController::class); | ||||