| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791 | 
							- <?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;
 
- /**
 
-  * "活动相关" - "互动数据"
 
-  * 
 
-  * @author lihuanchun 
 
-  *          
 
-  */
 
- class UserParticipateLog  extends Controller {
 
- 	private $objLottery; // 活动后端
 
- 	private $peratorData;
 
- 	
 
- 	/**
 
- 	 *  初始化
 
- 	 */
 
- 	public function __construct() {
 
- 		header ( "Content-Type: text/html; charset=utf-8" );
 
- 		$this->objLottery = new Lottery ();
 
- 		$this->operatorData = $this->getUser ();
 
- 		
 
- 		$this->setOutput('action', Request::g('action'));
 
- 	}
 
- 	
 
- 	public function doDefault() {
 
- 		
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 获取当前互动的互动数据
 
- 	 * 地址:页面: http://cas.lishuy.com/?c=Admin_Activity_UserParticipateLog&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 = ' id desc';
 
- 		$total_user_num = $objMLotteryLog->getUserParticipateLogNumGroupByUid ();
 
- 		
 
- 		if ($groupByUid) {
 
- 			$logData = $objMLotteryLog->findUserParticipateDataGroupByUid ( $limit, $order );
 
- 			$total_num = $total_user_num;
 
- 		} else {
 
- 			$condition = array (
 
- 					'events_id' => $events_id
 
- 			);
 
- 			$logData = $objMLotteryLog->findUserParticipateData ( $condition, $limit, $order );
 
- 			$total_num = $objMLotteryLog->getUserParticipateLogNum ( $condition );
 
- 		}
 
- 		// 分页
 
- 		$url_tpl = Request::url();
 
- 		$url_tpl .= "&page={page}";
 
- 		$objPage = new Page ( $total_num, $url_tpl, $page, $size );
 
- 		$page_html = $objPage->html ();
 
- 		
 
- 		$uids = array ();
 
- 		foreach ( $logData as $key => $data ) {
 
- 			$uids [$data ['uid']] = $data ['uid'];
 
- 		}
 
- 		
 
- 		# 通过UIDs 获取用户信息
 
- 		$objMUser = new User();
 
- 		$userData = $objMUser -> gets($uids);
 
- 		
 
- 		$this->tpl = 'admin/activity/user_participate_log';
 
- 		$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'){
 
- 			$logData =$this->setData($eventData,$logData);
 
- 		}
 
- 		
 
- 		$navConfig = $this->getUpPageNav($events_id, 'UserLog');
 
- 		$eventsDisplayStatus = LotteryEvents::getDisplay (); // [活动] 是否显示
 
- 		
 
- 		$this->setOutput ( 'eventsDisplayStatus', $eventsDisplayStatus );
 
- 		$this->setOutput ( 'groupByUid', $groupByUid );
 
- 		$this->setOutput ( 'navConfig', $navConfig ); //公用内部导航信息
 
- 		$this->setOutput ( 'page_html', $page_html ); //分页HTML
 
- 		$this->setOutput ( 'logData', $logData ); // i日志
 
- 		$this->setOutput ( 'total_user_num', $total_user_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)); // 后台管理相关数据
 
- 		
 
- 		$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);
 
- 		
 
- 		if ($groupByUid) {
 
- 			$download_url = Request::schemeDomain() . "/?c=Admin_Activity_UserParticipateLog&a=ShowUserParticipateLogExportData&groupByUid=true&events_id={$events_id}";
 
- 		} else {
 
- 			$download_url = Request::schemeDomain() . "/?c=Admin_Activity_UserParticipateLog&a=ShowUserParticipateLogExportData&events_id={$events_id}";
 
- 		}
 
- 		$this->setOutput('download_url', $download_url);
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 事件:更新审核状态
 
- 	 * 地址:http://cas.lishuy.com/index.php?c=Admin_Category_Index&a=Audit
 
- 	 * 参数:见方法内
 
- 	 */
 
