Manage.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace Ad\Lib;
  3. use Dever;
  4. class Manage
  5. {
  6. public function upPageCache($id, $name, $param)
  7. {
  8. $key = Dever::param('key', $param);
  9. Dever::load('ad/lib/data')->get($key, array(), false);
  10. if (Dever::project('log')) {
  11. $col = array
  12. (
  13. array
  14. (
  15. 'name' => '广告页面ID',
  16. 'key' => 'ad_page_id',
  17. ),
  18. array
  19. (
  20. 'name' => '广告位ID',
  21. 'key' => 'ad_info_id',
  22. ),
  23. array
  24. (
  25. 'name' => '广告投放ID',
  26. 'key' => 'ad_data_id',
  27. ),
  28. );
  29. $log = Dever::load('log/lib/manage')->addCol($col);
  30. }
  31. }
  32. public function upInfoCache($id, $name, $param)
  33. {
  34. $id = Dever::param('page_id', $param);
  35. $info = Dever::db('ad/page')->one($id);
  36. Dever::load('ad/lib/data')->get($info['key'], array(), false);
  37. }
  38. public function upDataCache($id, $name, $param)
  39. {
  40. $info_id = Dever::param('info_id', $param);
  41. $info = Dever::db('ad/info')->one($info_id);
  42. $info = Dever::db('ad/page')->one($info['page_id']);
  43. Dever::load('ad/lib/data')->get($info['key'], array(), false);
  44. }
  45. public function getTotalNum($id)
  46. {
  47. $info = Dever::db('ad/data')->one($id);
  48. $table = array();
  49. $table['投放时间'] = $info['type'] == 2 ? date("Y-m-d H:i:s", $info['sdate'])."<br />".date("Y-m-d H:i:s", $info['edate']) : "永久";
  50. $data = Dever::db('ad/stat')->sum(array('data_id' => $id));
  51. if ($data) {
  52. $table += $this->getData($data);
  53. }
  54. return Dever::table($table);
  55. }
  56. public function getNum($id)
  57. {
  58. $data = Dever::db('ad/stat')->one($id);
  59. $table = $this->getData($data);
  60. return Dever::table($table);
  61. }
  62. private function getData($data)
  63. {
  64. $table = array();
  65. $table['访问量'] = $data['pv_view'] ? $data['pv_view'] : 0;
  66. $table['点击量'] = $data['pv_click'] ? $data['pv_click'] : 0;
  67. if ($data['pv_click'] > 0 && $data['pv_view'] > 0) {
  68. $table['点击量/访问量'] = number_format(($data['pv_click']/$data['pv_view'])*100, 2) . '%';
  69. } else {
  70. $table['点击量/访问量'] = '0%';
  71. }
  72. return $table;
  73. }
  74. }