Merge branch 'dev'
This commit is contained in:
commit
3f429387b2
@ -370,7 +370,33 @@ class TestController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function test_15(){
|
public function test_15(){
|
||||||
$a = new Data();
|
$env_version = "release";
|
||||||
$a->product();
|
$app_env = \Hyperf\Support\env("APP_ENV",'dev');
|
||||||
|
if ($app_env == "dev"){
|
||||||
|
$env_version = "trial";
|
||||||
|
}
|
||||||
|
|
||||||
|
$options = [
|
||||||
|
"jump_wxa" => [
|
||||||
|
"path" => "pages/expertDetail/expertDetail",
|
||||||
|
"query" => "doctor_id=539452507563012096",
|
||||||
|
"env_version" => $env_version,
|
||||||
|
],
|
||||||
|
|
||||||
|
"expire_type" => 1,
|
||||||
|
"expire_interval" => 1,
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
$Wechat = new Wechat(1);
|
||||||
|
$result = $Wechat->createUrlScheme($options);
|
||||||
|
dump($result);
|
||||||
|
|
||||||
|
$options = [
|
||||||
|
"scheme" => $result['openlink']
|
||||||
|
];
|
||||||
|
|
||||||
|
$result = $Wechat->getUrlScheme($options);
|
||||||
|
dump($result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ abstract class Ca
|
|||||||
*/
|
*/
|
||||||
public function addUserSignConfig(string $user_id, string $card_num, array $data): bool
|
public function addUserSignConfig(string $user_id, string $card_num, array $data): bool
|
||||||
{
|
{
|
||||||
$option = [
|
$arg = [
|
||||||
'form_params' => [
|
'form_params' => [
|
||||||
'userId' => $user_id,//用户标识信息(为云证书entityId)
|
'userId' => $user_id,//用户标识信息(为云证书entityId)
|
||||||
'configKey' => $user_id, // 签章配置唯一标识,一张云证书配置一个
|
'configKey' => $user_id, // 签章配置唯一标识,一张云证书配置一个
|
||||||
@ -130,17 +130,41 @@ abstract class Ca
|
|||||||
];
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$response = $this->httpRequest(
|
$option = [
|
||||||
$this->api_url . '/signature-server/api/open/signature/userSignConfig',
|
"headers" => [
|
||||||
$option
|
"app_id" => $this->app_id,
|
||||||
);
|
"signature" => $this->getRequestSign($arg),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$option = array_merge($arg, $option);
|
||||||
|
|
||||||
|
$response = $this->client->post($this->api_url . '/signature-server/api/open/signature/userSignConfig', $option);
|
||||||
|
|
||||||
|
if ($response->getStatusCode() != '200') {
|
||||||
|
// 请求失败
|
||||||
|
throw new BusinessException($response->getBody()->getContents());
|
||||||
|
}
|
||||||
|
|
||||||
|
$body = json_decode($response->getBody(), true);
|
||||||
|
if (empty($body)) {
|
||||||
|
// 返回值为空
|
||||||
|
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
|
||||||
|
}
|
||||||
|
|
||||||
dump($response);
|
|
||||||
if ($response['result_code'] == "1104"){
|
if ($response['result_code'] == "1104"){
|
||||||
// 用户标识已经存在,请检查!
|
// 用户标识已经存在,请检查!
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($body['result_code'] != 0) {
|
||||||
|
// 请求失败
|
||||||
|
if (!empty($body['result_msg'])) {
|
||||||
|
throw new BusinessException($body['result_msg']);
|
||||||
|
}
|
||||||
|
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (GuzzleException $e) {
|
} catch (GuzzleException $e) {
|
||||||
throw new BusinessException($e->getMessage());
|
throw new BusinessException($e->getMessage());
|
||||||
|
|||||||
@ -342,4 +342,80 @@ class Wechat
|
|||||||
throw new BusinessException($e->getMessage(), HttpEnumCode::SERVER_ERROR);
|
throw new BusinessException($e->getMessage(), HttpEnumCode::SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成UrlScheme
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
* @throws RedirectionExceptionInterface
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws DecodingExceptionInterface
|
||||||
|
* @throws ClientExceptionInterface
|
||||||
|
* @throws TransportExceptionInterface
|
||||||
|
* @throws ServerExceptionInterface
|
||||||
|
*/
|
||||||
|
public function createUrlScheme(array $options): array|string
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->createApp($this->config['app_id'], $this->config['secret']);
|
||||||
|
|
||||||
|
$client = $this->createClient($this->config['app_id'], $this->config['secret']);
|
||||||
|
|
||||||
|
$response = $client->postJson('wxa/generatescheme', $options);
|
||||||
|
|
||||||
|
if ($response->isFailed()) {
|
||||||
|
// 出错了,处理异常
|
||||||
|
$result = $response->toArray();
|
||||||
|
if(empty($result)){
|
||||||
|
// 返回值为空
|
||||||
|
throw new BusinessException("返回值为空");
|
||||||
|
}
|
||||||
|
if (isset($result['errcode'])){
|
||||||
|
throw new BusinessException($result['errmsg']);
|
||||||
|
}
|
||||||
|
throw new BusinessException();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response->toArray();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw new BusinessException($e->getMessage(), HttpEnumCode::SERVER_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取UrlScheme
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
* @throws RedirectionExceptionInterface
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws DecodingExceptionInterface
|
||||||
|
* @throws ClientExceptionInterface
|
||||||
|
* @throws TransportExceptionInterface
|
||||||
|
* @throws ServerExceptionInterface
|
||||||
|
*/
|
||||||
|
public function getUrlScheme(array $options): array|string
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->createApp($this->config['app_id'], $this->config['secret']);
|
||||||
|
|
||||||
|
$client = $this->createClient($this->config['app_id'], $this->config['secret']);
|
||||||
|
|
||||||
|
$response = $client->postJson('/wxa/queryscheme', $options);
|
||||||
|
|
||||||
|
if ($response->isFailed()) {
|
||||||
|
// 出错了,处理异常
|
||||||
|
$result = $response->toArray();
|
||||||
|
if(empty($result)){
|
||||||
|
// 返回值为空
|
||||||
|
throw new BusinessException("返回值为空");
|
||||||
|
}
|
||||||
|
if (isset($result['errcode'])){
|
||||||
|
throw new BusinessException($result['errmsg']);
|
||||||
|
}
|
||||||
|
throw new BusinessException();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response->toArray();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw new BusinessException($e->getMessage(), HttpEnumCode::SERVER_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user