Browse Source

大数据格式调整

15954078560 2 years ago
parent
commit
70caba8911
3 changed files with 76 additions and 55 deletions
  1. 1 0
      .gitignore
  2. 23 21
      application/api/controller/Index.php
  3. 52 34
      application/api/controller/Notify.php

+ 1 - 0
.gitignore

@@ -19,3 +19,4 @@ public/download/
 /application/config.php
 /public/jiankang/*
 jiankang
+dashuju

+ 23 - 21
application/api/controller/Index.php

@@ -1410,23 +1410,23 @@ class Index extends Api
 
         //大数据上报
         $data = [
-            'favid' => (string)(config('cp_id') . date('Ymd') . getMillisecond() . mt_rand(10000000, 99999999)),
+            'favid' => (string)(config('data_cp_id') . date('Ymd') . getMillisecond() . mt_rand(10000000, 99999999)),
             'UserID' => $this->auth->mobile,
             'time' => date('Y-m-d H:i:s'),
             'type' => $count ? 0 : 1,
-            'cpid' => config('cp_id'),
+            'cpid' => config('data_cp_id'),
             'albumid' => $id,
             'albumname' => $info['title']
         ];
 
-        $data = json_encode($data, 320);
-        $filename = date('Ymd').'_'.config('cp_id').'_userfavdata_1.dat';
-        $check_filename = date('Ymd').'_'.config('cp_id').'_userfavdata_1.chk';
+        $data = join(json_decode('"\u0001"', true), $data);
+        $filename = date('Ymd').'_'.config('data_cp_id').'_userfavdata_1.dat';
+        $check_filename = date('Ymd').'_'.config('data_cp_id').'_userfavdata_1.chk';
 
-        error_log(print_r($data, 1) . PHP_EOL, 3, './jiankang/' . $filename);
-        error_log('', 3, './jiankang/' . $check_filename);
-        $finish_filename = date('Ymd') . '_' . config('cp_id') . '_userfavdata.finish';
-        error_log('', 3, './jiankang/' . $finish_filename);
+        error_log(print_r($data, 1) . PHP_EOL, 3, './dashuju/' . $filename);
+        error_log('', 3, './dashuju/' . $check_filename);
+        $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_userfavdata.finish';
+        error_log('', 3, './dashuju/' . $finish_filename);
 
         Db::commit();
         $this->success('操作成功');
@@ -1434,13 +1434,14 @@ class Index extends Api
 
     //用户观看行为
     public function userplay() {
-        $id = input('id', 0, 'intval');
+        $id = input('id', 0, 'intval'); //视频id
         $sn = input('sn', '', 'trim'); //SN号
         $start_time = input('start_time', '', 'trim'); //YYYY-MM-DD HH:MM:SS(24小时制)节目开始播放时间
         $end_time = input('end_time', '', 'trim'); //YYYY-MM-DD HH:MM:SS(24小时制)节目结束播放时间
         $csource = input('csource', 0, ''); //1:从搜索结果访问2:从用户收藏/书签访问3:从EPG访问4:从推荐页面访问5:从猜你喜欢个性化推荐页面访问(带上推荐接口的trace_id)99:其他
         $trace_id = input('trace_id', '', 'trim');
-
+        $istry = input('istry', 0, 'intval'); //0非试看 1试看
+        $start_posi = input('start_posi', 0, 'intval'); //播放起始点相对于影片起始点的时长,单位秒,例如从影片第 600 秒开始观看
 
         if (!$id) {
             $this->error('您的网络开小差了');
@@ -1464,21 +1465,22 @@ class Index extends Api
             'videoid' => $id,
             'videoname' => $info['title'],
             'csource' => $csource,
-            'fee_type' => $info['is_pay'] == 1 ? 1 : 4
+            'trace_id' => $trace_id,
+            'fee_type' => $info['is_pay'] == 1 ? 1 : 4,
+            'istry' => $istry,
+            'iscon' => 0,
+            'start_posi' => $start_posi
         ];
 
-        if ($content['csource'] == 5) {
-            $content['trace_id'] = $trace_id;
-        }
+        $content = join(json_decode('"\u0001"', true), $content);
 
-        $content = json_encode($content, 320);
         $filename = date('Ymd').'_'.config('cp_id').'_userplaydata_1.dat';
         $check_filename = date('Ymd').'_'.config('cp_id').'_userplaydata_1.chk';
 
-        error_log(print_r($content, 1) . PHP_EOL, 3, './jiankang/' . $filename);
-        error_log('', 3, './jiankang/' . $check_filename);
+        error_log(print_r($content, 1) . PHP_EOL, 3, './dashuju/' . $filename);
+        error_log('', 3, './dashuju/' . $check_filename);
         $finish_filename = date('Ymd') . '_' . config('cp_id') . '_userplaydata.finish';
-        error_log('', 3, './jiankang/' . $finish_filename);
+        error_log('', 3, './dashuju/' . $finish_filename);
     }
 
     //用户行为feedback
@@ -1496,10 +1498,10 @@ class Index extends Api
         $content['userid'] = $this->auth->mobile;
         $content['type'] = $type;
         if ($itemid) {
-            $content['itemid'] = config('cp_id') . '|' . $itemid;
+            $content['itemid'] = config('data_cp_id') . '|' . $itemid;
         }
         if ($otherid) {
-            $content['otherid'] = config('cp_id') . '|' . $otherid;
+            $content['otherid'] = config('data_cp_id') . '|' . $otherid;
         }
         if ($prodid) {
             $content['prodid'] = $prodid;

+ 52 - 34
application/api/controller/Notify.php

@@ -1098,12 +1098,24 @@ class Notify extends Api
         foreach ($list as $key => &$param) {
             $content = [
                 'Updatetype' => 1,
-                'cpid' =>  config('cp_id'),
+                'cpid' =>  config('data_cp_id'),
                 'channelid' => '1000035',
                 'albumid' => $param['id'],
                 'albumname' => $param['title'],
+                'albumnum' => 1,
+                'tag' => '',
+                'onlinetime' => '',
+                'bref' => '',
+                'onebref' => '',
                 'cornersign' => $param['is_pay'],
+                'director' => '',
+                'actor' => '',
+                'year' => '',
+                'area' => '',
+                'language' => '',
+                'score' => '',
                 'picurl' => config('upload.cdnurl') . $param['image'],
+                'picurl_v' => '',
                 'gotourl' => json_encode([
                     'action' => 'com.huxiu.heh.tv.ui.splash.SplashActivity',
                     'package' => 'com.huxiu.heh.tv',
@@ -1118,21 +1130,25 @@ class Notify extends Api
                         'type_id' => $param['video_type_id'],
                         'id' => $param['id']
                     ]
-                ], 320)
+                ], 320),
+                'is_politics' => '',
+                'second_type' => ''
             ];
 
-            $content = json_encode($content, 320);
-            $filename = date('Ymd').'_'.config('cp_id').'_albumsdata_1.dat';
-            $check_filename = date('Ymd').'_'.config('cp_id').'_albumsdata_1.chk';
+            $content = join(json_decode('"\u0001"', true), $content);
+            $filename = date('Ymd').'_'.config('data_cp_id').'_albumsdata_1.dat';
+            $check_filename = date('Ymd').'_'.config('data_cp_id').'_albumsdata_1.chk';
 
-            error_log(print_r($content, 1) . PHP_EOL, 3, './jiankang/' . $filename);
-            error_log('', 3, './jiankang/' . $check_filename);
+            error_log(print_r($content, 1) . PHP_EOL, 3, './dashuju/' . $filename);
+            error_log('', 3, './dashuju/' . $check_filename);
 
             if ($key == count($list) - 1) {
-                $finish_filename = date('Ymd') . '_' . config('cp_id') . '_albumsdata.finish';
-                error_log('', 3, './jiankang/' . $finish_filename);
+                $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_albumsdata.finish';
+                error_log('', 3, './dashuju/' . $finish_filename);
             }
         }
+
+        echo 'wan bi';
     }
 
     //媒资数据节目/内容粒度
@@ -1148,26 +1164,28 @@ class Notify extends Api
         foreach ($list as $key => &$param) {
             $content = [
                 'Updatetype' => 1,
-                'cpid' =>  config('cp_id'),
+                'cpid' =>  config('data_cp_id'),
                 'channelid' => '1000035',
                 'albumid' => $param['id'],
                 'albumname' => $param['title'],
                 'videoid' => $param['id'],
                 'videoname' => $param['title'],
+                'videonum' => 1,
                 'Contenttype' => 1,
-                'cornersign' => $param['is_pay']
+                'duration' => '',
+                'quality' => ''
             ];
 
-            $content = json_encode($content, 320);
-            $filename = date('Ymd').'_'.config('cp_id').'_videosdata_1.dat';
-            $check_filename = date('Ymd').'_'.config('cp_id').'_videosdata_1.chk';
+            $content = join(json_decode('"\u0001"', true), $content);
+            $filename = date('Ymd').'_'.config('data_cp_id').'_videosdata_1.dat';
+            $check_filename = date('Ymd').'_'.config('data_cp_id').'_videosdata_1.chk';
 
-            error_log(print_r($content, 1) . PHP_EOL, 3, './jiankang/' . $filename);
-            error_log('', 3, './jiankang/' . $check_filename);
+            error_log(print_r($content, 1) . PHP_EOL, 3, './dashuju/' . $filename);
+            error_log('', 3, './dashuju/' . $check_filename);
 
             if ($key == count($list) - 1) {
-                $finish_filename = date('Ymd') . '_' . config('cp_id') . '_videosdata.finish';
-                error_log('', 3, './jiankang/' . $finish_filename);
+                $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_videosdata.finish';
+                error_log('', 3, './dashuju/' . $finish_filename);
             }
         }
     }
@@ -1178,17 +1196,17 @@ class Notify extends Api
             'prod_code' => config('product_code'),
             'prod_name' => '月包会员',
             'prod_type' => 0,
-            'cpid' => config('cp_id')
+            'cpid' => config('data_cp_id')
         ];
 
-        $content = json_encode($content, 320);
-        $filename = date('Ymd').'_'.config('cp_id').'_productsdata_1.dat';
-        $check_filename = date('Ymd').'_'.config('cp_id').'_productsdata_1.chk';
+        $content = join(json_decode('"\u0001"', true), $content);
+        $filename = date('Ymd').'_'.config('data_cp_id').'_productsdata_1.dat';
+        $check_filename = date('Ymd').'_'.config('data_cp_id').'_productsdata_1.chk';
 
-        error_log(print_r($content, 1) . PHP_EOL, 3, './jiankang/' . $filename);
-        error_log('', 3, './jiankang/' . $check_filename);
-        $finish_filename = date('Ymd') . '_' . config('cp_id') . '_productsdata.finish';
-        error_log('', 3, './jiankang/' . $finish_filename);
+        error_log(print_r($content, 1) . PHP_EOL, 3, './dashuju/' . $filename);
+        error_log('', 3, './dashuju/' . $check_filename);
+        $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_productsdata.finish';
+        error_log('', 3, './dashuju/' . $finish_filename);
     }
 
     //产品包和媒资所属关系
@@ -1205,20 +1223,20 @@ class Notify extends Api
             $content = [
                 'Updatetype' => 1,
                 'prod_code' => config('product_code'),
-                'cpid' =>  config('cp_id'),
+                'cpid' =>  config('data_cp_id'),
                 'albumid' => $param['id']
             ];
 
-            $content = json_encode($content, 320);
-            $filename = date('Ymd').'_'.config('cp_id').'_productalbumdata_1.dat';
-            $check_filename = date('Ymd').'_'.config('cp_id').'_productalbumdata_1.chk';
+            $content = join(json_decode('"\u0001"', true), $content);
+            $filename = date('Ymd').'_'.config('data_cp_id').'_productalbumdata_1.dat';
+            $check_filename = date('Ymd').'_'.config('data_cp_id').'_productalbumdata_1.chk';
 
-            error_log(print_r($content, 1) . PHP_EOL, 3, './jiankang/' . $filename);
-            error_log('', 3, './jiankang/' . $check_filename);
+            error_log(print_r($content, 1) . PHP_EOL, 3, './dashuju/' . $filename);
+            error_log('', 3, './dashuju/' . $check_filename);
 
             if ($key == count($list) - 1) {
-                $finish_filename = date('Ymd') . '_' . config('cp_id') . '_productalbumdata.finish';
-                error_log('', 3, './jiankang/' . $finish_filename);
+                $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_productalbumdata.finish';
+                error_log('', 3, './dashuju/' . $finish_filename);
             }
         }
     }