This commit is contained in:
songliang 2023-07-12 21:49:47 +08:00
parent 0316911a57
commit f41ee6e04a
3 changed files with 13 additions and 6 deletions

View File

@ -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;
--

View File

@ -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);

View File

@ -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'];
}