From 5ab9632f897ba2a90c9b5dd3298d14c933d35268 Mon Sep 17 00:00:00 2001 From: lyt Date: Fri, 3 Aug 2018 14:37:29 +0800 Subject: [PATCH] =?UTF-8?q?paypal=20=E6=9F=A5=E7=9C=8B=E6=94=B6=E6=AC=BE?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=B7=B2=E5=BD=95=E5=85=A5=E8=AE=A2=E5=8D=95?= =?UTF-8?q?;+=E6=94=B6=E6=AC=BE=E8=BD=AC=E7=A7=BB=E5=88=B0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webht/third_party/pay/views/gai_setting.php | 2 +- .../third_party/paypal/controllers/index.php | 75 ++++++++++++++++ .../third_party/paypal/models/note_model.php | 6 +- .../paypal/models/paypal_model.php | 33 +++++++ .../third_party/paypal/views/gai_setting.php | 41 +++++++++ webht/third_party/paypal/views/note_list.php | 85 ++++++++++++++++++- 6 files changed, 235 insertions(+), 7 deletions(-) create mode 100644 webht/third_party/paypal/views/gai_setting.php diff --git a/webht/third_party/pay/views/gai_setting.php b/webht/third_party/pay/views/gai_setting.php index 355d3b2e..70be2c9b 100644 --- a/webht/third_party/pay/views/gai_setting.php +++ b/webht/third_party/pay/views/gai_setting.php @@ -1,4 +1,4 @@ -
+

已录入订单

