From f41ee6e04a0499374f7f7a53a6987256acb4fc43 Mon Sep 17 00:00:00 2001 From: songliang Date: Wed, 12 Jul 2023 21:49:47 +0800 Subject: [PATCH] ... --- sql/gamedb.sql | 9 ++++++--- sql/gamedb2006_migrate_230619_01.sql | 8 ++++++-- webapp/controller/ShopController.class.php | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 90987266..c2cc084b 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -1243,9 +1243,12 @@ CREATE TABLE `t_shop_free_record` ( `free_type` int(11) NOT NULL COMMENT '免费类型', `free_num` int(11) NOT NULL COMMENT '免费数量', `createtime` int(11) NOT NULL COMMENT '创建时间', - PRIMARY KEY (`idx`) -) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8; - + PRIMARY KEY (`idx`), + KEY `account_id` (`account_id`) USING HASH, + KEY `createtime` (`createtime`) USING BTREE, + KEY `id` (`id`) USING BTREE, + KEY `goods_id` (`goods_id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=78 DEFAULT CHARSET=utf8; -- diff --git a/sql/gamedb2006_migrate_230619_01.sql b/sql/gamedb2006_migrate_230619_01.sql index c75b3652..48b76c82 100644 --- a/sql/gamedb2006_migrate_230619_01.sql +++ b/sql/gamedb2006_migrate_230619_01.sql @@ -51,8 +51,12 @@ CREATE TABLE `t_shop_free_record` ( `free_type` int(11) NOT NULL COMMENT '免费类型', `free_num` int(11) NOT NULL COMMENT '免费数量', `createtime` int(11) NOT NULL COMMENT '创建时间', - PRIMARY KEY (`idx`) -) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8; + PRIMARY KEY (`idx`), + KEY `account_id` (`account_id`) USING HASH, + KEY `createtime` (`createtime`) USING BTREE, + KEY `id` (`id`) USING BTREE, + KEY `goods_id` (`goods_id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=78 DEFAULT CHARSET=utf8; insert into version (version) values(2023061901); diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 5ab561a9..327364f7 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -1937,7 +1937,7 @@ class ShopController extends BaseAuthedController switch ($free_type) { case 1: { $dayTime = myself()->_getNowDaySeconds(); - $sql = 'SELECT COUNT(*) as cnt FROM t_shop_free_record WHERE account_id = ? AND `id` = ? AND goods_id = ? AND createtime >= ?'; + $sql = 'SELECT COUNT(idx) as cnt FROM t_shop_free_record WHERE account_id = ? AND `id` = ? AND goods_id = ? AND createtime >= ?'; $row = $conn->execQueryOne($sql, array($account, $id, $goods_id, $dayTime)); return $row['cnt']; }