From c0ab8adfcb1918b9352c60933deb444c369ed553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 10 Sep 2020 17:25:46 +0800 Subject: [PATCH] add clear --- composer.json | 2 +- wchat/base/Access_Token.php | 20 ++++++++++++++++++++ wchat/officialaccount/AccessToken.php | 15 ++++++++++++++- wchat/officialaccount/AfficialAccount.php | 10 ++++++++-- wchat/officialaccount/Authorization.php | 2 +- wchat/qq/Token.php | 4 +++- wchat/wx/Recharge.php | 8 ++++++-- wchat/wx/SmallProgram.php | 5 ++++- wchat/wx/Token.php | 4 +++- 9 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 wchat/base/Access_Token.php diff --git a/composer.json b/composer.json index b666c53..14ad6d0 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ ], "autoload": { "psr-4": { - "wchat\\": "wchat" + "wchat\\": "./wchat/" }, "files": [ "Container.php" diff --git a/wchat/base/Access_Token.php b/wchat/base/Access_Token.php new file mode 100644 index 0000000..62efe7d --- /dev/null +++ b/wchat/base/Access_Token.php @@ -0,0 +1,20 @@ +config->getToken())) { return $this->config->getToken(); @@ -30,6 +31,11 @@ abstract class AfficialAccount extends Miniprogarampage if (!$result->isResultsOK()) { throw new \Exception($result->getMessage(), $result->getCode()); } + + if ($get_token) { + return $result->getData('access_token'); + } + return $result->getData(); } diff --git a/wchat/officialaccount/Authorization.php b/wchat/officialaccount/Authorization.php index 1b90c04..2fb4675 100644 --- a/wchat/officialaccount/Authorization.php +++ b/wchat/officialaccount/Authorization.php @@ -27,7 +27,7 @@ class Authorization extends AfficialAccount /** * @param $code - * @return array|mixed|Result + * @return Result * @throws Exception */ public function authorization_user_info($code) diff --git a/wchat/qq/Token.php b/wchat/qq/Token.php index 410289b..65d30f5 100644 --- a/wchat/qq/Token.php +++ b/wchat/qq/Token.php @@ -5,7 +5,9 @@ namespace wchat\qq; -class Token extends SmallProgram +use wchat\base\Access_Token; + +class Token extends SmallProgram implements Access_Token { diff --git a/wchat/wx/Recharge.php b/wchat/wx/Recharge.php index 67ba4d7..b1811b6 100644 --- a/wchat/wx/Recharge.php +++ b/wchat/wx/Recharge.php @@ -12,6 +12,10 @@ use wchat\common\HttpClient; use wchat\common\Result; use wchat\common\Help; +/** + * Class Recharge + * @package wchat\wx + */ class Recharge extends SmallProgram { private $money = 0; @@ -21,7 +25,7 @@ class Recharge extends SmallProgram private $data = []; private $transfers = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers'; - private $unifiedorder = 'https://api.mch.weixin.qq.com/pay/unifiedorder'; + private $uniformed = 'https://api.mch.weixin.qq.com/pay/unifiedorder'; /** * @param int $money @@ -62,7 +66,7 @@ class Recharge extends SmallProgram } return new Result($return); }); - return $this->send($this->unifiedorder, $this->builder()); + return $this->send($this->uniformed, $this->builder()); } /** diff --git a/wchat/wx/SmallProgram.php b/wchat/wx/SmallProgram.php index 310f822..46d231c 100644 --- a/wchat/wx/SmallProgram.php +++ b/wchat/wx/SmallProgram.php @@ -18,7 +18,7 @@ class SmallProgram extends Miniprogarampage * @return mixed * @throws \Exception */ - public function generateAccess_token() + public function generateAccess_token($get_token = false) { if (!empty($this->config->getToken())) { return $this->config->getToken(); @@ -34,6 +34,9 @@ class SmallProgram extends Miniprogarampage if (!$param->isResultsOK()) { throw new \Exception($param->getMessage()); } + if ($get_token) { + return $param->getData('access_token'); + } return $param->getData(); } diff --git a/wchat/wx/Token.php b/wchat/wx/Token.php index c98999b..96a6f1a 100644 --- a/wchat/wx/Token.php +++ b/wchat/wx/Token.php @@ -4,7 +4,9 @@ namespace wchat\wx; -class Token extends SmallProgram +use wchat\base\Access_Token; + +class Token extends SmallProgram implements Access_Token {