1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace Ad\Lib;
- use Dever;
- class Manage
- {
- public function upPageCache($id, $name, $param)
- {
- $key = Dever::param('key', $param);
- Dever::load('ad/lib/data')->get($key, array(), false);
- if (Dever::project('log')) {
- $col = array
- (
- array
- (
- 'name' => '广告页面ID',
- 'key' => 'ad_page_id',
- ),
- array
- (
- 'name' => '广告位ID',
- 'key' => 'ad_info_id',
- ),
- array
- (
- 'name' => '广告投放ID',
- 'key' => 'ad_data_id',
- ),
- );
- $log = Dever::load('log/lib/manage')->addCol($col);
- }
- }
- public function upInfoCache($id, $name, $param)
- {
- $id = Dever::param('page_id', $param);
- $info = Dever::db('ad/page')->one($id);
- Dever::load('ad/lib/data')->get($info['key'], array(), false);
- }
- public function upDataCache($id, $name, $param)
- {
- $info_id = Dever::param('info_id', $param);
- $info = Dever::db('ad/info')->one($info_id);
- $info = Dever::db('ad/page')->one($info['page_id']);
- Dever::load('ad/lib/data')->get($info['key'], array(), false);
- }
- public function getTotalNum($id)
- {
- $info = Dever::db('ad/data')->one($id);
- $table = array();
- $table['投放时间'] = $info['type'] == 2 ? date("Y-m-d H:i:s", $info['sdate'])."<br />".date("Y-m-d H:i:s", $info['edate']) : "永久";
- $data = Dever::db('ad/stat')->sum(array('data_id' => $id));
- if ($data) {
- $table += $this->getData($data);
- }
- return Dever::table($table);
- }
- public function getNum($id)
- {
- $data = Dever::db('ad/stat')->one($id);
- $table = $this->getData($data);
- return Dever::table($table);
- }
- private function getData($data)
- {
- $table = array();
- $table['访问量'] = $data['pv_view'] ? $data['pv_view'] : 0;
- $table['点击量'] = $data['pv_click'] ? $data['pv_click'] : 0;
- if ($data['pv_click'] > 0 && $data['pv_view'] > 0) {
- $table['点击量/访问量'] = number_format(($data['pv_click']/$data['pv_view'])*100, 2) . '%';
- } else {
- $table['点击量/访问量'] = '0%';
- }
- return $table;
- }
- }
|