From bdd7c8a401a35e37af1c5586671700c70ebf9ab2 Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Mon, 15 Jun 2026 19:10:02 +0800 Subject: [PATCH] vip --- .../Controllers/Mobile/VisitController.php | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Mobile/VisitController.php b/app/Http/Controllers/Mobile/VisitController.php index 84a2d6f..9fb7a60 100755 --- a/app/Http/Controllers/Mobile/VisitController.php +++ b/app/Http/Controllers/Mobile/VisitController.php @@ -470,24 +470,37 @@ class VisitController extends CommonController { $all = request()->all(); $messages = [ - 'idcard.required' => '身份证数组必填', 'type.required' => '访客类型必填', ]; $validator = Validator::make($all, [ - 'idcard' => 'required', 'type' => 'required', ], $messages); if ($validator->fails()) { return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]); } - $type = $all['type']; + $type = (int) $all['type']; + $idcards = array_values(array_filter(array_map(function ($idcard) { + return trim((string) $idcard); + }, (array) ($all['idcard'] ?? [])), function ($idcard) { + return $idcard !== ''; + })); + + // VIP 访客可不填证件号:无证件时不做学习校验 + if ($type === 4 && empty($idcards)) { + return $this->success([ + 'missing' => [], + 'expired' => [], + 'invalid' => [], + ]); + } + + if (empty($idcards)) { + return $this->fail([ResponseCode::ERROR_PARAMETER, '请提供证件号码']); + } + $missingIdcards = []; $expiredIdcards = []; - foreach ((array)$all['idcard'] as $idcard) { - $idcard = trim((string)$idcard); - if ($idcard === '') { - continue; - } + foreach ($idcards as $idcard) { $log = StudyLog::where('idcard', $idcard) ->where('type', $type) ->orderBy('id', 'desc')