数据表设计
DROP TABLE IF EXISTS `hcwt_floors`; CREATE TABLE `hcwt_floors` ( `f_id` int(11) NOT NULL AUTO_INCREMENT, `f_openid` varchar(100) DEFAULT NULL, PRIMARY KEY (`f_id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
盖楼源码
<?php include './hcWeChat/hcWeChat.php'; $hcWeChat = new hcWeChat(); /* 消息识别 */ $hcWeChat->getMsg(); //文本形式的消息处理 if($hcWeChat->msgType == 'text'){ //根据文本内容回复文本消息 switch($hcWeChat->msgContent){ case '盖楼': //设置中奖楼层 $floors = array(2, 5, 100, 1000, 200); $m = hcm('floors'); $in = array('f_openid' => $hcWeChat->openId); $lastId = $m->add($in); if(in_array($lastId, $floors)){ $hcWeChat->reTextMsg('共享您中奖了,楼层:'.$lastId); }else{ $hcWeChat->reTextMsg('楼层:'.$lastId.'!继续努力就可以中奖了!'); } break; } }