- 	public function doAudit() {
 
- 		$tableInfo = $_POST;
 
- 		$events_id = $tableInfo['id'];
 
- 		$eventData = $this->objLottery->getOneLotteryEvents ( $events_id );
 
- 		$this->objDLotteryEventsForms = new LotteryEventsForms();// 用户"参与"活动日志
 
- 		$this->objDLotteryData = new LotteryData();
 
- 		if (isset($tableInfo['yes']) && $tableInfo['yes']) {
 
- 			$tableInfo['yes'] = explode(',', $tableInfo['yes']);
 
- 			foreach ($tableInfo['yes'] as $k => $v) {
 
- 				$info = array(
 
- 					'audit' => 2,
 
- 					'operator_uid' => $operator_uid
 
- 				);
 
- 				$this->objDLotteryEventsForms->modify( $info, array (
 
- 						'id' => $v 
 
- 				));
 
- 				# 审核成功后,要把数据加到中奖表中
 
- 				$this->updateAuditData(2, $events_id, $eventData, $v, 0);
 
- 			}
 
- 		}
 
- 		if (isset($tableInfo['no']) && $tableInfo['no']) {
 
- 			$tableInfo['no'] = explode(',', $tableInfo['no']);
 
- 			foreach ($tableInfo['no'] as $k => $v) {
 
- 				$info = array(
 
- 					'audit' => 3,
 
- 					'operator_uid' => $operator_uid
 
- 				);
 
- 				$this->objDLotteryEventsForms->modify( $info, array (
 
- 						'id' => $v 
 
- 				));
 
- 				# 审核失败后,要把数据从中奖表中拿出来
 
- 				$this->updateAuditData(3, $events_id, $eventData, $v, 0);
 
- 			}
 
- 		}
 
- 		
 
- 		$this->ajax_success_exit();
 
- 	}
 
- 	private function updateAuditData($audit, $events_id, $eventData, $formId, $prize_id)
 
- 	{
 
- 		$form = $this->objDLotteryEventsForms->get($formId);
 
- 		if ($eventData['type'] == 4) {
 
- 			# 试用
 
- 			$img = $eventData['weixinShare']['imgUrl'];
 
- 			$img = $img ? $img : $eventData['img_url'];
 
- 			$prize = array(
 
- 				0 => array(
 
- 					'events_id' => $events_id,
 
- 					'prize_name'  =>$eventData['events_name'],
 
- 					'img_url' => $img,
 
- 					'type' => LotteryPrize::TYPE_VIRTUAL,
 
- 				)
 
- 			);
 
- 			$virtual_data = "/?c=EventsTry&events_id={$events_id}&formsId=" . $form['id'];
 
- 		} elseif ($eventData['type'] == 6) {
 
- 			# 邀请函
 
- 			$prize = array(
 
- 				0 => array(
 
- 					'events_id' => $events_id,
 
- 					'prize_name'  =>$eventData['events_name'],
 
- 					'img_url' => '/public/static/img/qricon.png',
 
- 					'type' => LotteryPrize::TYPE_ENTITY,
 
- 				)
 
- 			);
 
- 			$virtual_data = "/?c=EventsInvitation&a=Qrcode&events_id={$events_id}&formsId=" . $form['id'];
 
- 		}
 
- 		$info  = array(
 
- 				'events_id' => $events_id,
 
- 				'form_id' => $form['id'],
 
- 				'prize_id' => $prize_id,
 
- 				'audit' => $audit,
 
- 				'uid' => $form['uid'],
 
- 				'winners_time' => $form['update_time'],
 
- 				'winning_time' => $form['update_time'],
 
- 				'run_time_data' => array(
 
- 					'events' => $eventData,
 
- 					'prize' => $prize,
 
- 				),
 
- 				'virtual_data' => $virtual_data,
 
- 		);
 
- 		$dataInfo = $this->objDLotteryData->fetchOne(array
 
- 		(
 
- 			'events_id' => $events_id,
 
- 			'uid' => $info['uid'],
 
- 			'prize_id' => $prize_id,
 
- 		));
 
- 		if (!$dataInfo) {
 
- 			$this->objDLotteryData -> add($info);
 
- 		} else {
 
- 			$this->objDLotteryData -> modify($info, array('id' => $dataInfo['id']));
 
- 		}
 
- 	}
 
