getEventsCreateTimeToId(); if (!Verify::unsignedInt($events_id)) { self::fail_exit('无效id'); } # 获取用户信息 $objUserData = new UserInfo(); $uid = $this->getRunTimeUid(); $userData = $objUserData -> get($uid); $this->setOutput('userData', $userData); # 获取试用信息 $objLotteryEventsTypeTry = new LotteryEventsTypeTry($uid, $events_id); $tryInfo = $objLotteryEventsTypeTry->getEventsData(); # 检查是否移动端 $title = $tryInfo['weixinShare']['title'] ? $tryInfo['weixinShare']['title'] : $tryInfo['events_name']; $this->checkIsFromMobile($title); # 获取登录地址 $url = Request::g('url'); $plat_form_id = $this->getPlatFormId(); $objMLottery = new Lottery(); $thisUrl = $objMLottery -> getEventsUrl($tryInfo['type'],$tryInfo['create_time'],$url); $loginUrl = $this -> getLoginUrl($thisUrl); $this->setOutput('loginUrl', $loginUrl); # 判断是否需要登录 $ckLogin = $this->ckLogin(); $this->setOutput('ckLogin', $ckLogin); # 活动状态 $TIME = time(); $eventsStatus = false; if($TIME < $tryInfo['begin_time'] ){ $eventsStatus = 'STATUS_NOT_START'; } elseif ($TIME > $tryInfo['end_time']){ $eventsStatus = 'STATUS_HAS_END'; } elseif ($tryInfo['display'] == \Cas\Dao\LotteryEvents::EVENT_DISPLAY_HIDE) { //$eventsStatus = 'STATUS_HIDE'; //先注释了。此隐藏 之印象列表 } # 获取用户最新收货地址 $objDLotteryUserExpress = new LotteryUserExpress(); $userExpress = $objDLotteryUserExpress -> getUserExpress($uid); # 检查当前活动是否需要登录 $authorize =$tryInfo['authorize']; if ($authorize) { if($ckLogin==true){ self::redirect($loginUrl); } } # 记录PV UV日志 访问 $objCount = new Count(); $objCount->setPassLog( $events_id,$plat_form_id); # 视频播放 preg_match_all('/]+>/i', $tryInfo['events_tips'], $matches); if ($matches) foreach ($matches[0] as $key => $tmpMatch) { $tmp_new_video_html = ''; $tryInfo['events_tips'] = str_replace($tmpMatch, $tmp_new_video_html, $tryInfo['events_tips']); } $this->tpl = 'events_try'; $this->setOutput('display', $tryInfo['list_display']); $this->setOutput('userExpress', $userExpress); $this->setOutput('title', $tryInfo['weixinShare']['title'] ? $tryInfo['weixinShare']['title'] : $tryInfo['events_name']); $this->setOutput('tryInfo', $tryInfo); $this->setOutput('forms', $tryInfo['forms']); $this->setOutput('eventsStatus', $eventsStatus); $this->setOutput('weixinShare', $tryInfo['weixinShare']); } public function doApply() { # 1.必要参数验证 $uid = $this->getRunTimeUid(); if (!Verify::unsignedInt($uid)) { self::ajax_fail_exit('无效用户id'); } $events_id = Request::g('events_id'); if (!Verify::unsignedInt($events_id)) { self::ajax_fail_exit('无效试用id'); } $objLotteryEventsTypeTry = new LotteryEventsTypeTry($uid, $events_id); # 2.活动信息&用户行为验证 $tmpData = $objLotteryEventsTypeTry -> userTry() ; if(!$tmpData->isSuccess()){ print_r($tmpData);die; self::ajax_fail_exit($tmpData->getData()); } # 3.用户表单验证 $tryInfo = $objLotteryEventsTypeTry->getEventsData(); $forms = $tryInfo['forms']; $formData = Filter::arrayfilter($_POST, true); $objLotteryEventsForms = new LotteryEventsForms(); $tmpVerifyResult = $objLotteryEventsForms->verifyFormData($forms, $formData); if (!$tmpVerifyResult->isSuccess()) { self::ajax_fail_exit($tmpVerifyResult->getData()); } # 4.保存表单内容 $info = array_merge($formData, array('uid' => $uid, 'events_id' => $events_id)); if (!$objLotteryEventsForms->add($info)) { self::ajax_fail_exit('数据库操作失败'); } # 5.增加行为记录 $objLotteryEventsTypeTry->setLimitations(); self::ajax_success_exit(); } public function doFeedBack() { # 1.必要参数验证 $uid = $this->getRunTimeUid(); if (!Verify::unsignedInt($uid)) { self::ajax_fail_exit('无效用户id'); } $events_id = Request::g('events_id'); if (!Verify::unsignedInt($events_id)) { self::ajax_fail_exit('无效id'); } $objMLottery = new Lottery(); $eventData = $objMLottery->getOneLotteryEvents ( $events_id ); if (!$eventData) { self::ajax_fail_exit('无效id'); } $type = $eventData['type']; if (!in_array($type, array(4,6))) { self::ajax_fail_exit('无效类型'); } # 以下为数据验证 if ($type == 4) { # 验证是否有试用权限 $objLotteryEventsTypeTry = new LotteryEventsTypeTry($uid, $events_id); $tmpData = $objLotteryEventsTypeTry -> userTry() ; if($tmpData->isSuccess()){ self::ajax_fail_exit('没有申请'); } } if ($type == 6) { # 验证是否有邀请函 } $objLotteryUserFeedback = new LotteryUserFeedback(); $data = array(); $data['uid'] = $uid; $data['events_id'] = $events_id; $data['status'] = 1; $ids = $objLotteryUserFeedback->findIdsBy ( $data, 1, $order = ' id desc'); $info = $objLotteryUserFeedback->gets ( $ids ); $data['content'] = Request::g('content'); $data['pic'] = Request::g('pic'); if ($info) { $info = array_pop($info); $tmpResult = $objLotteryUserFeedback->modify($data, array ( 'id' => $info['id'] )); } else { $tmpResult = $objLotteryUserFeedback->add($data); } if (!$tmpResult) { self::ajax_fail_exit('错误的反馈信息'); } self::ajax_success_exit(); } public function display() { return $this->render(); } }