去日志
Some checks failed
Build Docker / build (push) Has been cancelled

This commit is contained in:
haomingming 2025-12-02 16:41:30 +08:00
parent 6e90c52cb8
commit 93d5aae5ac
2 changed files with 39 additions and 39 deletions

View File

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

View File

@ -106,7 +106,7 @@ class Prescription
), ),
]; ];
Log::getInstance()->info("处方平台获取药品请求数据:" . json_encode($option,JSON_UNESCAPED_UNICODE)); // Log::getInstance()->info("处方平台获取药品请求数据:" . json_encode($option,JSON_UNESCAPED_UNICODE));
try { try {
$response = $this->httpRequest($this->api_url . $this->version . '/drug/syncDrugCatalogue', $option); $response = $this->httpRequest($this->api_url . $this->version . '/drug/syncDrugCatalogue', $option);
if (empty($response['data'])){ if (empty($response['data'])){
@ -121,11 +121,11 @@ class Prescription
if (empty($response['data']['result'])){ if (empty($response['data']['result'])){
// 返回值为空 // 返回值为空
Log::getInstance()->error("处方平台获取药品返回result为空" . json_encode($response,JSON_UNESCAPED_UNICODE)); // Log::getInstance()->error("处方平台获取药品返回result为空" . json_encode($response,JSON_UNESCAPED_UNICODE));
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR)); throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
} }
Log::getInstance()->info("处方平台获取药品返回数据:" . json_encode($response,JSON_UNESCAPED_UNICODE)); // Log::getInstance()->info("处方平台获取药品返回数据:" . json_encode($response,JSON_UNESCAPED_UNICODE));
return $response['data']['result']; return $response['data']['result'];
} catch (GuzzleException $e) { } catch (GuzzleException $e) {
Log::getInstance()->error("处方平台获取药品请求异常:" . $e->getMessage()); Log::getInstance()->error("处方平台获取药品请求异常:" . $e->getMessage());
@ -204,14 +204,14 @@ class Prescription
"json" => $arg "json" => $arg
]; ];
Log::getInstance()->info("处方平台上报数据:" . json_encode($option,JSON_UNESCAPED_UNICODE)); // Log::getInstance()->info("处方平台上报数据:" . json_encode($option,JSON_UNESCAPED_UNICODE));
try { try {
$response = $this->httpRequest($this->api_url . $this->version . '/preOrder/receivePreOrder', $option); $response = $this->httpRequest($this->api_url . $this->version . '/preOrder/receivePreOrder', $option);
if (empty($response)){ if (empty($response)){
// 返回值错误为空 // 返回值错误为空
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR)); throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
} }
Log::getInstance()->info("处方平台返回数据:" . json_encode($response,JSON_UNESCAPED_UNICODE)); // Log::getInstance()->info("处方平台返回数据:" . json_encode($response,JSON_UNESCAPED_UNICODE));
return $response; return $response;
} catch (GuzzleException $e) { } catch (GuzzleException $e) {
throw new BusinessException($e->getMessage()); throw new BusinessException($e->getMessage());
@ -293,25 +293,25 @@ class Prescription
// 记录请求日志(隐藏敏感信息) // 记录请求日志(隐藏敏感信息)
$logArg = $arg; $logArg = $arg;
Log::getInstance()->info("处方平台HTTP请求" . $path . ",请求参数:" . json_encode($logArg,JSON_UNESCAPED_UNICODE)); // Log::getInstance()->info("处方平台HTTP请求" . $path . ",请求参数:" . json_encode($logArg,JSON_UNESCAPED_UNICODE));
$response = $this->client->post($path, $arg); $response = $this->client->post($path, $arg);
if ($response->getStatusCode() != '200'){ if ($response->getStatusCode() != '200'){
// 请求失败 // 请求失败
$errorBody = $response->getBody()->getContents(); $errorBody = $response->getBody()->getContents();
Log::getInstance()->error("处方平台HTTP请求失败状态码" . $response->getStatusCode() . ",错误信息:" . $errorBody); // Log::getInstance()->error("处方平台HTTP请求失败状态码" . $response->getStatusCode() . ",错误信息:" . $errorBody);
throw new BusinessException($errorBody); throw new BusinessException($errorBody);
} }
$body = json_decode($response->getBody(),true); $body = json_decode($response->getBody(),true);
if (empty($body)){ if (empty($body)){
// 返回值为空 // 返回值为空
Log::getInstance()->error("处方平台HTTP请求返回值为空路径" . $path); // Log::getInstance()->error("处方平台HTTP请求返回值为空路径" . $path);
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR)); throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
} }
Log::getInstance()->info("处方平台HTTP请求成功路径" . $path . ",返回数据:" . json_encode($body,JSON_UNESCAPED_UNICODE)); // Log::getInstance()->info("处方平台HTTP请求成功路径" . $path . ",返回数据:" . json_encode($body,JSON_UNESCAPED_UNICODE));
return $body; return $body;
} }
} }