- 	
 
- 	/**
 
- 	 *  显示 用户调查问卷 选择的结果集
 
- 	 */
 
- 	public function doShowResultSet(){
 
- 		$events_id = Request::varGetInt ( 'events_id' );
 
- 		$objMLotteryLog = new LotteryLog ( null, $events_id );
 
- 		$condition = array (
 
- 				'events_id' => $events_id
 
- 		);
 
- 		$logData = $objMLotteryLog->findUserParticipateData ( $condition);
 
- 		$eventData = $this->objLottery->getOneLotteryEvents ( $events_id );
 
- 		if($eventData['type'] != LotteryEvents:: TYPE_EVENTS_SURVEY){
 
- 			exit('end');
 
- 		}
 
- 		$return_data = array();
 
- 		
 
- 		$survery_question = $eventData['survery_question'];
 
- 	
 
- 		foreach($survery_question as $key => $data){
 
- 			
 
- 			$survery_question[$key]['choice'] = $data['choice']==0?'单选':'多选';
 
- 			$survery_question[$key]['num'] = 0;
 
- 			foreach($survery_question[$key]['answer'] as $k =>$d){
 
- 				$survery_question[$key]['answer'][$k]['num'] = 0;
 
- 			}
 
- 		}
 
- 		
 
- 		$log = array();
 
- 		foreach($logData as $key =>$data){
 
- 			$xznr = $data['other']['选择内容:'];
 
- 			if($xznr){
 
- 				$wtData = explode('|', $xznr);
 
- 				
 
- 				foreach($wtData as $key=> $wt){
 
- 					$survery_question[$key+1]['num'] ++;
 
- 					
 
- 					if($wt){
 
- 						$xz = explode(',', $wt);
 
- 						foreach($xz as $xzkey){
 
- 							$xzkey = (int)$xzkey;
 
- 							$survery_question[$key+1]['answer'][$xzkey]['num'] ++ ;
 
- 						}
 
- 					}
 
- 					
 
- 				}
 
- 			}
 
- 		}
 
- 	
 
- 	$mp=	$survery_question[1]['num'];
 
- 	echo "此次活动共计: {$mp}次 完成问卷<br><br><br>";
 
- 	foreach( $survery_question as $key=>$data){
 
- 			echo "问题[{$key}]:".$data['question'].'<br>';
 
- 			echo "选择类型:[".$data['choice'].']<br>';
 
- 			echo '选择:<br>';
 
- 			foreach($data['answer'] as $k => $d){
 
- 				$hhl=round(($d['num']/$data['num'])*100);
 
- 				echo "  ({$k}) ;  {$d['answer']};   [  {$hhl} %]<br>";
 
- 			}
 
- 			echo '<br><br><br>';
 
- 	}
 
- 		
 
- 	}
 
- 	
 
- 	
 
- 	/**
 
- 	 * 转换数据格式
 
- 	 */
 
