|
|
|
|
@ -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')
|
|
|
|
|
|