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->objDLotteryEventsTry = new LotteryEventsTry(); $this->objDLotteryUserExpress = new LotteryUserExpress(); } /** * 获取当前“试用”信息 */ public function getEventsData(){ return $this->objMlottery->getOneLotteryEvents($this->events_id); } /** * 申请试用 */ public function userTry(){ $eventsData = $this->objMlottery->getOneLotteryEvents($this->events_id); # 活动是否开始 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('您已提交过申请'); } # 记录参与日志 $other = array( 'postData' => $_POST, 'getData' => $_GET ); $this->objMLotteryLog ->addLog(DLog::LOG_TYPE_PARTICIPATION, $other); return ResultWrapper::success('ok'); } /** * 记录行为 */ 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); } }