DeliveryChannels.class.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <?php
  2. namespace Cas\Controller\Admin\Activity;
  3. use Cas\Module\Lottery;
  4. use Cas\Dao\PlatformBulletin;
  5. use KIF\Core\Request;
  6. use Cas\Dao\LotteryEvents;
  7. use Cas\Controller\Admin\Controller;
  8. use Cas\Dao\Platform;
  9. use Cas\Dao\LotteryDeliveryChannels;
  10. use KIF\Core\Config;
  11. use KIF\Page\Page;
  12. /**
  13. * "活动相关" - "投放渠道"
  14. * 页面: 获取所有渠道列表分页 doPageList
  15. * 事件: 添加渠道 doReqAddDeliveryChannels
  16. * 事件: 修改渠道 doReqUp
  17. * @author lihuanchun 
  18. *  
  19. */
  20. class DeliveryChannels extends Controller {
  21. private $objLottery; // 活动后端
  22. private $objDLotteryDeliveryChannels;
  23. private $objDPlatform;
  24. private $peratorData;
  25. private $objDoperatorData;
  26. /**
  27. *  初始化
  28. */
  29. public function __construct() {
  30. header ( "Content-Type: text/html; charset=utf-8" );
  31. $this->objLottery = new Lottery ();
  32. $this->operatorData = $this->getUser ();
  33. $this->objDPlatform = new Platform();
  34. $this->objDLotteryDeliveryChannels = new LotteryDeliveryChannels();
  35. }
  36. public function doDefault() {
  37. }
  38. /**
  39. * 默认页面
  40. * 获取所有渠道列表分页
  41. * 地址:http://cas.lishuy.com/?c=Admin_Activity_DeliveryChannels&a=PageList&events_id=
  42. */
  43. public function doPageList() {
  44. $events_id = Request::g('events_id');
  45. $events_Data = $this->objLottery->getOneLotteryEventsAndPrize ( $events_id );
  46. $platFormData = $this->objDPlatform -> getsAll();
  47. # 获取当前活动都添加哪些 列表
  48. # 返回列表IDs
  49. $platFormIds = array();
  50. foreach($platFormData as $key => $data){
  51. if($events_Data['platform_ids']&$key){
  52. $platFormIds[$key] = $key;
  53. }
  54. }
  55. $page = Request::varGetInt ( 'page', 1 );
  56. $size = 10;
  57. $offset = ($page - 1) * $size;
  58. $limit = "{$offset},{$size}";
  59. $condition = array(
  60. 'events_id' => $events_id
  61. );
  62. $total_num = $this->objDLotteryDeliveryChannels->totals ( $condition );
  63. $url_tpl = Request::schemeDomain () . "?c=Admin_Activity_DeliveryChannels&a=PageList";
  64. $url_tpl .= "?page={page}";
  65. $objPage = new Page ( $total_num, $url_tpl, $page, $size );
  66. $page_html = $objPage->html ();
  67. $order = 'id desc';
  68. $ids = $this->objDLotteryDeliveryChannels->findIdsBy ( $condition, $limit, $order );
  69. $deliveryChannelsData = $this->objDLotteryDeliveryChannels->gets ( $ids );
  70. $eventsDisplayStatus = LotteryEvents::getDisplay (); // [活动] 是否显示
  71. $objPlatform = new Platform();
  72. $formData = $objPlatform -> getsAll();
  73. foreach($deliveryChannelsData as $key => $data){
  74. $deliveryChannelsData[$key]['url'] = $this->objLottery->getEventsUrl ($events_Data['events']['type'] , $events_Data['events']['create_time'] , $formData[$data['platform_id']]['url']).'/?from='.$key;
  75. $this->createImgCodeUrl($deliveryChannelsData[$key]['url']);
  76. $deliveryChannelsData[$key]['img_url'] = $this->getImgCodePath($deliveryChannelsData[$key]['url']);
  77. }
  78. # 获取默认PV
  79. $this->setOutput( 'platFormIds' ,$platFormIds); // 当前活动包含的平台
  80. $this->setOutput ( 'platFormData', $platFormData ); // 当前所有平台列表信息
  81. $this->setOutput ( 'page_html', $page_html ); // 分页Html
  82. $this->setOutput ( 'deliveryChannelsData', $deliveryChannelsData ); // 渠道信息数据
  83. //公用内部导航信息
  84. $navConfig = $this->getUpPageNav($events_id, 'DeliveryChannels');
  85. $typeData = LotteryEvents::getType ();
  86. $this->setOutput ( 'navConfig', $navConfig );
  87. $this->setOutput ( 'typeData', $typeData );
  88. $this->setOutput ( 'eventData', $events_Data['events'] );
  89. $this->setOutput ( 'eventsDisplayStatus', $eventsDisplayStatus );
  90. $this->tpl = 'admin/activity/delivery_channels_list';
  91. $title = '基础设置';
  92. $this->setOutput('title', $title);
  93. $this->setOutput('menu_active', array('name' => 'mypublish', 'item' => '')); //激活菜单
  94. $this->addNavMenu('活动列表');
  95. $this->addNavMenu($title);
  96. $this->setOutput('displayDesc', LotteryEvents::getDisplay());
  97. $this->setOutput('pagePublicData', $this->getPagePublicData($events_id)); // 后台管理相关数据
  98. }
  99. /**
  100. * 页面: 添加渠道
  101. * 地址:http://cas.lishuy.com/?c=Admin_Activity_DeliveryChannels&a=PageAddDeliveryChannels&events_id=
  102. */
  103. public function doPageAddDeliveryChannels(){
  104. $events_id = Request::g('events_id');
  105. $events_Data = $this->objLottery->getOneLotteryEventsAndPrize ( $events_id );
  106. $platFormData = $this->objDPlatform -> getsAll();
  107. # 获取当前活动都添加哪些列表
  108. $platFormIds = array();
  109. foreach($platFormData as $key => $data){
  110. if($events_Data['events']['platform_ids']&$key){
  111. $platFormIds[$key] = $key;
  112. }
  113. }
  114. $this->setOutput ( 'platFormData', $platFormData );
  115. $this->setOutput ( 'platFormIds', $platFormIds );
  116. # 公用内部导航信息
  117. $navConfig = $this->getUpPageNav($events_id, 'DeliveryChannels');
  118. $typeData = LotteryEvents::getType ();
  119. $eventsDisplayStatus = LotteryEvents::getDisplay ();
  120. $this->setOutput ( 'navConfig', $navConfig );
  121. $this->setOutput ( 'typeData', $typeData );
  122. $this->setOutput ( 'eventData', $events_Data['events'] );
  123. $this->setOutput ( 'eventsDisplayStatus', $eventsDisplayStatus );
  124. $this->tpl = 'admin/activity/delivery_channels_add';
  125. $title = '添加投放渠道';
  126. $this->setOutput('title', $title);
  127. $this->setOutput('menu_active', array('name' => 'mypublish', 'item' => '')); //激活菜单
  128. $this->addNavMenu('活动列表');
  129. $this->addNavMenu($title);
  130. $this->setOutput('displayDesc', LotteryEvents::getDisplay());
  131. $this->setOutput('pagePublicData', $this->getPagePublicData($events_id)); // 后台管理相关数据
  132. }
  133. /**
  134. * 事件: 添加渠道
  135. * 地址:http://cas.lishuy.com/?c=Admin_Activity_DeliveryChannels&a=ReqAddDeliveryChannels
  136. */
  137. public function doReqAddDeliveryChannels (){
  138. $events_id = Request::p('events_id');
  139. $platform_id_str = Request::p('platform_ids_str');
  140. $str_name = Request::p('str_name');
  141. $platform_ids = explode('|', $platform_id_str);
  142. foreach($platform_ids as $key => $platform_id){
  143. if($platform_id){
  144. $info = array(
  145. 'events_id' => $events_id,
  146. 'platform_id' => $platform_id,
  147. 'str_name' => $str_name,
  148. 'perator_uid' => $this->doperatorData['uid'],
  149. );
  150. $this->objDLotteryDeliveryChannels -> add($info);
  151. }else{
  152. unset($platform_ids[$key]);
  153. }
  154. }
  155. if(empty($platform_ids)){
  156. $info = array(
  157. 'events_id' => $events_id,
  158. 'platform_id' => 0,
  159. 'str_name' => $str_name,
  160. 'perator_uid' => $this->doperatorData['uid'],
  161. );
  162. $this->objDLotteryDeliveryChannels -> add($info);
  163. }
  164. $this->ajax_success_exit('ok');
  165. }
  166. /**
  167. * 事件 : 修改
  168. * 地址:http://cas.lishuy.com/?c=Admin_Activity_DeliveryChannels&a=ReqUp
  169. * 参数见方法
  170. */
  171. public function doReqUp(){
  172. $delivery_channels_id = Request::p('delivery_channels_id');
  173. $str_name = Request::p('str_name');
  174. $info = array(
  175. 'str_name' => $str_name,
  176. );
  177. $condition = array(
  178. 'id' => $delivery_channels_id
  179. );
  180. $this->objDLotteryDeliveryChannels -> modify($info,$condition);
  181. // TODO 根据前端自定义返回结果或跳转
  182. return '';
  183. }
  184. public function display() {
  185. return $this->render ();
  186. }
  187. }