- 	public function setData($eventData,$logData){
 
- 		foreach($logData as $key => $data){
 
- 			$txt = '';
 
- 			$tmpLog = $data['other']['选择内容:'] ;
 
- 				
 
- 			$tmpData  = explode('|', $tmpLog) ;
 
- 			foreach($tmpData as  $k =>$d){
 
- 		
 
- 				$txt .= "<br><br>    题目  :".$eventData['survery_question'][$k+1]['question']."<br>用户选择:  ";
 
- 					
 
- 				$ttdd = explode(',', $d);
 
- 		
 
- 				foreach($ttdd as $tt){
 
- 					$tmptt = (int)$tt;
 
- 					$txt  = $txt .$eventData['survery_question'][$k+1] ['answer'][$tmptt]['answer']." |  ";
 
- 				}
 
- 			}
 
- 			$logData[$key]['other']['tmp'] = $txt;
 
- 				
 
- 		}
 
- 			
 
- 		foreach($logData as $key => $data){
 
- 			if(isset($logData[$key]['other']['tmp'])){
 
- 				$logData[$key]['other']['选择内容:']  = 	$logData[$key]['other']['tmp']."<br><br>" ;
 
- 				unset($logData[$key]['other']['tmp']);
 
- 			}else{
 
- 				$logData[$key]['other']['选择内容:'] = "用户未选择"."<br><br>" ;
 
- 			}
 
- 		}
 
- 		return $logData;
 
- 	}
 
- 	
 
- 	
 
- 	
 
- 	/**
 
- 	 * 导出:获取用户参与活动日志
 
- 	 * ?c=Admin_Activity_UserParticipateLog&a=ShowUserParticipateLogExportData&events_id=x
 
- 	 * ?c=Admin_Activity_UserParticipateLog&a=ShowUserParticipateLogExportData&groupByUid=true&events_id=x
 
- 	 */
 
- 	public function doShowUserParticipateLogExportData() {
 
- 		$events_id = Request::varGetInt ( 'events_id' );
 
- 		$groupByUid = Request::g ( 'groupByUid' );
 
- 	
 
- 		$datalist = array ();
 
- 		$objMLotteryLog = new LotteryLog ( null, $events_id );
 
- 		
 
- 		$allData = array ();
 
- 		if ($groupByUid) {
 
- 			$allData = $objMLotteryLog->findUserParticipateDataGroupByUid (null,null);
 
- 		} else {
 
- 			$condition = array (
 
- 					'events_id' => $events_id
 
- 			);
 
- 			$allData = $objMLotteryLog->findUserParticipateData ( $condition,null,null );
 
- 		}
 
- 		
 
- 		$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 ) {
 
- 			if (isset ( $data ['other'] )) {
 
- 				$otherStr = '';
 
- 				foreach ( $data ['other'] as $k => $d ) {
 
- 					$otherStr = $otherStr . $k . $d;
 
- 				}
 
- 				$titleTag .= $data ['uid'] . ',' . $userData [$data ['uid']] ['nickname'] . ',' . date ( 'Y-m-d H:i:s', $data ['create_time'] ) . ',' . $otherStr . "\n";
 
- 			} else {
 
- 				$titleTag .= $data ['uid'] . ',' . $userData [$data ['uid']] ['nickname'] . ',' . date ( 'Y-m-d H:i:s', $data ['create_time'] ) . ',空' . "\n";
 
- 			}
 
- 		}
 
- 		
 
- 		$titleTag = Convert::u82gb ( $titleTag );
 
- 	
 
- 		exit ( $titleTag );
 
- 	}
 
- 	
 
- 	
 
- 	/**
 
- 	 *  页面:[查看中奖详情]  
 
- 	 *  地址:页面: http://cas.lishuy.com/?c=Admin_Activity_UserParticipateLog&a=PageLotteryDataList&events_id=n
 
- 	 *  活动ID:events_id
 
- 	 *  筛选条件[奖品ID]:prize_id 
 
- 	 *  分页:page
 
- 	 *  详情:scratch_receive=false
 
- 	 */
 
