ipaylinks支付失败时不反悔交易号,导致查询错误

hotfix/远程访问多媒体中心
lyt 8 years ago
parent 7959c035aa
commit 1996e112ee

@ -379,7 +379,7 @@ class IPayLinksService extends CI_Controller
$this->IPayLinks_model->add_account_info( $this->IPayLinks_model->add_account_info(
$GAI_COLI_SN, $GAI_COLI_SN,
$advisor_info->COLI_ID, $advisor_info->COLI_ID,
$item->IPL_payAmount, $item->IPL_orderAmount,
$item->IPL_completeTime, $item->IPL_completeTime,
mb_strtoupper($item->IPL_currencyCode), mb_strtoupper($item->IPL_currencyCode),
$item->IPL_completeTime, $item->IPL_completeTime,
@ -397,7 +397,7 @@ class IPayLinksService extends CI_Controller
$GAI_COLI_SN = isset($advisor_info->COLI_SN) ? $advisor_info->COLI_SN : 0; $GAI_COLI_SN = isset($advisor_info->COLI_SN) ? $advisor_info->COLI_SN : 0;
$this->IPayLinks_model->add_tour_account_info( $this->IPayLinks_model->add_tour_account_info(
$GAI_COLI_SN, $GAI_COLI_SN,
$item->IPL_payAmount, $item->IPL_orderAmount,
$item->IPL_acquiringTime, $item->IPL_acquiringTime,
mb_strtoupper($item->IPL_currencyCode), mb_strtoupper($item->IPL_currencyCode),
$item->IPL_completeTime, $item->IPL_completeTime,
@ -408,7 +408,7 @@ class IPayLinksService extends CI_Controller
$ht_memo $ht_memo
); );
//添加汉特的订单提醒 //添加汉特的订单提醒
$this->IPayLinks_model->update_coli_introduction($GAI_COLI_SN, '已支付 ' . mb_strtoupper($item->IPL_currencyCode) . $item->IPL_payAmount); $this->IPayLinks_model->update_coli_introduction($GAI_COLI_SN, '已支付 ' . mb_strtoupper($item->IPL_currencyCode) . $item->IPL_orderAmount);
} }
} }
@ -427,7 +427,7 @@ class IPayLinksService extends CI_Controller
$fromEmail = ''; $fromEmail = '';
$toName = !empty($opi_firstname) ? $opi_firstname : ''; $toName = !empty($opi_firstname) ? $opi_firstname : '';
$toEmail = !empty($opi_email) ? $opi_email : ''; $toEmail = !empty($opi_email) ? $opi_email : '';
$subject = $orderid_info->orderid . '_' . $orderid_info->ordertype . ' / ' . $item->IPL_payAmount . $item->IPL_currencyCode . ' / ' . $fromName; $subject = $orderid_info->orderid . '_' . $orderid_info->ordertype . ' / ' . $item->IPL_orderAmount . $item->IPL_currencyCode . ' / ' . $fromName;
$body = $this->load->view('receipt_mail', $item, true); $body = $this->load->view('receipt_mail', $item, true);
$M_RelatedInfo = $item->IPL_sn; $M_RelatedInfo = $item->IPL_sn;
$M_AddTime = $item->IPL_completeTime; $M_AddTime = $item->IPL_completeTime;
@ -549,7 +549,7 @@ class IPayLinksService extends CI_Controller
echo "200"; echo "200";
return; return;
} }
$dealId = trim($asyns_resp->data->dealId); $dealId = trim($asyns_resp->data->dealId) ? trim($asyns_resp->data->dealId) : $this->create_guid();
bcscale(2); bcscale(2);
$this->Note_model->save_ipl( $this->Note_model->save_ipl(
strval($dealId) strval($dealId)
@ -566,7 +566,7 @@ class IPayLinksService extends CI_Controller
,strval($asyns_resp->data->resultMsg) ,strval($asyns_resp->data->resultMsg)
); );
// 查询支付结果;入库处理 // 查询支付结果;入库处理
if ( ! empty($asyns_resp->data->dealId)) { if ( ! empty(trim($asyns_resp->data->dealId))) {
$query = $this->query_pay_result($asyns_resp->data); $query = $this->query_pay_result($asyns_resp->data);
} }
// 返回状态码200 // 返回状态码200
@ -641,29 +641,32 @@ class IPayLinksService extends CI_Controller
if (is_array($resp)) { if (is_array($resp)) {
// 异步通知接收到的是post数组 // 异步通知接收到的是post数组
$ret->data = $respObject = (Object) $resp; $ret->data = $respObject = (Object) $resp;
$ref = "";
} else { } else {
$ref = $_SERVER['HTTP_REFERER'];
$r = iconv("UTF-8", "UTF-8//IGNORE", $resp); $r = iconv("UTF-8", "UTF-8//IGNORE", $resp);
$ret->data = $respObject = @ simplexml_load_string($resp); $ret->data = $respObject = @ simplexml_load_string($resp);
// test // test
// log_message("error", "xml result: \n $resp"); // log_message("error", "xml result: \n $resp");
if (false === $respObject) { if (false === $respObject) {
log_message('error','iPayLinks return ERROR ! Unknow ERROR ! Original return:'.$resp."; From: ".$_SERVER['HTTP_REFERER']); log_message('error','iPayLinks return ERROR ! Unknow ERROR ! Original return:'.$resp."; From: ".$ref);
return $ret; return $ret;
} }
} }
$rep_sign = $this->generate_sign((array)$respObject); $rep_sign = $this->generate_sign((array)$respObject);
if (strcmp($rep_sign,$respObject->signMsg)) { if (strcmp($rep_sign,$respObject->signMsg)) {
log_message('error','iPayLinks sign ERROR ! orderId:'.$respObject->orderId.'; dealId:'.$respObject->dealId . "; Original return:".$resp."; From: ".$_SERVER['HTTP_REFERER']); log_message('error','iPayLinks sign ERROR ! orderId:'.$respObject->orderId.'; dealId:'.$respObject->dealId . "; Original return:".$resp."; From: ".$ref);
return $ret; return $ret;
} }
// partnerId // partnerId
if (strcmp($respObject->partnerId, $this->pay_info_arr['partnerId'])) { if (strcmp($respObject->partnerId, $this->pay_info_arr['partnerId'])) {
log_message("error", " iPayLinks ERROR partnerId verify failed ".$respObject->partnerId." !== ".$this->pay_info_arr['partnerId'].'; orderId:'.$respObject->orderId.'; dealId:'.$respObject->dealId."; From: ".$_SERVER['HTTP_REFERER']); log_message("error", " iPayLinks ERROR partnerId verify failed ".$respObject->partnerId." !== ".$this->pay_info_arr['partnerId'].'; orderId:'.$respObject->orderId.'; dealId:'.$respObject->dealId."; From: ".$ref);
return $ret; return $ret;
} }
// resultCode payment failed // resultCode payment failed
if (strcmp(strval($respObject->resultCode), "0000")) { if (strcmp(strval($respObject->resultCode), "0000")) {
log_message('error',"iPayLinks payment failed! error code:".$respObject->resultCode."; result Msg: ".$respObject->resultMsg.'; orderId:'.$respObject->orderId.'; dealId:'.$respObject->dealId."; From: ".$_SERVER['HTTP_REFERER']); log_message('error',"iPayLinks payment failed! error code:".$respObject->resultCode."; result Msg: ".$respObject->resultMsg.'; orderId:'.$respObject->orderId.'; dealId:'.$respObject->dealId."; From: ".$ref);
} }
$ret->check = true; $ret->check = true;
return $ret; return $ret;
@ -783,7 +786,7 @@ class IPayLinksService extends CI_Controller
} }
//获取note详情以便后续修改各项数据 //获取note详情以便后续修改各项数据
public function note_modal($pn_txn_id, $pn_invoice = false) { public function note_modal($pn_txn_id = false, $pn_invoice = false ,$notice_time = false) {
$data = array(); $data = array();
$data['IPL_orderId'] = $pn_invoice; $data['IPL_orderId'] = $pn_invoice;
if (!empty($pn_txn_id)) { if (!empty($pn_txn_id)) {
@ -806,6 +809,29 @@ class IPayLinksService extends CI_Controller
echo json_encode('没找到数据!'); echo json_encode('没找到数据!');
return; return;
} }
public function note_order_modal($old_order,$pn_invoice = false ,$notice_time = false) {
$data = array();
$data['IPL_orderId'] = $pn_invoice;
if (!empty($pn_invoice)) {
$data['note'] = $this->Note_model->note_order($old_order,$notice_time);
if (!empty($data['note'])) {
if (!empty($pn_invoice)) {
$orderid_info = $this->analysis_orderid($pn_invoice);
} else {
$orderid_info = $this->analysis_orderid($data['note']->IPL_orderId);
}
if (!empty($orderid_info)) {
$orderid_info = json_decode($orderid_info);
$data['order_info'] = $this->IPayLinks_model->get_order($orderid_info->orderid, true, $orderid_info->ordertype);
}
$data["paytext"] = $this->payment_status();
echo json_encode($this->load->view('note_setting', $data, true));
return true;
}
}
echo json_encode('没找到数据!');
return;
}
//关闭note通知用于手动处理通知后 //关闭note通知用于手动处理通知后
public function close_note($pn_txn_id) { public function close_note($pn_txn_id) {
@ -846,6 +872,9 @@ class IPayLinksService extends CI_Controller
//用于HT--交易详情 //用于HT--交易详情
public function receipt($pm_transaction_id) { public function receipt($pm_transaction_id) {
if ( ! $pm_transaction_id) {
return false;
}
$data = array(); $data = array();
$data = $this->Note_model->note($pm_transaction_id); $data = $this->Note_model->note($pm_transaction_id);
$this->load->view('receipt_mail', $data); $this->load->view('receipt_mail', $data);

@ -42,7 +42,7 @@ class Note_model extends CI_Model {
public function search_date($date) { public function search_date($date) {
$this->init(); $this->init();
$search_sql = " AND pn.IPL_completeTime BETWEEN '$date 00:00:00' AND '$date 23:59:59' "; $search_sql = " AND pn.IPL_noticeTime BETWEEN '$date 00:00:00' AND '$date 23:59:59' ";
$this->search = $search_sql; $this->search = $search_sql;
$this->orderby=" ORDER BY CASE pn.IPL_sent WHEN 'sendfail' THEN 1 ELSE 2 END ,pn.IPL_sn DESC "; $this->orderby=" ORDER BY CASE pn.IPL_sent WHEN 'sendfail' THEN 1 ELSE 2 END ,pn.IPL_sn DESC ";
return $this->get_list(); return $this->get_list();
@ -55,6 +55,14 @@ class Note_model extends CI_Model {
return $this->get_list(); return $this->get_list();
} }
public function note_order($orderid,$notice_time)
{
$this->init();
$this->topnum=1;
$this->dealId=" AND pn.IPL_orderId=".$this->INFO->escape($orderid)." AND pn.IPL_noticeTime=".$this->INFO->escape($notice_time);
return $this->get_list();
}
public function search_key($search_key) { public function search_key($search_key) {
$this->init(); $this->init();
$this->topnum = 300; //限制最大数量,防止查询单词过短 $this->topnum = 300; //限制最大数量,防止查询单词过短
@ -81,7 +89,7 @@ class Note_model extends CI_Model {
* @author LYT <lyt@hainatravel.com> * @author LYT <lyt@hainatravel.com>
* @date 2017-08-29 * @date 2017-08-29
*/ */
public function save_ipl($IPL_dealId,$IPL_orderId,$IPL_currencyCode,$IPL_orderAmount,$IPL_payAmount,$IPL_stateCode,$IPL_acquiringTime,$IPL_completeTime,$IPL_memo,$IPL_payType,$IPL_resultCode=null,$IPL_resultMsg=null) { public function save_ipl($IPL_dealId,$IPL_orderId,$IPL_currencyCode,$IPL_orderAmount,$IPL_payAmount,$IPL_stateCode,$IPL_acquiringTime,$IPL_completeTime,$IPL_memo,$IPL_payType,$IPL_resultCode,$IPL_resultMsg) {
$sql = " $sql = "
INSERT INTO IPayLinksLog INSERT INTO IPayLinksLog
( (
@ -89,7 +97,7 @@ class Note_model extends CI_Model {
) )
VALUES VALUES
( (
?,?,?,?,?,?,?,?,?,'unsend', GETDATE(),?,?,? ?,?,?,?,?,?,?,?,?,'unsend', GETDATE(),?,?,N?
) )
"; ";
$query = $this->INFO->query($sql, $query = $this->INFO->query($sql,
@ -103,8 +111,6 @@ class Note_model extends CI_Model {
,$IPL_completeTime ,$IPL_completeTime
,$IPL_memo ,$IPL_memo
,$IPL_payType ,$IPL_payType
,$IPL_payer
,$IPL_payerEmail
,$IPL_resultCode ,$IPL_resultCode
,$IPL_resultMsg ,$IPL_resultMsg
)); ));

@ -93,7 +93,7 @@
<li class="col-sm-2 "><strong>#</strong></li> <li class="col-sm-2 "><strong>#</strong></li>
<li class="col-sm-7 "><strong>主题</strong></li> <li class="col-sm-7 "><strong>主题</strong></li>
<li class="col-sm-4 "><strong>交易号</strong></li> <li class="col-sm-4 "><strong>交易号</strong></li>
<li class="col-sm-3 "><strong>款(北京)时间</strong></li> <li class="col-sm-3 "><strong>时间</strong></li>
<li class="col-sm-3 "><strong>通知时间</strong></li> <li class="col-sm-3 "><strong>通知时间</strong></li>
<li class="col-sm-3 "><strong>通知状态</strong></li> <li class="col-sm-3 "><strong>通知状态</strong></li>
</a> </a>
@ -105,7 +105,11 @@
<li class="col-sm-2 nopadding-L" style="overflow:hidden;word-break: break-all;height: 25px;"><?php echo ($key + 1); ?></li> <li class="col-sm-2 nopadding-L" style="overflow:hidden;word-break: break-all;height: 25px;"><?php echo ($key + 1); ?></li>
<li class="col-sm-7 nopadding-L" style="overflow:hidden;word-break: break-all;height: 25px;"> <li class="col-sm-7 nopadding-L" style="overflow:hidden;word-break: break-all;height: 25px;">
<?php if ($item->IPL_dealId) { ?>
<a class="seen" target="_blank" href="http://www.mycht.cn/webht.php/apps/pay/ipaylinksservice/receipt/<?php echo $item->IPL_dealId; ?>"> <a class="seen" target="_blank" href="http://www.mycht.cn/webht.php/apps/pay/ipaylinksservice/receipt/<?php echo $item->IPL_dealId; ?>">
<?php } else {?>
<a class="seen" target="_blank" href="#">
<?php } ?>
<?php echo $item->IPL_orderId . ' / ' . $item->IPL_payAmount . $item->IPL_currencyCode; ?> <?php echo $item->IPL_orderId . ' / ' . $item->IPL_payAmount . $item->IPL_currencyCode; ?>
</a></li> </a></li>
@ -126,7 +130,7 @@
$class_css = 'btn-danger'; $class_css = 'btn-danger';
$show_send = $item->IPL_sent; $show_send = $item->IPL_sent;
} }
?><a href="javascript:void(0);" title="<?php echo $item->IPL_resultMsg; ?>" onclick="show_order_modal('<?php echo $item->IPL_dealId; ?>', '<?php echo $item->IPL_orderId; ?>')" class="btn btn-sm <?php echo $class_css; ?>"><?php echo $show_send; ?></a> ?><a href="javascript:void(0);" title="<?php echo $item->IPL_resultMsg; ?>" onclick="show_order_modal('<?php echo $item->IPL_dealId; ?>', '<?php echo $item->IPL_orderId; ?>','<?php echo $item->IPL_noticeTime; ?>','<?php echo $item->IPL_orderId; ?>')" class="btn btn-sm <?php echo $class_css; ?>"><?php echo $show_send; ?></a>
</li> </li>
</ul> </ul>
@ -182,11 +186,25 @@
$(".ui-datepicker").css('width', '15.7em'); $(".ui-datepicker").css('width', '15.7em');
}); });
function show_order_modal(pn_txn_id, pn_invoice) { function show_order_modal(pn_txn_id, pn_invoice,noticeTime,old_order) {
if (pn_txn_id) {
$.ajax({
type: "get",
dataType: "json",
url: 'http://www.mycht.cn/webht.php/apps/pay/ipaylinksservice/note_modal/' + pn_txn_id + '/' + pn_invoice + '/' + noticeTime,
success: function(data, textStatus) {
$('#modal_set_orderid_body').html(data);
$('#modal_set_orderid').modal('show');
},
error: function(msg) {
alert('\u53d1\u751f\u9519\u8bef\uff0c\u8bf7\u8054\u7cfbYCC...');
}
});
} else {
$.ajax({ $.ajax({
type: "get", type: "get",
dataType: "json", dataType: "json",
url: 'http://www.mycht.cn/webht.php/apps/pay/ipaylinksservice/note_modal/' + pn_txn_id + '/' + pn_invoice, url: '/webht.php/apps/pay/ipaylinksservice/note_order_modal/' + old_order + '/' + pn_invoice + '/' + noticeTime,
success: function(data, textStatus) { success: function(data, textStatus) {
$('#modal_set_orderid_body').html(data); $('#modal_set_orderid_body').html(data);
$('#modal_set_orderid').modal('show'); $('#modal_set_orderid').modal('show');
@ -196,6 +214,7 @@
} }
}); });
} }
}
function close_note() { function close_note() {
var pn_txn_id = $('#pn_txn_id').val(); var pn_txn_id = $('#pn_txn_id').val();

@ -2,15 +2,15 @@
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>交易号</dt> <dt>交易号</dt>
<dd><?php echo $note->IPL_dealId ?> ( <?php echo $paytext[intval(trim($note->IPL_stateCode))]; ?> )</dd> <dd><?php echo $note->IPL_dealId ?> ( <?php echo $paytext[intval(trim($note->IPL_stateCode))].".".$note->IPL_resultMsg; ?> )</dd>
</dl> </dl>
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>付款金额</dt> <dt>付款金额</dt>
<dd><?php echo $note->IPL_currencyCode . ' ' . $note->IPL_payAmount ?></dd> <dd><?php echo $note->IPL_currencyCode . ' ' . $note->IPL_orderAmount ?></dd>
</dl> </dl>
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>付款时间</dt> <dt>付款时间</dt>
<dd><?php echo $note->IPL_completeTime; ?></dd> <dd><?php echo $note->IPL_acquiringTime; ?></dd>
</dl> </dl>
@ -19,7 +19,7 @@
<dd> <dd>
<div class="input-group"> <div class="input-group">
<input type="text" class="form-control" id="pn_invoice" name="pn_invoice" value="<?php echo!empty($IPL_orderId) ? $IPL_orderId : $note->IPL_orderId; ?>"> <input type="text" class="form-control" id="pn_invoice" name="pn_invoice" value="<?php echo!empty($IPL_orderId) ? $IPL_orderId : $note->IPL_orderId; ?>">
<span class="input-group-addon search-btn" onclick="show_order_modal('<?php echo $note->IPL_dealId; ?>', $('#pn_invoice').val())"></span> <span class="input-group-addon search-btn" onclick="show_order_modal('<?php echo $note->IPL_dealId; ?>', $('#pn_invoice').val(),'<?php echo $note->IPL_noticeTime; ?>','<?php echo $note->IPL_orderId; ?>')"></span>
</div> </div>
<label class="text-danger">订单号形如: 160414408_B , B商务订单JJ160321052_T,T传统订单请务必加上后缀</label> <label class="text-danger">订单号形如: 160414408_B , B商务订单JJ160321052_T,T传统订单请务必加上后缀</label>
</dd> </dd>

Loading…
Cancel
Save