diff --git a/sql/gamedb.sql b/sql/gamedb.sql index c05f3e63..4accd994 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -89,7 +89,8 @@ CREATE TABLE `t_user_wallet_record` ( `dir` int(11) NOT NULL DEFAULT '0' COMMENT 'dir', `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', `type` int(11) NOT NULL DEFAULT '0' COMMENT 'type', - `value` bigint NOT NULL DEFAULT '0' COMMENT 'value', + `value` varchar(100) NOT NULL DEFAULT '' COMMENT 'value', + `state` int(11) NOT NULL DEFAULT '0' COMMENT 'state', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), diff --git a/sql/marketdb.sql b/sql/marketdb.sql index a9edff1a..5c2ff748 100644 --- a/sql/marketdb.sql +++ b/sql/marketdb.sql @@ -19,6 +19,22 @@ CREATE TABLE `version` ( ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `t_parameter` +-- + +DROP TABLE IF EXISTS `t_parameter`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_parameter` ( + `idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id', + `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name', + `value` mediumblob COMMENT 'value', + PRIMARY KEY (`idx`), + UNIQUE KEY `name` (`name`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `t_box_order` -- @@ -158,11 +174,13 @@ DROP TABLE IF EXISTS `t_transfer`; CREATE TABLE `t_transfer` ( `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `txhash` varchar(255) NOT NULL DEFAULT '' COMMENT 'txhash', + `block_number` varchar(60) NOT NULL DEFAULT '' COMMENT '块id', `type` int(11) NOT NULL DEFAULT '0' COMMENT 'type', `_from` varchar(255) NOT NULL DEFAULT '' COMMENT '_from', `_to` varchar(255) NOT NULL DEFAULT '' COMMENT '_to', - `value` bigint NOT NULL DEFAULT '0' COMMENT 'value', - `state` int(11) NOT NULL DEFAULT '0' COMMENT '0:未同步 1:同步成功', + `value` varchar(255) NOT NULL DEFAULT '' COMMENT 'value', + `state` int(11) NOT NULL DEFAULT '0' COMMENT '0:未同步 1:同步成功 2:失败', + `reason` mediumblob COMMENT 'reason', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), diff --git a/webapp/controller/CallbackController.class.php b/webapp/controller/CallbackController.class.php index 0dff5ff1..2dd1a76d 100644 --- a/webapp/controller/CallbackController.class.php +++ b/webapp/controller/CallbackController.class.php @@ -42,6 +42,7 @@ class CallbackController extends BaseController { myself()->_rspOk(); return; } + UserWalletRecord::add($conn, $txHash, $dir, $account, $type, $value); if (!in_array($dir, array(0, 1))){ myself()->_rspErr(1, ''); @@ -52,6 +53,11 @@ class CallbackController extends BaseController { myself()->_rspErr(2, ''); return; } + if (strlen($value) <= 18){ + myself()->_rspErr(4, ''); + return; + } + $value = substr($value, 0, -18); if ($value < 0 || empty($value)) { myself()->_rspErr(3, ''); return; @@ -114,11 +120,13 @@ class CallbackController extends BaseController { 'modifytime' => myself()->_getNowTime() )); } + UserWalletRecord::update($conn, + $txHash, + array( + 'state' => 1, + 'modifytime' => myself()->_getNowTime() + )); - UserWalletRecord::add($conn, $txHash, $dir, $account, $type, $value); - if ($this->isTestMode()) { - - } myself()->_rspOk(); } diff --git a/webapp/controller/WalletController.class.php b/webapp/controller/WalletController.class.php index 58b636e3..6a4a8369 100644 --- a/webapp/controller/WalletController.class.php +++ b/webapp/controller/WalletController.class.php @@ -18,11 +18,6 @@ use models\Transfer; class WalletController extends BaseController { - private function isTestMode() - { - return isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443 && SERVER_ENV == _TEST; - } - public function withdrawal() { $account = strtolower(getReqVal('account', '')); @@ -39,10 +34,6 @@ class WalletController extends BaseController { myself()->_rspData(array( 'seq_id' => $seqId )); - if ($this->isTestMode()) { - Withdrawal::testOk($seqId, $account, $type, $netId, $amount); - $this->notifyGame(0, $seqId, $account, $type, $netId, $amount); - } } public function queryWithdrawalResult() @@ -95,10 +86,6 @@ class WalletController extends BaseController { myself()->_rspData(array( 'state' => 2 )); - if ($this->isTestMode()) { - Withdrawal::testOk($txHash, $account, 1, 1, 1000); - $this->notifyGame(0, $txHash, $account, 1, 1, 1000); - } return; } if ($transferDb['state'] == 0) { @@ -114,28 +101,4 @@ class WalletController extends BaseController { } } - private function notifyGame($dir, $txhash, $account, $type, $netId, $value) - { - $apiUrl = "https://game2006api-test.kingsome.cn"; - $params = array( - 'c' => 'Callback', - 'a' => 'transfer', - 'dir' => $dir, - 'txhash' => $txhash, - 'account' => $account, - 'type' => $type, - 'value' => $value - ); - $url = $apiUrl . '/webapp/index.php'; - $response = ''; - if (!phpcommon\HttpClient::get - ($url, - $params, - $response)) { - phpcommon\sendError(500, 'server internal error'); - die(); - return; - } - } - } diff --git a/webapp/models/UserWalletRecord.php b/webapp/models/UserWalletRecord.php index e0ca1339..001de33a 100644 --- a/webapp/models/UserWalletRecord.php +++ b/webapp/models/UserWalletRecord.php @@ -35,4 +35,15 @@ class UserWalletRecord extends BaseModel { )); } + public static function update($conn, $txHash, $fieldKv) + { + SqlHelper::update( + $conn, + 't_user_wallet_record', + array( + 'txhash' => $txHash, + ), + $fieldKv); + } + }