objLottery = new Lottery (); $this->objLotteryUserHelp = new LotteryUserHelp (); $this->operatorData = $this->getUser (); $this->setOutput('action', Request::g('action')); } public function doDefault() { } /** * 获取当前互动的互动数据 * 地址:页面: http://cas.lishuy.com/?c=Admin_Activity_UserHelp&a=PageList&events_id=n * 参数:events_id 活动ID 必填 * 参数:groupByUid 是否用户排重  * */ public function doPageList() { $events_id = Request::varGetInt ( 'events_id' ); $groupByUid = Request::g ( 'groupByUid' ); // 用户是否排重 $objMLotteryLog = new LotteryLog ( null, $events_id ); $eventData = $this->objLottery->getOneLotteryEvents ( $events_id ); $this->setOutput ( 'eventData', $eventData ); $page = Request::varGetInt ( 'page', 1 ); $size = 10; $offset = ($page - 1) * $size; $limit = "{$offset},{$size}"; $order = ' num desc, id desc'; $condition = array ( 'events_id' => $events_id ); $total_num = $this->objLotteryUserHelp->totals ( $condition ); $ids = $this->objLotteryUserHelp->findIdsBy ( $condition, $limit, $order ); $helpData = $this->objLotteryUserHelp->gets ( $ids ); // 分页 $this->objLotteryUserHelpLog = new LotteryUserHelpLog (); $url_tpl = Request::url(); $url_tpl .= "&page={page}"; $objPage = new Page ( $total_num, $url_tpl, $page, $size ); $page_html = $objPage->html (); $uids = array (); foreach ( $helpData as $key => $data ) { $uids [$data ['uid']] = $data ['uid']; //$helpData[$key]['num'] = $this->objLotteryUserHelpLog->totals(array('help_id' => $data['id'])); } # 通过UIDs 获取用户信息 $objMUser = new User(); $userData = $objMUser -> gets($uids); $this->tpl = 'admin/activity/user_help'; $title = '助力排行'; $this->setOutput('title', $title); $this->setOutput('menu_active', array('name' => 'mypublish', 'item' => '')); //激活菜单 $this->addNavMenu('活动列表'); $this->addNavMenu($title); // 获取所有活动类型 $typeData = LotteryEvents::getType (); // 转换格式 if($eventData['type'] == LotteryEvents:: TYPE_EVENTS_SURVEY && $_GET['action'] == 'all'){ $helpData =$this->setData($eventData,$helpData); } $navConfig = $this->getUpPageNav($events_id, 'UserLog'); $eventsDisplayStatus = LotteryEvents::getDisplay (); // [活动] 是否显示 $isPrizes = in_array($eventData['type'], array(LotteryEvents::TYPE_EVENTS_TURNTABLE, LotteryEvents::TYPE_EVENTS_SCRATCH, LotteryEvents::TYPE_EVENTS_TRY, LotteryEvents::TYPE_EVENTS_INVITATION)); $this->setOutput('isPrizes', $isPrizes); $this->setOutput ( 'eventsDisplayStatus', $eventsDisplayStatus ); $this->setOutput ( 'groupByUid', $groupByUid ); $this->setOutput ( 'navConfig', $navConfig ); //公用内部导航信息 $this->setOutput ( 'page_html', $page_html ); //分页HTML $this->setOutput ( 'helpData', $helpData ); // i日志 $this->setOutput ( 'total_num', $total_num ); // 参与人数 $this->setOutput ( 'userData', $userData ); // 当前列表用户信息 $this->setOutput ( 'eventData', $eventData ); // 当前活动信息 $this->setOutput ( 'typeData', $typeData ); $this->setOutput('displayDesc', LotteryEvents::getDisplay()); $this->setOutput('pagePublicData', $this->getPagePublicData($events_id)); // 后台管理相关数据 if ($groupByUid) { $download_url = Request::schemeDomain() . "/?c=Admin_Activity_UserHelp&a=ExportData&groupByUid=true&events_id={$events_id}"; } else { $download_url = Request::schemeDomain() . "/?c=Admin_Activity_UserHelp&a=ExportData&events_id={$events_id}"; } $this->setOutput('download_url', $download_url); } /** * 导出:获取用户参与活动日志 * ?c=Admin_Activity_UserParticipateLog&a=doExportData&events_id=x * ?c=Admin_Activity_UserParticipateLog&a=doExportData&groupByUid=true&events_id=x */ public function doExportData() { $events_id = Request::varGetInt ( 'events_id' ); $groupByUid = Request::g ( 'groupByUid' ); $datalist = array (); $objMLotteryLog = new LotteryLog ( null, $events_id ); $allData = array (); $condition = array ( 'events_id' => $events_id ); $ids = $this->objLotteryUserHelp->findIdsBy ( $condition); $allData = $this->objLotteryUserHelp->gets ( $ids ); $uids = array (); foreach ( $allData as $key => $data ) { $uids [$data ['uid']] = $data ['uid']; } // 转换格式 $eventData = $this->objLottery->getOneLotteryEvents ( $events_id ); /* if($eventData['type'] == LotteryEvents:: TYPE_EVENTS_SURVEY ){ $allData =$this->setData($eventData,$allData); foreach($allData as $key => $data){ $allData[$key]['other']['选择内容:'] = str_replace("
",",", $allData[$key]['other']['选择内容:']); } } */ # 通过UIDs 获取用户信息 $objMUser = new User(); $userData = $objMUser -> gets($uids); $filename = '' . date ( 'YmdHis' ) . '.csv'; header ( "Content-Type: application/vnd.ms-excel; charset=GBK" ); header ( "Pragma: public" ); header ( "Expires: 0" ); header ( 'Content-Disposition: attachment; filename=' . $filename ); $titleTag = '用户ID,昵称,时间,邀请人次数量' . "\n"; foreach ( $allData as $data ) { $titleTag .= $data ['uid'] . ',' . $userData [$data ['uid']] ['nickname'] . ',' . date ( 'Y-m-d H:i:s', $data ['create_time'] ) . ',' . $data['num'] . "\n"; } $titleTag = Convert::u82gb ( $titleTag ); exit ( $titleTag ); } public function display() { return $this->render (); } }