From 48a24c26b9653ba293fffe901eba575dbc9847f2 Mon Sep 17 00:00:00 2001 From: lyt Date: Fri, 10 May 2019 09:28:22 +0800 Subject: [PATCH] =?UTF-8?q?paypal=20APP=E7=BB=84=E7=9A=84=E6=94=B6?= =?UTF-8?q?=E6=AC=BE=E6=8F=90=E9=86=92=E5=A4=96=E8=81=94=E6=A0=B8=E5=AF=B9?= =?UTF-8?q?=E6=94=B6=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../third_party/paypal/controllers/index.php | 75 +++++++++++++++---- webht/views/n-header.php | 2 +- 2 files changed, 61 insertions(+), 16 deletions(-) diff --git a/webht/third_party/paypal/controllers/index.php b/webht/third_party/paypal/controllers/index.php index ce530df9..168f2891 100644 --- a/webht/third_party/paypal/controllers/index.php +++ b/webht/third_party/paypal/controllers/index.php @@ -757,40 +757,50 @@ class Index extends CI_Controller { continue; } - //检测是否是APP订单,默认不处理 - // && $item->pn_payment_status !== 'Refunded' - if ( - ( (strpos($item->pn_memo, 'China Train Booking') !== false) - || (strpos($item->pn_memo, 'ChinaTrainBooking') !== false) - ) - && empty($pn_txn_id) - ) { //APP自动出票的订单不需要处理 - $this->Note_model->update_send($item->pn_txn_id, 'send'); - continue; - } - //根据note信息找到订单号 + $get_order_no = $item->pn_invoice; $orderid_info = $this->analysis_orderid($item->pn_invoice); if (empty($orderid_info)) { + $get_order_no = $item->pn_custom; $orderid_info = $this->analysis_orderid($item->pn_custom); } if (empty($orderid_info)) { + $get_order_no = $item->pn_item_name; $orderid_info = $this->analysis_orderid($item->pn_item_name); } if (empty($orderid_info)) { + $get_order_no = $item->pn_item_number; $orderid_info = $this->analysis_orderid($item->pn_item_number); } - //找不到订单号,设置为发送失败标示 if (empty($orderid_info)) { $this->Note_model->update_send($item->pn_txn_id, 'sendfail'); continue; } + $orderid_info = json_decode($orderid_info); + // 仅自动程序发送提醒 false == $handpick && + if ($item->pn_payment_status === 'Completed' + && $orderid_info->ordertype == 'A' && strpos($get_order_no, 'China Train Booking') !== false) { + // APP 组的China Train Booking-开头的订单号 + // 发送邮件提醒外联核对收款金额, 不写入收款记录 + $this->process_notify_APP($item, $orderid_info); + continue; + } + + //检测是否是APP订单,默认不处理 + // && $item->pn_payment_status !== 'Refunded' + if ( + ( (strpos($item->pn_memo, 'China Train Booking') !== false) + || (strpos($item->pn_memo, 'ChinaTrainBooking') !== false) + ) + && empty($pn_txn_id) + ) { //APP自动出票的订单不需要处理 + $this->Note_model->update_send($item->pn_txn_id, 'send'); + continue; + } //根据订单号查找外联信息 - $orderid_info = json_decode($orderid_info); - $handpick = empty($pn_txn_id) ? false : TRUE; $advisor_info = $this->Paypal_model->get_order($orderid_info->orderid, false, $orderid_info->ordertype, $handpick); // for trippest tourMaster 2018.05.28 @@ -1457,4 +1467,39 @@ class Index extends CI_Controller { return; } + public function process_notify_APP($item, $orderid_info) + { + $advisor_info = $this->Paypal_model->get_order($orderid_info->orderid, false, $orderid_info->ordertype); + //查不到订单信息 + if (empty($advisor_info)) { + $this->Note_model->update_send($item->pn_txn_id, 'sendfail'); + return false; + } + $opi_email = !empty($advisor_info->OPI_Email) ? $advisor_info->OPI_Email : ''; //lussie@chinahighlights.net + $opi_firstname = !empty($advisor_info->OPI_FirstName) ? $advisor_info->OPI_FirstName : !empty($advisor_info->OPI_Name) ? $advisor_info->OPI_Name : ''; //lussie + //没有外联信息表示订单未分配 + if (empty($opi_email) || empty($opi_firstname)) { + $this->Note_model->update_send($item->pn_txn_id, 'sendfail'); + return false; + } + //添加邮件发送记录 + if ($item->pn_send !== 'send') { + //给外联发送通知邮件 + $fromName = !empty($item->pn_payer) ? $item->pn_payer : ''; + $fromEmail = !empty($item->pn_payer_email) ? $item->pn_payer_email : ''; + $toName = !empty($opi_firstname) ? $opi_firstname : ''; + $toEmail = !empty($opi_email) ? $opi_email : ''; + // $subject = $orderid_info->orderid . '_' . $orderid_info->ordertype . ' / ' . $item->pn_mc_gross . $item->pn_mc_currency . ' / ' . $fromName; + $subject = "请核对收款_" . $orderid_info->orderid . "_" . $item->pn_mc_currency . "_" . $item->pn_mc_gross; + $body = $this->load->view('mail_templete', $item, true); //$item->pn_memo; + $M_RelatedInfo = $item->pn_sn; + $M_AddTime = $item->pn_payment_date; + $M_State = 0; + $this->Paypal_model->save_automail($fromName, $fromEmail, $toName, $toEmail, $subject, $body, $M_RelatedInfo, $M_State, $M_AddTime, 'paypal note'); + //添加邮件发送记录 end + $this->Note_model->update_send($item->pn_txn_id, 'send'); + } + return false; + } + } diff --git a/webht/views/n-header.php b/webht/views/n-header.php index cb06b1ad..2881dc99 100644 --- a/webht/views/n-header.php +++ b/webht/views/n-header.php @@ -8,7 +8,7 @@ - +