diff --git a/sql/marketdb.sql b/sql/marketdb.sql index c553714a..8d29e19d 100644 --- a/sql/marketdb.sql +++ b/sql/marketdb.sql @@ -19,35 +19,6 @@ 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_box` --- - -DROP TABLE IF EXISTS `t_box`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -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:支付成功', - - `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 `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_box_order` -- @@ -57,6 +28,7 @@ DROP TABLE IF EXISTS `t_box_order`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `t_box_order` ( `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `batch_id` int(11) NOT NULL DEFAULT '0' COMMENT '批次号', `order_id` varchar(60) NOT NULL DEFAULT '' COMMENT '订单id', `box_id` varchar(60) NOT NULL DEFAULT '' COMMENT '箱子唯一id', `item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id', @@ -68,6 +40,7 @@ CREATE TABLE `t_box_order` ( `bc_block_number` varchar(60) NOT NULL DEFAULT '' COMMENT '块id', `bc_fail_reason` varchar(255) NOT NULL DEFAULT '' COMMENT '原因', `buyer_address` varchar(60) NOT NULL DEFAULT '' COMMENT '购买者', + `token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'token_id', `price` bigint NOT NULL DEFAULT '0' COMMENT '价格', `payment_token_address` varchar(60) NOT NULL DEFAULT '' COMMENT '货币地址', `nonce` varchar(60) NOT NULL DEFAULT '' COMMENT 'nonce', @@ -79,6 +52,7 @@ CREATE TABLE `t_box_order` ( PRIMARY KEY (`idx`), UNIQUE KEY `order_id` (`order_id`), UNIQUE KEY `signature` (`signature`), + KEY `batch_id` (`batch_id`), KEY `state` (`state`), KEY `done` (`done`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; @@ -94,12 +68,14 @@ DROP TABLE IF EXISTS `t_nft`; CREATE TABLE `t_nft` ( `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'token_id', + `item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具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`), - UNIQUE KEY `token_id` (`token_id`) + UNIQUE KEY `token_id` (`token_id`), + KEY `owner_address` (`owner_address`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/webapp/controller/NewMarketController.class.php b/webapp/controller/NewMarketController.class.php index b298855b..4672570a 100644 --- a/webapp/controller/NewMarketController.class.php +++ b/webapp/controller/NewMarketController.class.php @@ -7,10 +7,10 @@ require_once('mt/WhiteList.php'); require_once('mt/Currency.php'); require_once('mt/Hero.php'); -require_once('models/Box.php'); +require_once('models/BoxOrder.php'); use phpcommon\SqlHelper; -use models\Box; +use models\BoxOrder; class NewMarketController extends BaseController { @@ -39,10 +39,10 @@ class NewMarketController extends BaseController { $presaleInfo = array( 'batch_id' => $currBatchMeta['batch_id'], 'countdown' => max(0, $currBatchMeta['_start_time_utc'] - myself()->_getNowTime()), - 'sold_num' => min(Box::getSoldNum($currBatchMeta['batch_id']), $currBatchMeta['number_of_props']), + 'sold_num' => min(BoxOrder::getSoldNum($currBatchMeta['batch_id']), $currBatchMeta['number_of_props']), 'inventory_num' => $currBatchMeta['number_of_props'], 'hint' => str_replace("\n", '\n', $currBatchMeta['hint']), - 'buyed' => Box::isBuyed($account, $currBatchMeta['batch_id']) + 'buyed' => BoxOrder::isBuyed($account, $currBatchMeta['batch_id']) ); $batchMetas = mt\MarketGoods::getBatchMetas($currBatchMeta['batch_id']); diff --git a/webapp/models/Box.php b/webapp/models/Box.php index 744c6ab9..38baac9e 100644 --- a/webapp/models/Box.php +++ b/webapp/models/Box.php @@ -5,7 +5,7 @@ namespace models; use mt; use phpcommon\SqlHelper; -class Box extends BaseModel { +class BoxOrder extends BaseModel { public function getSoldNum($batchId) { diff --git a/webapp/models/BoxOrder.php b/webapp/models/BoxOrder.php new file mode 100644 index 00000000..744c6ab9 --- /dev/null +++ b/webapp/models/BoxOrder.php @@ -0,0 +1,20 @@ +