This commit is contained in:
wucongxing 2023-10-24 15:05:38 +08:00
parent 674c3af243
commit f395e63b8e

View File

@ -12,7 +12,7 @@ use EasyWeChat\Kernel\HttpClient\AccessTokenAwareClient;
use EasyWeChat\MiniApp\Application; use EasyWeChat\MiniApp\Application;
use Hyperf\Cache\Cache; use Hyperf\Cache\Cache;
use Hyperf\Redis\Redis; use Hyperf\Redis\Redis;
use Hyperf\Utils\ApplicationContext; //use Hyperf\Utils\ApplicationContext;
use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface; use Psr\Container\NotFoundExceptionInterface;
use Psr\SimpleCache\CacheInterface; use Psr\SimpleCache\CacheInterface;
@ -21,6 +21,7 @@ use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Hyperf\Context\ApplicationContext;
/** /**
* 微信类 * 微信类
@ -87,7 +88,7 @@ class Wechat
$this->app = new Application($config); $this->app = new Application($config);
// 替换缓存 // 替换缓存
$this->app->setCache(ApplicationContext::getContainer()->get(CacheFactory::class)); $this->app->setCache(ApplicationContext::getContainer()->get(CacheInterface::class));
} catch (InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
throw new BusinessException('实例化EasyWeChat类失败:' . $e->getMessage(), HttpEnumCode::SERVER_ERROR); throw new BusinessException('实例化EasyWeChat类失败:' . $e->getMessage(), HttpEnumCode::SERVER_ERROR);
@ -244,6 +245,7 @@ class Wechat
if ($response->isFailed()) { if ($response->isFailed()) {
// 出错了,处理异常 // 出错了,处理异常
$result = $response->toArray(); $result = $response->toArray();
dump($result);
if(empty($result)){ if(empty($result)){
// 返回值为空 // 返回值为空
return []; return [];