Commit 619e9335 authored by wanjilong's avatar wanjilong

add: 优化pingxx报错,简化 raw json处理

parent 390161ad
...@@ -4,6 +4,7 @@ namespace App\Plugins; ...@@ -4,6 +4,7 @@ namespace App\Plugins;
use App\Exception\ExceptionErrorCatch; use App\Exception\ExceptionErrorCatch;
use Helpers\DebugLog; use Helpers\DebugLog;
use Api\PhpUtils\Log\FileLog;
class Hook extends \Yaf\Plugin_Abstract { class Hook extends \Yaf\Plugin_Abstract {
...@@ -45,23 +46,20 @@ class Hook extends \Yaf\Plugin_Abstract { ...@@ -45,23 +46,20 @@ class Hook extends \Yaf\Plugin_Abstract {
} }
public function preDispatch(\Yaf\Request_Abstract $request, \Yaf\Response_Abstract $response) { public function preDispatch(\Yaf\Request_Abstract $request, \Yaf\Response_Abstract $response) {
//处理$_POST, $_REQUEST请求,兼容application/json形式 // application/json形式,仅处理$_POST, 不整合$_GET, $_REQUEST
if(!$_POST && $request->isPost() if($request->isPost()
&& $request->getServer('CONTENT_TYPE') == 'application/json') { && $request->getServer('CONTENT_TYPE') == 'application/json') {
$jsonPost = file_get_contents("php://input"); $jsonPost = file_get_contents("php://input");
if(false && $jsonPost) { if(empty($jsonPost)) {
$_POST = json_decode($jsonPost, true); $_POST = [];
$ini = ini_get('request_order'); return true;
if($ini) {
$arrIni = str_split($ini, 1);
foreach($arrIni as $type) {
if(strtoupper($type) === 'G') {
$_REQUEST = array_merge($_REQUEST, $_GET);
}elseif(strtoupper($type) === 'P') {
$_REQUEST = array_merge($_REQUEST, $_POST);
}
}
} }
$_POST = json_decode($jsonPost, true);
if(!is_array($_POST)) {
$_POST = [];
FileLog::error('bp-gateway', 'json decode error raw:' . $jsonPost);
} }
} }
} }
......
...@@ -167,7 +167,7 @@ class PingxxService ...@@ -167,7 +167,7 @@ class PingxxService
'type'=>'http error', 'type'=>'http error',
]; ];
} }
FileLog::error('pingxx-createOrder:' . '创建订单返回', json_encode(['req'=>[$order, $metadata], 'res'=>$ret], JSON_UNESCAPED_UNICODE), $e); FileLog::error('pingxx-createOrder:' . '创建订单返回', json_encode(['req'=>[$order, $metadata], 'res'=>$respose], JSON_UNESCAPED_UNICODE), $e);
/** /**
{ {
"error": { "error": {
...@@ -246,7 +246,7 @@ class PingxxService ...@@ -246,7 +246,7 @@ class PingxxService
'type'=>'http error', 'type'=>'http error',
]; ];
} }
FileLog::error('pingxx-pay:' . '查询订单返回', json_encode(['req'=>[$orderId], 'res'=>$ret], JSON_UNESCAPED_UNICODE), $e); FileLog::error('pingxx-pay:' . '查询订单返回', json_encode(['req'=>[$orderId], 'res'=>$respose], JSON_UNESCAPED_UNICODE), $e);
} }
return $respose; return $respose;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment