Log.class.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 Cas\Dao\LotteryPvUvLog;
  12. use KIF\Dao\SqlHelper;
  13. use KIF\Dao\AbstractDao;
  14. /**
  15. * "活动相关" - "数据统计"
  16. *
  17. * @author lihuanchun 
  18. *  
  19. */
  20. class Log extends Controller {
  21. private $objLottery; // 活动后端
  22. private $peratorData;
  23. /**
  24. *  初始化
  25. */
  26. public function __construct() {
  27. header ( "Content-Type: text/html; charset=utf-8" );
  28. $this->objLottery = new Lottery ();
  29. $this->operatorData = $this->getUser ();
  30. }
  31. public function doDefault() {
  32. }
  33. /**
  34. * 默认页面
  35. * 获取所有渠道列表分页
  36. * 地址:页面: http://cas.lishuy.com/?c=Admin_Activity_Log&a=PageList&events_id=n
  37. */
  38. public function doPageList() {
  39. $events_id = Request::g('events_id');
  40. $select = Request::g('select');
  41. if ($select) {
  42. $b_time = strtotime(date('Y-m-d', time() - $select*60*60*24));
  43. $e_time = mktime(0,0,0) - 1;
  44. } else {
  45. $b_time = Request::g('b_time') ? strtotime(Request::g('b_time')) : strtotime(date('Y-m-d', time() - 7*60*60*24));
  46. $e_time = Request::g('e_time') ? strtotime(Request::g('e_time')) : mktime(0,0,0) - 1;
  47. }
  48. $events_Data = $this->objLottery->getOneLotteryEventsAndPrize ( $events_id );
  49. $objDLotteryPvUvLog = new LotteryPvUvLog();
  50. $condition = array();
  51. $condition ['events_id'] = $events_id;
  52. $condition['date'] = SqlHelper::addCompareOperator('>=', $b_time);
  53. $condition['`date`'] = SqlHelper::addCompareOperator('<', $e_time);
  54. $logDataIds = $objDLotteryPvUvLog -> findIdsBy($condition);
  55. $logData = $objDLotteryPvUvLog -> gets($logDataIds);
  56. $pvs = $uvs = array();
  57. foreach ($logData as $tmpLog) {
  58. $pvs[date('j', $tmpLog['date'])] = $tmpLog['pv_num'];
  59. $uvs[date('j', $tmpLog['date'])] = $tmpLog['uv_num'];
  60. }
  61. // 导航
  62. $navConfig = $this->getUpPageNav($events_id, 'Log');
  63. $eventsTypeData = LotteryEvents::getType (); // [活动] 类型
  64. $this->tpl = 'admin/activity/statis';
  65. $title = '数据统计';
  66. $this->setOutput('title', $title);
  67. $this->setOutput('menu_active', array('name' => 'mypublish', 'item' => '')); //激活菜单
  68. $this->addNavMenu('活动列表');
  69. $this->addNavMenu($title);
  70. $this->setOutput ( 'navConfig', $navConfig );// 导航 显示 URL 配置
  71. $this->setOutput('pagePublicData', $this->getPagePublicData($events_id)); // 后台管理相关数据
  72. $this->setOutput('events_Data', $events_Data);
  73. $this->setOutput('eventData', $events_Data['events']);
  74. $this->setOutput('typeData', $eventsTypeData);
  75. $this->setOutput('displayDesc', LotteryEvents::getDisplay());
  76. $xAxis = array();
  77. $i = 0;
  78. do {
  79. $x_time = $b_time + ($i*60*60*24);
  80. if ($x_time > $e_time) {
  81. break;
  82. }
  83. $tmpDay = date('j', $x_time);
  84. $xAxis[$i] = $tmpDay;
  85. $_pvs[$tmpDay] = $pvs[$tmpDay] ? $pvs[$tmpDay] : 0;
  86. $_uvs[$tmpDay] = $uvs[$tmpDay] ? $uvs[$tmpDay] : 0;
  87. $i++;
  88. } while (true);
  89. $this->setOutput('b_time', $b_time);
  90. $this->setOutput('e_time', $e_time);
  91. $this->setOutput('pvs', implode(',', $_pvs));
  92. $this->setOutput('uvs', implode(',', $_uvs));
  93. $this->setOutput('xAxis', implode(',', $xAxis));
  94. $this->setOutput('logData', $logData);
  95. }
  96. public function display() {
  97. return $this->render ();
  98. }
  99. }