@ -1,8 +1,6 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
// global $__PAYMENT_METHOD_CODE__;
class PaymentService extends CI_Controller {
public function __construct(){
@ -17,18 +15,52 @@ class PaymentService extends CI_Controller {
public function index()
{
}
public function note_list()
{
$this->permission->is_admin(true);
$data = array();
// $data["paytext"] = $this->payment_status();
$data["method_name"] = $this->input->get_post("method_name");
$data["keywords"] = $this->input->get_post("keywords");
$data["date"] = $this->input->get_post("date");
empty($data['date']) ? $data['date'] = date('Y-m-d') : false;
if (!empty($data['keywords'])) {
$data['notelist'] = $this->note_model->search_key($data['keywords']);
} else {
$data['notelist'] = $this->note_model->search_date($data['date']);
}
/**
* 导出记录用的记录节点
* TODO
*/
// $data['record_flags'] = $this->note_model->list_export_record();
$this->load->view("payment_list",$data);
return;
}
public function send_notify($transaction_id=NULL, $old_ssje=NULL)
public function note_faillist()
{
$this->permission->is_admin(true);
$data = array();
$data['date'] = date('Y-m-d');
$data['notelist'] = $this->note_model->failnote(100);
$this->load->view("payment_list",$data);
return;
}
public function send_notify($opn_id=NULL, $old_ssje=NULL)
{
log_message('error','send_notify begin ----');
// exit();
$data = array();
$show_index = 0;
//优先处理指定的交易号,用于修正交易号直接发送通知
if ( ! empty($transaction_id)) {
$data['unsend_list'] = $this->note_model->get_note($transaction_id);
if ( ! empty($op n_id)) {
$data['unsend_list'] = $this->note_model->get_note($op n_id);
}
// 待处理的
if (empty($data['unsend_list'])) {
@ -40,10 +72,6 @@ log_message('error','send_notify begin ----');
}
// 开始处理
foreach ($data['unsend_list'] as $key => $item) {
//显示处理记录
if (empty($transaction_id)) {
echo ++$show_index . ' ' . $item->OPN_transactionId . '< br / > ';
}
// 只处理完成状态
if ($item->OPN_transactionResult != 'completed') {
continue;
@ -74,19 +102,19 @@ log_message('error','send_notify begin ----');
}
// 开始查找订单和录入
$handpick = empty($transacti on_id) ? false : true;
$handpick = empty($op n_id) ? false : true;
$advisor_info = $this->account_model->get_order($orderid_info->orderid, false, $orderid_info->ordertype, $handpick);
$ssje = $this->account_model->get_ssje($item->OPN_orderAmount, $item->OPN_accountMethod, mb_strtoupper($item->OPN_currency));
$ssje = $this->account_model->get_ssje($item->OPN_orderAmount, mb_strtoupper($item->OPN_currency), $item->OPN_accountMethod );
$ssje = $old_ssje===NULL ? $ssje : $old_ssje;
$ht_memo = '交易号(自动录入):' . $item->OPN_transactionId;
if ( ! iss et($advisor_info->ordertype )) {
if ( emp ty ($advisor_info)) {
// record fail
$this->note_model->update_send($item->OPN_SN, $item->OPN_transactionId, 'sendfail');
continue;
}
$COLI_SN = isset($advisor_info->COLI_SN) ? $advisor_info->COLI_SN : 0;
$update_note_column = array();
if ($advisor_info->ordertype == 0) {
if ($advisor_info->order_ type == 0) {
/* 商务订单 */
if (substr($advisor_info->COLI_WebCode, 0, 6) == 'CHTAPP') {
/* APP */
@ -141,7 +169,7 @@ log_message('error','send_notify begin ----');
$update_note_column['OPN_accountType'] = 'B';
$update_note_column['OPN_accountStatus'] = 'recorded';
$update_note_column['OPN_accountTime'] = date('Y-m-d H:i:s');
} elseif ($advisor_info->ordertype == 1) {
} elseif ($advisor_info->order_ type == 1) {
/* 传统 */
$gai_sn = $this->account_model->add_tour_account_info(
$COLI_SN,
@ -187,15 +215,20 @@ log_message('error','send_notify begin ----');
$toName = !empty($opi_firstname) ? $opi_firstname : '';
$toEmail = !empty($opi_email) ? $opi_email : '';
$subject = $orderid_info->orderid . '_' . $orderid_info->ordertype . ' / ' . $item->OPN_orderAmount . $item->OPN_currency . ' / ' . $fromName;
$body = $this->load->view('mail_templete ', $item, true); //$item->pn_memo;
$body = $this->load->view('mail_advisor ', $item, true); //$item->pn_memo;
$M_RelatedInfo = $item->OPN_SN;
$M_AddTime = $item->OPN_completeTime;
$M_State = 0;
$this->account_model->save_automail($fromName, $fromEmail, $toName, $toEmail, $subject, $body, $M_RelatedInfo, $M_State, $M_AddTime, 'payment note', 'payment note');
//添加邮件发送记录 end
// 2. 给客人发邮件,通知账单 todo ?? 是否需要
$this->note_model->update_send($item->OPN_SN, $item->pn_txn_i d, 'send');
$this->note_model->update_send($item->OPN_SN, $item->OPN_transactionI d, 'send');
//显示处理记录
if (empty($opn_id)) {
echo ++$show_index . ' ' . $item->OPN_transactionId . '< br / > ';
}
}
return;
@ -203,6 +236,7 @@ log_message('error','send_notify begin ----');
}
/** 支付方式参数对应的配置文件名 */
/** @Deprecated */
public function method_name($name)
{
$config_name = 'paypal';
@ -246,14 +280,12 @@ log_message('error','send_notify begin ----');
case '15016': // wxpay
$orderid_info = analysis_orderid($content_obj->out_trade_no);
break;
// TODO
case '15018': // iPaylinks
break;
case '15015': // alipay
break;
default:
# code...
break;
@ -261,5 +293,99 @@ log_message('error','send_notify begin ----');
return $orderid_info;
}
public function convert_send_status()
{
# code...
}
public function gai_modal($pn_id = null, $neworder=null)
{
$this->permission->is_admin(true);
$data = array();
$note = $this->note_model->get_note($pn_id);
$data['note'] = $note[0];
$data['order_info'] = NULL;
$pn_invoice = $data['note']->OPN_orderId ? $data['note']->OPN_orderId : $data['note']->OPN_rawOrderId;
$pn_txn_id = $data['note']->OPN_transactionId;
$orderid_info = analysis_orderid($pn_invoice);
if (!empty($orderid_info)) {
$orderid_info = json_decode($orderid_info);
$data['order_info'] = $this->account_model->get_order($orderid_info->orderid, true, $orderid_info->ordertype);
if ($orderid_info->ordertype === 'T') {
$data['gai_info'] = $this->account_model->get_money_t($pn_txn_id);
} elseif ($orderid_info->ordertype === 'B' || $orderid_info->ordertype === 'TP') {
$data['gai_info'] = $this->account_model->get_money_b($pn_txn_id);
}
}
$data['old_order'] = $pn_invoice;
$data['new_order'] = $neworder;
if ($neworder !== null ) {
$neworder_id = analysis_orderid($neworder);
$neworder_id = json_decode($neworder_id);
if ( ! empty($neworder_id)) {
$data['order_info'] = $this->account_model->get_order($neworder_id->orderid, true, $neworder_id->ordertype);
}
}
echo json_encode($this->load->view('payment_gai_setting', $data, true));
}
public function gai_modal_save()
{
$data = array();
$old_ssje = NULL;
$pn_txn_id = $this->input->post('pn_txn_id');
$pn_id = $this->input->post('pn_id');
$neworder = $this->input->post('pn_invoice');
$note = $this->note_model->get_note($pn_id);
$data['note'] = $note[0];
$orderid_info = analysis_orderid($data['note']->OPN_orderId);
if (!empty($orderid_info)) {
$orderid_info = json_decode($orderid_info);
if ($orderid_info->ordertype === 'T') {
$data['gai_info'] = $this->account_model->get_money_t($pn_txn_id);
if ( ! empty($data['gai_info'])) {
$old_ssje = $data['gai_info'][0]->GAI_SSJE;
$this->account_model->delete_money_t($pn_txn_id);
}
} elseif ($orderid_info->ordertype === 'B' || $orderid_info->ordertype === 'TP') {
$data['gai_info'] = $this->account_model->get_money_b($pn_txn_id);
if ( ! empty($data['gai_info'])) {
$old_ssje = $data['gai_info'][0]->GAI_SSJE;
$this->account_model->delete_money_b($pn_txn_id);
}
}
}
if (!empty($pn_txn_id) & & !empty($neworder)) {
$orderid_info = analysis_orderid($neworder);
if (!empty($orderid_info)) {
$orderid_info = json_decode($orderid_info);
$advisor_info = $this->account_model->get_order($orderid_info->orderid, false, $orderid_info->ordertype);
if (!empty($advisor_info)) {
$this->note_model->set_invoice($data['note']->OPN_SN, $neworder);
$this->send_notify($data['note']->OPN_SN, $old_ssje);
echo json_encode('修改成功!');
return true;
}
}
}
echo json_encode('没找到数据!');
return;
}
public function close_gai($opn_id)
{
$data = array();
$data['note'] = $this->note_model->get_note($opn_id);
if (!empty($data['note'])) {
$this->note_model->update_send($opn_id, $data['note'][0]->OPN_transactionId, 'closed');
echo json_encode('该收款记录已经忽略!');
return true;
}
echo json_encode('没找到数据!');
return;
}
}