Compare commits

...

9 Commits
master ... dev

Author SHA1 Message Date
haomingming
93d5aae5ac 去日志
Some checks failed
Build Docker / build (push) Has been cancelled
2025-12-02 16:41:30 +08:00
haomingming
6e90c52cb8 添加 处方平台参数
Some checks are pending
Build Docker / build (push) Waiting to run
2025-12-02 16:25:18 +08:00
haomingming
270db5c040 修改 药店编码
Some checks are pending
Build Docker / build (push) Waiting to run
2025-12-02 15:02:01 +08:00
haomingming
e22d2380a4 5345345461 改为 534534546
Some checks are pending
Build Docker / build (push) Waiting to run
2025-12-01 17:40:57 +08:00
haomingming
31c034eee1 更改测试默认ca账号
Some checks are pending
Build Docker / build (push) Waiting to run
2025-12-01 16:45:33 +08:00
haomingming
bd0a3512bc 修改日志
Some checks are pending
Build Docker / build (push) Waiting to run
2025-12-01 16:26:26 +08:00
haomingming
206a765044 加日志
Some checks are pending
Build Docker / build (push) Waiting to run
2025-12-01 16:20:07 +08:00
haomingming
a33fe1033d 日志
Some checks are pending
Build Docker / build (push) Waiting to run
2025-12-01 11:19:17 +08:00
haomingming
12a4846d0e 加上日志
Some checks are pending
Build Docker / build (push) Waiting to run
2025-12-01 11:03:20 +08:00
5 changed files with 69 additions and 9 deletions

View File

