From 8c10f642c2104bfd1831f034c50ebb21d1cae018 Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Fri, 30 Oct 2026 11:55:11 +0800 Subject: [PATCH] =?UTF-8?q?=E9=81=93=E9=97=B8=E9=A2=84=E7=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RetryInvalidTimeCourseCarAppointments.php | 18 ++++++++++++++++-- app/Repositories/CarRepository.php | 8 +++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/RetryInvalidTimeCourseCarAppointments.php b/app/Console/Commands/RetryInvalidTimeCourseCarAppointments.php index b38fe39..48c50ac 100644 --- a/app/Console/Commands/RetryInvalidTimeCourseCarAppointments.php +++ b/app/Console/Commands/RetryInvalidTimeCourseCarAppointments.php @@ -86,12 +86,26 @@ class RetryInvalidTimeCourseCarAppointments extends Command // 仓库会记录新的请求、响应和第三方订单号;仅补发车位,不发送门禁或通知。 $out = null; - if ((new CarRepository())->courseAppointment($course, $sign, $plate, $out)) { + $sentAt = microtime(true); + $result = (new CarRepository())->courseAppointment($course, $sign, $plate, $out, function ($request) { + $seconds = (int) floor($request['ts'] / 1000); + $this->line('本次请求 reqId:' . $request['reqId']); + $this->line('本次请求 ts(毫秒):' . sprintf('%.0f', $request['ts'])); + $this->line('请求时间(北京时间):' . (new \DateTimeImmutable('@' . $seconds)) + ->setTimezone(new \DateTimeZone('Asia/Shanghai'))->format('Y-m-d H:i:s P')); + $this->line('请求时间(UTC):' . gmdate('Y-m-d H:i:s', $seconds) . ' UTC'); + foreach (['enterTime', 'leaveTime', 'failureTime'] as $field) { + $this->line($field . ':' . $request[$field]); + } + }); + $this->line('请求及日志处理耗时(秒):' . number_format(microtime(true) - $sentAt, 3, '.', '')); + $this->output->writeln('本次接口返回:' . ((string) $out !== '' ? (string) $out : '(空响应)'), \Symfony\Component\Console\Output\OutputInterface::OUTPUT_RAW); + if ($result) { $success++; $this->info('补发成功'); } else { $failed++; - $this->error('补发失败,请查看该报名的新第三方预约日志'); + $this->error('补发失败(接口返回或请求异常见上方)'); } } diff --git a/app/Repositories/CarRepository.php b/app/Repositories/CarRepository.php index ff16ab7..0e3259d 100755 --- a/app/Repositories/CarRepository.php +++ b/app/Repositories/CarRepository.php @@ -114,7 +114,7 @@ class CarRepository /** * 预约车位(课程报名渠道) */ - public function courseAppointment($course, $courseSigns, $plateNo, &$out) + public function courseAppointment($course, $courseSigns, $plateNo, &$out, ?callable $onRequest = null) { $url = $this->baseUrl . '/api/find/ReserveSpace'; $header[] = 'Content-Type: application/json;charset=UTF-8'; @@ -135,6 +135,12 @@ class CarRepository 'flag' => 1, 'cardType' => 100, ]; + // 诊断回调只提供实际发送的非鉴权字段,不暴露密钥或签名。 + if ($onRequest !== null) { + $onRequest(array_intersect_key($params, array_flip([ + 'ts', 'reqId', 'enterTime', 'leaveTime', 'failureTime', + ]))); + } $params['key'] = $this->sign($params); $params = json_encode($params); $result = [];