add clear

This commit is contained in:
2020-09-10 17:25:46 +08:00
parent 0d202fce14
commit c0ab8adfcb
9 changed files with 60 additions and 10 deletions
+1 -1
View File
@@ -13,7 +13,7 @@
], ],
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"wchat\\": "wchat" "wchat\\": "./wchat/"
}, },
"files": [ "files": [
"Container.php" "Container.php"
+20
View File
@@ -0,0 +1,20 @@
<?php
namespace wchat\base;
/**
* Interface Access_Token
* @package wchat\base
*/
interface Access_Token
{
/**
* @param false $get_token
* @return mixed
*/
public function generateAccess_token($get_token = false);
}
+14 -1
View File
@@ -4,9 +4,22 @@
namespace wchat\officialaccount; namespace wchat\officialaccount;
use wchat\base\Access_Token;
use wchat\common\HttpClient; use wchat\common\HttpClient;
class AccessToken extends AfficialAccount class AccessToken extends AfficialAccount implements Access_Token
{ {
/**
* @param false $get_token
* @return mixed
* @throws \Exception
*/
public function generateAccess_token($get_token = false)
{
return parent::generateAccess_token($get_token); // TODO: Change the autogenerated stub
}
} }
+8 -2
View File
@@ -14,10 +14,11 @@ abstract class AfficialAccount extends Miniprogarampage
private $url = 'https://api.weixin.qq.com/cgi-bin/token?'; private $url = 'https://api.weixin.qq.com/cgi-bin/token?';
/** /**
* @param bool $get_token
* @return mixed * @return mixed
* @throws * @throws \Exception
*/ */
public function generateAccess_token() public function generateAccess_token($get_token = false)
{ {
if (!empty($this->config->getToken())) { if (!empty($this->config->getToken())) {
return $this->config->getToken(); return $this->config->getToken();
@@ -30,6 +31,11 @@ abstract class AfficialAccount extends Miniprogarampage
if (!$result->isResultsOK()) { if (!$result->isResultsOK()) {
throw new \Exception($result->getMessage(), $result->getCode()); throw new \Exception($result->getMessage(), $result->getCode());
} }
if ($get_token) {
return $result->getData('access_token');
}
return $result->getData(); return $result->getData();
} }
+1 -1
View File
@@ -27,7 +27,7 @@ class Authorization extends AfficialAccount
/** /**
* @param $code * @param $code
* @return array|mixed|Result * @return Result
* @throws Exception * @throws Exception
*/ */
public function authorization_user_info($code) public function authorization_user_info($code)
+3 -1
View File
@@ -5,7 +5,9 @@ namespace wchat\qq;
class Token extends SmallProgram use wchat\base\Access_Token;
class Token extends SmallProgram implements Access_Token
{ {
+6 -2
View File
@@ -12,6 +12,10 @@ use wchat\common\HttpClient;
use wchat\common\Result; use wchat\common\Result;
use wchat\common\Help; use wchat\common\Help;
/**
* Class Recharge
* @package wchat\wx
*/
class Recharge extends SmallProgram class Recharge extends SmallProgram
{ {
private $money = 0; private $money = 0;
@@ -21,7 +25,7 @@ class Recharge extends SmallProgram
private $data = []; private $data = [];
private $transfers = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers'; 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 * @param int $money
@@ -62,7 +66,7 @@ class Recharge extends SmallProgram
} }
return new Result($return); return new Result($return);
}); });
return $this->send($this->unifiedorder, $this->builder()); return $this->send($this->uniformed, $this->builder());
} }
/** /**
+4 -1
View File
@@ -18,7 +18,7 @@ class SmallProgram extends Miniprogarampage
* @return mixed * @return mixed
* @throws \Exception * @throws \Exception
*/ */
public function generateAccess_token() public function generateAccess_token($get_token = false)
{ {
if (!empty($this->config->getToken())) { if (!empty($this->config->getToken())) {
return $this->config->getToken(); return $this->config->getToken();
@@ -34,6 +34,9 @@ class SmallProgram extends Miniprogarampage
if (!$param->isResultsOK()) { if (!$param->isResultsOK()) {
throw new \Exception($param->getMessage()); throw new \Exception($param->getMessage());
} }
if ($get_token) {
return $param->getData('access_token');
}
return $param->getData(); return $param->getData();
} }
+3 -1
View File
@@ -4,7 +4,9 @@
namespace wchat\wx; namespace wchat\wx;
class Token extends SmallProgram use wchat\base\Access_Token;
class Token extends SmallProgram implements Access_Token
{ {