- 	public function doPageLotteryDataList(){
 
- 		
 
- 		$events_id = Request::g ( 'events_id' );
 
- 		$scratch_receive = Request::g ( 'scratch_receive' );
 
- 		$eventsAndPrizeData =$this->objLottery->getOneLotteryEventsAndPrize($events_id);
 
- 		if($eventsAndPrizeData['events']['type'] == LotteryEvents::TYPE_EVENTS_SCRATCH){
 
- 		
 
- 		}
 
- 		// 取数据
 
- 		$page = Request::varGetInt ( 'page', 1 );
 
- 		$size = 20;
 
- 		$offset = ($page - 1) * $size;
 
- 		$limit = "{$offset},{$size}";
 
- 		$condition = array (
 
- 				'events_id' => $events_id,
 
- 				# 只有审核通过的才显示
 
- 				'audit' => 2,
 
- 		);
 
- 		
 
- 		// 刮刮卡 跳将特殊处理
 
- 		$pieze_notreceive_num = array();
 
- 		if($eventsAndPrizeData['events']['type'] == LotteryEvents::TYPE_EVENTS_SCRATCH){
 
- 				
 
- 			$condition['scratch_receive'] = LotteryData::EVENT_SCRATCH_RECEIVE_TRUE;
 
- 				
 
- 			foreach($eventsAndPrizeData['prize'] as $prize){
 
- 				$for_condition = array(
 
- 						'events_id' => $events_id,
 
- 						'prize_id' => $prize['id'],
 
- 						'scratch_receive' => LotteryData::EVENT_SCRATCH_RECEIVE_FALSE
 
- 				);
 
- 				$pieze_notreceive_num[$prize['id']] = $this->objLottery->getLotteryDataListNum($for_condition);
 
- 			}
 
- 		}
 
- 		
 
- 		// 筛选条件
 
- 		$prize_id = Request::g ( 'prize_id' );
 
- 		if ($prize_id) {
 
- 			$condition ['prize_id'] = $prize_id;
 
- 		}
 
- 		
 
- 		if($scratch_receive=='false'){
 
- // 			$condition['scratch_receive'] = LotteryData::EVENT_SCRATCH_RECEIVE_FALSE;
 
- 		}
 
- 		
 
- 		
 
- 		$total_num = $this->objLottery->getLotteryDataListNum($condition);
 
- 		$url_tpl = Request::url();
 
- 		if($prize_id){
 
- 			$url_tpl .= "&prize_id={$prize_id}";
 
- 		}
 
- 		$url_tpl .= "&page={page}";
 
- 		// 分页
 
- 		$objPage = new Page ( $total_num, $url_tpl, $page, $size );
 
- 		$page_html = $objPage->html ();
 
- 		
 
- 		$order = 'id desc';
 
- 		$lotteryData = $this->objLottery->getLotteryDataList ( $condition, $limit, $order );
 
- 		
 
- 		$uids = array();
 
- 		foreach ($lotteryData as $tmpItem) {
 
- 			$uids[] = $tmpItem['uid'];
 
- 		}
 
- 		
 
- 		# 通过UIDs 获取用户信息
 
- 		$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 $key => $data){
 
- 			$newUserExpData[$data['uid']] = $data;
 
- 		}
 
- 		
 
- 		$objLotteryEventsForms = new LotteryEventsForms();
 
- 		$formCondition = array(
 
- 			'events_id' => $events_id,
 
- 		);
 
- 		$ids = $objLotteryEventsForms->fetchOne($formCondition);
 
- 		if ($ids) {
 
- 			$formData = $objLotteryEventsForms->gets($ids);
 
- 			if ($formData) {
 
- 				foreach ($formData as $k => $v) {
 
- 					$formUserData[$v['uid']] = $v;
 
- 				}
 
- 				# 表单类型数据
 
- 				$formType = array();
 
- 				foreach ($eventsAndPrizeData['events']['forms'] as $tmpForms) {
 
- 					$formType[] = $tmpForms['name'];
 
- 				}
 
- 				$this->setOutput ( 'formType', $formType );
 
- 				$this->setOutput ( 'formUserData', $formUserData );
 
- 			}
 
- 		}
 
- 		$objDLotteryPrize = new LotteryPrize();
 
- 		$prizeType  = $objDLotteryPrize -> getType();
 
- 		$prizeDisplayStatus  = $objDLotteryPrize ->getDisplay();
 
- 		
 
- 		$this->tpl = 'admin/activity/user_participate_win';
 
- 		$title = '互动数据';
 
- 		$this->setOutput('title', $title);
 
