|
|
|
|
@ -77,6 +77,9 @@ class GateController extends CommonController
|
|
|
|
|
if (isset($all['code'])) {
|
|
|
|
|
$query->where('code', $all['code']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($all['person_no'])) {
|
|
|
|
|
$query->where('person_no', $all['person_no']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($all['idcard'])) {
|
|
|
|
|
$query->where('idcard', $all['idcard']);
|
|
|
|
|
}
|
|
|
|
|
@ -110,20 +113,18 @@ class GateController extends CommonController
|
|
|
|
|
$messages = [
|
|
|
|
|
'code.required' => '编号必填',
|
|
|
|
|
'type.required' => '类型必填',
|
|
|
|
|
'admin_id.required' => '操作人必填'
|
|
|
|
|
];
|
|
|
|
|
$validator = Validator::make($all, [
|
|
|
|
|
'code' => 'required',
|
|
|
|
|
'type' => 'required',
|
|
|
|
|
'admin_id' => 'required'
|
|
|
|
|
], $messages);
|
|
|
|
|
if ($validator->fails()) {
|
|
|
|
|
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
|
|
|
|
|
}
|
|
|
|
|
$check = Visit::where(function ($query) use ($all) {
|
|
|
|
|
$query->where('person_no', "{$all['keyword']}")
|
|
|
|
|
->orWhere('idcard', "{$all['keyword']}")
|
|
|
|
|
->orWhere('code', "{$all['keyword']}");
|
|
|
|
|
$query->where('person_no', "{$all['code']}")
|
|
|
|
|
->orWhere('idcard', "{$all['code']}")
|
|
|
|
|
->orWhere('code', "{$all['code']}");
|
|
|
|
|
})->first();
|
|
|
|
|
if (empty($check)) {
|
|
|
|
|
return $this->fail([ResponseCode::ERROR_BUSINESS, '拜访记录不存在']);
|
|
|
|
|
@ -132,7 +133,7 @@ class GateController extends CommonController
|
|
|
|
|
if ($all['type'] == 2) {
|
|
|
|
|
$remark = '离厂';
|
|
|
|
|
}
|
|
|
|
|
$gateLog = GateLog::add($all['admin_id'], $all['code'], $all['person_no'] ?? [], $all['car_no'] ?? [], $remark);
|
|
|
|
|
$gateLog = GateLog::add($this->getUserId(), $all['code'], $all['person_no'] ?? [], $all['car_no'] ?? [], $remark);
|
|
|
|
|
if ($all['type'] == 1) {
|
|
|
|
|
// 入场
|
|
|
|
|
Visit::where('code', $all['code'])->update(['audit_status' => 3, 'person_no' => $all['person_no'] ?? '', 'car_no' => $all['car_no'] ?? '']);
|
|
|
|
|
|