This commit is contained in:
2023-12-12 15:35:37 +08:00
parent 6438d8affb
commit d16adba08e
32 changed files with 285 additions and 311 deletions
+11 -14
View File
@@ -27,7 +27,7 @@ abstract class Subject extends Multiprogramming
/** /**
* @param array $keywords * @param array $keywords
*/ */
public function setKeywords(array $keywords) public function setKeywords(array $keywords): void
{ {
$this->keywords = $keywords; $this->keywords = $keywords;
} }
@@ -35,7 +35,7 @@ abstract class Subject extends Multiprogramming
/** /**
* @param $templateId * @param $templateId
*/ */
public function setTemplateId($templateId) public function setTemplateId($templateId): void
{ {
$this->templateId = $templateId; $this->templateId = $templateId;
} }
@@ -43,7 +43,7 @@ abstract class Subject extends Multiprogramming
/** /**
* @param $openId * @param $openId
*/ */
public function setOpenId($openId) public function setOpenId($openId): void
{ {
$this->openId = $openId; $this->openId = $openId;
} }
@@ -51,7 +51,7 @@ abstract class Subject extends Multiprogramming
/** /**
* @param $page * @param $page
*/ */
public function setPage($page) public function setPage($page): void
{ {
$this->page = $page; $this->page = $page;
} }
@@ -59,7 +59,7 @@ abstract class Subject extends Multiprogramming
/** /**
* @param $emphasis_keyword * @param $emphasis_keyword
*/ */
public function setEmphasisKeyword($emphasis_keyword) public function setEmphasisKeyword($emphasis_keyword): void
{ {
$this->emphasis_keyword = $emphasis_keyword; $this->emphasis_keyword = $emphasis_keyword;
} }
@@ -69,7 +69,7 @@ abstract class Subject extends Multiprogramming
* @param $context * @param $context
* @param string $color * @param string $color
*/ */
public function replaceKeyword($index, $context, string $color = '') public function replaceKeyword($index, $context, string $color = ''): void
{ {
if (empty($color)) { if (empty($color)) {
$color = '#000'; $color = '#000';
@@ -85,7 +85,7 @@ abstract class Subject extends Multiprogramming
* @param $color * @param $color
* @param $context * @param $context
*/ */
public function addKeyword($context, $color = null) public function addKeyword($context, $color = null): void
{ {
if (empty($color)) { if (empty($color)) {
$color = '#000'; $color = '#000';
@@ -135,7 +135,7 @@ abstract class Subject extends Multiprogramming
/** /**
* @return Result * @return Result
* @throws \Exception * @throws
*/ */
public function sendTemplate(): Result public function sendTemplate(): Result
{ {
@@ -158,7 +158,7 @@ abstract class Subject extends Multiprogramming
if (!empty($this->use_robot)) { if (!empty($this->use_robot)) {
$params['use_robot'] = $this->use_robot; $params['use_robot'] = $this->use_robot;
} }
$this->reset($result); $this->reset();
$client = new Client($this->getHost(), 443, true); $client = new Client($this->getHost(), 443, true);
$client->withHeader(['Content-Type' => 'application/json; charset=utf-8']); $client->withHeader(['Content-Type' => 'application/json; charset=utf-8']);
@@ -184,17 +184,14 @@ abstract class Subject extends Multiprogramming
} }
/** /**
* @param $result * @return void
* @return mixed
*/ */
public function reset($result) public function reset(): void
{ {
$this->openId = ''; $this->openId = '';
$this->keywords = []; $this->keywords = [];
$this->templateId = ''; $this->templateId = '';
$this->page = ''; $this->page = '';
return $result;
} }
} }
+120 -121
View File
@@ -13,126 +13,126 @@ abstract class Template extends Multiprogramming
{ {
private array $keywords = []; private array $keywords = [];
private string $templateId = ''; private string $templateId = '';
private string $formId = ''; private string $formId = '';
private string $openId = ''; private string $openId = '';
private string $page = 'pages/index/index'; private string $page = 'pages/index/index';
private string $emphasis_keyword = ''; private string $emphasis_keyword = '';
/** /**
* @param array $keywords * @param array $keywords
*/ */
public function setKeywords(array $keywords) public function setKeywords(array $keywords): void
{ {
$this->keywords = $keywords; $this->keywords = $keywords;
} }
/** /**
* @param $templateId * @param $templateId
*/ */
public function setTemplateId($templateId) public function setTemplateId($templateId): void
{ {
$this->templateId = $templateId; $this->templateId = $templateId;
} }
/** /**
* @param $formId * @param $formId
*/ */
public function setFormId($formId) public function setFormId($formId): void
{ {
$this->formId = $formId; $this->formId = $formId;
} }
/** /**
* @param $openId * @param $openId
*/ */
public function setOpenId($openId) public function setOpenId($openId): void
{ {
$this->openId = $openId; $this->openId = $openId;
} }
/** /**
* @param $page * @param $page
*/ */
public function setPage($page) public function setPage($page): void
{ {
$this->page = $page; $this->page = $page;
} }
/** /**
* @param $emphasis_keyword * @param $emphasis_keyword
*/ */
public function setEmphasisKeyword($emphasis_keyword) public function setEmphasisKeyword($emphasis_keyword): void
{ {
$this->emphasis_keyword = $emphasis_keyword; $this->emphasis_keyword = $emphasis_keyword;
} }
/** /**
* @param $index * @param $index
* @param $context * @param $context
* @param string $color * @param string $color
*/ */
public function replaceKeyword($index, $context, string $color = '') public function replaceKeyword($index, $context, string $color = ''): void
{ {
if (empty($color)) { if (empty($color)) {
$color = '#000'; $color = '#000';
} }
$this->keywords['keyword' . $index] = [ $this->keywords['keyword' . $index] = [
'value' => $context, 'value' => $context,
'color' => $color 'color' => $color
]; ];
} }
/** /**
* @param $color * @param $color
* @param $context * @param $context
*/ */
public function addKeyword($context, $color = null) public function addKeyword($context, $color = null): void
{ {
if (empty($color)) { if (empty($color)) {
$color = '#000'; $color = '#000';
} }
$this->keywords['keyword' . (count($this->keywords) + 1)] = [ $this->keywords['keyword' . (count($this->keywords) + 1)] = [
'value' => $context, 'value' => $context,
'color' => $color 'color' => $color
]; ];
} }
abstract public function getUrl(); abstract public function getUrl();
abstract public function getHost(); abstract public function getHost();
/** /**
* @return Result * @return Result
* @throws \Exception * @throws
* *
* 奴隶交易通知 * 奴隶交易通知
*/ */
public function sendTemplate(): Result public function sendTemplate(): Result
{ {
$access_token = $this->payConfig->getAccessToken(); $access_token = $this->payConfig->getAccessToken();
if (empty($access_token)) { if (empty($access_token)) {
throw new \Exception('request access_token con\'t null.'); throw new \Exception('request access_token con\'t null.');
} }
$params = [ $params = [
"touser" => $this->openId, "touser" => $this->openId,
"template_id" => $this->templateId, "template_id" => $this->templateId,
"page" => $this->page, "page" => $this->page,
"form_id" => $this->formId, "form_id" => $this->formId,
"data" => $this->keywords, "data" => $this->keywords,
]; ];
if (!empty($this->emphasis_keyword)) { if (!empty($this->emphasis_keyword)) {
$params['emphasis_keyword'] = $this->emphasis_keyword; $params['emphasis_keyword'] = $this->emphasis_keyword;
} }
$this->reset($result); $this->reset();
$client = new Client($this->getHost(), 443, true); $client = new Client($this->getHost(), 443, true);
$client->withHeader(['Content-Type' => 'application/json; charset=utf-8']); $client->withHeader(['Content-Type' => 'application/json; charset=utf-8']);
$proxyHost = $this->payConfig->getProxyHost(); $proxyHost = $this->payConfig->getProxyHost();
$proxyPort = $this->payConfig->getProxyPort(); $proxyPort = $this->payConfig->getProxyPort();
@@ -141,29 +141,28 @@ abstract class Template extends Multiprogramming
} }
$client->post($this->getUrl() . '?access_token=' . $access_token, $params); $client->post($this->getUrl() . '?access_token=' . $access_token, $params);
$client->close(); $client->close();
if (!in_array($client->getStatusCode(), [101, 200, 201])) { if (!in_array($client->getStatusCode(), [101, 200, 201])) {
return new Result(code: 505, message: $client->getBody()); return new Result(code: 505, message: $client->getBody());
} }
$body = json_decode($client->getBody(), true); $body = json_decode($client->getBody(), true);
if (isset($body['errcode']) && $body['errcode'] != 0) { if (isset($body['errcode']) && $body['errcode'] != 0) {
return new Result(code: $body['errcode'], message: $body['errmsg']); return new Result(code: $body['errcode'], message: $body['errmsg']);
} }
return new Result(code: 0, data: $body); return new Result(code: 0, data: $body);
} }
/** /**
* @param $result * @return void
* @return void */
*/ private function reset(): void
private function reset($result): void {
{ $this->openId = '';
$this->openId = ''; $this->keywords = [];
$this->keywords = []; $this->formId = '';
$this->formId = ''; $this->templateId = '';
$this->templateId = ''; $this->page = '';
$this->page = ''; }
}
} }
+4 -4
View File
@@ -11,10 +11,10 @@ class AppConfig
{ {
const TYPE_WCHAT_PROJECT = 0; const int TYPE_WCHAT_PROJECT = 0;
const TYPE_ALI_GAME_OR_APPLET = 3; const int TYPE_ALI_GAME_OR_APPLET = 3;
const TYPE_QQ_GAME_OR_APPLET = 1; const int TYPE_QQ_GAME_OR_APPLET = 1;
const TYPE_APP_PROJECT = 2; const int TYPE_APP_PROJECT = 2;
/** /**
+2 -2
View File
@@ -37,7 +37,7 @@ abstract class Multiprogramming implements Progaram
/** /**
* @param $code * @param $code
*/ */
public function setErrorCode($code) public function setErrorCode($code): void
{ {
$this->errorCode = $code; $this->errorCode = $code;
} }
@@ -45,7 +45,7 @@ abstract class Multiprogramming implements Progaram
/** /**
* @param $message * @param $message
*/ */
public function setErrorMessage($message) public function setErrorMessage($message): void
{ {
$this->errorMsg = $message; $this->errorMsg = $message;
} }
+1 -1
View File
@@ -107,7 +107,7 @@ class Result
* @param $key * @param $key
* @param $data * @param $data
* @return $this * @return $this
* @throws Exception * @throws
*/ */
public function setAttr($key, $data): static public function setAttr($key, $data): static
{ {
-1
View File
@@ -8,7 +8,6 @@
namespace wchat\qq; namespace wchat\qq;
use Kiri\Client;
use wchat\common\Result; use wchat\common\Result;
class Account extends SmallProgram class Account extends SmallProgram
+69 -69
View File
@@ -12,83 +12,83 @@ use wchat\common\Help;
*/ */
class Notify extends SmallProgram class Notify extends SmallProgram
{ {
public mixed $appid = null; public mixed $appid = null;
public mixed $mch_id = null; public mixed $mch_id = null;
public mixed $nonce_str = null; public mixed $nonce_str = null;
public mixed $sign = null; public mixed $sign = null;
public mixed $device_info = null; public mixed $device_info = null;
public mixed $trade_type = null; public mixed $trade_type = null;
public mixed $trade_state = null; public mixed $trade_state = null;
public mixed $bank_type = null; public mixed $bank_type = null;
public mixed $fee_type = null; public mixed $fee_type = null;
public mixed $total_fee = null; public mixed $total_fee = null;
public mixed $cash_fee = null; public mixed $cash_fee = null;
public mixed $coupon_fee = null; public mixed $coupon_fee = null;
public mixed $transaction_id = null; public mixed $transaction_id = null;
public mixed $out_trade_no = null; public mixed $out_trade_no = null;
public mixed $attach = null; public mixed $attach = null;
public mixed $time_end = null; public mixed $time_end = null;
public mixed $openid = null; public mixed $openid = null;
/** /**
* @return bool * @return bool
* 判断是否完成支付 * 判断是否完成支付
*/ */
public function isSuccess(): bool public function isSuccess(): bool
{ {
return $this->trade_state === 'SUCCESS'; return $this->trade_state === 'SUCCESS';
} }
/** /**
* @param array $params * @param array $params
* @return $this * @return $this
* @throws Exception * @throws
*/ */
public function setPayNotifyData(array $params): static public function setPayNotifyData(array $params): static
{ {
if (!$this->validation($params)) { if (!$this->validation($params)) {
throw new Exception('签名错误!'); throw new Exception('签名错误!');
} }
foreach ($params as $key => $val) { foreach ($params as $key => $val) {
$this->$key = $val; $this->$key = $val;
} }
return $this; return $this;
} }
public function __set(string $name, $value): void public function __set(string $name, $value): void
{ {
if (property_exists($this, $name)) { if (property_exists($this, $name)) {
$this->{$name} = $value; $this->{$name} = $value;
} }
} }
/** /**
* @param array $params * @param array $params
* @return bool * @return bool
*/ */
public function validation(array $params): bool public function validation(array $params): bool
{ {
$sign = $params['sign']; $sign = $params['sign'];
unset($params['sign']); unset($params['sign']);
$signType = $this->payConfig->getSignType(); $signType = $this->payConfig->getSignType();
$privateKey = $this->payConfig->pay->qq->mchSecret; $privateKey = $this->payConfig->pay->qq->mchSecret;
$nowSign = Help::sign($params, $privateKey, $signType); $nowSign = Help::sign($params, $privateKey, $signType);
if ($sign === $nowSign) { if ($sign === $nowSign) {
return true; return true;
} }
return false; return false;
} }
/** /**
* @return null * @return null
*/ */
public function getAppid() public function getAppid(): mixed
{ {
return $this->appid; return $this->appid;
} }
} }
+8 -9
View File
@@ -3,7 +3,6 @@
namespace wchat\wx; namespace wchat\wx;
use Kiri\Di\Container; use Kiri\Di\Container;
use ReflectionException;
use wchat\common\AppConfig; use wchat\common\AppConfig;
class QqFactory class QqFactory
@@ -14,15 +13,15 @@ class QqFactory
* @param $class * @param $class
* @param AppConfig $config * @param AppConfig $config
* @return mixed * @return mixed
* @throws ReflectionException * @throws
*/ */
public static function get($class, AppConfig $config): mixed public static function get($class, AppConfig $config): mixed
{ {
$container = Container::instance(); $container = Container::instance();
$object = $container->get($class); $object = $container->get($class);
$object->setPayConfig($config); $object->setPayConfig($config);
return $object; return $object;
} }
} }
+1 -3
View File
@@ -8,8 +8,6 @@
namespace wchat\qq; namespace wchat\qq;
use Exception;
use Kiri\Client;
use wchat\common\Result; use wchat\common\Result;
use wchat\common\Help; use wchat\common\Help;
@@ -30,7 +28,7 @@ class Recharge extends SmallProgram
/** /**
* @param string $value * @param string $value
*/ */
public function setSpillCreateIp(string $value) public function setSpillCreateIp(string $value): void
{ {
$this->spill_create_ip = $value; $this->spill_create_ip = $value;
} }
-1
View File
@@ -4,7 +4,6 @@
namespace wchat\qq; namespace wchat\qq;
use Kiri\Client;
use wchat\common\Result; use wchat\common\Result;
/** /**
-1
View File
@@ -4,7 +4,6 @@
namespace wchat\qq; namespace wchat\qq;
use wchat\common\Result;
/** /**
* Class Subject * Class Subject
-1
View File
@@ -4,7 +4,6 @@
namespace wchat\qq; namespace wchat\qq;
use Kiri\Client;
use wchat\common\Result; use wchat\common\Result;
class Token extends SmallProgram class Token extends SmallProgram
+5 -5
View File
@@ -37,7 +37,7 @@ class Cash_Bonus extends SmallProgram
/** /**
* @param string $value * @param string $value
*/ */
public function setMchName(string $value) public function setMchName(string $value): void
{ {
$this->_requestParams['mch_name'] = $value; $this->_requestParams['mch_name'] = $value;
} }
@@ -45,7 +45,7 @@ class Cash_Bonus extends SmallProgram
/** /**
* @param string $value * @param string $value
*/ */
public function setActName(string $value) public function setActName(string $value): void
{ {
$this->_requestParams['act_name'] = $value; $this->_requestParams['act_name'] = $value;
} }
@@ -53,7 +53,7 @@ class Cash_Bonus extends SmallProgram
/** /**
* @param string $value * @param string $value
*/ */
public function setWishing(string $value) public function setWishing(string $value): void
{ {
$this->_requestParams['wishing'] = $value; $this->_requestParams['wishing'] = $value;
} }
@@ -61,7 +61,7 @@ class Cash_Bonus extends SmallProgram
/** /**
* @param int $value * @param int $value
*/ */
public function setIconId(int $value) public function setIconId(int $value): void
{ {
$this->_requestParams['icon_id'] = $value; $this->_requestParams['icon_id'] = $value;
} }
@@ -69,7 +69,7 @@ class Cash_Bonus extends SmallProgram
/** /**
* @param int $value * @param int $value
*/ */
public function setBannerId(int $value) public function setBannerId(int $value): void
{ {
$this->_requestParams['banner_id'] = $value; $this->_requestParams['banner_id'] = $value;
} }
+3 -3
View File
@@ -40,7 +40,7 @@ class Enterprise_payment extends SmallProgram
/** /**
* @param string $value * @param string $value
*/ */
public function setOpUserId(string $value) public function setOpUserId(string $value): void
{ {
$this->_requestParams['op_user_id'] = $value; $this->_requestParams['op_user_id'] = $value;
} }
@@ -48,7 +48,7 @@ class Enterprise_payment extends SmallProgram
/** /**
* @param string $value * @param string $value
*/ */
public function setOpUserPassword(string $value) public function setOpUserPassword(string $value): void
{ {
$this->_requestParams['op_user_passwd'] = $value; $this->_requestParams['op_user_passwd'] = $value;
} }
@@ -56,7 +56,7 @@ class Enterprise_payment extends SmallProgram
/** /**
* @param string $value * @param string $value
*/ */
public function setSpbillCreateIp(string $value) public function setSpbillCreateIp(string $value): void
{ {
$this->_requestParams['spbill_create_ip'] = $value; $this->_requestParams['spbill_create_ip'] = $value;
} }
+4 -4
View File
@@ -23,10 +23,10 @@ class RedHatResult
public mixed $uin; public mixed $uin;
const RED_HAT_STATUS_PAID = 1; const int RED_HAT_STATUS_PAID = 1;
const RED_HAT_STATUS_SNATCHED = 2; const int RED_HAT_STATUS_SNATCHED = 2;
const RED_HAT_STATUS_EXPIRED = 3; const int RED_HAT_STATUS_EXPIRED = 3;
const RED_HAT_STATUS_REFUNDED = 4; const int RED_HAT_STATUS_REFUNDED = 4;
/** /**
-1
View File
@@ -8,7 +8,6 @@
namespace wchat\wx; namespace wchat\wx;
use Exception;
use wchat\common\Result; use wchat\common\Result;
class Account extends SmallProgram class Account extends SmallProgram
+13 -14
View File
@@ -4,7 +4,6 @@
namespace wchat\wx; namespace wchat\wx;
use Exception; use Exception;
use Kiri\Client;
use wchat\common\Result; use wchat\common\Result;
@@ -21,7 +20,7 @@ class Message extends SmallProgram
/** /**
* @param string $openid * @param string $openid
*/ */
public function setOpenid(string $openid) public function setOpenid(string $openid): void
{ {
$this->msgData['touser'] = $openid; $this->msgData['touser'] = $openid;
} }
@@ -29,7 +28,7 @@ class Message extends SmallProgram
/** /**
* @param string $content * @param string $content
* @return Result * @return Result
* @throws Exception * @throws
*/ */
public function sendTextNews(string $content): Result public function sendTextNews(string $content): Result
{ {
@@ -42,7 +41,7 @@ class Message extends SmallProgram
/** /**
* @param string $media_id * @param string $media_id
* @return Result * @return Result
* @throws Exception * @throws
*/ */
public function sendImageNews(string $media_id): Result public function sendImageNews(string $media_id): Result
{ {
@@ -56,7 +55,7 @@ class Message extends SmallProgram
/** /**
* @param string $media_id * @param string $media_id
* @return Result * @return Result
* @throws Exception * @throws
*/ */
public function sendVoiceNews(string $media_id): Result public function sendVoiceNews(string $media_id): Result
{ {
@@ -69,7 +68,7 @@ class Message extends SmallProgram
/** /**
* @param string $media_id * @param string $media_id
* @return Result * @return Result
* @throws Exception * @throws
*/ */
public function sendMpNewsNews(string $media_id): Result public function sendMpNewsNews(string $media_id): Result
{ {
@@ -86,7 +85,7 @@ class Message extends SmallProgram
* @param string $url * @param string $url
* @param string $picurl * @param string $picurl
* @return Result * @return Result
* @throws Exception * @throws
*/ */
public function sendNewsNews(string $title, string $description, string $url, string $picurl): Result public function sendNewsNews(string $title, string $description, string $url, string $picurl): Result
{ {
@@ -108,7 +107,7 @@ class Message extends SmallProgram
/** /**
* @param string $title * @param string $title
* @return Result * @return Result
* @throws Exception * @throws
*/ */
public function sendCardNews(string $title): Result public function sendCardNews(string $title): Result
{ {
@@ -125,7 +124,7 @@ class Message extends SmallProgram
* @param string $title * @param string $title
* @param string $description * @param string $description
* @return Result * @return Result
* @throws Exception * @throws
*/ */
public function sendVideoNews(string $media_id, string $thumb_media_id, string $title, string $description): Result public function sendVideoNews(string $media_id, string $thumb_media_id, string $title, string $description): Result
{ {
@@ -149,7 +148,7 @@ class Message extends SmallProgram
* @param string $title * @param string $title
* @param string $description * @param string $description
* @return Result * @return Result
* @throws Exception * @throws
*/ */
public function sendMusicNews(string $musicurl, string $hqmusicurl, string $thumb_media_id, string $title, string $description): Result public function sendMusicNews(string $musicurl, string $hqmusicurl, string $thumb_media_id, string $title, string $description): Result
{ {
@@ -170,7 +169,7 @@ class Message extends SmallProgram
* @param string $tail_content * @param string $tail_content
* @param array $menus * @param array $menus
* @return Result * @return Result
* @throws Exception * @throws
*/ */
public function sendMenuNews(string $head_content, string $tail_content, array $menus = []): Result public function sendMenuNews(string $head_content, string $tail_content, array $menus = []): Result
{ {
@@ -210,7 +209,7 @@ class Message extends SmallProgram
* @param string $pagepath * @param string $pagepath
* @param string $thumb_media_id * @param string $thumb_media_id
* @return Result * @return Result
* @throws Exception * @throws
*/ */
public function sendMiniprogrampageNews(string $title, string $appid, string $pagepath, string $thumb_media_id): Result public function sendMiniprogrampageNews(string $title, string $appid, string $pagepath, string $thumb_media_id): Result
{ {
@@ -231,7 +230,7 @@ class Message extends SmallProgram
* @param string $title * @param string $title
* @param string $introduction * @param string $introduction
* @return mixed * @return mixed
* @throws Exception * @throws
*/ */
public function uploadFile(string $filePath, string $type, bool $isPermanent = false, string $title = '', string $introduction = ''): Result public function uploadFile(string $filePath, string $type, bool $isPermanent = false, string $title = '', string $introduction = ''): Result
{ {
@@ -268,7 +267,7 @@ class Message extends SmallProgram
/** /**
* @return Result * @return Result
* @throws Exception * @throws
*/ */
private function sendKefuMsg(): Result private function sendKefuMsg(): Result
{ {
+5 -5
View File
@@ -71,11 +71,11 @@ class Notify extends SmallProgram
} }
/** /**
* @param string $name * @param string $name
* @param $value * @param mixed $value
* @return void * @return void
*/ */
public function __set(string $name, mixed $value): void public function __set(string $name, mixed $value): void
{ {
if (property_exists($this, $name)) { if (property_exists($this, $name)) {
+7 -8
View File
@@ -8,7 +8,6 @@
namespace wchat\wx; namespace wchat\wx;
use Kiri\Client;
use wchat\common\Result; use wchat\common\Result;
class PublicTemplate extends SmallProgram class PublicTemplate extends SmallProgram
@@ -27,7 +26,7 @@ class PublicTemplate extends SmallProgram
/** /**
* @param array $keywords * @param array $keywords
*/ */
public function setKeywords(array $keywords) public function setKeywords(array $keywords): void
{ {
$this->keywords = $keywords; $this->keywords = $keywords;
} }
@@ -35,7 +34,7 @@ class PublicTemplate extends SmallProgram
/** /**
* @param string $templateId * @param string $templateId
*/ */
public function setTemplateId(string $templateId) public function setTemplateId(string $templateId): void
{ {
$this->templateId = $templateId; $this->templateId = $templateId;
} }
@@ -43,7 +42,7 @@ class PublicTemplate extends SmallProgram
/** /**
* @param string $openId * @param string $openId
*/ */
public function setOpenId(string $openId) public function setOpenId(string $openId): void
{ {
$this->openId = $openId; $this->openId = $openId;
} }
@@ -51,7 +50,7 @@ class PublicTemplate extends SmallProgram
/** /**
* @param string $defaultUrl * @param string $defaultUrl
*/ */
public function setDefaultUrl(string $defaultUrl) public function setDefaultUrl(string $defaultUrl): void
{ {
$this->defaultUrl = $defaultUrl; $this->defaultUrl = $defaultUrl;
} }
@@ -61,7 +60,7 @@ class PublicTemplate extends SmallProgram
* @param string $context * @param string $context
* @param string $color * @param string $color
*/ */
public function replaceKeyword(string $name, string $context, string $color = '') public function replaceKeyword(string $name, string $context, string $color = ''): void
{ {
$this->keywords[$name] = ['value' => $context, 'color' => $color]; $this->keywords[$name] = ['value' => $context, 'color' => $color];
} }
@@ -72,7 +71,7 @@ class PublicTemplate extends SmallProgram
* @param string $context * @param string $context
* @param null $color * @param null $color
*/ */
public function addKeyword(string $name, string $context, $color = null) public function addKeyword(string $name, string $context, $color = null): void
{ {
if (empty($color)) { if (empty($color)) {
$color = '#000'; $color = '#000';
@@ -124,7 +123,7 @@ class PublicTemplate extends SmallProgram
/** /**
* @return Result * @return Result
* @throws \Exception * @throws
* *
* 奴隶交易通知 * 奴隶交易通知
*/ */
+2 -3
View File
@@ -4,7 +4,6 @@
namespace wchat\wx; namespace wchat\wx;
use Kiri\Client;
use wchat\common\Result; use wchat\common\Result;
/** /**
@@ -17,8 +16,8 @@ class SecCheck extends SmallProgram
private string $_url = '/wxa/img_sec_check?access_token='; private string $_url = '/wxa/img_sec_check?access_token=';
private string $_msgUrl = '/wxa/msg_sec_check?access_token='; private string $_msgUrl = '/wxa/msg_sec_check?access_token=';
private string $_mediaCheckAsync = '/wxa/media_check_async?access_token='; private string $_mediaCheckAsync = '/wxa/media_check_async?access_token=';
const MEDIA_VIDEO = 1; const int MEDIA_VIDEO = 1;
const MEDIA_IMAGE = 1; const int MEDIA_IMAGE = 1;
/** /**
* @param string $path * @param string $path
-1
View File
@@ -4,7 +4,6 @@
namespace wchat\wx; namespace wchat\wx;
use wchat\common\Result;
/** /**
* Class Subject * Class Subject
-1
View File
@@ -4,7 +4,6 @@
namespace wchat\wx; namespace wchat\wx;
use Kiri\Client;
use wchat\common\Result; use wchat\common\Result;
class Token extends SmallProgram class Token extends SmallProgram
+13 -13
View File
@@ -8,44 +8,44 @@ class NotifyModel
{ {
//公众号支付 //公众号支付
const PAY_TYPE_JSAPI = 'JSAPI'; const string PAY_TYPE_JSAPI = 'JSAPI';
//扫码支付 //扫码支付
const PAY_TYPE_NATIVE = 'NATIVE'; const string PAY_TYPE_NATIVE = 'NATIVE';
//App支付 //App支付
const PAY_TYPE_App = 'App'; const string PAY_TYPE_App = 'App';
//付款码支付 //付款码支付
const PAY_TYPE_MICROPAY = 'MICROPAY'; const string PAY_TYPE_MICROPAY = 'MICROPAY';
//H5支付 //H5支付
const PAY_TYPE_MWEB = 'MWEB'; const string PAY_TYPE_MWEB = 'MWEB';
//刷脸支付 //刷脸支付
const PAY_TYPE_FACEPAY = 'FACEPAY'; const string PAY_TYPE_FACEPAY = 'FACEPAY';
// 支付成功 // 支付成功
const PAY_RESULT_SUCCESS = 'SUCCESS'; const string PAY_RESULT_SUCCESS = 'SUCCESS';
// 转入退款 // 转入退款
const PAY_RESULT_REFUND = 'REFUND'; const string PAY_RESULT_REFUND = 'REFUND';
// 未支付 // 未支付
const PAY_RESULT_NOTPAY = 'NOTPAY'; const string PAY_RESULT_NOTPAY = 'NOTPAY';
// 已关闭 // 已关闭
const PAY_RESULT_CLOSED = 'CLOSED'; const string PAY_RESULT_CLOSED = 'CLOSED';
// 已撤销(付款码支付) // 已撤销(付款码支付)
const PAY_RESULT_REVOKED = 'REVOKED'; const string PAY_RESULT_REVOKED = 'REVOKED';
// 用户支付中(付款码支付) // 用户支付中(付款码支付)
const PAY_RESULT_USERPAYING = 'USERPAYING'; const string PAY_RESULT_USERPAYING = 'USERPAYING';
// 支付失败(其他原因,如银行返回失败) // 支付失败(其他原因,如银行返回失败)
const PAY_RESULT_PAYERROR = 'PAYERROR'; const string PAY_RESULT_PAYERROR = 'PAYERROR';
public string $appid; public string $appid;
+1 -4
View File
@@ -2,10 +2,7 @@
namespace wchat\wx\V3; namespace wchat\wx\V3;
use Exception;
use JetBrains\PhpStorm\ArrayShape; use JetBrains\PhpStorm\ArrayShape;
use Kiri\Client;
use Kiri\CurlClient;
use wchat\wx\SmallProgram; use wchat\wx\SmallProgram;
class TransferBatches extends SmallProgram class TransferBatches extends SmallProgram
@@ -16,7 +13,7 @@ class TransferBatches extends SmallProgram
/** /**
* @param TransferDetail $detail * @param TransferDetail $detail
* @return array * @return array
* @throws Exception * @throws
*/ */
#[ArrayShape([])] #[ArrayShape([])]
public function transfer(TransferDetail $detail): array public function transfer(TransferDetail $detail): array
+5 -5
View File
@@ -16,11 +16,11 @@ class TransferDetail
* @param string $user_name * @param string $user_name
*/ */
public function __construct( public function __construct(
readonly public string $out_detail_no, public string $out_detail_no,
readonly public int|float $transfer_amount, public int|float $transfer_amount,
readonly public string $transfer_remark, public string $transfer_remark,
readonly public string $openid, public string $openid,
readonly public string $user_name = '' public string $user_name = ''
) )
{ {
} }
+1 -2
View File
@@ -3,7 +3,6 @@
namespace wchat\wx\V3; namespace wchat\wx\V3;
use Exception; use Exception;
use Kiri\Client;
use wchat\wx\SmallProgram; use wchat\wx\SmallProgram;
class WxV3AppPayment extends SmallProgram class WxV3AppPayment extends SmallProgram
@@ -19,7 +18,7 @@ class WxV3AppPayment extends SmallProgram
* @param string|null $openId * @param string|null $openId
* @param string $payer_client_ip * @param string $payer_client_ip
* @return array * @return array
* @throws Exception * @throws
*/ */
public function payment(string $orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array public function payment(string $orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array
{ {
+1 -2
View File
@@ -3,7 +3,6 @@
namespace wchat\wx\V3; namespace wchat\wx\V3;
use Exception; use Exception;
use Kiri\Client;
use JetBrains\PhpStorm\ArrayShape; use JetBrains\PhpStorm\ArrayShape;
use wchat\wx\SmallProgram; use wchat\wx\SmallProgram;
@@ -20,7 +19,7 @@ class WxV3NativePayment extends SmallProgram
* @param string|null $openId * @param string|null $openId
* @param string $payer_client_ip * @param string $payer_client_ip
* @return array * @return array
* @throws Exception * @throws
*/ */
#[ArrayShape(['code_url' => "string"])] #[ArrayShape(['code_url' => "string"])]
public function payment(string $orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array public function payment(string $orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array
+1 -2
View File
@@ -3,7 +3,6 @@
namespace wchat\wx\V3; namespace wchat\wx\V3;
use Exception; use Exception;
use Kiri\Client;
use wchat\wx\SmallProgram; use wchat\wx\SmallProgram;
class WxV3Payment extends SmallProgram class WxV3Payment extends SmallProgram
@@ -19,7 +18,7 @@ class WxV3Payment extends SmallProgram
* @param string|null $openId * @param string|null $openId
* @param string $payer_client_ip * @param string $payer_client_ip
* @return array * @return array
* @throws Exception * @throws
*/ */
public function payment(string $orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array public function payment(string $orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array
{ {
+1 -2
View File
@@ -5,7 +5,6 @@ namespace wchat\wx\V3;
use Exception; use Exception;
use OpenSSLAsymmetricKey; use OpenSSLAsymmetricKey;
use Psr\Http\Message\RequestInterface; use Psr\Http\Message\RequestInterface;
use wchat\common\PayConfig;
use wchat\wx\SmallProgram; use wchat\wx\SmallProgram;
use wchat\wx\V3\Notify\GoodsDetail; use wchat\wx\V3\Notify\GoodsDetail;
use wchat\wx\V3\Notify\NotifyModel; use wchat\wx\V3\Notify\NotifyModel;
@@ -50,7 +49,7 @@ class WxV3PaymentNotify extends SmallProgram
/** /**
* @param RequestInterface $request * @param RequestInterface $request
* @return bool * @return bool
* @throws Exception * @throws
*/ */
public function verify(RequestInterface $request): bool public function verify(RequestInterface $request): bool
{ {
+4 -5
View File
@@ -4,7 +4,6 @@ namespace wchat\wx\V3;
use Exception; use Exception;
use Kiri\Client; use Kiri\Client;
use wchat\common\AppConfig;
use wchat\common\Help; use wchat\common\Help;
@@ -69,7 +68,7 @@ trait WxV3PaymentTait
/** /**
* @param string $orderNo * @param string $orderNo
* @return array * @return array
* @throws Exception * @throws
*/ */
public function searchByOutTradeNo(string $orderNo): array public function searchByOutTradeNo(string $orderNo): array
{ {
@@ -80,7 +79,7 @@ trait WxV3PaymentTait
/** /**
* @param string $orderNo * @param string $orderNo
* @return array * @return array
* @throws Exception * @throws
*/ */
public function searchByTransactionId(string $orderNo): array public function searchByTransactionId(string $orderNo): array
{ {
@@ -91,7 +90,7 @@ trait WxV3PaymentTait
/** /**
* @param string $parseUrl * @param string $parseUrl
* @return array * @return array
* @throws Exception * @throws
*/ */
private function search(string $parseUrl): array private function search(string $parseUrl): array
{ {
@@ -112,7 +111,7 @@ trait WxV3PaymentTait
* @param string $canonical_url * @param string $canonical_url
* @param string $body * @param string $body
* @return string * @return string
* @throws Exception * @throws
*/ */
public function signature(string $http_method, string $canonical_url, string $body = ''): string public function signature(string $http_method, string $canonical_url, string $body = ''): string
{ {
+1 -1
View File
@@ -20,7 +20,7 @@ class WxV3Withdrawal extends SmallProgram
* @param string $batch_remark * @param string $batch_remark
* @param TransferDetail[] $details * @param TransferDetail[] $details
* @return array * @return array
* @throws Exception * @throws
*/ */
public function payment(string $orderNo, string $batch_name, string $batch_remark, array $details): array public function payment(string $orderNo, string $batch_name, string $batch_remark, array $details): array
{ {
+2 -3
View File
@@ -3,7 +3,6 @@
namespace wchat\wx; namespace wchat\wx;
use Kiri\Di\Container; use Kiri\Di\Container;
use ReflectionException;
use wchat\common\AppConfig; use wchat\common\AppConfig;
class WxFactory class WxFactory
@@ -14,12 +13,12 @@ class WxFactory
* @param string $class * @param string $class
* @param AppConfig $config * @param AppConfig $config
* @return object|null * @return object|null
* @throws ReflectionException * @throws
*/ */
public static function get(string $class, AppConfig $config): ?object public static function get(string $class, AppConfig $config): ?object
{ {
$container = Container::instance(); $container = Container::instance();
$object = $container->get($class); $object = $container->get($class);
$object->setPayConfig($config); $object->setPayConfig($config);
return $object; return $object;
} }