This commit is contained in:
2026-06-12 23:57:22 +08:00
parent 0a535c3a89
commit 63e24922ad
15 changed files with 39 additions and 39 deletions
+3 -3
View File
@@ -172,10 +172,10 @@ abstract class Subject 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->statusCode, [101, 200, 201])) {
return new Result(code: 505, message: $client->getBody()); return new Result(code: 505, message: $client->body);
} }
$body = json_decode($client->getBody(), true); $body = json_decode($client->body, 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']);
} else { } else {
+3 -3
View File
@@ -143,10 +143,10 @@ 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->statusCode, [101, 200, 201])) {
return new Result(code: 505, message: $client->getBody()); return new Result(code: 505, message: $client->body);
} }
$body = json_decode($client->getBody(), true); $body = json_decode($client->body, 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']);
} }
+3 -3
View File
@@ -147,10 +147,10 @@ abstract class Multiprogramming implements Progaram
$client->get($requestUrl, $body); $client->get($requestUrl, $body);
} }
$client->close(); $client->close();
if (!in_array($client->getStatusCode(), [101, 200, 201])) { if (!in_array($client->statusCode, [101, 200, 201])) {
return new Result(code: 505, message: $client->getBody()); return new Result(code: 505, message: $client->body);
} }
$body = json_decode($client->getBody(), true); $body = json_decode($client->body, true);
if (is_null($body) || (isset($body['errcode']) && $body['errcode'] != 0)) { if (is_null($body) || (isset($body['errcode']) && $body['errcode'] != 0)) {
return new Result(code: $body['errcode'], message: $body['errmsg']); return new Result(code: $body['errcode'], message: $body['errmsg']);
} else { } else {
+3 -3
View File
@@ -56,10 +56,10 @@ 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->statusCode, [101, 200, 201])) {
return new Result(code: 505, message: $client->getBody()); return new Result(code: 505, message: $client->body);
} }
$body = json_decode($client->getBody(), true); $body = json_decode($client->body, 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']);
} else { } else {
+1 -1
View File
@@ -19,7 +19,7 @@
] ]
}, },
"require": { "require": {
"php": ">= 8.4", "php": ">= 8.5",
"game-worker/kiri-client": "^v2.5", "game-worker/kiri-client": "^v2.5",
"psr/container": "*", "psr/container": "*",
"ext-openssl": "*" "ext-openssl": "*"
+6 -6
View File
@@ -309,10 +309,10 @@ class Redhat extends SmallProgram
} }
$client->post($this->sendUrl, http_build_query($this->generate())); $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->statusCode, [101, 200, 201])) {
return new Result(code: 505, message: $client->getBody()); return new Result(code: 505, message: $client->body);
} }
$json = json_decode($client->getBody(), true); $json = json_decode($client->body, true);
if (isset($json['return_code']) && $json['return_code'] != 'SUCCESS') { if (isset($json['return_code']) && $json['return_code'] != 'SUCCESS') {
return new Result(code: 500, message: $json['return_msg'] ?? $json['retmsg']); return new Result(code: 500, message: $json['return_msg'] ?? $json['retmsg']);
} }
@@ -347,10 +347,10 @@ class Redhat extends SmallProgram
$client->withHeader(['Content-Type' => 'application/json']); $client->withHeader(['Content-Type' => 'application/json']);
$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->statusCode, [101, 200, 201])) {
return new Result(code: 505, message: $client->getBody()); return new Result(code: 505, message: $client->body);
} }
$json = json_decode($client->getBody(), true); $json = json_decode($client->body, true);
if (isset($json['result']) && $json['result'] != 'SUCCESS') { if (isset($json['result']) && $json['result'] != 'SUCCESS') {
return new Result(code: 500, message: $response['res_info'] ?? '订单查询失败!'); return new Result(code: 500, message: $response['res_info'] ?? '订单查询失败!');
} else { } else {
+3 -3
View File
@@ -84,10 +84,10 @@ class Cash_Bonus extends SmallProgram
public function mch_send(string $mch_billno, string $openId, float $price): Result public function mch_send(string $mch_billno, string $openId, float $price): Result
{ {
$client = $this->createClient($this->_cash, $this->orderConfig($mch_billno, $openId, $price)); $client = $this->createClient($this->_cash, $this->orderConfig($mch_billno, $openId, $price));
if (!in_array($client->getStatusCode(), [101, 200, 201])) { if (!in_array($client->statusCode, [101, 200, 201])) {
return new Result(code: 505, message: $client->getBody()); return new Result(code: 505, message: $client->body);
} }
$json = json_decode($client->getBody(), true); $json = json_decode($client->body, true);
if (isset($json['return_code']) && $json['return_code'] != 'SUCCESS') { if (isset($json['return_code']) && $json['return_code'] != 'SUCCESS') {
return new Result(code: 500, message: $json['return_msg'] ?? $json['retmsg']); return new Result(code: 500, message: $json['return_msg'] ?? $json['retmsg']);
+3 -3
View File
@@ -70,10 +70,10 @@ class Enterprise_payment extends SmallProgram
public function mch_send(string $mch_billno, string $openId, float $price): Result public function mch_send(string $mch_billno, string $openId, float $price): Result
{ {
$client = $this->createClient($this->_cash, $this->orderConfig($mch_billno, $openId, $price)); $client = $this->createClient($this->_cash, $this->orderConfig($mch_billno, $openId, $price));
if (!in_array($client->getStatusCode(), [101, 200, 201])) { if (!in_array($client->statusCode, [101, 200, 201])) {
return new Result(code: 505, message: $client->getBody()); return new Result(code: 505, message: $client->body);
} }
$json = json_decode($client->getBody(), true); $json = json_decode($client->body, true);
if (isset($json['return_code']) && $json['return_code'] != 'SUCCESS') { if (isset($json['return_code']) && $json['return_code'] != 'SUCCESS') {
return new Result(code: 500, data: $json['return_msg'] ?? $json['retmsg']); return new Result(code: 500, data: $json['return_msg'] ?? $json['retmsg']);
} else if ($json['result_code'] != 'SUCCESS') { } else if ($json['result_code'] != 'SUCCESS') {
+1 -1
View File
@@ -32,7 +32,7 @@ class WxV3AppPayment extends SmallProgram
$client->post('/v3/pay/transactions/components'); $client->post('/v3/pay/transactions/components');
$client->close(); $client->close();
$json = json_decode($client->getBody(), TRUE); $json = json_decode($client->body, TRUE);
if (!isset($json['prepay_id'])) { if (!isset($json['prepay_id'])) {
throw new Exception('微信支付调用失败'); throw new Exception('微信支付调用失败');
} }
+1 -1
View File
@@ -32,7 +32,7 @@ class WxV3NativePayment extends SmallProgram
$client->post('/v3/pay/transactions/native'); $client->post('/v3/pay/transactions/native');
$client->close(); $client->close();
$json = json_decode($client->getBody(), TRUE); $json = json_decode($client->body, TRUE);
if (!isset($json['code_url'])) { if (!isset($json['code_url'])) {
throw new Exception('微信支付调用失败'); throw new Exception('微信支付调用失败');
} }
+2 -2
View File
@@ -32,9 +32,9 @@ class WxV3Payment extends SmallProgram
$client->post('/v3/pay/transactions/jsapi'); $client->post('/v3/pay/transactions/jsapi');
$client->close(); $client->close();
$json = json_decode($client->getBody(), TRUE); $json = json_decode($client->body, TRUE);
if (!isset($json['prepay_id'])) { if (!isset($json['prepay_id'])) {
throw new Exception('微信支付调用失败: ' . $client->getBody()); throw new Exception('微信支付调用失败: ' . $client->body);
} }
return $this->createResponse($json, $body); return $this->createResponse($json, $body);
+1 -1
View File
@@ -102,7 +102,7 @@ trait WxV3PaymentTait
$client->get($parseUrl, ['mchid' => $config->pay->wx->mchId]); $client->get($parseUrl, ['mchid' => $config->pay->wx->mchId]);
$client->close(); $client->close();
return json_decode($client->getBody(), TRUE); return json_decode($client->body, TRUE);
} }
+3 -3
View File
@@ -33,10 +33,10 @@ class WxV3Transfer extends SmallProgram
$client->post('/v3/fund-app/mch-transfer/transfer-bills'); $client->post('/v3/fund-app/mch-transfer/transfer-bills');
$client->close(); $client->close();
Kiri::getLogger()->println($client->getBody()); Kiri::getLogger()->println($client->body);
if ($client->getStatusCode() == 200) { if ($client->statusCode == 200) {
return json_decode($client->getBody(), TRUE); return json_decode($client->body, TRUE);
} }
throw new Exception('转账申请发起失败'); throw new Exception('转账申请发起失败');
} }
+4 -4
View File
@@ -32,7 +32,7 @@ class WxV3Withdrawal extends SmallProgram
$client->post('/v3/pay/transactions/batches'); $client->post('/v3/pay/transactions/batches');
$client->close(); $client->close();
$json = json_decode($client->getBody(), TRUE); $json = json_decode($client->body, TRUE);
if (!isset($json['prepay_id'])) { if (!isset($json['prepay_id'])) {
throw new Exception('微信支付调用失败'); throw new Exception('微信支付调用失败');
} }
@@ -88,10 +88,10 @@ class WxV3Withdrawal extends SmallProgram
$client->post('/v3/fund-app/mch-transfer/transfer-bills'); $client->post('/v3/fund-app/mch-transfer/transfer-bills');
$client->close(); $client->close();
Kiri::getLogger()->println($client->getBody()); Kiri::getLogger()->println($client->body);
if ($client->getStatusCode() == 200) { if ($client->statusCode == 200) {
return json_decode($client->getBody(), TRUE); return json_decode($client->body, TRUE);
} }
throw new Exception('转账申请发起失败'); throw new Exception('转账申请发起失败');
} }
+2 -2
View File
@@ -76,7 +76,7 @@ class WxVirtualPayment extends SmallProgram
$client = new Client('api.weixin.qq.com', 443, true); $client = new Client('api.weixin.qq.com', 443, true);
$client->post('/xpay/query_order?access_token=' . $this->payConfig->getAccessToken() . '&pay_sig=' . $this->paySign('/xpay/query_order', $data), $data); $client->post('/xpay/query_order?access_token=' . $this->payConfig->getAccessToken() . '&pay_sig=' . $this->paySign('/xpay/query_order', $data), $data);
$resp = $client->getBody(); $resp = $client->body;
$client->close(); $client->close();
@@ -94,7 +94,7 @@ class WxVirtualPayment extends SmallProgram
$client = new Client('api.weixin.qq.com', 443, true); $client = new Client('api.weixin.qq.com', 443, true);
$client->post('/xpay/notify_provide_goods?access_token=' . $this->payConfig->getAccessToken() . '&pay_sig=' . $this->paySign('/xpay/notify_provide_goods', $data), $data); $client->post('/xpay/notify_provide_goods?access_token=' . $this->payConfig->getAccessToken() . '&pay_sig=' . $this->paySign('/xpay/notify_provide_goods', $data), $data);
$resp = $client->getBody(); $resp = $client->body;
$client->close(); $client->close();
return json_decode($resp, true); return json_decode($resp, true);