EventsOther.class.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. namespace Cas\Controller;
  3. use Cas\Dao\LotteryEvents;
  4. use KIF\Core\Request;
  5. use KIF\Verify;
  6. use Cas\Module\LotteryLog;
  7. use Cas\Dao\UserInfo;
  8. use Cas\Module\Count;
  9. use Cas\Module\Lottery;
  10. /**
  11. * 其他 活动
  12. */
  13. class EventsOther extends EventsController {
  14. public function doDefault() {
  15. $thisTime = time();
  16. $events_id = $this->getEventsCreateTimeToId();
  17. //$events_id = Request::g('events_id');
  18. if (!Verify::unsignedInt($events_id)) {
  19. self::fail_exit('无效id');
  20. }
  21. # 获取“其他”信息
  22. $objDLotteryEvents = new LotteryEvents();
  23. $otherInfo = $objDLotteryEvents -> get($events_id);
  24. # 获取登录地址
  25. $url = Request::g('url');
  26. $plat_form_id = $this->getPlatFormId();
  27. $objMLottery = new Lottery();
  28. $thisUrl = $objMLottery -> getEventsUrl($otherInfo['type'],$otherInfo['create_time'],$url);
  29. $loginUrl = $this -> getLoginUrl($thisUrl);
  30. $this->setOutput('loginUrl', $loginUrl);
  31. # 判断是否需要登录
  32. $ckLogin = $this->ckLogin();
  33. $this->setOutput('ckLogin', $ckLogin);
  34. # 获取用户信息
  35. $objUserData = new UserInfo();
  36. $uid = $this->getRunTimeUid();
  37. $userData = $objUserData -> get($uid);
  38. $this->setOutput('userData', $userData);
  39. $eventsBeginOrEndState = array( 'show' => false);
  40. if($thisTime < $otherInfo['begin_time'] ){
  41. $eventsBeginOrEndState['show'] = true;
  42. $eventsBeginOrEndState['msg'] = '未开始';
  43. }
  44. if($thisTime > $otherInfo['end_time']){
  45. $eventsBeginOrEndState['show'] = true;
  46. $eventsBeginOrEndState['msg'] = '已结束';
  47. }
  48. if($thisTime > $otherInfo['begin_time'] && $thisTime < $otherInfo['end_time']){
  49. $eventsBeginOrEndState['show'] = false;
  50. }
  51. # 检查当前活动是否需要登录
  52. $authorize = $otherInfo['authorize'];
  53. if ($authorize && $loginUrl) {
  54. if($ckLogin==true){
  55. self::redirect($loginUrl);
  56. }
  57. }
  58. # 记录PV UV日志 访问
  59. $objCount = new Count();
  60. $objCount->setPassLog( $events_id,$plat_form_id);
  61. if(isset($otherInfo['other_url']) && !empty($otherInfo['other_url']) && !$eventsBeginOrEndState['show'] ){
  62. #######用户行为记录########
  63. #用户抽中奖品
  64. $objMLotteryLog = new LotteryLog($uid,$events_id);
  65. $other = array(
  66. '跳转页面:' => '成功'
  67. );
  68. $objMLotteryLog ->addUserParticipateLog($other);
  69. #########################
  70. header ( "Location: ".$otherInfo['other_url'] );
  71. }else{
  72. self::echo_404();
  73. }
  74. exit;
  75. }
  76. public function display() {
  77. return $this->render();
  78. }
  79. }