- 		$this->setOutput('menu_active', array('name' => 'mypublish', 'item' => '')); //激活菜单
 
- 		$this->addNavMenu('活动列表');
 
- 		$this->addNavMenu($title);
 
- 		
 
- 		$this->setOutput ( 'newUserExpData', $newUserExpData );
 
- 		$this->setOutput ( 'page_html', $page_html );
 
- 		$this->setOutput ( 'eventData', $eventsAndPrizeData['events'] );
 
- 		$this->setOutput ( 'prizeData', $eventsAndPrizeData['prize'] );
 
- 		$this->setOutput ( 'pieze_notreceive_num', $pieze_notreceive_num );
 
- 		$this->setOutput ( 'prizeType', $prizeType );
 
- 		$this->setOutput ( 'lotteryData', $lotteryData );
 
- 		$this->setOutput('userData', $users);
 
- 		
 
- 		$navConfig = $this->getUpPageNav($events_id, 'UserLog');
 
- 		$this->setOutput ( 'navConfig', $navConfig );
 
- 		$typeData = LotteryEvents::getType ();
 
- 		$this->setOutput ( 'typeData', $typeData );
 
- 		$this->setOutput('displayDesc', LotteryEvents::getDisplay());
 
- 		$this->setOutput('pagePublicData', $this->getPagePublicData($events_id)); // 后台管理相关数据
 
- 		$this->setOutput('total_num', $total_num);
 
- 		
 
- 		$download_url = Request::schemeDomain() . "/?c=Admin_Activity_UserParticipateLog&a=ExportWinData&events_id={$events_id}";
 
- 		$this->setOutput('download_url', $download_url);
 
- 	}
 
- 	
 
- 	public function doExportWinData() {
 
- 		$events_id = Request::g ( 'events_id' );
 
- 		$condition = array (
 
- 				'events_id' => $events_id,
 
- 				# 只有审核通过的才显示
 
- 				'audit' => 2,
 
- 		);
 
- 		$order = 'id desc';
 
- 		$lotteryData = $this->objLottery->getLotteryDataList ( $condition, null, $order );
 
- 		
 
- 		$uids = array();
 
- 		foreach ($lotteryData as $tmpItem) {
 
- 			$uids[] = $tmpItem['uid'];
 
- 		}
 
- 		
 
- 		$eventsAndPrizeData =$this->objLottery->getOneLotteryEventsAndPrize($events_id);
 
- 		$prizeData = $eventsAndPrizeData['prize'];
 
- 		
 
- 		# 通过UIDs 获取用户信息
 
- 		$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 $key => $data){
 
- 			$newUserExpData[$data['uid']] = $data;
 
- 		}
 
- 	
 
- 		
 
- 		
 
- 		############发送头部信息############
 
- 		
 
- 		$fileName = date('YmdHis',time()) .".csv"; # 文件名
 
- 		$fileName = Convert::u82gb($fileName);
 
- 		header ( "Content-Type: application/vnd.ms-excel; charset=GBK" );
 
- 		header ( "Pragma: public" );
 
- 		header ( "Expires: 0" );
 
- 		header ( 'Content-Disposition: attachment; filename=' . $fileName );
 
- 		
 
- 		
 
- 		$title = "用户ID,昵称,时间,行为,用户收货信息\r\n";
 
- 		echo Convert::u82gb($title);
 
- 		
 
- 		foreach ($lotteryData as $tmpData) {
 
- 			$uid = $tmpData['uid'];
 
- 			$date = date('Y-m-d H:i:s', $tmpData['create_time']);
 
- 			$otherInfo = "获得奖品:{$prizeData[$tmpData['prize_id']]['prize_name']} ";
 
- 			if(isset($newUserExpData[$uid]['user_name'])){
 
- 				$info = "{$uid},{$users[$uid]['nickname']},{$date},{$otherInfo},姓名:{$newUserExpData[$uid]['user_name']}  地址:{$newUserExpData[$uid]['address']}  电话:{$newUserExpData[$uid]['phone']}\r\n";
 
- 			}else{
 
- 				$info = "{$uid},{$users[$uid]['nickname']},{$date},{$otherInfo},未填写\r\n";
 
- 			}
 
- 			
 
- 			echo Convert::u82gb($info);
 
- 		}
 
