123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- <?php
- namespace Cas\Controller;
- use KIF\Core\Request;
- use Cas\Dao\LotteryEvents;
- use Cas\Module\Lottery;
- use KIF\Dao\SqlHelper;
- use Cas\Dao\UserInfo;
- use Cas\Module\LotteryLog;
- use Cas\Dao\LotteryData;
- use Cas\Module\User;
- use Cas\Dao\LotteryUserExpress;
- use Cas\Dao\Category;
- class Index extends EventsController {
-
-
- public function doDefault() {
-
-
- $title = '精彩活动';
- $this->checkIsFromMobile($title);
-
- $plat_form_id = $this->getPlatFormId();
-
- $thisTime = time();
- $objMLottery = new Lottery();
-
- $url = Request::g('url');
- $thisUrl = Request::schemeDomain().'/list/'.$url;
- $loginUrl = $this -> getLoginUrl($thisUrl);
- $this->setOutput('loginUrl', $loginUrl);
-
-
- $ckLogin = $this->ckLogin();
- $this->setOutput('ckLogin', $ckLogin);
-
-
- $objUserData = new UserInfo();
- $uid = $this->getRunTimeUid();
- $userData = $objUserData -> get($uid);
- $this->setOutput('userData', $userData);
-
-
- $order = 'begin_time desc';
- $focusCondition = array(
- 'display' => LotteryEvents::EVENT_DISPLAY_SHOW,
- 'focus_display' => LotteryEvents::FOCUS_DISPLAY_SHOW,
- 'begin_time' => SqlHelper::addCompareOperator('<=', time()),
- 'platform_ids' => SqlHelper::addCompareOperator('&', $plat_form_id),
- );
- $focusData = $objMLottery -> getLotteryEventsList($focusCondition, "0,5", 'id desc');
-
- $condition = array(
- 'display' => LotteryEvents::EVENT_DISPLAY_SHOW,
-
- 'top_display' => LotteryEvents::TOP_DISPLAY_SHOW,
- 'begin_time' => SqlHelper::addCompareOperator('<=', time()),
- 'platform_ids' => SqlHelper::addCompareOperator('&', $plat_form_id),
- );
- $totals = $objMLottery -> getLotteryEventsListNum($condition);
- $offset = 0;
- $size = 10;
-
- $order = 'begin_time desc';
-
- $eventsData = $objMLottery -> getLotteryEventsList($condition, "{$offset},{$size}", $order);
- $TIME = time();
- foreach ($eventsData as $tmpKey => $tmpData) {
-
- $rday = ($tmpData['end_time'] - $TIME) / (24 * 60 * 60);
- $eventsData[$tmpKey]['rday'] = ceil($rday);
-
- $objMLotteryLog = new LotteryLog ( null, $tmpData['id'] );
- $eventsData[$tmpKey]['user_total'] = $objMLotteryLog->getUserParticipateLogNumGroupByUid ();
- }
-
- $condition = array('platform_id' => SqlHelper::addCompareOperator('&', $plat_form_id), 'scratch_receive' => LotteryData::EVENT_SCRATCH_RECEIVE_TRUE);
- $totals = $objMLottery -> getLotteryDataListNum($condition);
- $offset = 0;
- $size = 6;
- $order = 'update_time desc';
- $data = $objMLottery->getLotteryDataList($condition, "{$offset},{$size}", $order);
- if ($data) {
- $uids = array();
- foreach ($data as $k => $v) {
- $uids[] = $v['uid'];
- }
-
- $objMUser = new User();
- $users = $objMUser -> gets($uids);
- $objLotteryUserExpress = new LotteryUserExpress();
- $condition = array(
- 'uid' => $uids
- );
- $tmpUserExpIds = $objLotteryUserExpress->findIdsBy($condition);
- $userExpData = $objLotteryUserExpress -> gets($tmpUserExpIds);
- $newUserExpData = array();
- foreach($userExpData as $k => $v){
- $newUserExpData[$v['uid']] = $v;
- }
- $this->setOutput('newUserExpData', $newUserExpData);
-
- foreach ($data as $k => $v) {
- $data[$k]['user'] = array();
- $data[$k]['user']['cdate'] = $v['winners_time'];
- $data[$k]['user']['events'] = $eventsData[$v['events_id']]['events_name'];
- if (isset($users[$v['uid']]['headimgurl']) && $users[$v['uid']]['headimgurl']) {
- $data[$k]['user']['headimgurl'] = $users[$v['uid']]['headimgurl'];
- } else {
- $data[$k]['user']['headimgurl'] = 'http://news.mydrivers.com/Img/20110518/04481549.png';
- }
- if (isset($v['express']['phone']) && $v['express']['phone']) {
- $data[$k]['user']['mobile'] = substr_replace($v['express']['phone'],'****',3,4);
- } elseif (isset($newUserExpData[$v['uid']]['phone']) && $newUserExpData[$v['uid']]['phone']) {
- $data[$k]['user']['mobile'] = substr_replace($newUserExpData[$v['uid']]['phone'],'****',3,4);
- } else {
- unset($data[$k]);
- }
- }
- $this->setOutput('userData', $data);
- }
-
- $this->objDCategory = new Category ();
- $order = 'id desc';
- $condition = array ();
- $ids = $this->objDCategory->findIdsBy ( $condition, '0,5', $order );
- $categoryData = $this->objDCategory->gets ( $ids );
- $this->setOutput('categoryData', $categoryData);
- $this->setOutput('eventsData', $eventsData);
- $this->setOutput('title', '精彩活动');
- $this->setOutput('totals', ceil($totals / $size));
- $this->tpl = 'mrhi/index';
- $this->setOutput('plat_form_id', $plat_form_id);
- $this->setOutput('url', $url);
- }
-
- public function doAjax() {
- $page = Request::varGetInt('page', 1);
- $thisTime = time();
- $objMLottery = new Lottery();
- $plat_form_id = Request::g('plat_form_id');
- $condition = array(
- 'display' => LotteryEvents::EVENT_DISPLAY_SHOW,
- 'list_display' => LotteryEvents::LIST_DISPLAY_SHOW,
- 'top_display' => LotteryEvents::TOP_DISPLAY_SHOW,
- 'begin_time' => SqlHelper::addCompareOperator('<=', time()),
- 'platform_ids' => SqlHelper::addCompareOperator('&', $plat_form_id),
- );
- $totals = $objMLottery -> getLotteryEventsListNum($condition);
- $order = 'begin_time desc';
- $size = 10;
- $offset = ($page - 1) * $size;
- $limit = "{$offset},{$size}";
- $eventsData = $allLotteryEventsIds = $objMLottery -> getLotteryEventsList($condition,$limit,$order);
-
-
- $TIME = time();
- foreach ($eventsData as $tmpKey => $tmpData) {
- $rday = ($tmpData['end_time'] - $TIME) / (24 * 60 * 60);
- $eventsData[$tmpKey]['rday'] = ceil($rday);
- }
-
- $this->tpl = 'ajax_index';
- $data = array_fill(0, 4, 1);
- $this->setOutput('eventsData', $eventsData);
- $this->ajax_success_exit($this->render(true));
- }
-
- public function display() {
- $this->setOutput('action', 'index');
- return $this->render();
- }
- }
|