";s:14:"events_hd_tips";s:21:"填写问卷赢大礼";s:12:"events_rules";s:16:"


";s:15:"operationt_tips";s:0:"";s:13:"survery_prize";a:2:{i:1;a:4:{s:4:"name";s:24:"高姿世博限量套装";s:7:"img_url";s:69:"http://opcdn.sg.com.cn/public/upload/image/2015/1104/143703_40713.jpg";s:3:"num";s:1:"4";s:9:"unit_name";s:3:"份";}i:2;a:4:{s:4:"name";s:40:"格兰玛弗兰萝西滋润护手霜60ml";s:7:"img_url";s:69:"http://opcdn.sg.com.cn/public/upload/image/2015/1104/143735_25149.jpg";s:3:"num";s:2:"50";s:9:"unit_name";s:3:"份";}}s:8:"delivery";s:1:"1";s:5:"forms";a:3:{i:2;a:3:{s:4:"name";s:6:"姓名";s:4:"type";s:4:"text";s:8:"required";s:1:"1";}i:3;a:4:{s:4:"name";s:9:"手机号";s:4:"type";s:4:"text";s:4:"rule";a:2:{s:9:"regularid";s:1:"1";s:7:"regular";s:49:"/^(1[0-9][0-9]|15[0-9]|18[02-9]|14[57])[0-9]{8}$/";}s:8:"required";s:1:"1";}i:4;a:3:{s:4:"name";s:12:"收货地址";s:4:"type";s:4:"text";s:8:"required";s:1:"1";}}}'; $arr = unserialize($str); unset( $arr['survery_question'][5]['answer'][9] ); unset( $arr['survery_question'][8]['answer'][9] ); unset( $arr['survery_question'][12]['answer'][5] ); $objD = new LotteryEvents(); $objD -> modify($arr,array('id'=>141)); exit('end'); */ $thisTime = time(); $events_id = $this->getEventsCreateTimeToId(); if (!Verify::unsignedInt($events_id)) { self::fail_exit('无效id'); } # 获取用户信息 $objUserData = new UserInfo(); $uid = $this->getRunTimeUid(); $userData = $objUserData -> get($uid); $this->setOutput('userData', $userData); # 获取试用信息 $objDLotteryEvents = new LotteryEvents(); $surveyInfo = $objDLotteryEvents -> get($events_id); # 检查是否移动端 $title = $surveyInfo['weixinShare']['title'] ? $surveyInfo['weixinShare']['title'] : $surveyInfo['events_name']; $this->checkIsFromMobile($title); # 获取登录地址 $url = Request::g('url'); $plat_form_id = $this->getPlatFormId(); $objMLottery = new Lottery(); $thisUrl = $objMLottery -> getEventsUrl($surveyInfo['type'],$surveyInfo['create_time'],$url); $loginUrl = $this -> getLoginUrl($thisUrl); $this->setOutput('loginUrl', $loginUrl); # 判断是否需要登录 $ckLogin = $this->ckLogin(); $this->setOutput('ckLogin', $ckLogin); # 检查当前活动是否需要登录 $authorize =$surveyInfo['authorize']; if ($authorize && $loginUrl) { if($ckLogin==true){ self::redirect($loginUrl); } } $this->info($surveyInfo); # 记录PV UV日志 访问 $objCount = new Count(); $objCount->setPassLog( $events_id,$plat_form_id); # 活动状态 $TIME = time(); $eventsStatus = false; $objMLotteryEventsLimitations = new LotteryEventsLimitations(); if($TIME < $surveyInfo['begin_time'] ){ $eventsStatus = 'STATUS_NOT_START'; } elseif ($TIME > $surveyInfo['end_time']){ $eventsStatus = 'STATUS_HAS_END'; } elseif ($surveyInfo['display'] == \Cas\Dao\LotteryEvents::EVENT_DISPLAY_HIDE) { //$eventsStatus = 'STATUS_HIDE'; //先注释了。此隐藏 之印象列表 }elseif (!$objMLotteryEventsLimitations->ckEventRestrictions($uid,Request::ip(), $events_id)) { $eventsStatus = 'STATUS_HAS_RESTRTICTIONS'; } if (Cookie::get('SURVEY_IS_UNDERWAY') >= 2) { Cookie::set('SURVEY_IS_UNDERWAY', 1, null, $_SERVER['HTTP_HOST'], '/'); $this->setOutput('zepto', 1); $this->setOutput('display', $surveyInfo['list_display']); $this->tpl = 'events_survey_underway'; } else { $this->setOutput('display', $surveyInfo['list_display']); $this->tpl = 'events_survey'; } # 视频播放 preg_match_all('/]+>/i', $surveyInfo['events_tips'], $matches); if ($matches) foreach ($matches[0] as $key => $tmpMatch) { $tmp_new_video_html = ''; $surveyInfo['events_tips'] = str_replace($tmpMatch, $tmp_new_video_html, $surveyInfo['events_tips']); } $this->setOutput('eventsStatus', $eventsStatus); $this->setOutput('title', $surveyInfo['weixinShare']['title'] ? $surveyInfo['weixinShare']['title'] : $surveyInfo['events_name']); $this->setOutput('surveyInfo', $surveyInfo); $this->setOutput('forms', $surveyInfo['forms']); $this->setOutput('weixinShare', $surveyInfo['weixinShare']); } public function doSubmit() { $thisTime = time(); # 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(); $eventsData = $objMlottery->getOneLotteryEvents($events_id); # 活动是否开始 if($thisTime < $eventsData['begin_time'] || $thisTime > $eventsData['end_time']){ self::ajax_fail_exit('当前活动未开始'); } # 活动的 用户行为限制 $objMLotteryEventsLimitations = new LotteryEventsLimitations(); if(!$objMLotteryEventsLimitations->ckEventRestrictions($uid,Request::ip(), $events_id)){ self::ajax_fail_exit('请勿重复参与'); } # 3.用户表单验证 $forms = $eventsData['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.增加行为记录 $objMLotteryEventsLimitations->setUserEventNum($uid, $events_id); // 记录用户参与UID(天) $objMLotteryEventsLimitations->setIpEventNum(Request::ip(),$events_id);// 记录用户参与IP(天) $objMLotteryEventsLimitations->setUserParticipationNum($uid, $events_id); // 记录用户参与次数 $surveyAnswer = json_decode(Request::g('answer', null), true); $selectAnswers = ''; foreach ($surveyAnswer as $tmpKey => $tmpAnswer) { $surveyAnswer[$tmpKey] = $tmpAnswer = trim($tmpAnswer, ','); } # 6 记录参与日志 $other = array( '选择内容:' => join(' | ', $surveyAnswer), '表单内容:' => join(',', $formData), ); $objMLotteryLog = new LotteryLog($uid,$events_id); $objMLotteryLog ->addLog(\Cas\Dao\LotteryEventsLog::LOG_TYPE_PARTICIPATION_TRUE, $other); $objMLotteryLog->addUserParticipateLog($other); self::ajax_success_exit(); } public function display() { return $this->render(); } }