diff --git a/webht/third_party/pay/config/paypal.php b/webht/third_party/pay/config/paypal.php
index 70dcceaa..f0a6743a 100644
--- a/webht/third_party/pay/config/paypal.php
+++ b/webht/third_party/pay/config/paypal.php
@@ -1,4 +1,6 @@
load->helper('payment');
- // $this->config->load('wxpay', true);
+ $this->config->load('wxpay', true);
+ $this->config->load('paypal', true);
$this->load->model('Online_payment_note_model', 'note_model');
$this->load->model('Online_payment_account_model', 'account_model');
}
@@ -17,26 +20,245 @@ class PaymentService extends CI_Controller {
}
- public function send_notify($payment_method=NULL, $transactionId=NULL)
+ public function send_notify($transaction_id=NULL, $old_ssje=NULL)
{
- // $save_column['OPN_accountType'] = $xml_arr[''];
- // $save_column['OPN_accountStatus'] = $xml_arr[''];
- // $save_column['OPN_accountTime'] = $xml_arr[''];
+log_message('error','send_notify begin ----');
+// exit();
$data = array();
- $int = 0;
-
+ $show_index = 0;
//优先处理指定的交易号,用于修正交易号直接发送通知
- if ( ! empty($transactionId)) {
- $data['unsend_list'] = $this->note_model->get_note($payment_method, $transactionId);
+ if ( ! empty($transaction_id)) {
+ $data['unsend_list'] = $this->note_model->get_note($transaction_id);
}
// 待处理的
if (empty($data['unsend_list'])) {
- $data['unsend_list'] = $this->note_model->unsend_note($payment_method, 10);
+ $data['unsend_list'] = $this->note_model->unsend_note(10);
}
//没有未处理的数据再查找处理失败的数据
if (empty($data['unsend_list'])) {
- $data['unsend_list'] = $this->note_model->sendfail_note($payment_method, 20);
+ $data['unsend_list'] = $this->note_model->sendfail_note(20);
+ }
+ // 开始处理
+ foreach ($data['unsend_list'] as $key => $item) {
+ //显示处理记录
+ if (empty($transaction_id)) {
+ echo ++$show_index . ' ' . $item->OPN_transactionId . '
';
+ }
+ // 只处理完成状态
+ if ($item->OPN_transactionResult != 'completed') {
+ continue;
+ }
+ if ($item->OPN_noticeType == 'Refunded') {
+ // 退款处理
+ continue ;
+ }
+
+ // 提取订单号
+ $orderid_info = analysis_orderid($item->OPN_orderId); // 先用已设置过的
+ if (empty($orderid_info)) {
+ $orderid_info = $this->method_analysis_orderid($item->OPN_accountMethod, $item->OPN_rawContent);
+ if (empty($orderid_info)) {
+ $this->note_model->update_send($item->OPN_SN, $item->OPN_transactionId, 'sendfail');
+ continue;
+ }
+ }
+ $orderid_info = json_decode($orderid_info);
+ // TODO Trippest的订单号要特别查询
+ // 填入提取到的订单号
+ $this->note_model->set_invoice($item->OPN_SN, $orderid_info->orderid . '_' . $orderid_info->ordertype);
+
+ // APP自动出票的收款 跳过
+ if ($orderid_info->ordertype === 'A' && $item->OPN_noticeType === 'pay') {
+ $this->note_model->update_send($item->OPN_SN, $item->OPN_transactionId, 'closed');
+ continue;
+ }
+
+ // 开始查找订单和录入
+ $handpick = empty($transaction_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 = $old_ssje===NULL ? $ssje : $old_ssje;
+ $ht_memo = '交易号(自动录入):' . $item->OPN_transactionId;
+ if ( ! isset($advisor_info->ordertype)) {
+ // 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 (substr($advisor_info->COLI_WebCode, 0, 6) == 'CHTAPP') {
+ /* APP */
+ $this->account_model->add_account_info_forAPP(
+ $COLI_SN,
+ $item->OPN_accountMethod,
+ $advisor_info->COLI_ID,
+ $item->OPN_orderAmount,
+ $item->OPN_completeTime,
+ mb_strtoupper($item->OPN_currency),
+ $ssje,
+ $item->OPN_completeTime,
+ $item->OPN_completeTime,
+ $item->OPN_completeTime,
+ $item->OPN_payerName,
+ $item->OPN_payerEmail,
+ $item->OPN_transactionId,
+ $ht_memo
+ );
+ if ($advisor_info->COLI_WebCode == 'CHTAPP' && $advisor_info->COLI_State == 11) {
+ //只修改APP组的订单状态,并且订单进度是我的订单
+ $this->account_model->update_biz_coli_state($COLI_SN, 8); //把订单状态改为已付款
+ $this->account_model->insert_biz_order_log($COLI_SN, 'BS8');
+ }
+ } else {
+ /* 其他商务订单 */
+ // 第一次录入收款记录时变更状态,记录日志
+ if (false == $this->account_model->if_biz_gai_exists($item->OPN_transactionId) ) {
+ $this->account_model->update_biz_coli_state($COLI_SN, 13);
+ $this->account_model->insert_biz_order_log($COLI_SN, 'BS13');
+ }
+ $this->account_model->add_account_info(
+ $COLI_SN,
+ $item->OPN_accountMethod,
+ $advisor_info->COLI_ID,
+ $item->OPN_orderAmount,
+ $item->OPN_completeTime,
+ mb_strtoupper($item->OPN_currency),
+ $ssje,
+ $item->OPN_completeTime,
+ $item->OPN_completeTime,
+ $item->OPN_completeTime,
+ $item->OPN_payerName,
+ $item->OPN_payerEmail,
+ $item->OPN_transactionId,
+ $ht_memo
+ );
+ // 更新订单主表付款方式,防止没访问thankyou-train.asp
+ $this->account_model->update_paymanner($COLI_SN, $item->OPN_accountMethod);
+ }
+ // 更新note
+ $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) {
+ /* 传统 */
+ $gai_sn = $this->account_model->add_tour_account_info(
+ $COLI_SN,
+ $item->OPN_accountMethod,
+ $item->OPN_orderAmount,
+ $item->OPN_completeTime,
+ mb_strtoupper($item->OPN_currency),
+ $ssje,
+ $item->OPN_completeTime,
+ $item->OPN_completeTime,
+ $item->OPN_completeTime,
+ $item->OPN_payerName,
+ $item->OPN_payerEmail,
+ $item->OPN_transactionId,
+ $ht_memo
+ );
+ //添加汉特的订单提醒
+ $this->account_model->update_coli_introduction($COLI_SN, '已支付 ' . mb_strtoupper($item->OPN_currency) . $item->OPN_orderAmount);
+ // 添加HT任务
+ $this->account_model->exec_addToTask($gai_sn);
+ // 更新note
+ $update_note_column['OPN_accountType'] = 'B';
+ $update_note_column['OPN_accountStatus'] = 'recorded';
+ $update_note_column['OPN_accountTime'] = date('Y-m-d H:i:s');
+ }
+ // 更新note
+ if ( ! empty($update_note_column)) {
+ $where = " OPN_SN=" . $item->OPN_SN;
+ $this->note_model->update_note($where, $update_note_column);
+ }
+ // 邮件外联
+ $opi_email = !empty($advisor_info->OPI_Email) ? $advisor_info->OPI_Email : '';
+ $opi_firstname = !empty($advisor_info->OPI_FirstName) ? $advisor_info->OPI_FirstName : !empty($advisor_info->OPI_Name) ? $advisor_info->OPI_Name : '';
+ //没有外联信息表示订单未分配
+ if (empty($opi_email) || empty($opi_firstname)) {
+ $this->note_model->update_send($item->OPN_SN, $item->OPN_transactionId, 'sendfail');
+ continue;
+ }
+ //添加邮件发送记录
+ //给外联发送通知邮件
+ $fromName = !empty($item->OPN_payerName) ? $item->OPN_payerName : '';
+ $fromEmail = !empty($item->OPN_payerEmail) ? $item->OPN_payerEmail : '';
+ $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;
+ $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
+
+ $this->note_model->update_send($item->OPN_SN, $item->pn_txn_id, 'send');
+
+
+ }
+ return;
+ // return $this->output->set_content_type('application/json')->set_output(json_encode($data));
+ }
+
+ /** 支付方式参数对应的配置文件名 */
+ public function method_name($name)
+ {
+ $config_name = 'paypal';
+ switch ($name) {
+ case 'paypal':
+ $config_name = 'paypal';
+ break;
+ case 'weixin':
+ $config_name = 'wxpay';
+ break;
+ case 'ipaylinks':
+ $config_name = 'iPayLinks';
+ break;
+ case 'alipay':
+ $config_name = 'alipay';
+ break;
+
+ default:
+ # code...
+ break;
+ }
+ return $config_name;
+ }
+
+ private function method_analysis_orderid($name, $raw_content)
+ {
+ $content_obj = json_decode($raw_content);
+ $orderid_info = array();
+ switch (strval($name)) {
+ case '15002':
+ case '15010': // paypal
+ $orderid_info = analysis_orderid($content_obj->invoice);
+ empty($orderid_info) ? $orderid_info = analysis_orderid($content_obj->transaction_subject) : NULL;
+ empty($orderid_info) ? $orderid_info = analysis_orderid($content_obj->custom) : NULL;
+ empty($orderid_info) ? $orderid_info = analysis_orderid($content_obj->item_name) : NULL;
+ empty($orderid_info) ? $orderid_info = analysis_orderid($content_obj->item_name1) : NULL;
+ empty($orderid_info) ? $orderid_info = analysis_orderid($content_obj->item_number) : NULL;
+ empty($orderid_info) ? $orderid_info = analysis_orderid($content_obj->item_number1) : NULL;
+ break;
+
+ case '15016': // wxpay
+ $orderid_info = analysis_orderid($content_obj->out_trade_no);
+ break;
+
+ case '15018': // iPaylinks
+ break;
+
+ case '15015': // alipay
+ break;
+
+
+ default:
+ # code...
+ break;
}
+ return $orderid_info;
}
}
diff --git a/webht/third_party/pay/helpers/payment_helper.php b/webht/third_party/pay/helpers/payment_helper.php
index 53ceac5e..80dc5010 100644
--- a/webht/third_party/pay/helpers/payment_helper.php
+++ b/webht/third_party/pay/helpers/payment_helper.php
@@ -130,12 +130,18 @@ function analysis_orderid($note_invoice_string) {
$ordertype = 'N';
if (isset($note_invoice_string[1])) {
$ordertype_temp = trim($note_invoice_string[1]);
- if (substr($ordertype_temp, 0, 1) == 'T') {
+ if (substr($ordertype_temp, 0, 2) == 'TP') {
+ $ordertype = 'TP';
+ } elseif (substr($ordertype_temp, 0, 1) == 'T') {
$ordertype = 'T';
} elseif (substr($ordertype_temp, 0, 1) == 'B') {
$ordertype = 'B';
}
}
+ // 2018.05.28 for Trippest, tourMaster的订单号是01开头
+ if (substr($note_invoice_string[0], 0, 2) == '01') {
+ $ordertype = 'TP';
+ }
//手机订单、机票订单都没有加标示,在这里帮加上,暂时的,今后还是要在网前设置好
if ($ordertype == 'N' && isset($note_invoice_string[0])) {
diff --git a/webht/third_party/pay/models/Online_payment_account_model.php b/webht/third_party/pay/models/Online_payment_account_model.php
index 3c19ea87..3a42e20e 100644
--- a/webht/third_party/pay/models/Online_payment_account_model.php
+++ b/webht/third_party/pay/models/Online_payment_account_model.php
@@ -23,5 +23,275 @@ class Online_payment_account_model extends CI_Model {
return NULL;
}
+ //根据订单号获取外联邮箱
+ public function get_order($COLI_ID, $orderinfo = false, $ordertype = 'N', $handpick=false) {
+ $result = '';
+ $fieldsql = $orderinfo == false ? '' : " ,* ";
+ //先查商务订单B,APP订单A、再查传统订单T
+ if ($ordertype == 'B' || $ordertype == 'A') {
+ $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 =?";
+ $query = $this->HT->query($sql, array($COLI_ID));
+ $result = $query->result();
+ }
+ //后查传统订单的原因是因为传统订单的订单号去掉外联名字首字母后可能会和商务订单的重合。
+ if (empty($result) && ($ordertype == 'T')) {
+ $sql = "SELECT TOP 2 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_State $fieldsql from ConfirmLineInfo
+ LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
+ where COLI_ID like '%$COLI_ID'
+ order by CHARINDEX('$COLI_ID', COLI_ID) ";
+ $query = $this->HT->query($sql);
+ $result = $query->result();
+ if ($handpick === TRUE) {
+ $result = array($result[0]);
+ }
+ }
+
+ //查传统订单add_code,网前实时支付会先生成一个临时订单号存在add_code里,如订单45103248
+
+ if (empty($result) && ($ordertype == 'M')) {
+ $sql = "SELECT TOP 2 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode $fieldsql from ConfirmLineInfo
+ LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
+ where COLI_AddCode =? ";
+ $query = $this->HT->query($sql, array($COLI_ID));
+ $result = $query->result();
+ }
+
+ if (empty($result) && ($ordertype == 'M')) {
+ $sql = "SELECT TOP 2 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode $fieldsql from ConfirmLineInfo cli
+ LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
+ where
+ EXISTS (
+ SELECT TOP 1 1
+ FROM ConfirmLineInfoTmp clit
+ WHERE clit.COLI_ID = ?
+ AND cli.COLI_AddCode = CAST(clit.COLI_SN AS VARCHAR(10))
+ )
+ ";
+ $query = $this->HT->query($sql, array($COLI_ID));
+ $result = $query->result();
+ }
+
+ //订单号查询不到尝试使用团号查询
+ if (empty($result) && $ordertype == 'B') {
+ $sql = "SELECT TOP 2 0 as order_type,COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_Department,COLI_State $fieldsql from BIZ_ConfirmLineInfo
+ LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
+ where COLI_GroupCode like '%-$COLI_ID%'";
+ $query = $this->HT->query($sql);
+ $result = $query->result();
+ }
+ //团号查询不到尝试使用客人邮箱查询(预订多次的老客户得按日期新旧排序,取最新的数据)
+
+ if (!empty($result) && is_array($result) ) {
+ //print_r($result[0]);
+ //die();
+ if (count($result) > 1) {
+ $result = array();
+ } else {
+ $result = $result[0];
+ }
+ }
+
+ return $result;
+ }
+
+ public function if_biz_gai_exists($GAI_AccreditNo)
+ {
+ $sql = " SELECT TOP 1 1 FROM BIZ_GroupAccountInfo
+ WHERE (GAI_AccreditNo = ? OR GAI_Memo LIKE '%$GAI_AccreditNo%')
+ AND DeleteFlag=0";
+ $result = $this->HT->query($sql, array($GAI_AccreditNo));
+ return ($result->num_rows() > 0);
+ }
+
+ //修改订单状态
+ public function update_biz_coli_state($coli_sn, $coli_state) {
+ $sql = "
+ IF EXISTS
+ ( SELECT OPI_DEI_SN
+ FROM OperatorInfo
+ INNER JOIN BIZ_ConfirmLineInfo ON OPI_SN=COLI_OPI_ID
+ WHERE COLI_SN=? AND OPI_DEI_SN=10
+ )
+ UPDATE BIZ_ConfirmLineInfo
+ SET COLI_State=?
+ WHERE COLI_SN=?
+ ELSE
+ UPDATE BIZ_ConfirmLineInfo
+ SET COLI_State=? WHERE COLI_SN=?
+ AND COLI_State IN (0,1,9,11,12,13,14,40,50,60,101,102,999)
+ ";
+ $query = $this->HT->query($sql, array($coli_sn, $coli_state, $coli_sn, $coli_state, $coli_sn));
+ return $query;
+ }
+
+ /** 写入商务订单操作记录 */
+ public function insert_biz_order_log($coli_sn, $log_info)
+ {
+ $db_column = array(
+ "BOL_COLI_SN" => $coli_sn
+ ,"BOL_OPI_SN" => 0
+ ,"BOL_OPType" => $log_info
+ ,"BOL_OPTime" => date('Y-m-d H:i:s')
+ ,"BOL_Creator" => 0
+ ,"BOL_CreateTime" => date('Y-m-d H:i:s')
+ );
+ return $this->HT->insert("BIZ_OrderOperationLog", $db_column);
+ }
+
+ /*!
+ * 更新订单主表付款方式,防止没访问thankyou-train.asp
+ * @author LYT
+ * @date 2017-11-27
+ */
+ public function update_paymanner($COLI_SN, $paymanner = '15010')
+ {
+ $sql = "UPDATE BIZ_ConfirmLineInfo SET COLI_PayManner = ? WHERE COLI_SN=? ";
+ $query = $this->HT->query($sql, array($paymanner, $COLI_SN));
+ 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) {
+ //先判断是否有这条数据
+ $sql = "
+
+ IF NOT EXISTS(
+ SELECT TOP 1 1
+ FROM BIZ_GroupAccountInfo
+ WHERE (GAI_AccreditNo = ? OR GAI_Memo LIKE '%$GAI_AccreditNo%') AND DeleteFlag=0
+ )
+ INSERT INTO BIZ_GroupAccountInfo (
+ GAI_COLI_SN
+ ,GAI_COLI_ID
+ ,GAI_Type
+ ,GAI_SQJE
+ ,GAI_SQDate
+ ,GAI_SQJECurrency
+ ,GAI_SSJE
+ ,GAI_SSDate
+ ,GAI_AccountDate
+ ,GAI_SubmitDate
+ ,GAI_CusName
+ ,GAI_CusEmail
+ ,GAI_AccreditNo
+ ,GAI_Memo
+ ,GAI_State
+ ,DeleteFlag
+ ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,0)";
+ $query = $this->HT->query($sql, array($GAI_AccreditNo, $GAI_COLI_SN, $GAI_COLI_ID, $payment_method, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo));
+ $insertid = $this->HT->last_id('BIZ_GroupAccountInfo');
+ return $query;
+ }
+
+ //添加收款记录(商务订单),APP会自动增加记录,所以添加前根据金额来判断是否有重复记录
+ public function add_account_info_forAPP($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) {
+ //先判断是否有这条数据
+ $sql = "
+ IF NOT EXISTS(
+ SELECT TOP 1 1
+ FROM BIZ_GroupAccountInfo
+ WHERE GAI_COLI_SN = ? AND GAI_SQJE=? AND DeleteFlag=0 AND GAI_Type=?
+ )
+ INSERT INTO BIZ_GroupAccountInfo (
+ GAI_COLI_SN
+ ,GAI_COLI_ID
+ ,GAI_Type
+ ,GAI_SQJE
+ ,GAI_SQDate
+ ,GAI_SQJECurrency
+ ,GAI_SSJE
+ ,GAI_SSDate
+ ,GAI_AccountDate
+ ,GAI_SubmitDate
+ ,GAI_CusName
+ ,GAI_CusEmail
+ ,GAI_AccreditNo
+ ,GAI_Memo
+ ,GAI_State
+ ,DeleteFlag
+ ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,0)";
+ $query = $this->HT->query($sql, array($GAI_COLI_SN, $GAI_SQJE, $payment_method, $GAI_COLI_SN, $GAI_COLI_ID, $payment_method, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo));
+ $insertid = $this->HT->last_id('BIZ_GroupAccountInfo');
+ return $query;
+ }
+
+ //添加收款记录(传统订单)
+ public function add_tour_account_info($GAI_COLI_SN, $payment_method, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo) {
+ //先判断是否有这条数据
+ $sql = "
+
+ IF NOT EXISTS(
+ SELECT TOP 1 1
+ FROM GroupAccountInfo
+ WHERE (GAI_AccreditNo = ? OR GAI_Memo LIKE '%$GAI_AccreditNo%') and DeleteFlag=0
+ )
+ INSERT INTO GroupAccountInfo (
+ GAI_COLI_SN
+ ,GAI_Type
+ ,GAI_SQJE
+ ,GAI_SQDate
+ ,GAI_SQJECurrency
+ ,GAI_SSJE
+ ,GAI_SSDate
+ ,GAI_AccountDate
+ ,GAI_SubmitDate
+ ,GAI_CusName
+ ,GAI_CusEmail
+ ,GAI_AccreditNo
+ ,GAI_Memo
+ ,GAI_State
+ ,DeleteFlag
+ ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,0,0)";
+ $query = $this->HT->query($sql, array($GAI_AccreditNo, $GAI_COLI_SN, $payment_method, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo));
+ $insertid = $this->HT->last_id('GroupAccountInfo');
+ return $insertid;
+ }
+
+ //更新线路提醒
+ public function update_coli_introduction($coli_sn, $msg) {
+ $sql = "
+ update ConfirmLineInfo
+ set COLI_Introduction=ISNULL(COLI_Introduction,'')+' '+?
+ where 1=1
+ AND ISNULL(COLI_Introduction,'')=''
+ AND COLI_SN=?
+ ";
+ // isnull(COLI_Sended,0) in (0,1) 之前判断是新订单或者未分配状态才添加提示的,有些团是后面付款的,所以把限制取消掉
+ $query = $this->HT->query($sql, array($msg, $coli_sn));
+ return $query;
+ }
+
+ /** JJH: 添加订单收款记录之后执行 */
+ public function exec_addToTask($GAI_SN)
+ {
+ $sql = " if not exists (
+ select top 1 1 from Sysautotask
+ where SAT_Type=1 and SAT_SourceSN=$GAI_SN
+ ) exec SP_AddToSystask 1," . $GAI_SN;
+ $query = $this->HT->query($sql);
+ return $query;
+ }
+
+ public function save_automail($fromName, $fromEmail, $toName, $toEmail, $subject, $body, $M_RelatedInfo = '', $M_State = 0, $M_AddTime = '', $frominfo = 'paypal msg', $M_Web = 'paypal msg') {
+ $sql = "INSERT INTO
+ Email_AutomaticSend (
+ M_ReplyToName,
+ M_ReplyToEmail,
+ M_ToName,
+ M_ToEmail,
+ M_Title,
+ M_Body,
+ M_Web,
+ M_FromName,
+ M_ServiceSN,
+ M_State,
+ M_AddTime
+ ) VALUES (N?, N?, N?, N?, N?, N?, ?, N?, ?,?,getdate()) ";
+ $query = $this->HT->query($sql, array($fromName, $fromEmail, $toName, $toEmail, $subject, $body, $M_Web, $frominfo, $M_RelatedInfo, $M_State));
+ return $query;
+ }
+
}
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 86f4a9cc..5d0205e3 100644
--- a/webht/third_party/pay/models/Online_payment_note_model.php
+++ b/webht/third_party/pay/models/Online_payment_note_model.php
@@ -25,44 +25,65 @@ class Online_payment_note_model extends CI_Model {
return TRUE;
}
+ public function update_send($id, $transactionId, $send)
+ {
+ $column = array("OPN_noticeSendStatus" => $send, "OPN_noticeSendTime" => date('Y-m-d H:i:s'));
+ $where = " OPN_transactionId = '$transactionId' AND OPN_SN=" . $id;
+ return $this->update_note($where, $column);
+ }
+
+ //设置订单号
+ public function set_invoice($id, $pn_invoice)
+ {
+ $column = array("OPN_orderId" => $send);
+ $where = " OPN_SN=" . $id;
+ return $this->update_note($where, $column);
+ }
+
public $topnum = false;
public $orderby = false;
public $send = false;
public $search = false;
public $transactionId = false;
public $payment_status = false;
+ // public $payment_method = 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 ';
+ // if ($GLOBALS['__PAYMENT_METHOD_CODE__']) {
+ // $this->payment_method = ' AND opn.OPN_accountMethod = ' . $GLOBALS['__PAYMENT_METHOD_CODE__'] . ' ';
+ // }
+ $this->orderby = ' ORDER BY OPN_SN DESC ';
}
public function query_note()
{
$top_sql = $this->topnum ? (" TOP " . $this->topnum) : "";
- $sql .= "SELECT $top_sql opn.*
+ $sql = "SELECT $top_sql opn.*
FROM [InfoManager].[dbo].[OnlinePaymentNote] opn
WHERE 1=1 ";
+ // $this->payment_method ? $sql.=$this->payment_method : false;
$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);
+ $query = $this->info->query($sql);
return $query->result();
}
- public function get_note($payment_method=NULL, $transactionId=null)
+ public function get_note($transactionId)
{
$this->init_query();
$this->topnum=1;
- $this->transactionId = " AND opn.OPN_transactionId=" . $this->INFO->escape($transactionId);
+ $this->transactionId = " AND opn.OPN_transactionId=" . $this->info->escape($transactionId);
return $this->query_note();
}
- public function unsend_note($payment_method=NULL, $num=2)
+ public function unsend_note($num=2)
{
$this->init_query();
$this->topnum = $num;
@@ -70,7 +91,7 @@ class Online_payment_note_model extends CI_Model {
return $this->query_note();
}
- public function sendfail_note($payment_method=NULL, $num=2)
+ public function sendfail_note($num=2)
{
$this->init_query();
$this->topnum = $num;