From 4decfcfae7768118860b4d4b6f466fde651a8236 Mon Sep 17 00:00:00 2001 From: lyt Date: Wed, 17 Apr 2019 17:37:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E6=94=B6=E5=88=B0=E7=9A=84?= =?UTF-8?q?=E6=94=B6=E6=AC=BE=E6=8E=A8=E9=80=81,=E5=B0=86=E5=90=84?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E6=96=B9=E5=BC=8F=E7=9A=84=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=90=88=E5=B9=B6.=2020%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pay/controllers/PaymentService.php | 43 +++++++++++++++ .../pay/controllers/WxpayService.php | 9 +--- .../pay/models/Online_payment_note_model.php | 53 +++++++++++++++++++ 3 files changed, 97 insertions(+), 8 deletions(-) create mode 100644 webht/third_party/pay/controllers/PaymentService.php diff --git a/webht/third_party/pay/controllers/PaymentService.php b/webht/third_party/pay/controllers/PaymentService.php new file mode 100644 index 00000000..72dbf507 --- /dev/null +++ b/webht/third_party/pay/controllers/PaymentService.php @@ -0,0 +1,43 @@ +load->helper('payment'); + // $this->config->load('wxpay', true); + $this->load->model('Online_payment_note_model', 'note_model'); + $this->load->model('Online_payment_account_model', 'account_model'); + } + + public function index() + { + + } + + public function send_notify($payment_method=NULL, $transactionId=NULL) + { + // $save_column['OPN_accountType'] = $xml_arr['']; + // $save_column['OPN_accountStatus'] = $xml_arr['']; + // $save_column['OPN_accountTime'] = $xml_arr['']; + $data = array(); + $int = 0; + + //优先处理指定的交易号,用于修正交易号直接发送通知 + if ( ! empty($transactionId)) { + $data['unsend_list'] = $this->note_model->get_note($payment_method, $transactionId); + } + // 待处理的 + if (empty($data['unsend_list'])) { + $data['unsend_list'] = $this->note_model->unsend_note($payment_method, 10); + } + //没有未处理的数据再查找处理失败的数据 + if (empty($data['unsend_list'])) { + $data['unsend_list'] = $this->note_model->sendfail_note($payment_method, 20); + } + } + +} + diff --git a/webht/third_party/pay/controllers/WxpayService.php b/webht/third_party/pay/controllers/WxpayService.php index d6f7ce6b..2ee2daa0 100644 --- a/webht/third_party/pay/controllers/WxpayService.php +++ b/webht/third_party/pay/controllers/WxpayService.php @@ -90,13 +90,6 @@ log_message('error','notify begin ----'); # exit(); // end } - public function send_notify() - { - // $save_column['OPN_accountType'] = $xml_arr['']; - // $save_column['OPN_accountStatus'] = $xml_arr['']; - // $save_column['OPN_accountTime'] = $xml_arr['']; - } - public function check_sign($xml_arr) { if ( ! array_key_exists('sign', $xml_arr)) { @@ -135,7 +128,7 @@ log_message('error','notify begin ----'); } //签名步骤四:所有字符转为大写 $result = strtoupper($string); -log_message('error',$result); +// log_message('error',$result); return $result; } diff --git a/webht/third_party/pay/models/Online_payment_note_model.php b/webht/third_party/pay/models/Online_payment_note_model.php index 2c721c52..86f4a9cc 100644 --- a/webht/third_party/pay/models/Online_payment_note_model.php +++ b/webht/third_party/pay/models/Online_payment_note_model.php @@ -25,6 +25,59 @@ class Online_payment_note_model extends CI_Model { return TRUE; } + public $topnum = false; + public $orderby = false; + public $send = false; + public $search = false; + public $transactionId = false; + public $payment_status = false; + public function init_query() { + $this->topnum = false; + $this->send = false; + $this->search = false; + $this->payment_status = false; + $this->transactionId = false; + $this->orderby = ' ORDER BY OPN_SN DESC '; + } + + public function query_note() + { + $top_sql = $this->topnum ? (" TOP " . $this->topnum) : ""; + $sql .= "SELECT $top_sql opn.* + FROM [InfoManager].[dbo].[OnlinePaymentNote] opn + WHERE 1=1 "; + $this->send ? $sql.=$this->send : false; + $this->search ? $sql.=$this->search : false; + $this->transactionId ? $sql.=$this->transactionId : false; + $this->orderby ? $sql.=$this->orderby : false; + $query = $this->INFO->query($sql); + return $query->result(); + } + + public function get_note($payment_method=NULL, $transactionId=null) + { + $this->init_query(); + $this->topnum=1; + $this->transactionId = " AND opn.OPN_transactionId=" . $this->INFO->escape($transactionId); + return $this->query_note(); + } + + public function unsend_note($payment_method=NULL, $num=2) + { + $this->init_query(); + $this->topnum = $num; + $this->send = " AND (OPN_noticeSendStatus='unsend' OR OPN_noticeSendStatus='' OR OPN_noticeSendStatus IS NULL) "; + return $this->query_note(); + } + + public function sendfail_note($payment_method=NULL, $num=2) + { + $this->init_query(); + $this->topnum = $num; + $this->send = " AND OPN_noticeSendStatus='sendfail' "; + return $this->query_note(); + } + }