- 		
 
- 		
 
- 		exit;
 
- 	}
 
- 	
 
- 	
 
- 	/**
 
- 	 * 页面: [表单数据]
 
- 	 * 地址:http://cas.lishuy.com/?c=Admin_Activity_UserParticipateLog&a=PageEventFormData&events_id=n
 
- 	 * 活动ID:events_id
 
- 	 * 分页:page
 
- 	 */
 
- 	public function doPageEventFormData(){
 
- 		$events_id = Request::varGetInt ( 'events_id');
 
- 		if (!Verify::unsignedInt($events_id)) {
 
- 			self::fail_exit_bs('无效events_id');
 
- 		}
 
- 	
 
- 		$page = Request::varGetInt ( 'page', 1 );
 
- 		$size = 10;
 
- 		$offset = ($page - 1) * $size;
 
- 		$limit = "{$offset},{$size}";
 
- 		$condition = array (
 
- 				'events_id' => $events_id
 
- 		);
 
- 	
 
- 		$objLotteryEventsForms = new LotteryEventsForms();
 
- 		$ids = $objLotteryEventsForms->findIdsBy($condition,$limit,'id desc');
 
- 		$formData = $objLotteryEventsForms->gets($ids);
 
- 		
 
- 		$uids = array();
 
- 		foreach ($formData as $tmpItem) {
 
- 			$uids[] = $tmpItem['uid'];
 
- 		}
 
- 	
 
- 		$objLotteryEvents = new LotteryEvents();
 
- 		$eventData = $objLotteryEvents->get($events_id);
 
- 		# 审核状态只有在邀请函和试用才有,type=6&4
 
- 		$audit = false;
 
- 		if (in_array($eventData['type'], array(4,6))) {
 
- 			$audit = true;
 
- 		}
 
- 		$this->setOutput ( 'audit', $audit );
 
- 	
 
- 		# 表单类型数据
 
- 		$formType = array();
 
- 		foreach ($eventData['forms'] as $tmpForms) {
 
- 			$formType[] = $tmpForms['name'];
 
- 		}
 
- 	
 
- 		# 分页
 
- 		$total_num = $objLotteryEventsForms->totals($condition);
 
- 		$url_tpl = Request::url();
 
- 		$url_tpl .= "&page={page}";
 
- 		$objPage = new Page ( $total_num, $url_tpl, $page, $size );
 
- 		$page_html = $objPage->html ();
 
- 		
 
- 		# 通过UIDs 获取用户信息
 
- 		$objMUser = new User();
 
- 		$users = $objMUser -> gets($uids);
 
- 		$this->tpl = 'admin/activity/user_participate_form';
 
- 		$title = '互动数据';
 
- 		$this->setOutput('title', $title);
 
- 		$this->setOutput('menu_active', array('name' => 'mypublish', 'item' => '')); //激活菜单
 
- 		$this->addNavMenu('活动列表');
 
- 		$this->addNavMenu($title);
 
- 		$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('eventData', $eventData);
 
- 		$this->setOutput ( 'page_html', $page_html );
 
- 		$this->setOutput ( 'formData', $formData );
 
- 		$this->setOutput('formType', $formType);
 
- 		$this->setOutput('userData', $users);
 
- 		
 
- 		$navConfig = $this->getUpPageNav($events_id, 'UserLog');
 
- 		$this->setOutput ( 'navConfig', $navConfig );
 
- 		$typeData = LotteryEvents::getType ();
 
- 		$this->setOutput ( 'typeData', $typeData );
 
- 		$this->setOutput('displayDesc', LotteryEvents::getDisplay());
 
- 		$this->setOutput('pagePublicData', $this->getPagePublicData($events_id)); // 后台管理相关数据
 
- 		$this->setOutput('total_num', $total_num);
 
- 		$download_url = Request::schemeDomain() . "/?c=Admin_Activity_UserParticipateLog&a=ExportFormData&events_id={$events_id}";
 
- 		$this->setOutput('download_url', $download_url);
 
- 	}
 
