wxpay 收款通知处理;收款通知列表;

feature/pay
lyt 7 years ago
parent 9cef2510b4
commit aecdf6eddf

@ -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,7 +15,6 @@ class PaymentService extends CI_Controller {
public function index()
{
}
public function note_list()
@ -34,19 +31,36 @@ class PaymentService extends CI_Controller {
} else {
$data['notelist'] = $this->note_model->search_date($data['date']);
}
$this->load->view("iPayLinks_list",$data);
/**
* 导出记录用的记录节点
* 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($opn_id)) {
$data['unsend_list'] = $this->note_model->get_note($opn_id);
}
// 待处理的
if (empty($data['unsend_list'])) {
@ -88,7 +102,7 @@ log_message('error','send_notify begin ----');
}
// 开始查找订单和录入
$handpick = empty($transaction_id) ? false : true;
$handpick = empty($opn_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, mb_strtoupper($item->OPN_currency), $item->OPN_accountMethod);
$ssje = $old_ssje===NULL ? $ssje : $old_ssje;
@ -207,11 +221,12 @@ log_message('error','send_notify begin ----');
$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->OPN_transactionId, 'send');
//显示处理记录
if (empty($transaction_id)) {
if (empty($opn_id)) {
echo ++$show_index . ' ' . $item->OPN_transactionId . '<br/>';
}
@ -278,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;
}
}

@ -28,7 +28,7 @@ class Online_payment_account_model extends CI_Model {
$result = '';
$fieldsql = $orderinfo == false ? '' : " ,* ";
//先查商务订单B,APP订单A、再查传统订单T
if ($ordertype == 'B' || $ordertype == 'A') {
if ($ordertype == 'B' || $ordertype == 'A' || $ordertype == 'TP') {
$sql = "SELECT TOP 2 0 as order_type,COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_Department,COLI_PayManner,COLI_State $fieldsql from BIZ_ConfirmLineInfo
LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
where COLI_ID =?";
@ -152,6 +152,40 @@ class Online_payment_account_model extends CI_Model {
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;
}
//添加收款记录(商务订单)
public function add_account_info($GAI_COLI_SN, $payment_method, $GAI_COLI_ID, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo) {
//先判断是否有这条数据

@ -92,14 +92,59 @@ class Online_payment_note_model extends CI_Model {
return $query->result();
}
public function get_note($transactionId)
public function get_note($opn_id)
{
$this->init_query();
$this->topnum=1;
$this->transactionId = " AND opn.OPN_transactionId=" . $this->info->escape($transactionId);
$this->search = " AND opn.OPN_SN=" . $this->info->escape($opn_id);
return $this->query_note();
}
public function search_key($keyword)
{
$this->init_query();
$this->topnum = 300;
$keyword = trim($keyword);
$search_sql = "";
if ( ! empty($keyword)) {
$search_sql.=" AND ( OPN_transactionId = '$keyword'
OR OPN_orderId like '%$keyword%'
OR OPN_rawOrderId like '%$keyword%' )";
}
$this->search = $search_sql;
return $this->query_note();
}
public function search_date($date)
{
$this->init_query();
$this->search = " AND OPN_noticeTime BETWEEN '$date 00:00:00' AND '$date 23:59:59' ";
return $this->query_note();
}
public function failnote($topnum = 2) {
$this->init_query();
$this->topnum = $topnum;
$this->send = " AND OPN_noticeSendStatus='sendfail' ";
return $this->query_note();
}
/*!
* 导出记录
* @date 2019-04-28
* @param integer $sn [description]
*/
public function list_export_record($sn=0)
{
$search_sql = $sn===0 ? "" : " and TEL_SN=$sn ";
$sql = "SELECT TOP 10 *
FROM [InfoManager].[dbo].[Transaction_Export_Log]
WHERE 1=1
$search_sql
order by TEL_SN desc";
return $this->info->query($sql)->result();
}
}

Loading…
Cancel
Save