diff --git a/sql/marketdb.sql b/sql/marketdb.sql index c48ff25a..b0cc441e 100644 --- a/sql/marketdb.sql +++ b/sql/marketdb.sql @@ -20,60 +20,80 @@ CREATE TABLE `version` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `t_goods` +-- Table structure for table `t_box` -- -DROP TABLE IF EXISTS `t_goods`; +DROP TABLE IF EXISTS `t_box`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `t_goods` ( +CREATE TABLE `t_box` ( `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `box_id` varchar(60) NOT NULL DEFAULT '' COMMENT '箱子唯一id', `goods_id` int(11) NOT NULL DEFAULT '0' COMMENT 'goods id', `goods_idx` int(11) NOT NULL DEFAULT '0' COMMENT 'goods idx', `item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id', `state` int(11) NOT NULL DEFAULT '0' COMMENT 'state 0:待支付 1:支付成功', - `buy_count` int(11) NOT NULL DEFAULT '0' COMMENT 'buy count', - `last_buyer` varchar(60) NOT NULL DEFAULT '' COMMENT '最后购买者', - `last_buy_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后一次购买时间', + + `order_id` varchar(60) NOT NULL DEFAULT '' COMMENT '订单id(订单过期后设置为空)', + `order_valid` int(11) NOT NULL DEFAULT '0' COMMENT '订单是否有效', + `owner_address` varchar(60) NOT NULL DEFAULT '' COMMENT '所有者', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), - UNIQUE KEY `goods_id_goods_idx` (`goods_id`, `goods_idx`) + UNIQUE KEY `box_id` (`box_id`), + UNIQUE KEY `order_id` (`order_id`), + KEY `state` (`state`), + KEY `owner_address` (`owner_address`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `t_buy_record` +-- Table structure for table `t_box_order` -- -DROP TABLE IF EXISTS `t_buy_record`; +DROP TABLE IF EXISTS `t_box_order`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `t_buy_record` ( +CREATE TABLE `t_box_order` ( `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', - `buyer` varchar(60) NOT NULL DEFAULT '' COMMENT 'buyer', - `goods_id` int(11) NOT NULL DEFAULT '0' COMMENT 'goods id', - `goods_idx` int(11) NOT NULL DEFAULT '0' COMMENT 'goods idx', - `item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id', + `order_id` varchar(60) NOT NULL DEFAULT '' COMMENT '订单id', + `box_id` varchar(60) NOT NULL DEFAULT '' COMMENT '箱子唯一id', + `state` int(11) NOT NULL DEFAULT '0' COMMENT 'state 0:待支付 1:支付成功', + `self_node_confirm_time` int(11) NOT NULL DEFAULT '0' COMMENT '本节点上链时间', + `self_node_sync_count` int(11) NOT NULL DEFAULT '0' COMMENT '本节点同步次数', + `self_node_sync_time` int(11) NOT NULL DEFAULT '0' COMMENT '本节点最后一次同步时间', + `other_node_confirm_time` int(11) NOT NULL DEFAULT '0' COMMENT '其他节点上链时间', + `buyer_address` varchar(60) NOT NULL DEFAULT '' COMMENT '购买者', + `price` bigint NOT NULL DEFAULT '0' COMMENT '价格', + `payment_token_address` varchar(60) NOT NULL DEFAULT '' COMMENT '货币地址', + `nonce` varchar(60) NOT NULL DEFAULT '' COMMENT 'nonce', + `signature` varchar(60) NOT NULL DEFAULT '' COMMENT '签名', + `buy_time` int(11) NOT NULL DEFAULT '0' COMMENT '购买时间', + `expired` int(11) NOT NULL DEFAULT '0' COMMENT '是否过期', + `buy_count` int(11) NOT NULL DEFAULT '0' COMMENT '购买次数', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), - KEY `goods_id_goods_idx` (`goods_id`, `goods_idx`), - KEY `buyer` (`buyer`) + UNIQUE KEY `order_id` (`order_id`), + UNIQUE KEY `signature` (`signature`), + KEY `state` (`state`), + KEY `self_node_confirm_time` (`self_node_confirm_time`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `t_nfts` +-- Table structure for table `t_nft` -- -DROP TABLE IF EXISTS `t_nfts`; +DROP TABLE IF EXISTS `t_nft`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `t_nfts` ( +CREATE TABLE `t_nft` ( `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'token_id', `owner_id` varchar(255) NOT NULL DEFAULT '' COMMENT 'owner_id', + `owner_address` varchar(255) NOT NULL DEFAULT '' COMMENT 'owner_address', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), @@ -81,4 +101,24 @@ CREATE TABLE `t_nfts` ( ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `t_log` +-- + +DROP TABLE IF EXISTS `t_log`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_log` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `type` varchar(255) NOT NULL DEFAULT '' COMMENT '日志类型', + `subtype` varchar(255) NOT NULL DEFAULT '' COMMENT '日志子类型', + `param1` mediumblob COMMENT 'param1', + `param2` mediumblob COMMENT 'param2', + `param3` mediumblob COMMENT 'param3', + `param4` mediumblob COMMENT 'param4', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + -- Dump completed on 2015-08-19 18:51:22 diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index 4f6373f3..963e950d 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -50,6 +50,19 @@ class MarketController extends BaseController { $this->_rspErr(2, 'insufficient inventory'); return; } + $params = array( + 'account' => $account, + 'goods_id' => $goodsId, + ); + $response = ''; + $url = ''; + if (!phpcommon\HttpClient::get($url, + $params, + $response)) { + phpcommon\sendError(100, 'internal error'); + die(); + return; + } } public function sell()