Commit 619e9335 authored by wanjilong's avatar wanjilong

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

parent 390161ad
......@@ -4,6 +4,7 @@ namespace App\Plugins;
use App\Exception\ExceptionErrorCatch;
use Helpers\DebugLog;
use Api\PhpUtils\Log\FileLog;
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) {
//处理$_POST, $_REQUEST请求,兼容application/json形式
if(!$_POST && $request->isPost()
// application/json形式,仅处理$_POST, 不整合$_GET, $_REQUEST
if($request->isPost()
&& $request->getServer('CONTENT_TYPE') == 'application/json') {
$jsonPost = file_get_contents("php://input");
if(false && $jsonPost) {
$_POST = json_decode($jsonPost, true);
$ini = ini_get('request_order');
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);
}
}
}
$jsonPost = file_get_contents("php://input");
if(empty($jsonPost)) {
$_POST = [];
return true;
}
$_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
'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": {
......@@ -246,7 +246,7 @@ class PingxxService
'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;
......
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