From 299e0c7e84ec3967fc61a5a529ba5a0d128d515c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 26 Jan 2022 16:53:07 +0800 Subject: [PATCH] 1 --- sql/marketdb.sql | 3 +-- webapp/models/BoxOrder.php | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/sql/marketdb.sql b/sql/marketdb.sql index a60898a2..a9da6397 100644 --- a/sql/marketdb.sql +++ b/sql/marketdb.sql @@ -28,8 +28,8 @@ 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', + `batch_id` int(11) NOT NULL DEFAULT '0' COMMENT '批次号', `item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id', `state` int(11) NOT NULL DEFAULT '0' COMMENT 'state 0:待支付 1:支付成功', `bc_synced` int(11) NOT NULL DEFAULT '0' COMMENT '0:未上链 1:已上链', @@ -44,7 +44,6 @@ CREATE TABLE `t_box_order` ( `payment_token_address` varchar(60) NOT NULL DEFAULT '' COMMENT '货币地址', `nonce` varchar(60) NOT NULL DEFAULT '' COMMENT 'nonce', `signature` varchar(255) NOT NULL DEFAULT '' COMMENT '签名', - `expired` int(11) NOT NULL DEFAULT '0' COMMENT '是否过期', `done` int(11) NOT NULL DEFAULT '0' COMMENT '是否已完成', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', diff --git a/webapp/models/BoxOrder.php b/webapp/models/BoxOrder.php index 36e8a6a7..c42e87a3 100644 --- a/webapp/models/BoxOrder.php +++ b/webapp/models/BoxOrder.php @@ -10,7 +10,8 @@ class BoxOrder extends BaseModel { public function getSoldNum($batchId) { $row = myself()->_getMarketMysql()->execQueryOne - ('SELECT COUNT(*) AS sold_num FROM t_box_order WHERE batch_id=:batch_id;', + ('SELECT COUNT(*) AS sold_num FROM t_box_order WHERE batch_id=:batch_id AND ' . + ' (state = 1 OR done <> 1);', array( ':batch_id' => $batchId )); @@ -20,7 +21,8 @@ class BoxOrder extends BaseModel { public function isBuyed($buyerAddress, $batchId) { $row = myself()->_getMarketMysql()->execQueryOne - ('SELECT COUNT(*) AS buy_count FROM t_box_order WHERE batch_id=:batch_id AND buyer_address=:buyer_address;', + ('SELECT COUNT(*) AS buy_count FROM t_box_order WHERE batch_id=:batch_id AND ' . + ' buyer_address=:buyer_address AND (state = 1 OR done <> 1);', array( ':buyer_address' => $buyerAddress, ':batch_id' => $batchId