initConfig('ca.v2.online', 'ca_v2_online'); } public function getCloudCert(array $data, string $type = 'Personal'): mixed { $option = [ 'form_params' => [ 'entityId' => $data['user_id'], 'entityType' => $type, 'personalPhone' => (string) $data['mobile'], 'personalName' => $data['card_name'] ?? '', 'personalIdNumber' => $data['card_num'] ?? '', 'orgName' => $data['org_name'] ?? '', 'orgNumber' => $data['org_number'] ?? '', 'pin' => $data['user_id'], 'province' => '四川省', 'locality' => '成都市', 'authType' => '实人认证', 'authTime' => $this->getAuthTime(), 'authResult' => '认证通过', 'authNoticeType' => '数字证书申请告知', ], ]; try { $response = $this->httpRequest( $this->api_url . '/cloud-certificate-service/api/cloudCert/open/v2/cert/certEnroll', $option ); if (empty($response)) { throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR)); } return $response; } catch (GuzzleException $e) { throw new BusinessException($e->getMessage()); } } public function removeCloudCert(array $data): mixed { $option = [ 'form_params' => [ 'entityId' => $data['user_id'], 'pin' => $data['user_id'], 'authType' => '实人认证', 'authTime' => $this->getAuthTime(), 'authResult' => '认证通过', 'authNoticeType' => '数字证书吊销告知', ], ]; try { $response = $this->httpRequest( $this->api_url . '/cloud-certificate-service/api/cloudCert/open/v2/cert/certRevoke', $option ); if (empty($response)) { throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR)); } return $response; } catch (GuzzleException $e) { throw new BusinessException($e->getMessage()); } } public function renewCloudCert(array $data): mixed { $option = [ 'form_params' => [ 'entityId' => $data['user_id'], 'pin' => $data['user_id'], 'authType' => '实人认证', 'authTime' => $this->getAuthTime(), 'authResult' => '认证通过', 'authNoticeType' => '数字证书更新告知', ], ]; try { $response = $this->httpRequest( $this->api_url . '/cloud-certificate-service/api/cloudCert/open/v2/cert/certRenew', $option ); if (empty($response)) { throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR)); } return $response; } catch (GuzzleException $e) { throw new BusinessException($e->getMessage()); } } public function getServiceUrl(array $data): mixed { $option = [ 'form_params' => $data, ]; try { return $this->httpRequest($this->api_url . '/open/api/data/getServiceUrl', $option); } catch (GuzzleException $e) { throw new BusinessException($e->getMessage()); } } public function getPasswordLessSignInfo(string $entityId): mixed { $option = [ 'form_params' => [ 'entityId' => $entityId, ], ]; try { return $this->httpRequest($this->api_url . '/open/api/data/passwordLessSignInfo', $option); } catch (GuzzleException $e) { throw new BusinessException($e->getMessage()); } } protected function resolveCertSerialnumber(string $entityId, array $response): string { $serialNumber = parent::resolveCertSerialnumber($entityId, $response); if ($serialNumber !== '') { return $serialNumber; } $signInfo = $this->getPasswordLessSignInfo($entityId); return (string) ($signInfo['certSn'] ?? ''); } protected function getAuthTime(): string { return (string) round(microtime(true) * 1000); } }