- 	
 
- 	public function doExportFormData() {
 
- 		$events_id = Request::varGetInt ( 'events_id');
 
- 		if (!Verify::unsignedInt($events_id)) {
 
- 			self::fail_exit_bs('无效events_id');
 
- 		}
 
- 		
 
- 		$condition = array (
 
- 			'events_id' => $events_id
 
- 		);
 
- 		
 
- 		$objLotteryEventsForms = new LotteryEventsForms();
 
- 		$ids = $objLotteryEventsForms->findIdsBy($condition,null,'id desc');
 
- 		$formData = $objLotteryEventsForms->gets($ids);
 
- 		
 
- 		$uids = array();
 
- 		foreach ($formData as $tmpItem) {
 
- 			$uids[] = $tmpItem['uid'];
 
- 		}
 
- 		
 
- 		$objLotteryEvents = new LotteryEvents();
 
- 		$eventData = $objLotteryEvents->get($events_id);
 
- 		
 
- 		# 表单类型数据
 
- 		$formType = array();
 
- 		foreach ($eventData['forms'] as $tmpForms) {
 
- 			$formType[] = $tmpForms['name'];
 
- 		}
 
- 		
 
- 		# 通过UIDs 获取用户信息
 
- 		$objMUser = new User();
 
- 		$users = $objMUser -> gets($uids);
 
- 		
 
- 		############发送头部信息############
 
- 		$fileName = date('YmdHis',time()) .".csv"; # 文件名
 
- 		$fileName = Convert::u82gb($fileName);
 
- 		header ( "Content-Type: application/vnd.ms-excel; charset=GBK" );
 
- 		header ( "Pragma: public" );
 
- 		header ( "Expires: 0" );
 
- 		header ( 'Content-Disposition: attachment; filename=' . $fileName );
 
- 		
 
- 		# 审核状态只有在邀请函和试用才有,type=6&4
 
- 		$audit = false;
 
- 		if (in_array($eventData['type'], array(4,6))) {
 
- 			$audit = true;
 
- 		}
 
- 		$this->setOutput ( 'audit', $audit );
 
- 		$title = "用户ID,昵称,时间,行为\r\n";
 
- 		if ($audit) {
 
- 			$title = "用户ID,昵称,时间,行为,审核状态\r\n";
 
- 		}
 
- 		echo Convert::u82gb($title);
 
- 		
 
- 		foreach ($formData as $tmpData) {
 
- 			$uid = $tmpData['uid'];
 
- 			$date = date('Y-m-d H:i:s', $tmpData['create_time']);
 
- 			$formInfo = '';
 
- 			foreach ($formType as $formName) {
 
- 				$formInfo = "{$formName}:{$tmpData[$formName]} ";
 
- 			}
 
- 			$info = "{$uid},{$users[$uid]['nickname']},{$date},{$formInfo}\r\n";
 
- 			if ($audit) {
 
- 				$status = $tmpData['audit'];
 
- 				if ($status == 1) {
 
- 					$status = '未审核';
 
- 				} elseif ($status == 2) {
 
- 					$status = '审核通过';
 
- 				} elseif ($status == 3) {
 
- 					$status = '审核未通过';
 
- 				}
 
- 				$info = "{$uid},{$users[$uid]['nickname']},{$date},{$formInfo},{$status}\r\n";
 
- 			}
 
- 			echo Convert::u82gb($info);
 
- 		}
 
- 		exit;
 
- 	}
 
- 	
 
- 	
 
- 	public function display() {
 
- 		return $this->render ();
 
- 	}
 
- }
 
- 	
 
 
  |