13 Commits

Author SHA1 Message Date
as2252258 b87232bbc0 Default Changelist 2023-11-07 13:48:18 +08:00
as2252258 d9528679ff Default Changelist 2023-11-07 13:48:04 +08:00
as2252258 09544ee4a2 Default Changelist 2023-08-18 20:24:15 +08:00
as2252258 a7c6939a9f Default Changelist 2023-08-18 19:59:46 +08:00
as2252258 0578ba384b Default Changelist 2023-08-18 19:58:45 +08:00
as2252258 7abbaaca46 Default Changelist 2023-08-18 19:50:25 +08:00
as2252258 d574ce2c42 Default Changelist 2023-08-18 19:47:48 +08:00
as2252258 2275ed92d1 Default Changelist 2023-08-18 17:47:42 +08:00
as2252258 48467b88ce Default Changelist 2023-08-18 17:40:46 +08:00
as2252258 e87728266b Default Changelist 2023-08-18 16:59:47 +08:00
as2252258 ae67dce77b Default Changelist 2023-08-18 16:58:36 +08:00
as2252258 2ff7ceb66b Default Changelist 2023-08-18 16:57:32 +08:00
as2252258 c74c3b004b Default Changelist 2023-08-18 15:34:49 +08:00
23 changed files with 97 additions and 178 deletions
+1
View File
@@ -1,3 +1,4 @@
/.idea/php.xml /.idea/php.xml
vendor/ vendor/
composer.lock composer.lock
.idea/*
+1 -1
View File
@@ -21,8 +21,8 @@
}, },
"require": { "require": {
"php": ">= 8.0", "php": ">= 8.0",
"game-worker/kiri-client": "~v2.6",
"game-worker/kiri-container": "~v1.9", "game-worker/kiri-container": "~v1.9",
"game-worker/kiri-client": "~v2.8",
"psr/container": "*" "psr/container": "*"
}, },
"require-dev": { "require-dev": {
+1 -1
View File
@@ -166,7 +166,7 @@ abstract class Subject extends Multiprogramming
$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: 'network error.'); 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) {
+1 -1
View File
@@ -137,7 +137,7 @@ abstract class Template extends Multiprogramming
$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: 'network error.'); 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) {
+1 -1
View File
@@ -57,7 +57,7 @@ class Result
public static function init(Client $client): static public static function init(Client $client): static
{ {
if (!in_array($client->getStatusCode(), [101, 200, 201])) { if (!in_array($client->getStatusCode(), [101, 200, 201])) {
return new Result(code: 505, message: 'network error.'); 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) {
+1 -1
View File
@@ -56,7 +56,7 @@ class Recharge extends SmallProgram
$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: 'network error.'); return new Result(code: 505, message: $client->getBody());
} }
$data = Help::toArray($client->getBody()); $data = Help::toArray($client->getBody());
+15 -145
View File
@@ -11,12 +11,9 @@ class Redhat extends SmallProgram
{ {
private string $charset = 'UTF8'; private string $charset = 'UTF8';
private string $nonce_str = '';
private string $sign = ''; private string $sign = '';
private string $mch_billno = ''; private string $mch_billno = '';
private string $mch_id = '';
private string $mch_name = ''; private string $mch_name = '';
private string $qqappid = '';
private string $re_openid = ''; private string $re_openid = '';
private string $total_amount = ''; private string $total_amount = '';
private string $total_num = ''; private string $total_num = '';
@@ -24,12 +21,9 @@ class Redhat extends SmallProgram
private string $act_name = ''; private string $act_name = '';
private string $icon_id = ''; private string $icon_id = '';
private string $banner_id = ''; private string $banner_id = '';
private string $notify_url = '';
private string $not_send_msg = ''; private string $not_send_msg = '';
private string $min_value = ''; private string $min_value = '';
private string $max_value = ''; private string $max_value = '';
private string $key = '';
private string $signType = '';
private string $sendUrl = '/cgi-bin/hongbao/qpay_hb_mch_send.cgi'; private string $sendUrl = '/cgi-bin/hongbao/qpay_hb_mch_send.cgi';
@@ -51,22 +45,6 @@ class Redhat extends SmallProgram
$this->charset = $charset; $this->charset = $charset;
} }
/**
* @return string
*/
public function getNonceStr(): string
{
return $this->nonce_str;
}
/**
* @param string $nonce_str
*/
public function setNonceStr(string $nonce_str): void
{
$this->nonce_str = $nonce_str;
}
/** /**
* @return string * @return string
*/ */
@@ -99,22 +77,6 @@ class Redhat extends SmallProgram
$this->mch_billno = $mch_billno; $this->mch_billno = $mch_billno;
} }
/**
* @return string
*/
public function getMchId(): string
{
return $this->mch_id;
}
/**
* @param string $mch_id
*/
public function setMchId(string $mch_id): void
{
$this->mch_id = $mch_id;
}
/** /**
* @return string * @return string
*/ */
@@ -131,21 +93,6 @@ class Redhat extends SmallProgram
$this->mch_name = $mch_name; $this->mch_name = $mch_name;
} }
/**
* @return string
*/
public function getQqappid(): string
{
return $this->qqappid;
}
/**
* @param string $qqappid
*/
public function setQqappid(string $qqappid): void
{
$this->qqappid = $qqappid;
}
/** /**
* @return string * @return string
@@ -259,22 +206,6 @@ class Redhat extends SmallProgram
$this->banner_id = $banner_id; $this->banner_id = $banner_id;
} }
/**
* @return string
*/
public function getNotifyUrl(): string
{
return $this->notify_url;
}
/**
* @param string $notify_url
*/
public function setNotifyUrl(string $notify_url): void
{
$this->notify_url = $notify_url;
}
/** /**
* @return string * @return string
*/ */
@@ -323,84 +254,20 @@ class Redhat extends SmallProgram
$this->max_value = $max_value; $this->max_value = $max_value;
} }
/**
* @return string
*/
public function getKey(): string
{
return $this->key;
}
/**
* @param string $key
*/
public function setKey(string $key): void
{
$this->key = $key;
}
/**
* @return string
*/
public function getSignType(): string
{
return $this->signType;
}
/**
* @param string $signType
*/
public function setSignType(string $signType): void
{
$this->signType = $signType;
}
/**
* @return string
*/
public function getSendUrl(): string
{
return $this->sendUrl;
}
/**
* @param string $sendUrl
*/
public function setSendUrl(string $sendUrl): void
{
$this->sendUrl = $sendUrl;
}
/**
* @return string
*/
public function getSearchUrl(): string
{
return $this->searchUrl;
}
/**
* @param string $searchUrl
*/
public function setSearchUrl(string $searchUrl): void
{
$this->searchUrl = $searchUrl;
}
/** /**
* @return mixed * @return mixed
* 构建请求参数 * 构建请求参数
*/ */
private function generate(): array public function generate(): array
{ {
$requestParam = []; $requestParam = [];
$requestParam['charset'] = $this->getCharset(); $requestParam['charset'] = $this->getCharset();
$requestParam['nonce_str'] = $this->getNonceStr(); $requestParam['nonce_str'] = Help::random(30);
$requestParam['mch_billno'] = $this->getMchBillno(); $requestParam['mch_billno'] = $this->getMchBillno();
$requestParam['mch_id'] = $this->getMchId(); $requestParam['mch_id'] = $this->config->getMchId();
$requestParam['mch_name'] = $this->getMchName(); $requestParam['mch_name'] = $this->getMchName();
$requestParam['qqappid'] = $this->getQqappid(); $requestParam['qqappid'] = $this->config->getAppid();
$requestParam['re_openid'] = $this->getReOpenid(); $requestParam['re_openid'] = $this->getReOpenid();
$requestParam['total_amount'] = $this->getTotalAmount() * 100; $requestParam['total_amount'] = $this->getTotalAmount() * 100;
$requestParam['min_value'] = $this->getMinValue() * 100; $requestParam['min_value'] = $this->getMinValue() * 100;
@@ -409,7 +276,7 @@ class Redhat extends SmallProgram
$requestParam['wishing'] = $this->getWishing(); $requestParam['wishing'] = $this->getWishing();
$requestParam['act_name'] = $this->getActName(); $requestParam['act_name'] = $this->getActName();
$requestParam['icon_id'] = $this->getIconId(); $requestParam['icon_id'] = $this->getIconId();
$requestParam['notify_url'] = $this->getNotifyUrl(); $requestParam['notify_url'] = $this->config->getNotifyUrl();
$requestParam['sign'] = $this->builderSign($requestParam); $requestParam['sign'] = $this->builderSign($requestParam);
@@ -423,7 +290,7 @@ class Redhat extends SmallProgram
*/ */
private function builderSign($requestParam): string private function builderSign($requestParam): string
{ {
return Help::sign($requestParam, $this->getKey(), $this->getSignType()); return Help::sign($requestParam, $this->config->getKey(), $this->config->getSignType());
} }
/** /**
@@ -432,11 +299,14 @@ class Redhat extends SmallProgram
public function redEnvelopes(): Result public function redEnvelopes(): Result
{ {
$client = new Client('api.qpay.qq.com', 443, true); $client = new Client('api.qpay.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'application/json']); $client->withHeader(['Content-Type' => 'application/x-www-form-urlencoded']);
$client->post($this->sendUrl, $this->generate()); $client->withSslKeyFile($this->config->getSslKey());
$client->withSslCertFile($this->config->getSslCert());
$client->withCa($this->config->getSslCa());
$client->post($this->sendUrl, http_build_query($this->generate()));
$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: 'network error.'); return new Result(code: 505, message: $client->getBody());
} }
$json = json_decode($client->getBody(), true); $json = json_decode($client->getBody(), true);
if (isset($json['return_code']) && $json['return_code'] != 'SUCCESS') { if (isset($json['return_code']) && $json['return_code'] != 'SUCCESS') {
@@ -457,8 +327,8 @@ class Redhat extends SmallProgram
*/ */
public function searchByOrderNo($listid, $orderNo = null): Result public function searchByOrderNo($listid, $orderNo = null): Result
{ {
$requestParam['nonce_str'] = $this->getNonceStr(); $requestParam['nonce_str'] = Help::random(31);
$requestParam['mch_id'] = $this->getMchId(); $requestParam['mch_id'] = $this->config->getMchId();
$requestParam['listid'] = $listid; $requestParam['listid'] = $listid;
if (!empty($orderNo)) { if (!empty($orderNo)) {
$requestParam['mch_billno'] = $orderNo; $requestParam['mch_billno'] = $orderNo;
@@ -469,7 +339,7 @@ class Redhat extends SmallProgram
$client->post($this->searchUrl, $requestParam); $client->post($this->searchUrl, $requestParam);
$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: 'network error.'); return new Result(code: 505, message: $client->getBody());
} }
$json = json_decode($client->getBody(), true); $json = json_decode($client->getBody(), true);
if (isset($json['result']) && $json['result'] != 'SUCCESS') { if (isset($json['result']) && $json['result'] != 'SUCCESS') {
+2 -2
View File
@@ -40,7 +40,7 @@ class SecCheck extends SmallProgram
$client->upload($path, $data); $client->upload($path, $data);
$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: 'network error.'); 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) {
@@ -68,7 +68,7 @@ class SecCheck extends SmallProgram
$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: 'network error.'); 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) {
+1 -1
View File
@@ -25,7 +25,7 @@ class Token extends SmallProgram
$client->get('/api/getToken', $query); $client->get('/api/getToken', $query);
$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: 'network error.'); 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) {
+1 -1
View File
@@ -94,7 +94,7 @@ class Cash_Bonus extends SmallProgram
$client->post($this->_cash, $this->orderConfig($mch_billno, $openId, $price)); $client->post($this->_cash, $this->orderConfig($mch_billno, $openId, $price));
$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: 'network error.'); return new Result(code: 505, message: $client->getBody());
} }
$json = json_decode($client->getBody(), true); $json = json_decode($client->getBody(), true);
+1 -1
View File
@@ -80,7 +80,7 @@ class Enterprise_payment extends SmallProgram
$client->post($this->_cash, $this->orderConfig($mch_billno, $openId, $price)); $client->post($this->_cash, $this->orderConfig($mch_billno, $openId, $price));
$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: 'network error.'); return new Result(code: 505, message: $client->getBody());
} }
$json = json_decode($client->getBody(), true); $json = json_decode($client->getBody(), true);
if (isset($json['return_code']) && $json['return_code'] != 'SUCCESS') { if (isset($json['return_code']) && $json['return_code'] != 'SUCCESS') {
+5 -5
View File
@@ -34,7 +34,7 @@ class Account extends SmallProgram
$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: 'network error.'); 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) {
@@ -63,7 +63,7 @@ class Account extends SmallProgram
$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: 'network error.'); 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) {
@@ -115,7 +115,7 @@ class Account extends SmallProgram
$client->post($url . $this->getConfig()->getAccessToken(), $sendBody); $client->post($url . $this->getConfig()->getAccessToken(), $sendBody);
$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: 'network error.'); return new Result(code: 505, message: $client->getBody());
} }
$body = json_decode($client->getBody(), true); $body = json_decode($client->getBody(), true);
if (!is_null($body)) { if (!is_null($body)) {
@@ -151,7 +151,7 @@ class Account extends SmallProgram
$client->post($url . $this->getConfig()->getAccessToken(), $sendBody); $client->post($url . $this->getConfig()->getAccessToken(), $sendBody);
$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: 'network error.'); return new Result(code: 505, message: $client->getBody());
} }
$body = json_decode($client->getBody(), true); $body = json_decode($client->getBody(), true);
if (!is_null($body)) { if (!is_null($body)) {
@@ -187,7 +187,7 @@ class Account extends SmallProgram
$client->post($url . $this->getConfig()->getAccessToken(), $sendBody); $client->post($url . $this->getConfig()->getAccessToken(), $sendBody);
$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: 'network error.'); return new Result(code: 505, message: $client->getBody());
} }
$body = json_decode($client->getBody(), true); $body = json_decode($client->getBody(), true);
if (!is_null($body)) { if (!is_null($body)) {
+2 -2
View File
@@ -267,7 +267,7 @@ class Message extends SmallProgram
$this->msgData = []; $this->msgData = [];
if (!in_array($client->getStatusCode(), [101, 200, 201])) { if (!in_array($client->getStatusCode(), [101, 200, 201])) {
return new Result(code: 505, message: 'network error.'); 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) {
@@ -303,7 +303,7 @@ class Message extends SmallProgram
$this->msgData = []; $this->msgData = [];
if (!in_array($client->getStatusCode(), [101, 200, 201])) { if (!in_array($client->getStatusCode(), [101, 200, 201])) {
return new Result(code: 505, message: 'network error.'); 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) {
+1 -1
View File
@@ -152,7 +152,7 @@ class PublicTemplate extends SmallProgram
$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: 'network error.'); 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) {
+3 -3
View File
@@ -42,7 +42,7 @@ class SecCheck extends SmallProgram
$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: 'network error.'); 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) {
@@ -70,7 +70,7 @@ class SecCheck extends SmallProgram
$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: 'network error.'); 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) {
@@ -108,7 +108,7 @@ class SecCheck extends SmallProgram
$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: 'network error.'); 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) {
+1 -1
View File
@@ -25,7 +25,7 @@ class Token extends SmallProgram
$client->get('cgi-bin/token', $query); $client->get('cgi-bin/token', $query);
$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: 'network error.'); 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) {
+1 -1
View File
@@ -39,7 +39,7 @@ class WxV2AppPayment extends SmallProgram
$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: 'network error.'); return new Result(code: 505, message: $client->getBody());
} }
$data = Help::toArray($client->getBody()); $data = Help::toArray($client->getBody());
if (isset($data['return_code']) && $data['return_code'] != 'SUCCESS') { if (isset($data['return_code']) && $data['return_code'] != 'SUCCESS') {
+4 -4
View File
@@ -41,7 +41,7 @@ class WxV2PayJsApi extends SmallProgram
$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: 'network error.'); return new Result(code: 505, message: $client->getBody());
} }
$data = Help::toArray($client->getBody()); $data = Help::toArray($client->getBody());
if (isset($data['return_code']) && $data['return_code'] != 'SUCCESS') { if (isset($data['return_code']) && $data['return_code'] != 'SUCCESS') {
@@ -87,7 +87,7 @@ class WxV2PayJsApi extends SmallProgram
$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: 'network error.'); return new Result(code: 505, message: $client->getBody());
} }
$data = Help::toArray($client->getBody()); $data = Help::toArray($client->getBody());
if (isset($data['return_code']) && $data['return_code'] != 'SUCCESS') { if (isset($data['return_code']) && $data['return_code'] != 'SUCCESS') {
@@ -133,7 +133,7 @@ class WxV2PayJsApi extends SmallProgram
$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: 'network error.'); return new Result(code: 505, message: $client->getBody());
} }
$data = Help::toArray($client->getBody()); $data = Help::toArray($client->getBody());
if (isset($data['return_code']) && $data['return_code'] != 'SUCCESS') { if (isset($data['return_code']) && $data['return_code'] != 'SUCCESS') {
@@ -179,7 +179,7 @@ class WxV2PayJsApi extends SmallProgram
$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: 'network error.'); return new Result(code: 505, message: $client->getBody());
} }
$data = Help::toArray($client->getBody()); $data = Help::toArray($client->getBody());
if (isset($data['return_code']) && $data['return_code'] != 'SUCCESS') { if (isset($data['return_code']) && $data['return_code'] != 'SUCCESS') {
+1 -1
View File
@@ -44,7 +44,7 @@ class WxV2Withdrawal extends SmallProgram
$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: 'network error.'); return new Result(code: 505, message: $client->getBody());
} }
$data = Help::toArray($client->getBody()); $data = Help::toArray($client->getBody());
+50
View File
@@ -0,0 +1,50 @@
<?php
namespace wchat\wx\V3;
use Exception;
use JetBrains\PhpStorm\ArrayShape;
use Kiri\Client;
use wchat\wx\SmallProgram;
class TransferBatches extends SmallProgram
{
use WxV3PaymentTait;
/**
* @param string $orderNo
* @param int $total
* @param string $openId
* @return array
* @throws Exception
*/
#[ArrayShape(['code_url' => "string"])]
public function request(string $orderNo, int $total, string $openId): array
{
$body['appid'] = $this->getConfig()->getAppid();
$body['out_trade_no'] = $orderNo;
$body["batch_name"] = $this->getConfig()->getBody();
$body["batch_remark"] = $this->getConfig()->getBody();
$body["total_amount"] = $total;
$body["total_num"] = 1;
$body["transfer_detail_list"] = [
[
"out_detail_no" => $orderNo,
"transfer_amount" => $total,
"transfer_remark" => $this->getConfig()->getBody(),
"openid" => $openId,
]
];
$sign = $this->signature('POST', '/v3/transfer/batches', $json = json_encode($body, JSON_UNESCAPED_UNICODE));
$client = new Client('api.mch.weixin.qq.com', 443, TRUE);
$client->withAddedHeader('Authorization', $sign)->withContentType('application/json')
->withAgent('application/json')->withBody($json)
->post('/v3/transfer/batches');
$client->close();
return json_decode($client->getBody(), TRUE);
}
}
+1 -2
View File
@@ -4,7 +4,6 @@ namespace wchat\wx\V3;
use Exception; use Exception;
use Kiri\Client; use Kiri\Client;
use Kiri\Message\Stream;
use JetBrains\PhpStorm\ArrayShape; use JetBrains\PhpStorm\ArrayShape;
use wchat\wx\SmallProgram; use wchat\wx\SmallProgram;
@@ -32,7 +31,7 @@ class WxV3NativePayment extends SmallProgram
$client = new Client('api.mch.weixin.qq.com', 443, TRUE); $client = new Client('api.mch.weixin.qq.com', 443, TRUE);
$client->withAddedHeader('Authorization', $sign)->withContentType('application/json') $client->withAddedHeader('Authorization', $sign)->withContentType('application/json')
->withAgent('application/json')->withBody(new Stream($json)) ->withAgent('application/json')->withBody($json)
->post('/v3/pay/transactions/native'); ->post('/v3/pay/transactions/native');
$client->close(); $client->close();
+1 -2
View File
@@ -4,7 +4,6 @@ namespace wchat\wx\V3;
use Exception; use Exception;
use Kiri\Client; use Kiri\Client;
use Kiri\Message\Stream;
use wchat\wx\SmallProgram; use wchat\wx\SmallProgram;
class WxV3Payment extends SmallProgram class WxV3Payment extends SmallProgram
@@ -34,7 +33,7 @@ class WxV3Payment extends SmallProgram
$client->withAddedHeader('Authorization', $sign) $client->withAddedHeader('Authorization', $sign)
->withContentType('application/json') ->withContentType('application/json')
->withAddedHeader('User-Agent', 'application/json') ->withAddedHeader('User-Agent', 'application/json')
->withBody(new Stream($json)) ->withBody($json)
->post('/v3/pay/transactions/jsapi'); ->post('/v3/pay/transactions/jsapi');
$client->close(); $client->close();
+1 -1
View File
@@ -33,7 +33,7 @@ class WxV3Withdrawal extends SmallProgram
$client->withAddedHeader('Authorization', $sign) $client->withAddedHeader('Authorization', $sign)
->withContentType('application/json') ->withContentType('application/json')
->withAddedHeader('User-Agent', 'application/json') ->withAddedHeader('User-Agent', 'application/json')
->withBody(new Stream($json)) ->withBody($json)
->post('/v3/pay/transactions/batches'); ->post('/v3/pay/transactions/batches');
$client->close(); $client->close();