uid = $uid; $this->events_id = $events_id; $this->objMlottery = new Lottery(); $this->objMLotteryLog = new LotteryLog($uid,$events_id); $this->thisTime = time(); $this->objMLotteryEventsLimitations = new LotteryEventsLimitations(); $this->objDLotteryEventsInvitation = new LotteryEventsInvitation(); } /** * 获取当前“邀请函活动”信息 */ public function getEventsData(){ return $this->objMlottery->getOneLotteryEvents($this->events_id); } /** * 检查当前用户是否在白名单中 */ public function ckUidInWhiteList(){ $eventsData = $this->objMlottery->getOneLotteryEvents($this->events_id); if($eventsData['invitation_white_list'] !='' && isset($eventsData['invitation_white_list']) && !isset($eventsData['invitation_white_list'][$this->uid])){ return false; } return true; } /** * 提交用户信息 */ public function submitUser(){ $eventsData = $this->objMlottery->getOneLotteryEvents($this->events_id); if($eventsData['invitation_white_list'] !='' && isset($eventsData['invitation_white_list']) && !isset($eventsData['invitation_white_list'][$this->uid])){ return ResultWrapper::fail('抱歉您没有权限参与此活动'); } # 活动是否开始 if($this->thisTime < $eventsData['begin_time'] || $this->thisTime > $eventsData['end_time']){ return ResultWrapper::fail('当前活动未开始'); } # 活动限制 if(!$this->objMLotteryEventsLimitations->ckEventRestrictions($this->uid,Request::ip(), $this->events_id)){ return ResultWrapper::fail('您已成功领取二维码'); } # 获取当前活动最大上线 if($eventsData['participation_user_max_num']){ $runNum = $this->objMlottery->getParticipationUserNum($this->events_id); if($runNum >= $eventsData['participation_user_max_num'] ){ return ResultWrapper::fail('实在抱歉,由于参与太热情,报名人数已满,敬请关注下次活动'); } } # 记录参与日志 $other = array( 'postData' => $_POST, 'getData' => $_GET ); $this->objMLotteryLog ->addLog(DLog::LOG_TYPE_PARTICIPATION, $other); return ResultWrapper::success('通过'); } # 记录行为 public function setLimitations(){ $this->objMLotteryEventsLimitations->setUserEventNum($this->uid, $this->events_id); // 记录用户参与UID(天) $this->objMLotteryEventsLimitations->setIpEventNum(Request::ip(), $this->events_id);// 记录用户参与IP(天) $this->objMLotteryEventsLimitations->setUserParticipationNum($this->uid, $this->events_id); // 记录用户参与次数 # 记录"参与成功"日志 $other = array(); $this->objMLotteryLog ->addLog(DLog::LOG_TYPE_PARTICIPATION_TRUE, $other); # 记录"用户参与" other 表单内容 $other = array( '表单内容:' => join(',', $_POST), ); $this->objMLotteryLog ->addUserParticipateLog($other); } /** * 获取生成二维码链接的token */ public function getQrcodeUrlToken() { $sjs = '8SY-NXOsFMooo'; $arr = array($this->uid, $this->events_id); sort($arr); return md5(implode($arr) . $sjs); } }