@ -67,7 +67,7 @@ class CaService extends BaseService
if ($type == 1){
// 医院
$this->sign_image_path = "basic/file/hospital_signature.png";
$this->entity_id = "5345345461";
$this->entity_id = "534534546";
$this->card_num = "91510106MABTJY4K9R";
}elseif($type == 2){
// 用户
@ -84,7 +84,7 @@ class CaService extends BaseService
if ($app_env == 'prod'){
$this->entity_id = $user_doctor_info['user_id'];
}else{
$this->entity_id = "491925054435950592";
$this->entity_id = "516904855112556544";
}
$this->card_num = $user_doctor_info['card_num'];

View File

@ -393,7 +393,8 @@ class OrderPrescriptionService extends BaseService
$prescription_pdf_oss_path = "/applet/prescription/" . $order_prescription["order_prescription_id"] . ".pdf";
$arg = array();
$arg['terminalCode'] = "ZD-10003";
// $arg['terminalCode'] = "ZD-10003";
$arg['terminalCode'] = config('prescription_platform.terminal_code');
$arg['orderNo'] = $order_product['order_product_no']; // 订单编号
$arg['transactNo'] = $order_product['escrow_trade_no']; // 流水单号
$arg['payDate'] = $order_product['pay_time']; // 支付时间

View File

@ -113,7 +113,9 @@ return [
"client_id" => env('PRE_PLAT_CLIENT_ID', 'ZD-004'),
"client_secret" => env('PRE_PLAT_CLIENT_SECRET', '0baa5927164710b9f800bf33546b6da3'),
"api_url" => env('PRE_PLAT_APP_URL', 'http://49.233.3.200:6304/api/thridapi/'),
"pharmacy_code" => env('PRE_PLAT_PHARMACY_CODE', 'ZD-10003'), // 药店编码
"pharmacy_code" => env('PRE_PLAT_PHARMACY_CODE', 'ZD-10198'), // 药店编码
"zhongduan_code" => env('PRE_PLAT_ZHONGDUAN_CODE', 'ZD-10199'), // 终端编码
"terminal_code" => env('PRE_PLAT_TERMINAL_CODE', 'ZD-10199'), // 机构编码
],
'regulatory_platform' => [ // 四川省互联网医疗服务监管平台
"client_id" => env('REG_PLAT_CLIENT_ID', '09b117f8d1eb4dbfbf565447205ea60f'),

View File

@ -350,6 +350,12 @@ abstract class Ca
*/
public function httpRequest(string $path, array $arg = []): mixed
{
// 请求前日志
// Log::getInstance()->info('CA接口请求开始', [
// '请求地址' => $path,
// '原始参数' => $arg,
// ]);
$option = [
"headers" => [
"app_id" => $this->app_id,
@ -359,26 +365,61 @@ abstract class Ca
$arg = array_merge($arg, $option);
// 合并 header 后的最终请求参数日志
// 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接口请求失败', [
// '请求地址' => $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']);
}
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
}
// 请求成功日志
// Log::getInstance()->info('CA接口请求成功', [
// '请求地址' => $path,
// '返回数据' => $body,
// ]);
return $body['body'];
}

View File

@ -106,23 +106,29 @@ class Prescription
),
];
// Log::getInstance()->info("处方平台获取药品请求数据:" . json_encode($option,JSON_UNESCAPED_UNICODE));
try {
$response = $this->httpRequest($this->api_url . $this->version . '/drug/syncDrugCatalogue', $option);
if (empty($response['data'])){
// 返回值为空
if (!empty($response['message'])){
Log::getInstance()->error("处方平台获取药品返回数据为空:" . json_encode($response,JSON_UNESCAPED_UNICODE));
throw new BusinessException($response['message']);
}
Log::getInstance()->error("处方平台获取药品返回数据为空,无错误信息");
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
}
if (empty($response['data']['result'])){
// 返回值为空
// Log::getInstance()->error("处方平台获取药品返回result为空" . json_encode($response,JSON_UNESCAPED_UNICODE));
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
}
// Log::getInstance()->info("处方平台获取药品返回数据:" . json_encode($response,JSON_UNESCAPED_UNICODE));
return $response['data']['result'];
} catch (GuzzleException $e) {
Log::getInstance()->error("处方平台获取药品请求异常:" . $e->getMessage());
throw new BusinessException($e->getMessage());
}
}
@ -198,14 +204,14 @@ class Prescription
"json" => $arg
];
Log::getInstance()->info("处方平台上报数据:" . json_encode($option,JSON_UNESCAPED_UNICODE));
// Log::getInstance()->info("处方平台上报数据:" . json_encode($option,JSON_UNESCAPED_UNICODE));
try {
$response = $this->httpRequest($this->api_url . $this->version . '/preOrder/receivePreOrder', $option);
if (empty($response)){
// 返回值错误为空
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;
} catch (GuzzleException $e) {
throw new BusinessException($e->getMessage());
@ -220,9 +226,10 @@ class Prescription
*/
public function getPrescription(string $order_product_no,string $prescription_code): array
{
$terminal_code = config('prescription_platform.terminal_code');
$option = [
"json" => [
"terminalCode" => "ZD-10003",
"terminalCode" => $terminal_code,
"orderNo" => $order_product_no,
"prescriptionNo" => $prescription_code,
]
@ -283,19 +290,28 @@ class Prescription
$arg = array_merge($arg,$option);
}
// 记录请求日志(隐藏敏感信息)
$logArg = $arg;
// Log::getInstance()->info("处方平台HTTP请求" . $path . ",请求参数:" . json_encode($logArg,JSON_UNESCAPED_UNICODE));
$response = $this->client->post($path, $arg);
if ($response->getStatusCode() != '200'){
// 请求失败
throw new BusinessException($response->getBody()->getContents());
$errorBody = $response->getBody()->getContents();
// Log::getInstance()->error("处方平台HTTP请求失败状态码" . $response->getStatusCode() . ",错误信息:" . $errorBody);
throw new BusinessException($errorBody);
}
$body = json_decode($response->getBody(),true);
if (empty($body)){
// 返回值为空
// Log::getInstance()->error("处方平台HTTP请求返回值为空路径" . $path);
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
}
// Log::getInstance()->info("处方平台HTTP请求成功路径" . $path . ",返回数据:" . json_encode($body,JSON_UNESCAPED_UNICODE));
return $body;
}
}