...
|
...
|
@@ -7,18 +7,13 @@ use LibModels\Web\Product\PayData; |
|
|
use WebPlugin\Pay\weixin\lib\WxPayApi;
|
|
|
use WebPlugin\Pay\weixin\lib\WxPayNotify;
|
|
|
use WebPlugin\Pay\weixin\lib\WxPayOrderQuery;
|
|
|
use WebPlugin\PhpLog;
|
|
|
use WebPlugin\UdpLog;
|
|
|
|
|
|
class PayNotifyCallBack extends WxPayNotify
|
|
|
{
|
|
|
// 向ERP提交订单状态有关接口调用日志和更新订单状态有关接口调用日志
|
|
|
const ORDER_STATUS_LOG = '/Data/logs/pc_pay/order_status';
|
|
|
// 日志等级,2表示记录信息等级的日志
|
|
|
const LOG_LEVEL = 2;
|
|
|
// 获取微信订单中的订单号需要截取的开始位置
|
|
|
// 获取微信订单中的orderCode需要截取的开始位置
|
|
|
const ORDER_CODE_START = 8;
|
|
|
|
|
|
private $log = null;
|
|
|
private $_uid;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -27,8 +22,6 @@ class PayNotifyCallBack extends WxPayNotify |
|
|
*/
|
|
|
public function __construct($uid)
|
|
|
{
|
|
|
// 初始化日志
|
|
|
$this->log = new PhpLog(self::ORDER_STATUS_LOG, 'PRC', self::LOG_LEVEL);
|
|
|
$this->_uid = $uid;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -38,12 +31,9 @@ class PayNotifyCallBack extends WxPayNotify |
|
|
{
|
|
|
$input = new WxPayOrderQuery();
|
|
|
$input->SetTransaction_id($transaction_id);
|
|
|
$this->log->LogInfo('微信扫码支付交易号:' . $transaction_id);
|
|
|
UdpLog::info("【{$this->logProjectPrefix}-微信扫码支付】,function:Queryorder,微信扫码支付交易号", $transaction_id);
|
|
|
$result = WxPayApi::orderQuery($input);
|
|
|
|
|
|
$this->log->LogInfo('begin PayNotifyCallBack->Queryorder');
|
|
|
$this->log->LogInfo('===开始查询微信扫码订单=====');
|
|
|
$this->log->LogInfo(var_export($result, true));
|
|
|
UdpLog::info("【{$this->logProjectPrefix}-微信扫码支付】,function:Queryorder,扫码订单结果", $result);
|
|
|
|
|
|
if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") {
|
|
|
$orderCode = substr($result['out_trade_no'], self::ORDER_CODE_START);
|
...
|
...
|
@@ -54,32 +44,21 @@ class PayNotifyCallBack extends WxPayNotify |
|
|
$tradeNo = $result['out_trade_no'];
|
|
|
$bankBillNo = $result['bank_type'];
|
|
|
|
|
|
$this->log->LogInfo('===[' . $orderCode . ']===');
|
|
|
|
|
|
$this->log->LogInfo('==[' . $orderCode . ']=开始调用ERP提交订单状态接口,接口方法为web.SpaceOrders.submitOrderStatus===');
|
|
|
$this->log->LogInfo('==[' . $orderCode . ']=请求参数为orderCode=' . $orderCode . '===');
|
|
|
// ERP提交订单状态
|
|
|
$erpReturn = PayData::submitOrderStatus($orderCode, $payment, $bankName, $bankCode, $amount, $orderCode, $tradeNo, $bankBillNo);
|
|
|
$this->log->LogInfo('==[' . $orderCode . ']=结束调用ERP提交订单状态接口,返回结果为===');
|
|
|
$this->log->LogInfo(var_export($erpReturn, true));
|
|
|
UdpLog::info("【{$this->logProjectPrefix}-微信扫码支付】,orderCode:{$orderCode},function:Queryorder,ERP提交订单状态", $erpReturn);
|
|
|
|
|
|
$this->log->LogInfo('==[' . $orderCode . ']=开始调用获取订单详情方式接口,接口方法为app.SpaceOrders.detail===');
|
|
|
$orderInfo = OrderData::getOrderDetail('', $orderCode);
|
|
|
$this->log->LogInfo('==[' . $orderCode . ']=结束调用获取订单详情方式接口,返回结果为===');
|
|
|
$this->log->LogInfo(var_export($orderInfo, true));
|
|
|
UdpLog::info("【{$this->logProjectPrefix}-微信扫码支付】,orderCode:{$orderCode},function:Queryorder,订单详情", $orderInfo);
|
|
|
|
|
|
if (!isset($orderInfo['data']) || empty($orderInfo['data'])) {
|
|
|
$this->log->LogInfo('==[' . $orderCode . ']=微信支付状态同步中未获取到订单详情信息===');
|
|
|
UdpLog::error("【{$this->logProjectPrefix}-微信扫码支付】,orderCode:{$orderCode},function:Queryorder,微信支付状态同步中未获取到订单详情信息", $orderInfo);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
$this->log->LogInfo('==[' . $orderCode . ']=开始调用更新订单状态接口,接口方法为web.SpaceOrders.updatePaymentStatus===');
|
|
|
$this->log->LogInfo('==[' . $orderCode . ']=请求参数为orderId=' . $orderInfo['data']['order_id'] . 'uid=' . $this->_uid . '===');
|
|
|
// 更新订单的状态
|
|
|
$updateOrderStatus = PayData::updateOrderStatus($orderInfo['data']['order_id'], $this->_uid, $payment, 'Y', $bankCode);
|
|
|
$this->log->LogInfo('==[' . $orderCode . ']=结束调用更新订单状态接口,返回结果为===');
|
|
|
$this->log->LogInfo(var_export($updateOrderStatus, true));
|
|
|
$this->log->LogInfo('==[' . $orderCode . ']=微信扫码订单支付成功===');
|
|
|
UdpLog::info("【{$this->logProjectPrefix}-微信扫码支付】,orderCode:{$orderCode},function:Queryorder,更新订单状态结果", $updateOrderStatus);
|
|
|
|
|
|
return true;
|
|
|
}
|
...
|
...
|
@@ -90,23 +69,19 @@ class PayNotifyCallBack extends WxPayNotify |
|
|
//重写回调处理函数
|
|
|
public function NotifyProcess($data, &$msg)
|
|
|
{
|
|
|
$this->log->LogInfo('begin notifyProcess');
|
|
|
$this->log->LogInfo(var_export($data, true));
|
|
|
|
|
|
UdpLog::info("【{$this->logProjectPrefix}-微信扫码支付】,function:NotifyProcess,参数", $data);
|
|
|
if (!array_key_exists("transaction_id", $data)) {
|
|
|
$msg = "输入参数不正确";
|
|
|
$this->log->LogInfo('=====微信扫码支付通知结果为:' . $msg . '=====');
|
|
|
UdpLog::info("【{$this->logProjectPrefix}-微信扫码支付】,function:NotifyProcess,输入参数不正确", $data);
|
|
|
return false;
|
|
|
}
|
|
|
//查询订单,判断订单真实性
|
|
|
if (!$this->Queryorder($data["transaction_id"])) {
|
|
|
$msg = "订单查询失败";
|
|
|
$this->log->LogInfo('=====微信扫码支付通知结果为:' . $msg . '=====');
|
|
|
UdpLog::info("【{$this->logProjectPrefix}-微信扫码支付】,function:NotifyProcess,订单查询失败", $data);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
$this->log->LogInfo('=====微信扫码支付通知结果为:' . $msg . '=====');
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
...
|
...
|
|