123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- <?php
- namespace Cas\Controller\Admin\Activity;
- use Cas\Module\Lottery;
- use Cas\Dao\PlatformBulletin;
- use KIF\Core\Request;
- use Cas\Dao\LotteryEvents;
- use Cas\Controller\Admin\Controller;
- use Cas\Dao\Platform;
- use Cas\Dao\LotteryDeliveryChannels;
- use KIF\Core\Config;
- use Cas\Module\LotteryLog;
- use KIF\Page\Page;
- use Cas\Module\User;
- use KIF\Data\Convert;
- use Cas\Dao\LotteryData;
- use Cas\Dao\LotteryPrize;
- use Cas\Dao\LotteryEventsForms;
- use KIF\Verify;
- use Cas\Dao\LotteryUserExpress;
- use Cas\Dao\LotteryUserParticipateLog;
- use Cas\Dao\LotteryUserHelp;
- use Cas\Dao\LotteryUserHelpLog;
- /**
- * "活动相关" - "互动数据"
- *
- * @author lihuanchun
- *
- */
- class UserHelp extends Controller {
- private $objLottery; // 活动后端
- private $peratorData;
-
- /**
- * 初始化
- */
- public function __construct() {
- header ( "Content-Type: text/html; charset=utf-8" );
- $this->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 );
- $helpData = $this->objLotteryUserHelp->fetchAll ($condition, $limit, $order );
- // 分页
- $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
- );
- $order = ' num desc, id desc';
- $helpData = $this->objLotteryUserHelp->fetchAll ($condition, 10000, $order );
-
- $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("<br>",",", $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 ();
- }
- }
-
|