| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 | 
							- <?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 KIF\Page\Page;
 
- /**
 
-  * "活动相关" - "投放渠道"
 
-  *  页面:   获取所有渠道列表分页   doPageList
 
-  *  事件:   添加渠道   doReqAddDeliveryChannels
 
-  *  事件:  修改渠道   doReqUp
 
-  * @author lihuanchun 
 
-  *          
 
-  */
 
- class DeliveryChannels extends Controller {
 
- 	private $objLottery; // 活动后端
 
- 	private $objDLotteryDeliveryChannels;
 
- 	private $objDPlatform;
 
- 	private $peratorData;
 
- 	private $objDoperatorData;
 
- 	/**
 
- 	 *  初始化
 
- 	 */
 
- 	public function __construct() {
 
- 		header ( "Content-Type: text/html; charset=utf-8" );
 
- 		$this->objLottery = new Lottery ();
 
- 		$this->operatorData = $this->getUser ();
 
- 		$this->objDPlatform = new Platform();
 
- 					
 
- 		$this->objDLotteryDeliveryChannels = new LotteryDeliveryChannels();
 
- 	}
 
- 	
 
- 	public function doDefault() {
 
- 		
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 默认页面
 
- 	 * 获取所有渠道列表分页
 
- 	 * 地址:http://cas.lishuy.com/?c=Admin_Activity_DeliveryChannels&a=PageList&events_id=
 
- 	 */
 
- 	public function doPageList() {
 
- 		
 
- 		$events_id = Request::g('events_id');
 
- 		$events_Data = $this->objLottery->getOneLotteryEventsAndPrize ( $events_id );
 
- 		$platFormData = $this->objDPlatform  -> getsAll();
 
- 		
 
- 		
 
- 		# 获取当前活动都添加哪些 列表
 
- 		# 返回列表IDs
 
- 		$platFormIds = array();
 
- 		foreach($platFormData as $key => $data){
 
- 			if($events_Data['platform_ids']&$key){
 
- 				$platFormIds[$key] = $key;
 
- 			}
 
- 		}
 
- 		
 
- 		$page = Request::varGetInt ( 'page', 1 );
 
- 		$size = 10;
 
- 		$offset = ($page - 1) * $size;
 
- 		$limit = "{$offset},{$size}";
 
- 		$condition  = array(
 
- 				'events_id' =>  $events_id
 
- 		);
 
- 		
 
- 		$total_num = $this->objDLotteryDeliveryChannels->totals ( $condition );
 
- 		
 
- 		$url_tpl = Request::schemeDomain () . "?c=Admin_Activity_DeliveryChannels&a=PageList";
 
- 		$url_tpl .= "?page={page}";
 
- 		$objPage = new Page ( $total_num, $url_tpl, $page, $size );
 
- 		$page_html = $objPage->html ();
 
- 		$order = 'id desc';
 
- 		$ids = $this->objDLotteryDeliveryChannels->findIdsBy ( $condition, $limit, $order );
 
- 		$deliveryChannelsData = $this->objDLotteryDeliveryChannels->gets ( $ids );
 
- 		
 
- 		$eventsDisplayStatus = LotteryEvents::getDisplay (); // [活动] 是否显示
 
- 		$objPlatform  = new Platform();
 
- 		$formData = $objPlatform -> getsAll();
 
- 		foreach($deliveryChannelsData as $key => $data){
 
- 			$deliveryChannelsData[$key]['url'] = $this->objLottery->getEventsUrl   ($events_Data['events']['type'] , $events_Data['events']['create_time']  , $formData[$data['platform_id']]['url']).'/?from='.$key;
 
- 			$this->createImgCodeUrl($deliveryChannelsData[$key]['url']);
 
- 			$deliveryChannelsData[$key]['img_url']  = $this->getImgCodePath($deliveryChannelsData[$key]['url']);
 
- 		}
 
- 		
 
- 		# 获取默认PV
 
- 		
 
- 		
 
- 		
 
- 		
 
- 		$this->setOutput( 'platFormIds' ,$platFormIds); // 当前活动包含的平台
 
- 		$this->setOutput ( 'platFormData', $platFormData ); // 当前所有平台列表信息
 
- 		$this->setOutput ( 'page_html', $page_html ); // 分页Html
 
- 		
 
- 	
 
- 		
 
- 		$this->setOutput ( 'deliveryChannelsData', $deliveryChannelsData ); // 渠道信息数据 
 
- 		
 
- 		
 
- 		//公用内部导航信息
 
- 		$navConfig = $this->getUpPageNav($events_id, 'DeliveryChannels');
 
- 		$typeData = LotteryEvents::getType (); 
 
- 		$this->setOutput ( 'navConfig', $navConfig ); 
 
- 		$this->setOutput ( 'typeData', $typeData );
 
- 		$this->setOutput ( 'eventData', $events_Data['events'] );
 
- 		$this->setOutput ( 'eventsDisplayStatus', $eventsDisplayStatus );
 
- 		
 
- 		$this->tpl = 'admin/activity/delivery_channels_list';
 
- 		$title = '基础设置';
 
- 		$this->setOutput('title', $title);
 
- 		$this->setOutput('menu_active', array('name' => 'mypublish', 'item' => '')); //激活菜单
 
- 		$this->addNavMenu('活动列表');
 
- 		$this->addNavMenu($title);
 
- 		$this->setOutput('displayDesc', LotteryEvents::getDisplay());
 
- 		$this->setOutput('pagePublicData', $this->getPagePublicData($events_id)); // 后台管理相关数据
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 页面:   添加渠道
 
- 	 * 地址:http://cas.lishuy.com/?c=Admin_Activity_DeliveryChannels&a=PageAddDeliveryChannels&events_id=
 
- 	 */
 
- 	public function doPageAddDeliveryChannels(){
 
- 		$events_id = Request::g('events_id');
 
- 		
 
- 		$events_Data = $this->objLottery->getOneLotteryEventsAndPrize ( $events_id );
 
- 		
 
- 		$platFormData = $this->objDPlatform  -> getsAll();
 
- 		
 
- 		# 获取当前活动都添加哪些列表
 
- 		$platFormIds = array();
 
- 		foreach($platFormData as $key => $data){
 
- 			if($events_Data['events']['platform_ids']&$key){
 
- 				$platFormIds[$key] = $key;
 
- 			}
 
- 		}
 
- 		
 
- 		$this->setOutput ( 'platFormData', $platFormData );
 
- 		$this->setOutput ( 'platFormIds', $platFormIds );
 
- 		
 
- 		
 
- 		
 
- 		# 公用内部导航信息
 
- 		$navConfig = $this->getUpPageNav($events_id, 'DeliveryChannels');
 
- 		$typeData = LotteryEvents::getType ();
 
- 		$eventsDisplayStatus = LotteryEvents::getDisplay ();
 
- 		$this->setOutput ( 'navConfig', $navConfig );
 
- 		$this->setOutput ( 'typeData', $typeData );
 
- 		$this->setOutput ( 'eventData', $events_Data['events'] );
 
- 		$this->setOutput ( 'eventsDisplayStatus', $eventsDisplayStatus );
 
- 		
 
- 		
 
- 		$this->tpl = 'admin/activity/delivery_channels_add';
 
- 		$title = '添加投放渠道';
 
- 		$this->setOutput('title', $title);
 
- 		$this->setOutput('menu_active', array('name' => 'mypublish', 'item' => '')); //激活菜单
 
- 		$this->addNavMenu('活动列表');
 
- 		$this->addNavMenu($title);
 
- 		
 
- 		$this->setOutput('displayDesc', LotteryEvents::getDisplay());
 
- 		$this->setOutput('pagePublicData', $this->getPagePublicData($events_id)); // 后台管理相关数据
 
- 	}
 
- 	
 
- 	
 
- 	
 
- 	
 
- 	/**
 
- 	 * 事件:   添加渠道
 
- 	 * 地址:http://cas.lishuy.com/?c=Admin_Activity_DeliveryChannels&a=ReqAddDeliveryChannels
 
- 	 */
 
- 	public function doReqAddDeliveryChannels (){
 
- 		
 
- 		$events_id = Request::p('events_id');
 
- 		$platform_id_str = Request::p('platform_ids_str');
 
- 		$str_name = Request::p('str_name');
 
- 		$platform_ids = explode('|', $platform_id_str);
 
- 		
 
- 		foreach($platform_ids as $key => $platform_id){
 
- 			if($platform_id){
 
- 				$info = array(
 
- 						'events_id'  =>  $events_id,
 
- 						'platform_id'  => $platform_id,
 
- 						'str_name' => $str_name,
 
- 						'perator_uid' => $this->doperatorData['uid'],
 
- 				);
 
- 				$this->objDLotteryDeliveryChannels -> add($info);
 
- 			}else{
 
- 				unset($platform_ids[$key]);
 
- 			}
 
- 		}
 
- 		
 
- 		if(empty($platform_ids)){
 
- 			$info = array(
 
- 					'events_id'  =>  $events_id,
 
- 					'platform_id'  => 0,
 
- 					'str_name' => $str_name,
 
- 					'perator_uid' => $this->doperatorData['uid'],
 
- 			);
 
- 			$this->objDLotteryDeliveryChannels -> add($info);
 
- 		}
 
- 		
 
- 		
 
- 		
 
- 		$this->ajax_success_exit('ok');
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 事件 : 修改
 
- 	 * 地址:http://cas.lishuy.com/?c=Admin_Activity_DeliveryChannels&a=ReqUp
 
- 	 *  参数见方法
 
- 	 */
 
- 	public function doReqUp(){
 
- 		$delivery_channels_id = Request::p('delivery_channels_id');
 
- 		$str_name = Request::p('str_name');
 
- 		$info = array(
 
- 				'str_name' => $str_name,
 
- 		);
 
- 		$condition = array(
 
- 				'id' => $delivery_channels_id
 
- 		);
 
- 		$this->objDLotteryDeliveryChannels -> modify($info,$condition);
 
- 		
 
- 		// TODO 根据前端自定义返回结果或跳转
 
- 		return '';
 
- 	}
 
- 	
 
- 	
 
- 	
 
- 	
 
- 	public function display() {
 
- 		return $this->render ();
 
- 	}
 
- }
 
- 	
 
 
  |