道闸预约

master
lion 2 weeks ago
parent c40a4a00a0
commit 8c10f642c2

@ -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('补发失败(接口返回或请求异常见上方)');
}
}

@ -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 = [];

Loading…
Cancel
Save