From 7721fb27685cb4b51a970d9438fff61a75066177 Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq.com> Date: Wed, 4 Mar 2026 17:07:31 +0800 Subject: [PATCH] =?UTF-8?q?VIP=E8=BF=9B=E5=87=BA=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/VipAccessRecordController.php | 113 ++++++++++++++++++ app/Models/AdminVipAccessRecord.php | 18 +++ ...7_create_admin_vip_access_record_table.php | 32 +++++ 3 files changed, 163 insertions(+) create mode 100644 app/Http/Controllers/Admin/VipAccessRecordController.php create mode 100644 app/Models/AdminVipAccessRecord.php create mode 100644 database/migrations/2026_03_04_160517_create_admin_vip_access_record_table.php diff --git a/app/Http/Controllers/Admin/VipAccessRecordController.php b/app/Http/Controllers/Admin/VipAccessRecordController.php new file mode 100644 index 0000000..f8e9698 --- /dev/null +++ b/app/Http/Controllers/Admin/VipAccessRecordController.php @@ -0,0 +1,113 @@ +responseService = $responseService; + } + + public function index(Request $request): JsonResponse + { + try { + $query = AdminVipAccessRecord::query(); + + if ($request->has('space')) { + $space = $request->input('space'); + $query->where('parking_space_id', 'like', "%{$space}%"); + } + + if ($request->has('space_number')) { + // $space_number = $request->input('space_number'); + } + + if ($request->has('license')) { + $license = $request->input('license'); + $vipIds = AdminVipList::query()->where( + 'license', + 'like', + "%{$license}%" + )->pluck('id'); + if ($vipIds) { + $query->whereIn('vip_list_id', $vipIds); + } else { + $query->where('id', 0); + } + } + + if ($request->has('enter_start_time') + && $request->has( + 'enter_end_time' + ) + ) { + $enter_start_time = $request->input('enter_start_time'); + $enter_end_time = $request->input('enter_end_time'); + $query->whereBetween( + 'enter_time', + [$enter_start_time, $enter_end_time] + ); + } + + if ($request->has('leave_start_time') + && $request->has( + 'leave_end_time' + ) + ) { + $leave_start_time = $request->input('leave_start_time'); + $leave_end_time = $request->input('leave_end_time'); + $query->whereBetween( + 'enter_time', + [$leave_start_time, $leave_end_time] + ); + } + + // 分页 + $page = $request->input('page', 1); + $perPage = $request->input('per_page', 10); + + $total = $query->count(); + $items = $query->latest()->forPage($page, $perPage)->get()->each( + function ($item) { + $item['license_number'] = AdminVipList::query()->where( + 'id', + $item['vip_list_id'] + )->value('license'); + return $item; + } + ); + + return $this->responseService->success([ + 'items' => $items, + 'total' => $total, + 'page' => $page, + 'per_page' => $perPage, + 'last_page' => ceil($total / $perPage), + ]); + } catch (Exception $e) { + $m_prefix = __('exception.get_user_info_list_failed'); + return $this->responseService->systemError( + $m_prefix . ':' . $e->getMessage() + ); + } + } +} diff --git a/app/Models/AdminVipAccessRecord.php b/app/Models/AdminVipAccessRecord.php new file mode 100644 index 0000000..4d6ba18 --- /dev/null +++ b/app/Models/AdminVipAccessRecord.php @@ -0,0 +1,18 @@ +id(); + $table->integer('parking_space_id')->index('parking_space_id')->comment('车位类型'); + $table->integer('parking_number_id')->comment('车位编号'); + $table->integer('vip_list_id')->index('vip_list_id')->comment('vip名单编号'); + $table->dateTime('enter_time')->comment('进入时间'); + $table->dateTime('leave_time')->comment('离开时间'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('admin_vip_access_record'); + } +};