diff --git a/app/Services/CaService.php b/app/Services/CaService.php index 03b2adf..14f5149 100644 --- a/app/Services/CaService.php +++ b/app/Services/CaService.php @@ -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']; diff --git a/app/Services/OrderPrescriptionService.php b/app/Services/OrderPrescriptionService.php index e34a073..c9ca983 100644 --- a/app/Services/OrderPrescriptionService.php +++ b/app/Services/OrderPrescriptionService.php @@ -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']; // 支付时间 diff --git a/app/Services/PatientOrderService.php b/app/Services/PatientOrderService.php index 737696a..276f602 100644 --- a/app/Services/PatientOrderService.php +++ b/app/Services/PatientOrderService.php @@ -1677,18 +1677,17 @@ class PatientOrderService extends BaseService // 处理运费数据 $app_env = config('app_env', 'prod'); - if ($app_env != "dev") { - // 获取运费金额 - $Prescription = new Prescription(); - - $result = $Prescription->getLogisticsFee(); - if ($freight_calculation_amount >= $result['drugCost']) { - $logistics_fee = 0; - } else { - $logistics_fee = $result['freight']; - } - } else { - $logistics_fee = 0; + if (env("APP_ENV") == "prod") { + // $Prescription = new Prescription(); + // $result = $Prescription->getLogisticsFee(); + // if ($freight_calculation_amount < $result['drugCost']) { + // $logistics_fee = $result['freight']; + // } + //测试环境 运费 + $logistics_fee = 7; + }else{ + //测试环境 运费 + $logistics_fee = 1.9; } // 实际支付金额=商品总金额-优惠卷金额+运费金额 @@ -2291,11 +2290,16 @@ class PatientOrderService extends BaseService // 获取运费金额 $logistics_fee = 0; if (env("APP_ENV") == "prod") { - $Prescription = new Prescription(); - $result = $Prescription->getLogisticsFee(); - if ($freight_calculation_amount < $result['drugCost']) { - $logistics_fee = $result['freight']; - } + // $Prescription = new Prescription(); + // $result = $Prescription->getLogisticsFee(); + // if ($freight_calculation_amount < $result['drugCost']) { + // $logistics_fee = $result['freight']; + // } + //测试环境 运费 + $logistics_fee = 7; + }else{ + //测试环境 运费 + $logistics_fee = 1.9; } // 实际支付金额=商品总金额-优惠卷金额+运费金额 diff --git a/config/config.php b/config/config.php index 9fb07ba..6497f4a 100644 --- a/config/config.php +++ b/config/config.php @@ -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'), diff --git a/extend/Ca/Ca.php b/extend/Ca/Ca.php index 851ebc9..d86e86b 100644 --- a/extend/Ca/Ca.php +++ b/extend/Ca/Ca.php @@ -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']; } diff --git a/extend/Prescription/Prescription.php b/extend/Prescription/Prescription.php index 7c40750..cb1ff4e 100644 --- a/extend/Prescription/Prescription.php +++ b/extend/Prescription/Prescription.php @@ -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; } } \ No newline at end of file