修改添加签章配置重复问题

This commit is contained in:
2023-07-19 08:55:05 +08:00
parent b3cfc5e9d0
commit 4e1a642438
3 changed files with 134 additions and 8 deletions
+76
View File
@@ -342,4 +342,80 @@ class Wechat
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);
}
}
}