From 7e20f2cffdd43ea76ffa24367e28a4c1050931d7 Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Fri, 22 May 2026 17:43:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B8=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Admin/GateController.php | 6 +++++- app/Http/Controllers/Admin/VisitController.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Admin/GateController.php b/app/Http/Controllers/Admin/GateController.php index 4e22c94..4f211d3 100755 --- a/app/Http/Controllers/Admin/GateController.php +++ b/app/Http/Controllers/Admin/GateController.php @@ -195,12 +195,16 @@ class GateController extends CommonController if ($today < $check->start_date || $today > $check->end_date) { return $this->fail([ResponseCode::ERROR_BUSINESS, '当前不在长期访客有效周期内']); } + // 按自然日 biz_date:每日独立先进后离;昨日仅进或未核销等,不影响今日也需当日先「进厂」再「离厂」 $todayLastLog = GateLog::where('visit_id', $check->id)->where('biz_date', $today)->orderByDesc('id')->first(); + if (!$todayLastLog && !empty($check->code)) { + $todayLastLog = GateLog::where('code', $check->code)->where('biz_date', $today)->orderByDesc('id')->first(); + } if ((int)$all['type'] === 1 && $todayLastLog && (int)$todayLastLog->action === 1) { return $this->fail([ResponseCode::ERROR_BUSINESS, '今日已进厂,请先离厂后再进厂']); } if ((int)$all['type'] === 2 && (!$todayLastLog || (int)$todayLastLog->action !== 1)) { - return $this->fail([ResponseCode::ERROR_BUSINESS, '今日无有效进厂记录,无法离厂']); + return $this->fail([ResponseCode::ERROR_BUSINESS, '今日暂无有效进厂记录,无法离厂。请以当日为准先核销进厂(若昨日仅有进厂或昨日未离,今日也需先核销进厂)。']); } } $remark = '进厂'; diff --git a/app/Http/Controllers/Admin/VisitController.php b/app/Http/Controllers/Admin/VisitController.php index 61b9d5c..0db9963 100755 --- a/app/Http/Controllers/Admin/VisitController.php +++ b/app/Http/Controllers/Admin/VisitController.php @@ -162,7 +162,7 @@ class VisitController extends CommonController 'action' => $item->action, 'action_text' => $item->action_text, 'remark' => $item->remark, - 'created_at' => $item->created_at, + 'created_at' => $item->created_at ? $item->created_at->format('Y-m-d H:i:s') : null, 'admin_name' => $item->admin->name ?? '', 'person_no' => $item->person_no ?? [], 'car_no' => $item->car_no ?? [],