2 Commits
1.0.3 ... 1.0.4

Author SHA1 Message Date
3d867be82d 微调 2021-08-12 17:06:57 +08:00
a803fc2f1d 增加查询接口 2021-08-12 16:43:15 +08:00
4 changed files with 36 additions and 12 deletions

View File

@@ -156,8 +156,7 @@ class Init
{ {
$signStr = $this->getSignString(); $signStr = $this->getSignString();
$private_key = $this->getPrivate(); $private_key = $this->getPrivate();
$privKeyId = openssl_get_privatekey($private_key);
$privKeyId = openssl_get_privatekey($private_key);
if (!$privKeyId) { if (!$privKeyId) {
throw new \Exception('私钥格式有误'); throw new \Exception('私钥格式有误');
@@ -301,7 +300,6 @@ class Init
} }
$client = new Client(); $client = new Client();
try { try {
$response = $client->request('POST', $url, [ $response = $client->request('POST', $url, [
'form_params' => $paramArray, 'form_params' => $paramArray,
@@ -312,26 +310,27 @@ class Init
if ($response->getStatusCode() == 200) { if ($response->getStatusCode() == 200) {
$body = $response->getBody(); $body = $response->getBody();
$content = str_replace(["\r\n", "\n", "\r", '/n', "\\n",], '&', $body->getContents()); $content = str_replace(["\r\n", "\n", "\r", '/n', "\\n",], '&', $body->getContents());
parse_str($content, $data); parse_str($content, $data);
$this->data = $data; $this->data = $data;
if ($data['transRet'] != 'SUCCESS') { if (isset($data['queryResult']) && $data['queryResult'] != 'SUCCESS') {
$this->code = false; throw new \Exception('返回的数据错误');
$this->message = $data['resultDis']; }
if (isset($data['transRet']) && $data['transRet'] != 'SUCCESS') {
throw new \Exception($data['resultDis']);
} }
$this->code = true; $this->code = true;
} else { } else {
$this->code = false; throw new \Exception('未正常返回数据');
$this->message = '接口错误 Post';
} }
} catch (\Exception $exception) { } catch (\Exception $exception) {
$this->code = false; $this->code = false;
$this->message = '接口错误 Post' . $exception->getMessage(); $this->message = '接口错误 ' . $exception->getMessage();
} }
} }

View File

@@ -13,6 +13,28 @@ class Query extends Init
public function start() public function start()
{ {
$this->setIsLower(false);
$this->addData();
$this->setSignData();
$url = config('wounicom.uri.unicom.query');
$this->sendPost($this->params, $url);
return $this->respond();
}
public function addData()
{
$order = $this->params;
$data = [
'merNo' => $this->merNo,
'orderNo' => $order->orderid,
'orderDate' => $order->created_at->format('Ymd'),
'charSet' => 'UTF-8',
'signType' => config('wounicom.signType'),
];
$this->params = $data;
} }

View File

@@ -35,7 +35,7 @@ class Refund extends Init
'orderDate' => $order->created_at->format('Ymd'), 'orderDate' => $order->created_at->format('Ymd'),
'payJournl' => $order->payment->out_trade_no, 'payJournl' => $order->payment->out_trade_no,
'merReqTime' => Carbon::now()->format('YmdHis'), 'merReqTime' => Carbon::now()->format('YmdHis'),
'amount' => -1, 'amount' => $order->payment->amount * 100,
'reason' => '退款', 'reason' => '退款',
'signType' => 'RSA_SHA256', 'signType' => 'RSA_SHA256',
]; ];

View File

@@ -45,7 +45,10 @@ class WoUnicom
*/ */
public function query() public function query()
{ {
return (new Query()); $action = new Query();
$action->setConfig();
return $action;
} }
/** /**