Authored by Rock Zhang

添加更多的支付有关的日志

@@ -38,7 +38,13 @@ class PayNotifyCallBack extends WxPayNotify @@ -38,7 +38,13 @@ class PayNotifyCallBack extends WxPayNotify
38 { 38 {
39 $input = new WxPayOrderQuery(); 39 $input = new WxPayOrderQuery();
40 $input->SetTransaction_id($transaction_id); 40 $input->SetTransaction_id($transaction_id);
  41 + $this->log->LogInfo('微信扫码支付交易号:' . $transaction_id);
41 $result = WxPayApi::orderQuery($input); 42 $result = WxPayApi::orderQuery($input);
  43 +
  44 + $this->log->LogInfo('begin PayNotifyCallBack->Queryorder');
  45 + $this->log->LogInfo('===开始查询微信扫码订单=====');
  46 + $this->log->LogInfo(var_export($result, true));
  47 +
42 if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") { 48 if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") {
43 $orderCode = substr($result['out_trade_no'], self::ORDER_CODE_START); 49 $orderCode = substr($result['out_trade_no'], self::ORDER_CODE_START);
44 $payment = 21; // 微信扫码支付 50 $payment = 21; // 微信扫码支付
@@ -84,13 +90,18 @@ class PayNotifyCallBack extends WxPayNotify @@ -84,13 +90,18 @@ class PayNotifyCallBack extends WxPayNotify
84 //重写回调处理函数 90 //重写回调处理函数
85 public function NotifyProcess($data, &$msg) 91 public function NotifyProcess($data, &$msg)
86 { 92 {
  93 + $this->log->LogInfo('begin notifyProcess');
  94 + $this->log->LogInfo(var_export($data, true));
  95 +
87 if (!array_key_exists("transaction_id", $data)) { 96 if (!array_key_exists("transaction_id", $data)) {
88 $msg = "输入参数不正确"; 97 $msg = "输入参数不正确";
  98 + $this->log->LogInfo('=====微信扫码支付通知结果为:' . $msg . '=====');
89 return false; 99 return false;
90 } 100 }
91 //查询订单,判断订单真实性 101 //查询订单,判断订单真实性
92 if (!$this->Queryorder($data["transaction_id"])) { 102 if (!$this->Queryorder($data["transaction_id"])) {
93 $msg = "订单查询失败"; 103 $msg = "订单查询失败";
  104 + $this->log->LogInfo('=====微信扫码支付通知结果为:' . $msg . '=====');
94 return false; 105 return false;
95 } 106 }
96 107
1 <?php 1 <?php
2 2
3 namespace WebPlugin\Pay\weixin\lib; 3 namespace WebPlugin\Pay\weixin\lib;
  4 +use WebPlugin\PhpLog;
4 5
5 /** 6 /**
6 * 7 *
@@ -10,6 +11,10 @@ namespace WebPlugin\Pay\weixin\lib; @@ -10,6 +11,10 @@ namespace WebPlugin\Pay\weixin\lib;
10 */ 11 */
11 class WxPayNotify extends WxPayNotifyReply 12 class WxPayNotify extends WxPayNotifyReply
12 { 13 {
  14 + // 向ERP提交订单状态有关接口调用日志和更新订单状态有关接口调用日志
  15 + const ORDER_STATUS_LOG = '/Data/logs/pc_pay/order_status';
  16 + // 日志等级,2表示记录信息等级的日志
  17 + const LOG_LEVEL = 2;
13 18
14 /** 19 /**
15 * 20 *
@@ -18,15 +23,22 @@ class WxPayNotify extends WxPayNotifyReply @@ -18,15 +23,22 @@ class WxPayNotify extends WxPayNotifyReply
18 */ 23 */
19 final public function Handle($needSign = true) 24 final public function Handle($needSign = true)
20 { 25 {
  26 + // 初始化日志
  27 + $log = new PhpLog(self::ORDER_STATUS_LOG, 'PRC', self::LOG_LEVEL);
  28 + $log->LogInfo('begin WxPayNotify->Handle');
  29 +
21 $msg = "OK"; 30 $msg = "OK";
22 //当返回false的时候,表示notify中调用NotifyCallBack回调失败获取签名校验失败,此时直接回复失败 31 //当返回false的时候,表示notify中调用NotifyCallBack回调失败获取签名校验失败,此时直接回复失败
23 $result = WxpayApi::notify(array($this, 'NotifyCallBack'), $msg); 32 $result = WxpayApi::notify(array($this, 'NotifyCallBack'), $msg);
  33 + $log->LogInfo(var_export($result, true));
24 if ($result == false) { 34 if ($result == false) {
  35 + $log->LogInfo('===微信扫码支付Handle失败===');
25 $this->SetReturn_code("FAIL"); 36 $this->SetReturn_code("FAIL");
26 $this->SetReturn_msg($msg); 37 $this->SetReturn_msg($msg);
27 $this->ReplyNotify(false); 38 $this->ReplyNotify(false);
28 return; 39 return;
29 } else { 40 } else {
  41 + $log->LogInfo('===微信扫码支付Handle成功===');
30 //该分支在成功回调到NotifyCallBack方法,处理完成之后流程 42 //该分支在成功回调到NotifyCallBack方法,处理完成之后流程
31 $this->SetReturn_code("SUCCESS"); 43 $this->SetReturn_code("SUCCESS");
32 $this->SetReturn_msg("OK"); 44 $this->SetReturn_msg("OK");
@@ -284,6 +284,7 @@ class NoticeController extends WebAction @@ -284,6 +284,7 @@ class NoticeController extends WebAction
284 $uid = $this->getSession(self::SESSION_UID_KEY); 284 $uid = $this->getSession(self::SESSION_UID_KEY);
285 $this->setSession(self::SESSION_UID_KEY, null); 285 $this->setSession(self::SESSION_UID_KEY, null);
286 } 286 }
  287 + $this->log->LogInfo($uid);
287 $notify = new PayNotifyCallBack($uid); 288 $notify = new PayNotifyCallBack($uid);
288 $notify->handle(false); 289 $notify->handle(false);
289 } 290 }