123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- <?php
- namespace Cas\Controller;
- use Cas\Module\LotteryEventsTypeTurntable;
- use Cas\Dao\LotteryEvents;
- use KIF\Dao\SqlHelper;
- use Cas\Module\Lottery;
- use Cas\Dao\LotteryUserExpress;
- use KIF\Core\Request;
- use KIF\Verify;
- use Cas\Module\LotteryEventsTypeTry;
- use Cas\Dao\UserInfo;
- use Cas\Module\Count;
- use Cas\Dao\Platform;
- /**
- * 转盘
- * lihuanchun
- */
- class EventsTurntable extends EventsController {
-
- public function doDefault() {
- $thisTime = time();
- $events_id = $this->getEventsCreateTimeToId();
- //$events_id = Request::g('events_id');
- if (!Verify::unsignedInt($events_id)) {
- self::fail_exit('无效id');
- }
-
- # 获取用户信息
- $objUserData = new UserInfo();
- $uid = $this->getRunTimeUid();
- $userData = $objUserData -> get($uid);
- $this->setOutput('userData', $userData);
-
- # 获取转盘信息 & 8 个位置的奖品
- $objLotteryEventsTypeTurntable = new LotteryEventsTypeTurntable($uid,$events_id);
- $turntableData = $objLotteryEventsTypeTurntable -> getEventsData();
-
- # 检查是否移动端
- $title = $turntableData['events']['weixinShare']['title'] ? $turntableData['events']['weixinShare']['title'] : $turntableData['events']['events_name'];
- //$this->checkIsFromMobile($title);
-
- # 获取试用信息
- $objLotteryEventsTypeTry = new LotteryEventsTypeTry($uid, $events_id);
- $tryInfo = $objLotteryEventsTypeTry->getEventsData();
-
- # 获取登录地址
- $url = Request::g('url');
- $plat_form_id = $this->getPlatFormId();
- $objMLottery = new Lottery();
- $thisUrl = $objMLottery -> getEventsUrl($turntableData['events']['type'],$turntableData['events']['create_time'],$url);
- $loginUrl = $this -> getLoginUrl($thisUrl);
-
- $this->setOutput('loginUrl', $loginUrl);
-
- # 判断是否需要登录
- $ckLogin = $this->ckLogin();
- $this->setOutput('ckLogin', $ckLogin);
-
-
-
- # 其他开始活动
- $objDLottery = new Lottery();
- $condition = array(
- 'display' => LotteryEvents::EVENT_DISPLAY_SHOW,
- 'id' => SqlHelper::addCompareOperator('!=', $events_id),
- 'begin_time' => SqlHelper::addCompareOperator('<', $thisTime),
- 'end_time' => SqlHelper::addCompareOperator('>', $thisTime)
- );
- $otherEventsData = $objDLottery -> getLotteryEventsList($condition, 3, 'id desc');
-
- # 检查当前活动是否需要登录
- $authorize = $turntableData['events']['authorize'];
- if ($authorize && $loginUrl) {
- if($ckLogin==true){
- //self::redirect($loginUrl);
- }
- }
-
-
- # 活动状态
- $TIME = time();
- $eventsStatus = false;
- if($TIME < $turntableData['events']['begin_time'] ){
- $eventsStatus = 'STATUS_NOT_START';
-
- } elseif ($TIME > $turntableData['events']['end_time']){
- $eventsStatus = 'STATUS_HAS_END';
-
- } elseif ($turntableData['events']['display'] == \Cas\Dao\LotteryEvents::EVENT_DISPLAY_HIDE) {
- //$eventsStatus = 'STATUS_HIDE'; //先注释了。此隐藏 之印象列表
- }
-
-
- # 获取用户最新收货地址
- $objDLotteryUserExpress = new LotteryUserExpress();
- $userExpress = $objDLotteryUserExpress -> getUserExpress($uid);
-
-
- # 页面渲染所需JSON
- $jsonTurntableData = array();
-
- foreach($turntableData['turntable_prizes'] as $key => $data){
- if(is_array($data)){
- $jsonTurntableData[$data['id']] = $key;
- }else{
- $jsonTurntableData['NoPrize'] = $key;
- }
- }
-
- $this->info($turntableData['events']);
-
- # 记录PV UV日志 访问
- $objCount = new Count();
- $plat_form_id = $this->getPlatFormId();
- $objCount->setPassLog( $events_id,$plat_form_id);
-
- # 视频播放
- preg_match_all('/<embed\s{1}src=\"([^\"]+)\"[^>]+>/i', $turntableData['events']['events_tips'], $matches);
- if ($matches) foreach ($matches[0] as $key => $tmpMatch) {
- $tmp_new_video_html = '<iframe class="video_iframe" height=498 width=510 src="'.$matches[1][$key].'" frameborder=0 allowfullscreen></iframe>';
- $turntableData['events']['events_tips'] = str_replace($tmpMatch, $tmp_new_video_html, $turntableData['events']['events_tips']);
- }
-
- $jsonTurntableData = json_encode($jsonTurntableData);
- $this->tpl = 'events_turntable';
- $this->setOutput('title', $turntableData['events']['weixinShare']['title'] ? $turntableData['events']['weixinShare']['title'] : $turntableData['events']['events_name']);
- //print_r($turntableData);die;
- $this->setOutput('display', $turntableData['events']['list_display']);
- $this->setOutput('jsonTurntableData', $jsonTurntableData);
- $this->setOutput('turntableData', $turntableData);
- $this->setOutput('otherEventsData', $otherEventsData);
- $this->setOutput('eventsStatus', $eventsStatus);
- $this->setOutput('weixinShare', $turntableData['events']['weixinShare']);
- }
-
- /**
- * 转盘动作
- */
- public function doRotation() {
-
- # 获取转盘信息
- $events_id = Request::g('events_id');
- if (!Verify::unsignedInt($events_id)) {
- self::fail_exit('无效id');
- }
-
- $uid = $this->getRunTimeUid();
- $objLotteryEventsTypeTurntable = new LotteryEventsTypeTurntable($uid,$events_id);
- $turntableData = $objLotteryEventsTypeTurntable -> getEventsData();
-
- # 检查当前活动是否需要登录 & 获取登录地址
- $plat_form_id = $this->getPlatFormId();
- $objPlatForm = new Platform();
- $form = $objPlatForm -> get($plat_form_id);
- $url = $form['url'];
- $objMLottery = new Lottery();
- $thisUrl = $objMLottery -> getEventsUrl($turntableData['events']['type'],$turntableData['events']['create_time'],$url);
- $loginUrl = $this -> getLoginUrl($thisUrl);
-
- $authorize = $turntableData['events']['authorize'];
- if ($authorize && $loginUrl) {
- $ckLogin = $this->ckLogin();
- if($ckLogin==true){
- self::ajax_fail_exit(array('url' =>$loginUrl));
- }
- }
-
- $tmpLotteryData = $objLotteryEventsTypeTurntable ->sweepstakes();
- if(!$tmpLotteryData -> isSuccess()){
- self::ajax_fail_exit($tmpLotteryData->getData());
- }
- $lotteryData = $tmpLotteryData -> getData();
- $prize_id = $lotteryData['prize_id'];
-
- $thisPrizeData = array();
- $thisPrizeData['prize_name'] = $turntableData['prize'][$prize_id]['prize_name'];
- $thisPrizeData['id'] = $prize_id;
- $thisPrizeData['lottery_data_id'] = $lotteryData['id'];
- $thisPrizeData['express'] = $turntableData['prize'][$prize_id]['express'];
- $thisPrizeData['img_url'] = $turntableData['prize'][$prize_id]['img_url'];
- $thisPrizeData['express'] = $turntableData['prize'][$prize_id]['express'];
- $thisPrizeData['type'] = $turntableData['prize'][$prize_id]['type'];
- $thisPrizeData['virtual_data'] = isset($lotteryData['virtual_data'])?$lotteryData['virtual_data']:'';
- self::ajax_success_exit($thisPrizeData);
- }
-
-
-
- public function display() {
- return $this->render();
- }
- }
|