ipaylinks 多次付款失败后成功的异步通知未成功,退款不处理,交易失败不处理

feature/trippest
lyt 7 years ago
parent 5cdef0d34f
commit 4c9fb41945

@ -257,13 +257,14 @@ class IPayLinksService extends CI_Controller
return;
}
public function query_pay($day_offset = 3, $orderid=NULL)
public function query_pay($day_offset = 1, $orderid=NULL)
{
$this->query_info_arr["queryOrderId"] = $this->create_guid();
$this->query_info_arr["orderId"] = $orderid;
$this->query_info_arr["beginTime"] = date('YmdHis',strtotime("-$day_offset days"));
$this->query_info_arr["endTime"] = date('YmdHis',strtotime("+$day_offset days"));
$this->query_info_arr["mode"] = 1;
// $this->query_info_arr["beginTime"] = date('YmdHis',strtotime("-$day_offset days"));
// $this->query_info_arr["endTime"] = date('YmdHis',strtotime("+$day_offset days"));
$this->query_info_arr["mode"] = 1;
// $this->query_info_arr["type"] = $day_offset; // 1-支付;2-退款
$this->query_info_arr["signMsg"] = $this->generate_sign($this->query_info_arr);
$resp = $this->curl($this->queryUrl,$this->query_info_arr);
@ -610,10 +611,11 @@ class IPayLinksService extends CI_Controller
log_message('error','iPayLinks asyn notify: ' . $this->input->post("orderId"));
$asyns_resp = $this->verify_sign($resp_arr);
}
log_message('error','iPayLinks asyn notify body: ' . json_encode($asyns_resp->data));
// 未得到结果
if (empty($asyns_resp->data->orderId)) {
return;
}
// if (empty($asyns_resp->data->orderId)) {
// return;
// }
// dealId
$dealId = trim($asyns_resp->data->dealId) ;
$tmp_deal = $dealId ? $dealId : $this->create_guid();
@ -634,7 +636,7 @@ class IPayLinksService extends CI_Controller
, strval(date('Y-m-d H:i:s',strtotime($asyns_resp->data->refundTime)))
, strval(date('Y-m-d H:i:s',strtotime($asyns_resp->data->completeTime)))
, $asyns_resp->data->resultCode
, "0000"
, null
, json_encode($asyns_resp->data)
, "refund"
);
@ -643,7 +645,7 @@ class IPayLinksService extends CI_Controller
// 支付成功
// 查询支付结果;入库处理
if ( ! empty($dealId)) {
// if ( ! empty($dealId)) {
$this->Note_model->save_ipl(
strval($tmp_deal)
,strval($asyns_resp->data->orderId)
@ -661,7 +663,7 @@ class IPayLinksService extends CI_Controller
,strval($payer_email)
);
$query = $this->query_pay_result($asyns_resp->data);
}
// }
// 返回状态码200
return;
}
@ -1009,7 +1011,7 @@ class IPayLinksService extends CI_Controller
, strval(date('Y-m-d H:i:s',strtotime($refund->refundTime)))
, strval(date('Y-m-d H:i:s',strtotime($refund->completeTime)))
, $refund->stateCode
, "0000"
, ($refund->stateCode==2) ? "0000" : null
, json_encode($refund)
, "refund"
);
@ -1297,4 +1299,17 @@ class IPayLinksService extends CI_Controller
$objWriter->save('php://output');
}
public function sign_fun()
{
$req = $this->input->post();
$str = $this->generate_sign($req);
return $this->output->set_content_type('application/json')->set_output(json_encode(array("str" => $str)));
}
public function test()
{
$this->Note_model->test();
return ;
}
}

