修改日志
Some checks are pending
Build Docker / build (push) Waiting to run

This commit is contained in:
haomingming 2025-12-01 16:26:26 +08:00
parent 206a765044
commit bd0a3512bc

View File

@ -351,9 +351,9 @@ abstract class Ca
public function httpRequest(string $path, array $arg = []): mixed
{
// 请求前日志
Log::getInstance()->info('CA-HTTP-REQUEST-START', [
'url' => $path,
'params' => $arg,
Log::getInstance()->info('CA接口请求开始', [
'请求地址' => $path,
'原始参数' => $arg,
]);
$option = [
@ -366,30 +366,48 @@ abstract class Ca
$arg = array_merge($arg, $option);
// 合并 header 后的最终请求参数日志
Log::getInstance()->info('CA-HTTP-REQUEST-PARAMS', [
'url' => $path,
'final_params' => $arg,
Log::getInstance()->info('CA接口最终请求参数', [
'请求地址' => $path,
'最终参数' => $arg,
]);
$response = $this->client->post($path, $arg);
// 记录原始响应(未解析)
Log::getInstance()->info('CA接口原始响应', [
'请求地址' => $path,
'HTTP状态码' => $response->getStatusCode(),
'原始响应内容' => (string)$response->getBody(),
]);
if ($response->getStatusCode() != '200') {
// 请求失败
Log::getInstance()->error('CA-HTTP-REQUEST-ERROR', [
'url' => $path,
'status_code' => $response->getStatusCode(),
'response' => $response->getBody()->getContents(),
Log::getInstance()->error('CA接口请求失败', [
'请求地址' => $path,
'HTTP状态码' => $response->getStatusCode(),
'响应内容' => $response->getBody()->getContents(),
]);
throw new BusinessException($response->getBody()->getContents());
}
$body = json_decode($response->getBody(), true);
// 记录接口返回的完整 body
Log::getInstance()->info('CA接口返回BODY', [
'请求地址' => $path,
'返回数据' => $body,
]);
if (empty($body)) {
// 返回值为空
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
}
if ($body['result_code'] != 0) {
// 请求失败
// 业务失败
Log::getInstance()->error('CA业务处理失败', [
'请求地址' => $path,
'返回数据' => $body,
]);
if (!empty($body['result_msg'])) {
throw new BusinessException($body['result_msg']);
}
@ -397,9 +415,9 @@ abstract class Ca
}
// 请求成功日志
Log::getInstance()->info('CA-HTTP-REQUEST-SUCCESS', [
'url' => $path,
'response' => $body,
Log::getInstance()->info('CA接口请求成功', [
'请求地址' => $path,
'返回数据' => $body,
]);
return $body['body'];