diff --git a/sql/paydb.sql b/sql/paydb.sql index 2a46fa9..8cdf2df 100644 --- a/sql/paydb.sql +++ b/sql/paydb.sql @@ -89,7 +89,7 @@ DROP TABLE IF EXISTS `confirmed_order`; CREATE TABLE `confirmed_order` ( `idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id', `orderid` varchar(60) DEFAULT '' COMMENT '订单id', - `status` int(11) NOT NULL DEFAULT '0' COMMENT '0: 新添加订单 1:已经完成订单', + `status` int(11) NOT NULL DEFAULT '0' COMMENT '0: 未确认 1:已确认', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', PRIMARY KEY (`idx`), KEY `orderid` (`orderid`) diff --git a/webapp/controller/PayNotifyController.class.php b/webapp/controller/PayNotifyController.class.php index e8c1b1d..ec92dd2 100644 --- a/webapp/controller/PayNotifyController.class.php +++ b/webapp/controller/PayNotifyController.class.php @@ -53,6 +53,7 @@ class PayNotifyController { if ($sign_info != $_REQUEST['SignInfo']) { die('sign error'); } + $nowtime = time(); $conn = $this->getMysql($_REQUEST['OrderNo']); $conn->execScript("INSERT INTO notify_his(orderid, request_data, ipv4, createtime)" . "VALUES(:orderid, :request_data, :ipv4, :createtime);", @@ -71,6 +72,16 @@ class PayNotifyController { ); if ($row) { if ($row['status'] == 0 && $row['sp_pay_result'] == 0) { + $ret = $conn->execScript('INSERT INTO confirmed_order(orderid, status, createtime)' . + 'VALUES(:orderid, :status, :createtime);', + array( + ':orderid' => $_REQUEST['OrderNo'], + ':status' => 0, + ':createtime' => 0, + )); + if (!$ret) { + die('dberror'); + } $ret = $conn->execScript('UPDATE orderinfo SET ' . ' sp_pay_result = 1, ' . ' sp_confirm_time = :sp_confirm_time, ' . @@ -79,7 +90,7 @@ class PayNotifyController { array( 'orderid' => $_REQUEST['OrderNo'], 'sp_orderid' => $_REQUEST['BillNo'], - 'sp_confirm_time' => time() + 'sp_confirm_time' => $nowtime )); if ($ret) { die('ok');