@ -5,12 +5,12 @@ if (!defined('BASEPATH'))
class Note_model extends CI_Model {
var $topnum = false;
var $orderby = false;
var $send = false;
var $search = false;
var $dealId = false;
var $payment_status = false;
var $topnum = null;
var $orderby = null;
var $send = null;
var $search = null;
var $dealId = null;
var $payment_status = null;
function __construct() {
parent::__construct();
@ -18,12 +18,12 @@ class Note_model extends CI_Model {
}
public function init() {
$this->topnum = false;
$this->send = false;
$this->search = false;
$this->payment_status = false;
$this->dealId = false;
$this->orderby = ' ORDER BY pn.IPL_sn DESC ';
$this->topnum = null;
$this->send = null;
$this->search = null;
$this->payment_status = null;
$this->dealId = null;
$this->orderby = ' ORDER BY IPL_sn DESC ';
}
public function unsend($topnum = 2) {
@ -42,16 +42,16 @@ class Note_model extends CI_Model {
public function search_date($date) {
$this->init();
$search_sql = " AND (pn.IPL_noticeTime BETWEEN '$date 00:00:00' AND '$date 23:59:59' or IPL_sent<>'send') ";
$search_sql = " AND (IPL_noticeTime BETWEEN '$date 00:00:00' AND '$date 23:59:59' or IPL_sent<>'send') ";
$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 IPL_sent DESC ,IPL_sn DESC ";
return $this->get_list();
}
public function note($txn_id){
$this->init();
$this->topnum=1;
$this->dealId=" AND pn.IPL_dealId=".$this->INFO->escape($txn_id);
$this->dealId=" AND IPL_dealId=".$this->INFO->escape($txn_id);
return $this->get_list();
}
@ -59,7 +59,7 @@ class Note_model extends CI_Model {
{
$this->init();
$this->topnum=1;
$this->dealId=" AND pn.IPL_orderId=".$this->INFO->escape($orderid)." AND pn.IPL_noticeTime=".$this->INFO->escape($notice_time);
$this->dealId=" AND IPL_orderId=".$this->INFO->escape($orderid)." AND IPL_noticeTime=".$this->INFO->escape($notice_time);
return $this->get_list();
}
@ -69,9 +69,9 @@ class Note_model extends CI_Model {
$search_sql = '';
$search_key = trim($search_key);
if (!empty($search_key)) {
$search_sql.=" AND ( pn.IPL_dealId = '$search_key'
OR pn.IPL_orderId like '%$search_key%'
OR pn.IPL_memo like '%$search_key%' )";
$search_sql.=" AND ( IPL_dealId = '$search_key'
OR IPL_orderId like '%$search_key%'
OR IPL_memo like '%$search_key%' )";
}
$this->search = $search_sql;
return $this->get_list();
@ -81,7 +81,7 @@ class Note_model extends CI_Model {
{
$this->init();
$this->topnum = 1;
$this->search = " AND pn.IPL_dealId = '".$dealId."' ";
$this->search = " AND IPL_dealId = '".$dealId."' ";
return $this->get_list();
}
@ -124,31 +124,23 @@ class Note_model extends CI_Model {
public function get_list() {
$this->topnum ? $sql = "SELECT TOP " . $this->topnum : $sql = "SELECT ";
$sql .= "
pn.IPL_sn
,pn.IPL_dealId
,pn.IPL_orderId
,pn.IPL_currencyCode
,pn.IPL_orderAmount
,pn.IPL_payAmount
,pn.IPL_stateCode
,pn.IPL_resultCode
,pn.IPL_resultMsg
,pn.IPL_acquiringTime
,pn.IPL_completeTime
,pn.IPL_memo
,pn.IPL_sent
,pn.IPL_payType
,pn.IPL_noticeTime
,pn.IPL_payerName
,pn.IPL_payerEmail
pn.*
FROM IPayLinksLog pn
WHERE 1=1
AND IPL_stateCode<>3
";
$this->send ? $sql.=$this->send : false;
$this->search ? $sql.=$this->search : false;
$this->dealId ? $sql.=$this->dealId : false;
$this->orderby ? $sql.=$this->orderby : false;
and pn.IPL_payType='pay'
and (pn.IPL_stateCode=2 or pn.IPL_resultCode='0000')
$this->send
$this->search
$this->dealId
UNION ALL
select * from InfoManager.dbo.IPayLinksLog ipl2
where 1=1
and ipl2.IPL_payType='refund'
and ipl2.IPL_stateCode=2
$this->search
$this->dealId
$this->orderby
";
$query = $this->INFO->query($sql);
if ($this->topnum === 1) {
if ($query->num_rows() > 0) {
@ -197,7 +189,7 @@ class Note_model extends CI_Model {
$sql = "IF NOT EXISTS(
SELECT TOP 1 1
FROM IPayLinksLog
WHERE IPL_dealId = ?
WHERE IPL_dealId = ? AND IPL_payType='refund'
)
INSERT INTO IPayLinksLog
(
@ -277,8 +269,8 @@ class Note_model extends CI_Model {
public function date_range($from, $to, $currency=NULL)
{
$this->init();
$search_sql = " AND pn.IPL_resultCode='0000' ";
$search_sql .= " AND pn.IPL_acquiringTime BETWEEN '$from 00:00:00' AND '$to 23:59:59' ";
$search_sql = " AND IPL_resultCode='0000' ";
$search_sql .= " AND IPL_acquiringTime BETWEEN '$from 00:00:00' AND '$to 23:59:59' ";
if ( ! empty($currency)) {
$search_sql .= " AND IPL_currencyCode = '$currency' ";
}
@ -287,4 +279,11 @@ class Note_model extends CI_Model {
return $this->get_list();
}
public function test()
{
$sql = " ";
$this->INFO->query($sql);
return;
}
}

Loading…
Cancel
Save