diff --git a/sql/gamedb.sql b/sql/gamedb.sql index e0cf94bd..0bc50f0b 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -1908,3 +1908,28 @@ CREATE TABLE `t_server_task_battle_count` ( PRIMARY KEY (`idx`) ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_recharge_order` +-- + +DROP TABLE IF EXISTS `t_recharge_order`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_recharge_order` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `order_id` varchar(255) COMMENT '订单号', + `account_id` varchar(60) NOT NULL COMMENT '账号id', + `account_address` varchar(60) NOT NULL COMMENT '钱包地址', + `currency_address` varchar(60) NOT NULL DEFAULT '' COMMENT '货币地址', + `currency_name` varchar(60) NOT NULL DEFAULT '' COMMENT '货币名称', + `status` int(11) NOT NULL DEFAULT '0' COMMENT '0: 支付中 1: 已发货', + `item_id` int(11) NOT NULL COMMENT '道具id', + `item_num` bigint NOT NULL DEFAULT '0' COMMENT '道具数量', + `price` varchar(60) COLLATE utf8_bin NOT NULL COMMENT '价格', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + UNIQUE KEY `order_id` (`order_id`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index b500b7c4..3ca4dcfe 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -101,6 +101,7 @@ class BaseAuthedController extends BaseController { if (SERVER_ENV != _DEBUG) { if (SERVER_ENV == _TEST) { if ($this->sessionId == "CzRXrGHxwQZJNCeXkTRA") { + return; } else { if (!phpcommon\isValidSessionId($this->accountId, $this->sessionId)) { diff --git a/webapp/controller/BlockChainController.class.php b/webapp/controller/BlockChainController.class.php index df13620d..06440cf5 100644 --- a/webapp/controller/BlockChainController.class.php +++ b/webapp/controller/BlockChainController.class.php @@ -4,6 +4,7 @@ require_once('mt/Parameter.php'); require_once('mt/Item.php'); require_once('mt/Drop.php'); require_once('mt/Hero.php'); +require_once('mt/Recharge.php'); require_once('models/Hero.php'); require_once('models/Gun.php'); @@ -14,6 +15,7 @@ require_once('models/BuyRecord.php'); require_once('models/Chip.php'); require_once('models/BcOrder.php'); require_once('models/Mall.php'); +require_once('models/Recharge.php'); require_once('services/AwardService.php'); require_once('services/PropertyChgService.php'); @@ -28,6 +30,7 @@ use models\BuyRecord; use models\Chip; use models\BcOrder; use models\Mall; +use models\Recharge; use services\BlockChainService; @@ -454,6 +457,43 @@ class BlockChainController extends BaseAuthedController { )); } + public function rechargeBuyS() + { + $goodsMeta = mt\Recharge::get(getReqVal('goods_id', '')); + if (!$goodsMeta) { + myself()->_rspErr(1, 'goods_id paramater error'); + return; + } + $orderId = Recharge::addOrder($goodsMeta['id']); + { + $params = array( + 'c' => 'BcService', + 'a' => 'recharge', + 'account_address' => myself()->_getAddress(), + 'passport_address' => myself()->_getAddress(), + 'net_id' => NET_ID, + 'amount' => 1, + 'currency_name' => 'TestToken', + 'order_id' => $orderId, + ); + error_log(json_encode($params)); + { + $url = self::getWeb3ServiceUrl(); + $response = ''; + if (!phpcommon\HttpClient::get + ($url, + $params, + $response)) { + myself()->_rspErr(500, 'server internal error'); + die(); + return; + } + error_log($response); + echo $response; + } + } + } + private static function getWeb3ServiceUrl() { $web3ServiceCluster = require_once('../config/web3service.cluster.php'); diff --git a/webapp/models/Recharge.php b/webapp/models/Recharge.php new file mode 100644 index 00000000..51ba0017 --- /dev/null +++ b/webapp/models/Recharge.php @@ -0,0 +1,40 @@ +_getNowTime(), + myself()->_getAddress() + ); + SqlHelper::insert + (myself()->_getSelfMysql(), + 't_recharge_order', + array( + 'order_id' => $orderId, + 'account_id' => myself()->_getAccountId(), + 'account_address' => myself()->_getAddress(), + 'currency_address' => '0xfd42bfb03212da7e1a4608a44d7658641d99cf34', + 'currency_name' => 'TestToken', + 'status' => 0, + 'item_id' => $goodsId, + 'item_num' => 1, + 'price' => 1, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ) + ); + return $orderId; + } + +}