契約更新関連追加 #10

Merged
y.higashide merged 1 commits from main_higashide into main 2025-09-05 21:14:17 +09:00
9 changed files with 854 additions and 42 deletions
Showing only changes of commit 1b48a9a139 - Show all commits

View File

@ -4,10 +4,11 @@ namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Carbon\Carbon;
class RegularContractController extends Controller
{
public function showInfo()
public function showInfo(Request $request)
{
$user_id = session('user_id');
if (!$user_id) {
@ -52,13 +53,24 @@ class RegularContractController extends Controller
)
->get();
\Log::info('契約情報表示画面にアクセス', [
'user_id' => $user_id,
]);
if ($request->route()->getName() === 'regular_contract.info') {
// 契約情報表示画面の処理
\Log::info('契約情報表示画面にアクセス', [
'user_id' => $user_id,
]);
$view = 'regular_contract.info';
$active_menu = 'SWC-3-1';
} else {
// 契約更新画面の処理
\Log::info('契約更新画面にアクセス', [
'user_id' => $user_id,
]);
$view = 'regular_contract.update';
$active_menu = 'SWC-4-1';
}
return view('regular_contract.info', [
'active_menu' => 'SWC-3-1', // マイページメニューの選択状態用
return view($view, [
'active_menu' => $active_menu, // マイページメニューの選択状態用
'user_name' => $user_name, // ユーザー名(ヘッダー用)
'contracts' => $contracts,
]);
@ -90,6 +102,7 @@ class RegularContractController extends Controller
'contract_cancel_flag' => 0,
'800m_flag' => 0,
'psection_id' => $old_contract->psection_id,
'ptype_id' => $old_contract->ptype_id,
'zone_id' => $old_contract->zone_id,
'pplace_no' => $old_contract->pplace_no
]);
@ -124,7 +137,7 @@ class RegularContractController extends Controller
->first();
return view('regular_contract.confirm_category', [
'active_menu' => 'SWC-4-3', // マイページメニューの選択状態用
'active_menu' => 'SWC-4-1', // マイページメニューの選択状態用
'user_name' => $user ? $user->user_name : '', // ユーザー名(ヘッダー用)
'user' => $user,
'contract' => $contract
@ -134,15 +147,6 @@ class RegularContractController extends Controller
/**
* 契約区分確認画面の「確認して進む」ボタン押下時の分岐処理
* 本人確認書類アップロード画面 or 利用期間選択画面へ遷移
*
* 分岐条件は下記の通り:
* 1. 利用者分類(一般/学生user.user_categoryid=usertype.user_categoryidのusertype_subject1で判別
* 2. 利用者分類(減免/減免でないregular_contract.contract_reduction=1なら減免
* 3. 駐輪場マスタの設定減免確認種別reduction_confirm.reduction_confirm_type0=確認しない,1=年1回,2=毎更新時)
* 4. 駐輪場マスタの設定年度跨ぎpark.overyear_flag0/NULL=年跨ぎなし,1=年跨ぎあり)
* 5. 駐輪場マスタの設定学生証確認種別park.student_id_confirm_type0=確認しない,1=年1回,2=毎更新時)
* 6. 契約期間に4/1が含まれる場合は年度跨ぎ判定に利用
* 7. ユーザー区分が「学生」の場合のみ、契約終了日が卒業年月日を超える場合も本人確認書類アップロード画面へ
*/
public function confirmCategoryNext($contract_id)
{
@ -170,39 +174,56 @@ class RegularContractController extends Controller
// 分岐条件
$reduction_confirm_type = isset($reduction_confirm) ? $reduction_confirm->reduction_confirm_type : 0;
$student_id_confirm_type = isset($park) ? $park->student_id_confirm_type : 0;
$overyear_flag = isset($park) ? $park->overyear_flag : 0;
// $overyear_flag = isset($park) ? $park->overyear_flag : 0;
// 契約期間に4/1が含まれるか判定
$contract_start = new \DateTime($contract->contract_periods);
$contract_end = new \DateTime($contract->contract_periode);
// $contract_start = new \DateTime($contract->contract_periods);
// $contract_end = new \DateTime($contract->contract_periode);
// 4/1の年は契約開始年
$april_first = new \DateTime($contract_start->format('Y') . '-04-01');
// $april_first = new \DateTime($contract_start->format('Y') . '-04-01');
// 契約終了日が4/1より前なら翌年の4/1も考慮
if ($contract_end < $april_first) {
/**if ($contract_end < $april_first) {
$april_first->modify('+1 year');
}
$includes_april_first = ($contract_start <= $april_first && $contract_end >= $april_first);
$includes_april_first = ($contract_start <= $april_first && $contract_end >= $april_first);*/
// ユーザー区分が「学生」の場合のみ卒業年月日判定
$exceeds_graduation = false;
/**$exceeds_graduation = false;
if (isset($usertype) && $usertype->usertype_subject1 === '学生') {
$graduation_date = isset($user) ? $user->user_graduate : null;
if ($graduation_date) {
$graduation_dt = new \DateTime($graduation_date);
$exceeds_graduation = ($contract_end > $graduation_dt);
}
}
}*/
// 本人確認書類アップロード画面へ遷移する条件
// 1. reduction_confirm_typeが1年1回または2毎更新時
// 2. student_id_confirm_typeが1年1回または2毎更新時
// 3. 年度跨ぎoveryear_flag=1以外かつ契約期間に4/1が含まれる場合
if (
in_array($reduction_confirm_type, [1, 2]) ||
in_array($student_id_confirm_type, [1, 2]) ||
($overyear_flag != 1 && $includes_april_first) ||
$exceeds_graduation
) {
$need_identity = false;
// 減免確認種別reduction_confirm_type=1は年度跨ぎのみ、2は無条件で本人確認
/**if ($reduction_confirm_type == 1 && $includes_april_first) {
$need_identity = true;
}*/
/**if ($reduction_confirm_type == 2) {*/
if (in_array($reduction_confirm_type, [1, 2])) {
$need_identity = true;
}
// 学生証確認種別:学生の場合かつ減免でない場合のみ判定
if (isset($usertype) && $usertype->usertype_subject1 === '学生' && in_array($student_id_confirm_type, [1, 2]) && $contract->contract_reduction == 0) {
$need_identity = true;
}
// 年度跨ぎ判定
/**if ($overyear_flag != 1 && $includes_april_first) {
$need_identity = true;
}*/
// 卒業年月日超過判定
/**if ($exceeds_graduation) {
$need_identity = true;
}*/
if ($need_identity) {
// 本人確認書類アップロード画面へ
return redirect()->route('regular_contract.upload_identity', ['contract_id' => $contract_id]);
} else {
@ -210,4 +231,226 @@ class RegularContractController extends Controller
return redirect()->route('regular_contract.select_period', ['contract_id' => $contract_id]);
}
}
public function uploadIdentity($contract_id)
{
$user_id = session('user_id');
if (!$user_id) {
return redirect('/login');
}
$user_name = DB::table('user')->where('user_id', $user_id)->value('user_name');
\Log::info('契約更新用本人確認書類アップロード画面にアクセス', [
'user_id' => $user_id,
]);
return view('regular_contract.upload_identity', [
'active_menu' => 'SWC-4-1', // マイページメニューの選択状態用
'user_name' => $user_name, // ユーザー名(ヘッダー用)
'contract_id' => $contract_id,
]);
}
public function uploadIdentitySubmit(Request $request, $contract_id)
{
$user_id = session('user_id');
if (!$user_id) {
return redirect('/login');
}
// バリデーション
$rules = [
'user_idcard' => 'required|file|mimes:jpeg,png,jpg,gif,webp',
'user_idcard2' => 'nullable|file|mimes:jpeg,png,jpg,gif,webp',
];
$messages = [
'user_idcard.required' => '本人確認書類をアップロードしてください。',
'user_idcard.file' => '本人確認書類(おもて)はファイルで指定してください。',
'user_idcard.mimes' => '本人確認書類(おもて)は画像ファイルで指定してください。',
'user_idcard2.file' => '本人確認書類(ウラ)はファイルで指定してください。',
'user_idcard2.mimes' => '本人確認書類(ウラ)は画像ファイルで指定してください。',
];
$validator = \Validator::make($request->all(), $rules, $messages);
if ($validator->fails()) {
return redirect()->route('regular_contract.upload_identity', ['contract_id' => $contract_id])
->withErrors($validator)
->withInput();
}
// おもて画像保存
$front = $request->file('user_idcard');
$filename_front = uniqid('photo1_') . '.' . $front->getClientOriginalExtension();
$front->storeAs('photo', $filename_front, 'public');
// userテーブルに保存 本人確認書類チェック済フラグや更新日時も更新項目に追加
$updateData = [
'photo_filename1' => $filename_front,
'user_idcard_chk_flag' => 1,
'user_chk_day' => null,
'user_chk_opeid' => null,
'updated_at' => now(),
];
// ウラ画像がある場合保存し更新項目に追加
if ($request->hasFile('user_idcard2')) {
$back = $request->file('user_idcard2');
$filename_back = uniqid('photo2_') . '.' . $back->getClientOriginalExtension();
$back->storeAs('photo', $filename_back, 'public');
$updateData['photo_filename2'] = $filename_back;
}
DB::table('user')->where('user_id', $user_id)->update($updateData);
// 更新対象の旧契約を検索
$old_contract_id = DB::table('regular_contract')->where('contract_id', $contract_id)->value('old_contract_id');
// 旧契約を契約更新済に更新
DB::table('regular_contract')->where('contract_id', $old_contract_id)->update(['contract_renewal' => 0]);
// 利用者マスタから学校とユーザー名、定期契約マスタから駐輪場IDを取得
$user = DB::table('user')->where('user_id', $user_id)->first();
$park_id = DB::table('regular_contract')->where('contract_id', $contract_id)->value('park_id');
// que_classの分岐
$que_class = is_null($user->user_school) ? 1 : 2;
// オペレーターキュー発行
DB::table('operator_que')->insert([
'que_class' => $que_class,
'user_id' => $user_id,
'contract_id' => $contract_id,
'park_id' => $park_id,
'que_status' => 1,
'que_status_comment' => '本人確認手動処理を行ってください',
'created_at' => now(),
]);
\Log::info('本人確認書類確認中画面にアクセス', [
'user_id' => $user_id,
]);
// 本人確認書類確認中画面へ遷移
return view('regular_contract.identity_checking', [
'active_menu' => 'SWC-4-1', // マイページメニューの選択状態用
'user_name' => $user->user_name // ユーザー名(ヘッダー用)
]);
}
public function selectPeriod($contract_id)
{
$user_id = session('user_id');
if (!$user_id) {
return redirect('/login');
}
// 必要な各マスタ情報を取得
$user = DB::table('user')->where('user_id', $user_id)->first();
$contract = DB::table('regular_contract')->where('contract_id', $contract_id)->first();
// $city_id = DB::table('park')->where('park_id', $contract->park_id)->value('city_id');
//$city_name = DB::table('city')->where('city_id', $city_id)->value('city_name');
$park = DB::table('park')->where('park_id', $contract->park_id)->first();
$city = DB::table('city')->where('city_id', $park->city_id)->first();
$regular_type = DB::table('regular_type')->where('city_id', $city->city_id)->first();
$usertype = DB::table('usertype')->where('user_categoryid', $contract->user_categoryid)->first();
// 2重化しているマスタのため現在のテーブル名を取得
$master_setting = DB::table('setting')->value('web_master');
$tableName = 'price' . $master_setting;
// 利用者区分に応じた逆利用フラグを取得
$inverse_use_flag_column = ($usertype->usertype_subject1 == '一般') ? 'inverse_use_flag1' : 'inverse_use_flag2';
$inverse_use_flag = $park->$inverse_use_flag_column;
if ($inverse_use_flag == 0) {
// regident_cityまたはrelate_cityが一致するか
$is_same = (
strpos($user->user_regident_city, $city->city_name) !== false ||
strpos($user->user_relate_city, $city->city_name) !== false
);
} else {
// regident_cityのみ一致するか
$is_same = (strpos($user->user_regident_city, $city->city_name) !== false);
}
$target_subject2 = $is_same ? '区民' : '区民外';
$user_categoryid = DB::table('usertype')
->where('usertype_subject1', $usertype->usertype_subject1)
->where('usertype_subject2', $target_subject2)
->where('usertype_subject3', $usertype->usertype_subject3)
->value('user_categoryid');
// 駐輪場所マスタから料金を取得
$prices = DB::table($tableName)
->where('park_id', $contract->park_id)
->where('psection_id', $contract->psection_id)
->where('ptype_id', $contract->ptype_id)
->where('user_categoryid', $user_categoryid)
->get();
\Log::info('契約区分取得', [
'user_categoryid' => $user_categoryid,
'target_subject2' => $target_subject2,
'park_id' => $contract->park_id,
'psection_id' => $contract->psection_id,
'ptype_id' => $contract->ptype_id,
'prices' => $prices->toArray(),
]);
\Log::info('利用期間選択画面にアクセス', [
'user_id' => $user_id,
]);
// 利用期間選択画面へ遷移
return view('regular_contract.select_period', [
'active_menu' => 'SWC-4-1', // マイページメニューの選択状態用
'user_name' => $user->user_name, // ユーザー名(ヘッダー用)
'contract_id' => $contract_id,
'regular_type' => $regular_type,
'prices' => $prices,
]);
}
public function updatePeriod(Request $request)
{
$user_id = session('user_id');
if (!$user_id) {
return redirect('/login');
}
// 期間選択チェック
$request->validate([
'month' => 'required',
], [
'month.required' => '契約期間が選択されていません。',
]);
$contract_id = $request->input('contract_id');
$month = $request->input('month');
$price = $request->input('price_' . $month);
\Log::info('契約期間更新処理', [
'month' => $month,
'price' => $price,
]);
$today = now();
$day = $today->day;
if ($day <= 19) {
// 今月の1日
$contract_periods = $today->copy()->startOfMonth()->format('Y-m-d');
} else {
// 翌月の1日
$contract_periods = $today->copy()->addMonth()->startOfMonth()->format('Y-m-d');
}
$contract_periode = Carbon::parse($contract_periods)->addMonths($month - 1)->endOfMonth()->format('Y-m-d');
// 契約更新
DB::table('regular_contract')->where('contract_id', $contract_id)->update([
'enable_months' => $month,
'billing_amount' => $price,
'contract_periods' => $contract_periods,
'contract_periode' => $contract_periode,
'updated_at' => now(),
]);
// 完了後はウェルネット決済画面(仮)へリダイレクト
return redirect()->route('wellnet.payment');
}
}

View File

@ -2,6 +2,14 @@
if (!isset($active_menu)) $active_menu = '';
@endphp
<section id="my-menu" class="bg-success">
<style>
.navbar-toggler::after,
.nav-link::after,
.nav-item::after {
display: none !important;
content: none !important;
}
</style>
<div class="container-fluid">
<nav class="navbar navbar-expand-lg navbar-dark">
<a id="my-menu-btn" class="navbar-toggler text-center" href="#navbarSupportedContent" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> マイメニューを開く </a>
@ -10,10 +18,10 @@ if (!isset($active_menu)) $active_menu = '';
<li class="nav-item {{ $active_menu == 'SWO-4-1' ? 'active' : '' }}"><a class="nav-link" href="{{ url('SWO-4-1.html') }}">マイページトップ<span class="sr-only">(current)</span></a></li>
<li class="nav-item {{ $active_menu == 'SWC-1-1' ? 'active' : '' }}"><a class="nav-link" href="{{ url('/user/info') }}">ユーザー情報確認</a></li>
<li class="nav-item {{ $active_menu == 'SWC-3-1' ? 'active' : '' }}"><a class="nav-link" href="{{ url('/regular_contract/info') }}">定期契約情報</a></li>
<li class="nav-item {{ $active_menu == 'SWC-4-1' ? 'active' : '' }}"><a class="nav-link" href="{{ url('SWC-4-1.html') }}">契約更新</a></li>
<li class="nav-item {{ $active_menu == 'SWC-4-1' ? 'active' : '' }}"><a class="nav-link" href="{{ url('/regular_contract/update') }}">契約更新</a></li>
<li class="nav-item {{ $active_menu == 'SWC-6-1' ? 'active' : '' }}"><a class="nav-link" href="{{ url('SWC-6-1.html') }}">契約履歴</a></li>
<li class="nav-item {{ $active_menu == 'SWC-8-1' ? 'active' : '' }}"><a class="nav-link" href="{{ url('SWC-8-1.html') }}">新規定期契約</a></li>
<li class="nav-item {{ $active_menu == 'SWC-11-1' ? 'active' : '' }}"><a class="nav-link" href="{{ url('SWC-11-1.html') }}">空き待ち状況確認</a></li>
<li class="nav-item {{ $active_menu == 'SWC-8-1' ? 'active' : '' }}"><a class="nav-link" href="{{ url('/regular_contract/create') }}">新規定期契約</a></li>
<li class="nav-item {{ $active_menu == 'SWC-11-1' ? 'active' : '' }}"><a class="nav-link" href="{{ url('/park_waitlist') }}">空き待ち状況確認</a></li>
<li class="nav-item {{ $active_menu == 'SWC-10-1' ? 'active' : '' }}"><a class="nav-link" href="{{ url('SWC-10-1.html') }}">駐輪場検索</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url('../howto.html') }}" target="_blank">このページの使い方</a></li>
</ul>

View File

@ -18,7 +18,7 @@
</div>
<div class="col-6 col-md-2 mb20">
<div class="card text-center border-success">
<a href="{{ url('SWC-4-1.html') }}" target="_top">
<a href="{{ url('regular_contract/update') }}" target="_top">
<figure><img src="{{ asset('assets/img/menu-koshin.png') }}" alt="" class="w-75 mt10"></figure>
<p class="text-success">定期契約を<br>更新する</p>
</a>
@ -34,7 +34,7 @@
</div>
<div class="col-6 col-md-2 mb20">
<div class="card text-center border-success">
<a href="{{ url('SWC-8-1.html') }}" target="_top">
<a href="{{ url('regular_contract/create') }}" target="_top">
<figure><img src="{{ asset('assets/img/menu-shinki.png') }}" alt="" class="w-75 mt10"></figure>
<p class="text-success">新規定期契約<br>申し込み</p>
</a>
@ -58,7 +58,7 @@
</div>
<div class="col-6 col-md-2 mb20">
<div class="card text-center border-success">
<a href="{{ url('SWC-11-1.html') }}" target="_top">
<a href="{{ url('park_waitlist') }}" target="_top">
<figure><img src="{{ asset('assets/img/menu-yoyaku.png') }}" alt="" class="w-75 mt10"></figure>
<p class="text-success">空き待ち状況の確認</p>
</a>

View File

@ -0,0 +1,85 @@
@extends('layouts.app')
@section('content')
<main>
<header class="alert alert-success">
<h4 class="container">契約更新 > 定期契約を更新する</h4>
</header>
<section id="" class="container mt30 mb50">
<div class="col-12 col-md-8 offset-0 offset-md-2 mb30">
<h3 class="alert-success">現在の契約区分をご確認ください。</h3>
</div>
<div class="col-12 col-lg-6 mb10 subject-radio offset-0 offset-md-3">
@if(isset($contract) && isset($contract->securityreg_display_flag) && $contract->securityreg_display_flag == 1)
<p class="text-center">登録している防犯登録番号:{{ $contract->user_securitynum }}</p>
@endif
@php
$usertype = isset($user) && isset($user->user_categoryid) ? DB::table('usertype')->where('user_categoryid', $user->user_categoryid)->first() : null;
@endphp
<input type="radio" name="subject1" id="user_categoryid_ippan" value="一般" @if(isset($usertype) && $usertype->usertype_subject1 == '一般') checked @endif disabled>
<label for="user_categoryid_ippan" class="btn btn-lg btn-block btn-outline-success mb-3">一般</label>
<input type="radio" name="subject1" id="user_categoryid_gakusei" value="学生" @if(isset($usertype) && $usertype->usertype_subject1 == '学生') checked @endif disabled>
<label for="user_categoryid_gakusei" class="btn btn-lg btn-block btn-outline-success mb-3">学生</label>
</div>
<div class="col-12 col-md-3 offset-0 offset-md-3">
<label class="required" for="user_workplace">
減免
</label>
<a class="text-primary" href="#" data-toggle="modal" data-target="#reductionModal">
<i
style="display:inline-block;width:1.1em;height:1.1em;line-height:1.1em;text-align:center;border-radius:50%;border:1.2px solid #007bff;color:#007bff;font-style:normal;font-weight:bold;font-size:0.95em;background:#fff;"></i>
</a>
<!-- 減免説明モーダル -->
<div class="modal fade" id="reductionModal" tabindex="-1" aria-labelledby="reductionModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-body">
<div>
【一般】<br>
 学生以外の利用者の方<br>
【学生】<br>
 学生の利用者の方<br>
【減免】<br>
 以下に該当される利用者の方が、減免の対象になる場合があります。<br>
 (例)<br>
  ・高齢者の方<br>
  ・障がい者の方<br>
  ・生活保護を受けられている方<br>
  ・中国残留邦人の方<br>
  ・児童扶養手当を受給されている方<br>
 詳しくはサポートセンターまでお問い合わせください。<br>
 TEL03-5856-4720
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">キャンセル</button>
</div>
</div>
</div>
</div>
<div class="d-flex align-items-center mb-2">
<div class="form-check form-check-inline" style="margin-right: 1.5em;">
<input class="form-check-input" type="radio" name="subject3" id="yes" value="減免" @if(isset($contract) && $contract->contract_reduction == 1) checked @endif disabled>
<label class="form-check-label" for="yes" style="color: #000;">はい</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="subject3" id="no" value="該当なし" @if(!isset($contract) || $contract->contract_reduction != 1) checked @endif disabled>
<label class="form-check-label" for="no" style="color: #000;">いいえ</label>
</div>
</div>
</div>
<div class="col-12 col-md-6 offset-0 offset-md-3">
<p>ご登録の区分・減免について変更がある場合は、お手数ですが以下の<br>電話番号までお問い合わせください。</p>
<p>電話03-5856-4720<br>毎日14時21時年末年始休</p>
</div>
<div class="col-12 col-md-6 offset-0 offset-md-3">
<a href="{{ route('regular_contract.confirm_category_next', ['contract_id' => $contract->contract_id]) }}" class="btn btn-lg btn-block btn-success">確認して進む</a>
</div>
</section>
</main>
@endsection

View File

@ -0,0 +1,23 @@
@extends('layouts.app')
@section('content')
<main>
<header class="alert alert-success">
<h4 class="container">契約更新 >本人確認書類確認中</h4>
</header>
<section id="" class="container mt30 mb50">
<div class="col-12 col-md-8 offset-0 offset-md-2 mb30">
<h3 class="alert-success text-center">ただいま書類確認中です。</h3>
</div>
<div class="col-12 col-md-6 offset-1 offset-md-3 mb30">
<p>
ご利用者本人確認に最大3営業日お時間を頂戴したく存じます。<br>
完了次第、メールにてご連絡いたしますので、しばらくお待ちください。<br><br>
</p>
</div>
<div class="col-12 col-md-6 offset-1 offset-md-3 mb30">
<a href="{{ url('mypage') }}" class="btn btn-lg btn-block btn-outline-success">マイページへ戻る</a>
</div>
</section>
</main>
@endsection

View File

@ -0,0 +1,81 @@
@extends('layouts.app')
@section('content')
<main>
<header class="alert alert-success">
<h4 class="container">契約更新 > 定期契約を更新する</h4>
</header>
<section id="" class="container mt30 mb50">
@if ($errors->has('month'))
<div class="alert alert-danger text-center">
{{ $errors->first('month') }}
</div>
@endif
<form class="row form" action="{{ url('regular_contract/update_period') }}" method="post">
@csrf
<input type="hidden" name="contract_id" value="{{ $contract_id }}">
<div class="col-12 col-md-8 offset-0 offset-md-2 mb30">
<h3 class="alert-success">契約期間を選択してください。</h3>
<div class="hcenter">
@if ($regular_type->regular_class_1 == 1)
<div class="text-center">
<input type="radio" name="month" id="m1" value="1">
<input type="hidden" name="price_1" value="{{ optional($prices->where('price_month', 1)->first())->price }}">
<label for="m1" class="radio mr20 font-weight-bold">1ヶ月</label>
<span class="d-block mt-0">
{{ optional($prices->where('price_month', 1)->first())->price ? number_format(optional($prices->where('price_month', 1)->first())->price) . '円' : '価格未設定' }}
</span>
</div>
@endif
@if ($regular_type->regular_class_2 == 1)
<div class="text-center">
<input type="radio" name="month" id="m2" value="2">
<input type="hidden" name="price_2" value="{{ optional($prices->where('price_month', 2)->first())->price }}">
<label for="m2" class="radio mr20 font-weight-bold">2ヶ月</label>
<span class="d-block mt-0">
{{ optional($prices->where('price_month', 2)->first())->price ? number_format(optional($prices->where('price_month', 2)->first())->price) . '円' : '価格未設定' }}
</span>
</div>
@endif
@if ($regular_type->regular_class_3 == 1)
<div class="text-center">
<input type="radio" name="month" id="m3" value="3">
<input type="hidden" name="price_3" value="{{ optional($prices->where('price_month', 3)->first())->price }}">
<label for="m3" class="radio mr20 font-weight-bold">3ヶ月</label>
<span class="d-block mt-0">
{{ optional($prices->where('price_month', 3)->first())->price ? number_format(optional($prices->where('price_month', 3)->first())->price) . '円' : '価格未設定' }}
</span>
</div>
@endif
@if ($regular_type->regular_class_6 == 1)
<div class="text-center">
<input type="radio" name="month" id="m6" value="6">
<input type="hidden" name="price_6" value="{{ optional($prices->where('price_month', 6)->first())->price }}">
<label for="m6" class="radio mr20 font-weight-bold">6ヶ月</label>
<span class="d-block mt-0">
{{ optional($prices->where('price_month', 6)->first())->price ? number_format(optional($prices->where('price_month', 6)->first())->price) . '円' : '価格未設定' }}
</span>
</div>
@endif
@if ($regular_type->regular_class_12 == 1)
<div class="text-center">
<input type="radio" name="month" id="m12" value="12">
<input type="hidden" name="price_12" value="{{ optional($prices->where('price_month', 12)->first())->price }}">
<label for="m12" class="radio mr20 font-weight-bold">12ヶ月</label>
<span class="d-block mt-0">
{{ optional($prices->where('price_month', 12)->first())->price ? number_format(optional($prices->where('price_month', 12)->first())->price) . '円' : '価格未設定' }}
</span>
</div>
@endif
</div>
</div>
<div class="col-12 col-md-6 offset-0 offset-md-3">
<input type="submit" class="btn btn-lg btn-block btn-success" value="決定" />
</div>
<div class="col-12 col-md-5 offset-0 offset-md-1 mt50 mb50"> <a href="{{ url('regular_contract/info') }}"
class="btn btn-lg btn-block btn-outline-success">契約一覧へ戻る</a> </div>
<div class="col-12 col-md-5 mt50 mb50"> <a class="btn btn-lg btn-block btn-outline-success"
href="{{ url('/mypage') }}">マイページへ戻る</a> </div>
</form>
</section>
</main>
@endsection

View File

@ -0,0 +1,321 @@
@extends('layouts.app')
@section('content')
@php
function safeCarbonFromDDHM($dd, $hm = '00:00') {
$now = \Carbon\Carbon::now();
if (!$dd || !preg_match('/^\d{1,2}$/', $dd)) return null;
if (!$hm || !preg_match('/^\d{2}:\d{2}$/', $hm)) $hm = '00:00';
$date = $now->format('Y-m-') . str_pad($dd, 2, '0', STR_PAD_LEFT);
$time = $hm . ':00';
try {
return \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $date . ' ' . $time);
} catch (Exception $e) {
return null;
}
}
@endphp
<main>
<header class="alert alert-success">
<h4 class="container">定期契約情報 > 定期契約情報を確認する</h4>
</header>
<section class="container mt30 mb50">
@if(count($contracts) > 0)
@foreach($contracts as $i => $contract)
@if($i % 2 == 0)
<div class="row">
@endif
<article class="col-12 col-lg-6 mb20">
@php
$now = \Carbon\Carbon::now();
$update_flag = $contract->contract_renewal;
$start_dd = $contract->update_grace_period_start_date;
$start_hm = $contract->update_grace_period_start_time;
$end_dd = $contract->update_grace_period_end_date;
$end_hm = $contract->update_grace_period_end_time;
$contract_end_dt = $contract->contract_periode ? \Carbon\Carbon::parse($contract->contract_periode) : null;
$periode_month = $contract_end_dt ? $contract_end_dt->month : null;
$periode_year = $contract_end_dt ? $contract_end_dt->year : null;
$bg = 'alert-warning';
$btn_text = '更新する';
$btn_active = true;
// 契約終了月より前は「ご契約中」
if ($now->lt($contract_end_dt)) {
$bg = 'bg-white';
$btn_text = 'ご契約中';
$btn_active = false;
} else {
// 契約終了月より後は猶予期間判定
if (is_numeric($start_dd) && is_numeric($end_dd)) {
// 開始日
$start_date = $contract_end_dt->format('Y-m-') . str_pad($start_dd, 2, '0', STR_PAD_LEFT);
$start_time = ($start_hm && preg_match('/^\d{2}:\d{2}$/', $start_hm)) ? $start_hm : '00:00';
$start_dt = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $start_date . ' ' . $start_time . ':00');
// 終了日
if ($start_dd < $end_dd) {
$end_date=$contract_end_dt->format('Y-m-') . str_pad($end_dd, 2, '0', STR_PAD_LEFT);
$end_time = ($end_hm && preg_match('/^\d{2}:\d{2}$/', $end_hm)) ? $end_hm : '23:59';
$end_dt = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $end_date . ' ' . $end_time . ':00');
} else {
$next_month_dt = $contract_end_dt->copy()->addMonth();
$end_date = $next_month_dt->format('Y-m-') . str_pad($end_dd, 2, '0', STR_PAD_LEFT);
$end_time = ($end_hm && preg_match('/^\d{2}:\d{2}$/', $end_hm)) ? $end_hm : '23:59';
$end_dt = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $end_date . ' ' . $end_time . ':00');
}
} else {
$start_dt = null;
$end_dt = null;
}
// 猶予期間判定
if ($update_flag === 0) {
$bg = 'bg-white';
$btn_text = '手続き中';
$btn_active = false;
} elseif ($update_flag === 1) {
$bg = 'bg-white';
$btn_text = '更新済';
$btn_active = false;
} elseif ($start_dt && $end_dt && $now->between($start_dt, $end_dt)) {
// 猶予期間内
if ($contract_end_dt && $now->gt($contract_end_dt)) {
$bg = 'alert-danger';
$btn_text = '更新する';
$btn_active = true;
} else {
$bg = 'alert-warning';
$btn_text = '更新する';
$btn_active = true;
}
} else {
$bg = 'bg-white';
$btn_text = 'ご契約中';
$btn_active = false;
}
}
// 契約終了月の場合(既存ロジック)
if (is_numeric($start_dd) && is_numeric($end_dd)) {
// 開始日
$start_date = $contract_end_dt->format('Y-m-') . str_pad($start_dd, 2, '0', STR_PAD_LEFT);
$start_time = ($start_hm && preg_match('/^\d{2}:\d{2}$/', $start_hm)) ? $start_hm : '00:00';
$start_dt = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $start_date . ' ' . $start_time . ':00');
// 終了日
if ($start_dd < $end_dd) {
$end_date=$contract_end_dt->format('Y-m-') . str_pad($end_dd, 2, '0', STR_PAD_LEFT);
$end_time = ($end_hm && preg_match('/^\d{2}:\d{2}$/', $end_hm)) ? $end_hm : '23:59';
$end_dt = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $end_date . ' ' . $end_time . ':00');
} else {
$next_month_dt = $contract_end_dt->copy()->addMonth();
$end_date = $next_month_dt->format('Y-m-') . str_pad($end_dd, 2, '0', STR_PAD_LEFT);
$end_time = ($end_hm && preg_match('/^\d{2}:\d{2}$/', $end_hm)) ? $end_hm : '23:59';
$end_dt = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $end_date . ' ' . $end_time . ':00');
}
} else {
$start_dt = null;
$end_dt = null;
}
// 以降は既存のボタン・背景色判定ロジック
if ($update_flag===0) {
$bg='bg-white';
$btn_text='手続き中';
$btn_active=false;
}
elseif ($update_flag===1) {
$bg='bg-white';
$btn_text='更新済';
$btn_active=false;
}
elseif (!is_null($end_dt) && $end_dt->gt($start_dt)) {
if ($start_dt && $now->lt($start_dt)) {
$bg = 'bg-white';
$btn_text = 'ご契約中';
$btn_active = false;
} else {
// 契約終了日を過ぎていて、更新可能期間内は赤背景
if ($contract_end_dt && $now->gt($contract_end_dt) && $start_dt && $end_dt && $now->between($start_dt, $end_dt)) {
$bg = 'alert-danger';
$btn_text = '更新する';
$btn_active = true;
} else {
$bg = 'alert-warning';
$btn_text = '更新する';
$btn_active = true;
}
}
}
elseif ($start_dt && $start_dt->gt($end_dt)) {
if ($now->lt($start_dt)) {
$bg = 'bg-white';
$btn_text = 'ご契約中';
$btn_active = false;
} elseif ($now->gte($start_dt) && $now->lte($contract_end_dt->copy()->endOfMonth())) {
$bg = 'alert-warning';
$btn_text = '更新する';
$btn_active = true;
} else {
$bg = 'alert-danger';
$btn_text = '更新する';
$btn_active = true;
}
}
@endphp
@if($bg == 'bg-white')
<div class="card border-success">
@elseif($bg == 'alert-warning')
<div class="card alert-warning">
@elseif($bg == 'alert-danger')
<div class="card alert-danger">
@else
<div class="card">
@endif
<style>
.table.text-center {
border-radius: 0.25rem !important;
border-collapse: separate !important;
overflow: hidden;
}
.btn-outline-secondary.badge-pill.custom-rounded-btn[disabled],
.btn-outline-secondary.badge-pill.custom-rounded-btn.disabled {
pointer-events: none;
cursor: default !important;
background: #fff !important;
color: #6c757d !important;
border-color: #6c757d !important;
opacity: 1 !important;
}
.btn-outline-secondary.badge-pill.custom-rounded-btn:not([disabled]):hover,
.btn-outline-secondary.badge-pill.custom-rounded-btn:not(.disabled):hover {
color: #212529 !important;
}
.border-warning {
border: 1px solid #ffc107 !important;
}
.border-white {
border: 1px solid #fff !important;
}
.border-danger {
border: 1px solid #dc3545 !important;
}
.table-no-margin {
margin-bottom: 0 !important;
padding-bottom: 0 !important;
}
</style>
<table class="table text-center table-no-margin {{ $bg }}
@if($bg == 'alert-warning') border-warning
@elseif($bg == 'bg-white') border-white
@elseif($bg == 'alert-danger') border-danger
@endif">
<tr>
<th>定期契約ID</th>
<td>{{ $contract->contract_id }}</td>
</tr>
<tr>
<th>駐輪場名</th>
<td>{{ $contract->park_name }}</td>
</tr>
<tr>
<th>利用者区分</th>
<td>{{ $contract->usertype_subject1 }}</td>
</tr>
<tr>
<th>利用開始日</th>
<td>{{ \Carbon\Carbon::parse($contract->contract_periods)->format('Y/m/d') }}</td>
</tr>
<tr>
<th>契約月数</th>
<td>{{ $contract->enable_months }}ヶ月</td>
</tr>
<tr>
<td colspan="2" class="text-center">
<div style="display: flex; flex-direction: column; align-items: center;">
<div style="display: flex; gap: 6px; margin-bottom: 12px;">
@if($bg == 'alert-warning' && $btn_active)
<a href="{{ url('regular_contract/update/' . $contract->contract_id) }}" class="btn btn-warning badge-pill custom-rounded-btn">{{ $btn_text }}</a>
@elseif($bg == 'alert-danger' && $btn_active)
<a href="{{ url('regular_contract/update/' . $contract->contract_id) }}" class="btn btn-danger badge-pill custom-rounded-btn">{{ $btn_text }}</a>
@else
<button type="button" class="btn btn-outline-secondary badge-pill custom-rounded-btn" disabled>{{ $btn_text }}</button>
@endif
@if($bg == 'alert-warning')
<button type="button" id="cancelModalBtn" class="btn btn-outline-warning badge-pill custom-rounded-btn" style="background: transparent;" data-bs-toggle="modal" data-bs-target="#cancelModal">解約について</button>
@elseif($bg == 'alert-danger')
<button type="button" id="cancelModalBtn" class="btn btn-outline-danger badge-pill custom-rounded-btn" style="background: transparent;" data-bs-toggle="modal" data-bs-target="#cancelModal">解約について</button>
@else
<button type="button" id="cancelModalBtn" class="btn btn-outline-secondary badge-pill custom-rounded-btn" style="background: transparent;" data-bs-toggle="modal" data-bs-target="#cancelModal">解約について</button>
@endif
</div>
@php
$has_receipt = DB::table('inv_publish')->where('contract_id', $contract->contract_id)->exists();
@endphp
@if($has_receipt)
@if($bg == 'alert-warning')
<a href="{{ url('receipt/download/' . $contract->contract_id) }}" class="btn btn-outline-warning badge-pill custom-rounded-btn" style="background: transparent;">領収書再発行</a>
@elseif($bg == 'alert-danger')
<a href="{{ url('receipt/download/' . $contract->contract_id) }}" class="btn btn-outline-danger badge-pill custom-rounded-btn" style="background: transparent;">領収書再発行</a>
@else
<a href="{{ url('receipt/download/' . $contract->contract_id) }}" class="btn btn-outline-secondary badge-pill custom-rounded-btn" style="background: transparent;">領収書再発行</a>
@endif
@else
@if($bg == 'alert-warning')
<a href="{{ url('receipt/input/' . $contract->contract_id) }}" class="btn btn-outline-warning badge-pill custom-rounded-btn" style="background: transparent;">領収書発行</a>
@elseif($bg == 'alert-danger')
<a href="{{ url('receipt/input/' . $contract->contract_id) }}" class="btn btn-outline-danger badge-pill custom-rounded-btn" style="background: transparent;">領収書発行</a>
@else
<a href="{{ url('receipt/input/' . $contract->contract_id) }}" class="btn btn-outline-secondary badge-pill custom-rounded-btn" style="background: transparent;">領収書発行</a>
@endif
@endif
</div>
</td>
</tr>
</table>
</div>
</article>
@if($i % 2 == 1 || $i == count($contracts) - 1)
</div>
@endif
@endforeach
@else
<div class="col-12 col-lg-12 mb20">
<p>定期契約情報はありません。</p>
</div>
@endif
{{-- modal moved to end of file to avoid clipping issues --}}
<form class="row form">
<div class="col-12 col-md-4 offset-0 offset-md-4 mt50 mb50">
<a href="{{ url('mypage') }}" class="btn btn-lg btn-block btn-outline-success">マイページへ戻る</a>
</div>
</form>
</section>
</main>
@endsection
<!-- 解約についてモーダル -->
<div class="modal fade" id="cancelModal" tabindex="-1" aria-labelledby="cancelModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
解約の手続きにつきましては、下記コールセンターへお問い合わせください。<br>So-Managerコールセンター<br>03-5856-4720
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">閉じる</button>
</div>
</div>
</div>
</div>
<style>
.custom-rounded-btn {
border-radius: 2rem !important;
padding-left: 2rem !important;
padding-right: 2rem !important;
font-weight: 500;
min-width: 140px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
</style>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>

View File

@ -0,0 +1,40 @@
@extends('layouts.app')
@section('content')
<main>
<header class="alert alert-success">
<h4 class="container">契約更新 >本人確認書類のアップロード</h4>
</header>
@if ($errors->has('user_idcard'))
<div class="alert alert-danger text-center">{{ $errors->first('user_idcard') }}</div>
@endif
<section id="" class="container mt30 mb50">
<form class="row form" action="{{ route('regular_contract.upload_identity_submit', ['contract_id' => $contract_id]) }}" method="POST" enctype="multipart/form-data">
@csrf
<div class="col-12 col-md-8 offset-0 offset-md-2 mb30">
<h3 class="alert-success text-center">本人確認書類をアップロードしてください。</h3>
</div>
<div class="col-12 col-md-6 offset-1 offset-md-3 mb30">
<p>
本人確認書類のアップロードが必要な契約更新です。<br>
証明書類のアップロードをお願いします。<br><br>
また卒業などで料金区分が変わる方はコールセンターまでお問い合わせ下さい。<br><br>
So-Manager コールセンター<br>
TEL:03-5856-4720毎日12時22時
</p>
</div>
<div class="col-12 col-md-6 offset-1 offset-md-3 mb30">
おもて<span style="color: red;">*</span>
<input type="file" class="mb10" id="user_idcard" name="user_idcard" accept="image/*" /><br>
ウ ラ<span style="color: transparent;">*</span>
<input type="file" class="mb10" id="user_idcard2" name="user_idcard2" accept="image/*" />
</div>
<div class="col-12 col-md-4 offset-0 offset-md-2 mt10">
<a href="{{ route('regular_contract.confirm_category', ['contract_id' => $contract_id]) }}" class="btn btn-lg btn-block btn-outline-success">戻る</a>
</div>
<div class="col-12 col-md-4 mt10">
<input type="submit" class="btn btn-lg btn-block btn-success" value="アップロードする" />
</div>
</form>
</section>
</main>
@endsection

View File

@ -1,3 +1,4 @@
<?php
use Illuminate\Http\Request;
@ -56,8 +57,8 @@ Route::post('/swo7_2',[InquiryConfirmController::class, 'confirm'])->name('swo7_
Route::post('/swo7_3',[InquiryConfirmController::class, 'complete'])->name('swo7_3');
Route::post('/swo8_3', [PasswordReminderController::class, 'sendMail'])->name('swo8_3');
//マイページ(仮)
Route::get('/mypage', function () {
// 仮の表示(コントローラー未作成の場合)
return 'マイページ(仮)';
})->name('mypage');
@ -65,7 +66,6 @@ Route::get('/mypage', function () {
Route::get('/user/info', [UserInfoController::class, 'show'])
->name('user.info');
// ユーザー情報編集画面GET: 編集フォーム表示)
Route::get('/user/edit', [UserEditController::class, 'show'])
->name('user.edit');
@ -109,6 +109,8 @@ Route::get('regular_contract/create', [RegularContractCreateController::class, '
->name('regular_contract.create');
// 定期契約更新
Route::get('regular_contract/update', [RegularContractController::class, 'showInfo'])
->name('regular_contract.update');
Route::get('regular_contract/update/{contract_id}', [RegularContractController::class, 'update']);
// 契約区分確認
Route::get('regular_contract/confirm_category/{contract_id}', [RegularContractController::class, 'confirmCategory'])
@ -118,14 +120,19 @@ Route::get('regular_contract/confirm_category_next/{contract_id}', [RegularContr
// 本人確認書類アップロード
Route::get('regular_contract/upload_identity/{contract_id}', [RegularContractController::class, 'uploadIdentity'])
->name('regular_contract.upload_identity');
// 本人確認書類確認中
Route::post('regular_contract/upload_identity/{contract_id}', [RegularContractController::class, 'uploadIdentitySubmit'])
->name('regular_contract.upload_identity_submit');
// 利用期間選択
Route::get('regular_contract/select_period/{contract_id}', [RegularContractController::class, 'selectPeriod'])
->name('regular_contract.select_period');
Route::post('regular_contract/update_period', [App\Http\Controllers\RegularContractController::class, 'updatePeriod'])
->name('regular_contract.update_period');
// 空き待ち状況確認画面
Route::get('park_waitlist', [ParkWaitlistController::class, 'index'])
->name('park_waitlist.index');
// ログイン画面(仮)
Route::get('/login', function () {
return '
<form method="POST" action="/login">
@ -136,9 +143,13 @@ Route::get('/login', function () {
';
})->name('login');
Route::post('/login', function (Request $request) {
$user_id = $request->input('user_id');
Session::put('user_id', $user_id); // 入力されたIDをそのまま保存
return redirect('/user/info'); // 認証なしでリダイレクト
});
// ウェルネット決済画面(仮)
Route::get('/wellnet/payment', function (): mixed {
return '<h1>ウェルネット決済画面</h1>';
})->name('wellnet.payment');