diff --git a/webht/third_party/paypal/controllers/index.php b/webht/third_party/paypal/controllers/index.php index 6c466f89..472e3bec 100644 --- a/webht/third_party/paypal/controllers/index.php +++ b/webht/third_party/paypal/controllers/index.php @@ -1031,4 +1031,79 @@ class Index extends CI_Controller { $objWriter->save('php://output'); } + /** 查看收款记录的是否已录入到订单 */ + public function gai_modal($pn_txn_id=null, $pn_id = null, $neworder=null) + { + $data = array(); + $data['note'] = $this->Note_model->note($pn_txn_id, $pn_id); + $orderid_info = $this->analysis_orderid($data['note']->pn_invoice); + if (!empty($orderid_info)) { + $orderid_info = json_decode($orderid_info); + if ($orderid_info->ordertype === 'T') { + $data['gai_info'] = $this->Paypal_model->get_money_t($pn_txn_id); + } elseif ($orderid_info->ordertype === 'B') { + $data['gai_info'] = $this->Paypal_model->get_money_b($pn_txn_id); + } + } + $data['old_order'] = $data['note']->pn_invoice; + $data['new_order'] = $neworder; + $data['order_info'] = null; + if ($neworder !== null) { + $neworder_id = $this->analysis_orderid($neworder); + $neworder_id = json_decode($neworder_id); + if ( ! empty($neworder_id)) { + $data['order_info'] = $this->Paypal_model->get_order($neworder_id->orderid, true, $neworder_id->ordertype); + } + } + echo json_encode($this->load->view('gai_setting', $data, true)); + } + public function gai_modal_save() + { + $data = array(); + $pn_txn_id = $this->input->post('pn_txn_id'); + $pn_id = $this->input->post('pn_id'); + $neworder = $this->input->post('pn_invoice'); + + $data['note'] = $this->Note_model->note($pn_txn_id, $pn_id); + $orderid_info = $this->analysis_orderid($data['note']->pn_invoice); + if (!empty($orderid_info)) { + $orderid_info = json_decode($orderid_info); + if ($orderid_info->ordertype === 'T') { + $data['gai_info'] = $this->Paypal_model->get_money_t($pn_txn_id); + $this->Paypal_model->delete_money_t($pn_txn_id); + } elseif ($orderid_info->ordertype === 'B') { + $data['gai_info'] = $this->Paypal_model->get_money_b($pn_txn_id); + $this->Paypal_model->delete_money_b($pn_txn_id); + } + } + + if (!empty($pn_txn_id) && !empty($neworder)) { + $orderid_info = $this->analysis_orderid($neworder); + if (!empty($orderid_info)) { + $orderid_info = json_decode($orderid_info); + $advisor_info = $this->Paypal_model->get_order($orderid_info->orderid, false, $orderid_info->ordertype); + if (!empty($advisor_info)) { + $this->Note_model->set_invoice($pn_txn_id, $neworder); + $this->send_note($pn_txn_id); + echo json_encode('修改成功!'); + return true; + } + } + } + echo json_encode('没找到数据!'); + return; + } + public function closeGai($pn_txn_id) + { + $data = array(); + $data['note'] = $this->Note_model->note($pn_txn_id); + if (!empty($data['note'])) { + $this->Note_model->update_send($pn_txn_id, 'closeRecord'); + echo json_encode('该收款记录已经忽略!'); + return true; + } + echo json_encode('没找到数据!'); + return; + } + } diff --git a/webht/third_party/paypal/models/note_model.php b/webht/third_party/paypal/models/note_model.php index 71835876..8aff1673 100644 --- a/webht/third_party/paypal/models/note_model.php +++ b/webht/third_party/paypal/models/note_model.php @@ -45,16 +45,17 @@ class Note_model extends CI_Model { public function search_date($date) { $this->init(); - $search_sql = " AND (pn.pn_datetime BETWEEN '$date 00:00:00' AND '$date 23:59:59' OR pn_send<>'send') "; + $search_sql = " AND (pn.pn_datetime BETWEEN '$date 00:00:00' AND '$date 23:59:59' OR pn_send not in ('send','closeRecord')) "; $this->search = $search_sql; $this->orderby=" ORDER BY CASE pn.pn_send WHEN 'sendfail' THEN 1 ELSE 2 END ,pn.pn_sn DESC "; return $this->get_list(); } - public function note($pn_txn_id){ + public function note($pn_txn_id, $pn_sn=NULL){ $this->init(); $this->topnum=1; $this->pn_txn_id=" AND pn.pn_txn_id=".$this->HT->escape($pn_txn_id); + $this->pn_txn_id .= ($pn_sn===NULL) ? "" : " AND pn.pn_sn=".$this->HT->escape($pn_sn); return $this->get_list(); } @@ -118,6 +119,7 @@ class Note_model extends CI_Model { $this->search ? $sql.=$this->search : false; $this->pn_txn_id ? $sql.=$this->pn_txn_id : false; $this->orderby ? $sql.=$this->orderby : false; +// log_message('error',$sql); $query = $this->HT->query($sql); //print_r($this->HT->queries); if ($this->topnum === 1) { diff --git a/webht/third_party/paypal/models/paypal_model.php b/webht/third_party/paypal/models/paypal_model.php index 73101e6a..b2d116bb 100644 --- a/webht/third_party/paypal/models/paypal_model.php +++ b/webht/third_party/paypal/models/paypal_model.php @@ -521,4 +521,37 @@ class Paypal_model extends CI_Model { $query = $this->HT->query($sql, array($paymanner, $COLI_SN)); return $query; } + //根据交易号获取收款记录(传统订单) + public function get_money_t($pn_invoice) { + $sql = "SELECT GroupAccountInfo.* + from GroupAccountInfo + where DeleteFlag=0 and GAI_AccreditNo=? + "; + $query = $this->HT->query($sql, array($pn_invoice)); + $result = $query->result(); + return $result; + } + //根据交易号获取收款记录(商务订单) + public function get_money_b($pn_invoice) { + $sql = "SELECT BIZ_GroupAccountInfo.* + from BIZ_GroupAccountInfo + where DeleteFlag=0 and GAI_AccreditNo=? + "; + $query = $this->HT->query($sql, array($pn_invoice)); + $result = $query->result(); + return $result; + } + /** 删除收款记录 */ + public function delete_money_t($deadId) + { + $sql = "UPDATE GroupAccountInfo SET DeleteFlag=1 WHERE GAI_AccreditNo=?"; + $query = $this->HT->query($sql, array($deadId)); + return $query; + } + public function delete_money_b($deadId) + { + $sql = "UPDATE BIZ_GroupAccountInfo SET DeleteFlag=1 WHERE GAI_AccreditNo=?"; + $query = $this->HT->query($sql, array($deadId)); + return $query; + } } diff --git a/webht/third_party/paypal/views/gai_setting.php b/webht/third_party/paypal/views/gai_setting.php new file mode 100644 index 00000000..e11d0137 --- /dev/null +++ b/webht/third_party/paypal/views/gai_setting.php @@ -0,0 +1,41 @@ + + +

已录入订单

+
+ + + + + + + + +
申请金额/币种实收金额
GAI_SQJE; ?> GAI_SQJECurrency; ?>GAI_SSJE; ?> CNY
+

撤回以上订单收款记录, 并转移到订单:

+ +

未自动录入到订单

+ +
+ + +
+ +
订单详细内容:
+

+ $order_info->COLI_SN
"; + echo "COLI_ID => $order_info->COLI_ID
"; + echo "OPI_Email => $order_info->OPI_Email
"; + echo "OPI_Name => $order_info->OPI_Name
"; + echo!empty($order_info->COLI_GroupCode) ? "COLI_GroupCode => $order_info->COLI_GroupCode
" : false; + echo!empty($order_info->COLI_OrderDetailText) ? "COLI_OrderDetailText => $order_info->COLI_OrderDetailText\n" : false; + } else { + echo '找不到目标订单内容'; + } + ?> +

+ + +
diff --git a/webht/third_party/paypal/views/note_list.php b/webht/third_party/paypal/views/note_list.php index 0d8a07ce..69e711d3 100644 --- a/webht/third_party/paypal/views/note_list.php +++ b/webht/third_party/paypal/views/note_list.php @@ -41,6 +41,7 @@ return date; } }); +