From 8245e0cfb63df7052940c9ca1e664a4e5e3b2cc6 Mon Sep 17 00:00:00 2001 From: Anyon Date: Thu, 24 Dec 2020 15:05:54 +0800 Subject: [PATCH] Update Test.php --- app/wechat/controller/api/Test.php | 34 +++++++++++++----------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/app/wechat/controller/api/Test.php b/app/wechat/controller/api/Test.php index 848f18b4b..2daf053e6 100644 --- a/app/wechat/controller/api/Test.php +++ b/app/wechat/controller/api/Test.php @@ -18,6 +18,7 @@ namespace app\wechat\controller\api; use app\wechat\service\WechatService; use think\admin\Controller; use think\admin\extend\CodeExtend; +use think\Response; use WeChat\Contracts\Tools; /** @@ -29,12 +30,12 @@ class Test extends Controller { /** * 微信JSAPI支付二维码 - * @return \think\Response + * @return Response * @throws \Endroid\QrCode\Exceptions\ImageFunctionFailedException * @throws \Endroid\QrCode\Exceptions\ImageFunctionUnknownException * @throws \Endroid\QrCode\Exceptions\ImageTypeInvalidException */ - public function jsapiQrc() + public function jsapiQrc(): Response { $this->url = sysuri('wechat/api.test/jsapi', [], false, true); return $this->_buildQrcResponse($this->url); @@ -42,12 +43,12 @@ class Test extends Controller /** * 显示网页授权二维码 - * @return \think\Response + * @return Response * @throws \Endroid\QrCode\Exceptions\ImageFunctionFailedException * @throws \Endroid\QrCode\Exceptions\ImageFunctionUnknownException * @throws \Endroid\QrCode\Exceptions\ImageTypeInvalidException */ - public function oauthQrc() + public function oauthQrc(): Response { $this->url = sysuri('wechat/api.test/oauth', [], false, true); return $this->_buildQrcResponse($this->url); @@ -55,12 +56,12 @@ class Test extends Controller /** * 显示网页授权二维码 - * @return \think\Response + * @return Response * @throws \Endroid\QrCode\Exceptions\ImageFunctionFailedException * @throws \Endroid\QrCode\Exceptions\ImageFunctionUnknownException * @throws \Endroid\QrCode\Exceptions\ImageTypeInvalidException */ - public function jssdkQrc() + public function jssdkQrc(): Response { $this->url = sysuri('wechat/api.test/jssdk', [], false, true); return $this->_buildQrcResponse($this->url); @@ -68,12 +69,12 @@ class Test extends Controller /** * 微信扫码支付模式一二维码显示 - * @return \think\Response + * @return Response * @throws \Endroid\QrCode\Exceptions\ImageFunctionFailedException * @throws \Endroid\QrCode\Exceptions\ImageFunctionUnknownException * @throws \Endroid\QrCode\Exceptions\ImageTypeInvalidException */ - public function scanOneQrc() + public function scanOneQrc(): Response { $pay = WechatService::WePayOrder(); return $this->_buildQrcResponse($pay->qrcParams('8888888')); @@ -81,14 +82,14 @@ class Test extends Controller /** * 扫码支付模式二测试二维码 - * @return \think\Response + * @return Response * @throws \Endroid\QrCode\Exceptions\ImageFunctionFailedException * @throws \Endroid\QrCode\Exceptions\ImageFunctionUnknownException * @throws \Endroid\QrCode\Exceptions\ImageTypeInvalidException * @throws \WeChat\Exceptions\InvalidResponseException * @throws \WeChat\Exceptions\LocalCacheException */ - public function scanTwoQrc() + public function scanTwoQrc(): Response { $result = WechatService::WePayOrder()->create([ 'body' => '测试商品', @@ -103,7 +104,6 @@ class Test extends Controller /** * 网页授权测试 - * @return string * @throws \WeChat\Exceptions\InvalidResponseException * @throws \WeChat\Exceptions\LocalCacheException * @throws \think\Exception @@ -120,7 +120,6 @@ class Test extends Controller /** * JSSDK测试 - * @return string * @throws \WeChat\Exceptions\InvalidResponseException * @throws \WeChat\Exceptions\LocalCacheException * @throws \think\Exception @@ -141,7 +140,7 @@ class Test extends Controller * @throws \WeChat\Exceptions\InvalidResponseException * @throws \WeChat\Exceptions\LocalCacheException */ - public function scanOneNotify() + public function scanOneNotify(): string { $pay = WechatService::WePayOrder(); $notify = $pay->getNotify(); @@ -209,9 +208,6 @@ class Test extends Controller echo "当前用户OPENID: {$user['openid']}"; echo "\n--- 创建预支付码 ---\n"; var_export($result); - echo ''; - - echo '
';
         echo "\n\n--- JSAPI 及 H5 参数 ---\n";
         var_export($options);
         echo '
'; @@ -235,7 +231,7 @@ class Test extends Controller * @return string * @throws \WeChat\Exceptions\InvalidResponseException */ - public function notify() + public function notify(): string { $wechat = WechatService::WePayOrder(); p($wechat->getNotify()); @@ -245,12 +241,12 @@ class Test extends Controller /** * 创建二维码响应对应 * @param string $url 二维码内容 - * @return \think\Response + * @return Response * @throws \Endroid\QrCode\Exceptions\ImageFunctionFailedException * @throws \Endroid\QrCode\Exceptions\ImageFunctionUnknownException * @throws \Endroid\QrCode\Exceptions\ImageTypeInvalidException */ - private function _buildQrcResponse(string $url) + private function _buildQrcResponse(string $url): Response { $qrCode = new \Endroid\QrCode\QrCode(); $qrCode->setText($url)->setSize(300)->setPadding(20)->setImageType('png');