diff --git a/app/Controller/PatientDoctorController.php b/app/Controller/PatientDoctorController.php index b4c868a..53f8758 100644 --- a/app/Controller/PatientDoctorController.php +++ b/app/Controller/PatientDoctorController.php @@ -26,6 +26,8 @@ class PatientDoctorController extends AbstractController $request = $this->container->get(PatientDoctorRequest::class); $request->scene('getInquiryDoctorList')->validateResolved(); + $user_info = $this->request->getAttribute("userInfo") ?? []; + $PatientDoctorService = new PatientDoctorService(); $data = $PatientDoctorService->getInquiryDoctorList(); return $this->response->json($data); diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index a752847..762ad0a 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -55,6 +55,7 @@ use App\Services\PatientOrderService; use App\Services\UserCouponService; use App\Services\UserDoctorService; use App\Utils\Data; +use App\Utils\HttpRequest; use App\Utils\Jwt; use App\Utils\Log; use App\Utils\Mask; @@ -507,6 +508,51 @@ class TestController extends AbstractController // $PatientOrderService = new PatientOrderService(); // $product_datas = $PatientOrderService->calculateProductOrderItemActualPrice($product_datas,$coupons); // dump($product_datas); + + // 使用 +// $params = [ +// 'project_id' => "1897100403531583488", +// 'starttime' => "2025-03-05 00:00:00", +// 'endtime' => "2025-03-05 23:59:59" +// ]; + $params = [ + 'sid' => "1897103702804664320", + 'starttime' => "2025-03-05 00:00:00", + 'endtime' => "2025-03-05 23:59:59" + ]; + $timestamp = 1736755831000; + $secret = 'zxcv'; + + try { + $signature = $this->genSignature($params, (string)$timestamp, $secret); + + $HttpRequest = new HttpRequest(); + $requestUrl = "127.0.0.1:8513/res/case/behavior/list"; + + $option = [ +// 'headers' => [ +// 'platformKey' => '654321', +// 'sign' => $signature, +// 'timestamp' => "1736755831000", +// ], + 'headers' => [ + 'platformKey' => '654321', + 'sign' => $signature, + 'timestamp' => "1736755831000", + ], + 'query' => [ + 'sid' => "1897103702804664320", + 'starttime' => "2025-03-05 00:00:00", + 'endtime' => "2025-03-05 23:59:59" + ] + ]; + + $data = $HttpRequest->getRequest($requestUrl,$option); + dump($data); + + } catch (\Throwable $e) { + echo "错误: " . $e->getMessage() . "\n"; + } } // 退款 @@ -959,4 +1005,67 @@ class TestController extends AbstractController return success(); } + + /** + * 生成签名 + * + * @param array $paramsMap 请求参数数组 + * @param string $timestamp 时间戳 + * @param string $secret 秘钥 + * @return string 签名 + */ + function genSignature(array $paramsMap, string $timestamp, string $secret): string { + // 对参数进行排序 + $paramsData = $this->sortMapParams($paramsMap); + $paramsData['timestamp'] = $timestamp; + + // 转换为 JSON + $jsonData = json_encode($paramsData, JSON_UNESCAPED_UNICODE); + if ($jsonData === false) { + return "错误"; + } + + dump($jsonData); + + // 计算 HMAC-SHA256 签名 + return $this->hmacSHA256($jsonData, $secret); + } + + /** + * 对数组的键进行排序,包括多层嵌套 + * + * @param array $data 输入的数组 + * @return array 排序后的数组 + */ + function sortMapParams(array $data): array { + ksort($data); // 对键进行升序排序 + foreach ($data as $key => &$value) { + if (is_array($value)) { + if (array_keys($value) !== range(0, count($value) - 1)) { + // 如果是关联数组,递归排序 + $value = $this->sortMapParams($value); + } else { + // 如果是索引数组,递归处理其中的每个元素 + foreach ($value as &$subValue) { + if (is_array($subValue)) { + $subValue = $this->sortMapParams($subValue); + } + } + } + } + } + return $data; + } + + /** + * 计算 HMAC-SHA256 签名 + * + * @param string $data 要签名的数据 + * @param string $key 秘钥 + * @return string 签名 + */ + function hmacSHA256(string $data, string $key): string { + return hash_hmac('sha256', $data, $key); + } + } \ No newline at end of file diff --git a/app/Services/PatientDoctorService.php b/app/Services/PatientDoctorService.php index cda5ba2..e9845f4 100644 --- a/app/Services/PatientDoctorService.php +++ b/app/Services/PatientDoctorService.php @@ -75,6 +75,23 @@ class PatientDoctorService extends BaseService $doctor_params["iden_auth_status"] = 1;// 身份认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) $doctor_params["is_bind_bank"] = 1;// 是否已绑定结算银行卡(0:否 1:是) + $user_info = $this->request->getAttribute("userInfo") ?? []; + $params = array(); + $params['user_id'] = $user_info['user_id']; + $user = User::getOne($params); + if (!empty($user)){ + if ($user["mobile"] == "15026619021"){ + $doctor_params["multi_point_status"] = 1; + } + + $app_env = config('app_env','dev'); + if ($app_env == 'dev'){ + if ($user["mobile"] == "17600901561"){ + $doctor_params["multi_point_status"] = 1; + } + } + } + $fields = [ "user_doctor.doctor_id", "user_id",