调整日志
This commit is contained in:
@@ -139,7 +139,7 @@ class Init
|
|||||||
$result = (bool) openssl_verify($signStr, $sign, $pub_key_id, 'SHA256');
|
$result = (bool) openssl_verify($signStr, $sign, $pub_key_id, 'SHA256');
|
||||||
openssl_free_key($pub_key_id);
|
openssl_free_key($pub_key_id);
|
||||||
} else {
|
} else {
|
||||||
throw new \Exception('私钥格式有误');
|
throw new \Exception('公钥格式有误');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class Sign extends Init
|
|||||||
// $signMsg = str_replace('\\', '', $signMsg);
|
// $signMsg = str_replace('\\', '', $signMsg);
|
||||||
$signMsg = str_replace(' ', '+', $signMsg);
|
$signMsg = str_replace(' ', '+', $signMsg);
|
||||||
$this->sign = $signMsg;
|
$this->sign = $signMsg;
|
||||||
|
info($this->sign);
|
||||||
|
|
||||||
return $this->checkSign();
|
return $this->checkSign();
|
||||||
|
|
||||||
|
|||||||
17
src/Model/Wounicom.php
Normal file
17
src/Model/Wounicom.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace XuanChen\WoUnicom\Model;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Wounicom extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $guarded = [];
|
||||||
|
|
||||||
|
public $casts = [
|
||||||
|
'source' => 'json',
|
||||||
|
'outsource' => 'json',
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
46
src/Traits/Log.php
Normal file
46
src/Traits/Log.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace XuanChen\WoUnicom\Traits;
|
||||||
|
|
||||||
|
use XuanChen\WoUnicom\Model\Wounicom as LogModel;
|
||||||
|
|
||||||
|
trait Log
|
||||||
|
{
|
||||||
|
|
||||||
|
public $log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes: 输入日志
|
||||||
|
* @Author: 玄尘
|
||||||
|
* @Date : 2021/5/11 15:58
|
||||||
|
* @param $data
|
||||||
|
*/
|
||||||
|
public function createLog($data, $str)
|
||||||
|
{
|
||||||
|
return $this->log = LogModel::create([
|
||||||
|
'orderId' => $data['orderid'],
|
||||||
|
'payFloodId' => $data['payfloodid'],
|
||||||
|
'payResult' => $data['payresult'],
|
||||||
|
'payBalance' => $data['paybalance'],
|
||||||
|
'paymentBalanceDetail' => $data['paymentbalancedetail'],
|
||||||
|
'respTime' => $data['resptime'],
|
||||||
|
'source' => [
|
||||||
|
'data' => $data,
|
||||||
|
'check_sign' => $str,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes: 更新
|
||||||
|
* @Author: 玄尘
|
||||||
|
* @Date : 2021/7/23 11:03
|
||||||
|
* @param $data
|
||||||
|
*/
|
||||||
|
public function updateLog($data)
|
||||||
|
{
|
||||||
|
$this->log->outsource = $data;
|
||||||
|
$this->log->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ use XuanChen\WoUnicom\Action\Order;
|
|||||||
use XuanChen\WoUnicom\Action\Query;
|
use XuanChen\WoUnicom\Action\Query;
|
||||||
use XuanChen\WoUnicom\Action\Refund;
|
use XuanChen\WoUnicom\Action\Refund;
|
||||||
use XuanChen\WoUnicom\Action\Sign;
|
use XuanChen\WoUnicom\Action\Sign;
|
||||||
|
use XuanChen\WoUnicom\Traits\Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 沃钱包支付
|
* 沃钱包支付
|
||||||
@@ -19,6 +20,8 @@ use XuanChen\WoUnicom\Action\Sign;
|
|||||||
class WoUnicom
|
class WoUnicom
|
||||||
{
|
{
|
||||||
|
|
||||||
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notes: 下单
|
* Notes: 下单
|
||||||
* @Author: 玄尘
|
* @Author: 玄尘
|
||||||
@@ -92,7 +95,7 @@ class WoUnicom
|
|||||||
$res = $this->sign()->setParams($data)->start();
|
$res = $this->sign()->setParams($data)->start();
|
||||||
|
|
||||||
//日志
|
//日志
|
||||||
$this->unicomLog($data, $res);
|
$this->createLog($data, $res);
|
||||||
|
|
||||||
//验签成功
|
//验签成功
|
||||||
if ($res === true) {
|
if ($res === true) {
|
||||||
@@ -112,6 +115,7 @@ class WoUnicom
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
$order = \App\Models\Order::where('orderid', $data['orderid'])->first();
|
$order = \App\Models\Order::where('orderid', $data['orderid'])->first();
|
||||||
|
|
||||||
if ($order && $order->state == 'UNPAY') {
|
if ($order && $order->state == 'UNPAY') {
|
||||||
$payment = \App\Models\Payment::where('orderable_type', get_class($order))
|
$payment = \App\Models\Payment::where('orderable_type', get_class($order))
|
||||||
->where('orderable_id', $order->id)
|
->where('orderable_id', $order->id)
|
||||||
@@ -127,35 +131,14 @@ class WoUnicom
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
$this->updateLog(['SUCCESS']);
|
||||||
|
|
||||||
return 'SUCCESS';
|
return 'SUCCESS';
|
||||||
} else {
|
} else {
|
||||||
|
$this->updateLog(['验签失败']);
|
||||||
|
|
||||||
return '验签失败';
|
return '验签失败';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Notes: 输入日志
|
|
||||||
* @Author: 玄尘
|
|
||||||
* @Date : 2021/5/11 15:58
|
|
||||||
* @param $data
|
|
||||||
*/
|
|
||||||
public function unicomLog($data, $str)
|
|
||||||
{
|
|
||||||
$inputData = [
|
|
||||||
'orderId' => $data['orderid'],
|
|
||||||
'payFloodId' => $data['payfloodid'],
|
|
||||||
'payResult' => $data['payresult'],
|
|
||||||
'payBalance' => $data['paybalance'],
|
|
||||||
'paymentBalanceDetail' => $data['paymentbalancedetail'],
|
|
||||||
'respTime' => $data['resptime'],
|
|
||||||
'source' => [
|
|
||||||
'data' => $data,
|
|
||||||
'check_sign' => $str,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
return \App\Models\Wounicom::create($inputData);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user