From d0edfe6970f9d1de90e642fffa214ac8064f028b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 21 Aug 2019 21:02:59 +0800 Subject: [PATCH] 1 --- sql/paydb.sql | 3 ++- webapp/controller/PayController.class.php | 30 ++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/sql/paydb.sql b/sql/paydb.sql index 8c7bfd9..f37ea6a 100644 --- a/sql/paydb.sql +++ b/sql/paydb.sql @@ -53,6 +53,8 @@ DROP TABLE IF EXISTS `orderinfo`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `orderinfo` ( `idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id', + `minigame_appid` varchar(60) DEFAULT '' COMMENT '支付小程序appid', + `minigame_accountid` varchar(60) DEFAULT '' COMMENT '支付小程序账号id(channel + "_" + gameid + "_" + openid)', `orderid` varchar(60) DEFAULT '' COMMENT '订单id', `accountid` varchar(60) DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', `channel` int(11) NOT NULL COMMENT 'channel', @@ -60,7 +62,6 @@ CREATE TABLE `orderinfo` ( `openid` varchar(50) NOT NULL COMMENT '平台openid', `itemid` int(11) NOT NULL COMMENT 'itemid', `price` double NOT NULL COMMENT 'price', - `nickname` tinyblob COMMENT 'nickname', `ipv4` varchar(50) NOT NULL DEFAULT '' COMMENT '账号创建时ipv4地址', `status` int(11) NOT NULL DEFAULT '0' COMMENT '0: 新添加订单 1:已经完成订单', `confirmtime` int(11) NOT NULL DEFAULT '0' COMMENT 'GameServer订单确认时间', diff --git a/webapp/controller/PayController.class.php b/webapp/controller/PayController.class.php index 2ee5153..7e40a4f 100644 --- a/webapp/controller/PayController.class.php +++ b/webapp/controller/PayController.class.php @@ -61,6 +61,8 @@ class PayController { } $nowtime = time(); $openid = phpcommon\extractOpenId($_REQUEST['account_id']); + $minigame_appid = self::SUB_APPID; + $minigame_accountid = $_REQUEST['account_id']; { $ipos = strpos($_REQUEST['data'], '_'); $gameid = substr($_REQUEST['data'], 0, $ipos); @@ -78,6 +80,8 @@ class PayController { die(); } $game_account_id = $jsonobj['account_id']; + $game_channel = phpcommon\extractChannel($jsonobj['account_id']); + $game_openid = phpcommon\extractOpenId($jsonobj['account_id']); $amount = $jsonobj['price']; $itemid = $jsonobj['itemid']; $itemnum = $jsonobj['itemnum']; @@ -134,7 +138,31 @@ class PayController { $xmlobj = new \SimpleXMLElement(base64_decode($response)); if ($xmlobj->RespCode == '0000') { $conn = $this->getMysql($_REQUEST['account_id']); -# $ret = $conn->execScript(); + $ret = $conn->execScript('INSERT INTO orderinfo(orderid, accountid, channel, gameid, openid, ' . + ' itemid, price, ipv4, createtime, sp_orderid, ' . + ' minigame_appid, minigame_accountid)' . + 'VALUES(:orderid, :accountid, :channel, :gameid, :openid, :itemid, ' . + ' :price, :ipv4, :createtime, :sp_orderid, :minigame_appid, :minigame_accountid);', + array( + ':orderid' => $orderid, + ':accountid' => $game_account_id, + ':openid' => $game_openid, + ':channel' => $game_channel, + ':gameid' => $gameid, + ':itemid' => $itemid, + ':price' => $amount, + ':ipv4' => phpcommon\getIPv4(), + ':createtime' => time(), + ':sp_orderid' => (string)$xmlobj->OrderNo, + ':minigame_appid' => $minigame_appid, + ':minigame_accountid' => $minigame_accountid, + )); + if (!$ret) { + echo json_encode(array( + 'errcode' => 2, + 'errmsg' => '服务器内部错误', + )); + } echo json_encode(array( 'errcode' => 0, 'errmsg' => '',