Bladeren bron

对接大数据

15954078560 2 jaren geleden
bovenliggende
commit
a225c6d905
2 gewijzigde bestanden met toevoegingen van 207 en 0 verwijderingen
  1. 69 0
      application/api/controller/Index.php
  2. 138 0
      application/api/controller/Notify.php

+ 69 - 0
application/api/controller/Index.php

@@ -1408,7 +1408,76 @@ class Index extends Api
             $this->error('操作失败');
         }
 
+        //大数据上报
+        $data = [
+            'favid' => (string)(config('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'),
+            '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';
+
+        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);
+
         Db::commit();
         $this->success('操作成功');
     }
+
+    //用户观看行为
+    public function userplay() {
+        $id = input('id', 0, 'intval');
+        $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');
+
+
+        if (!$id) {
+            $this->error('您的网络开小差了');
+        }
+
+        $info = Db::name('video')->where(['id' => $id])->find();
+        if (!$info) {
+            $this->error('数据不存在');
+        }
+
+        $content = [
+            'playid' => (string)(config('cp_id') . date('Ymd') . getMillisecond() . mt_rand(10000000, 99999999)),
+            'UserID' => $this->auth->mobile,
+            'SN' => $sn,
+            'start_time' => $start_time,
+            'end_time' => $end_time,
+            'service_type' => 1,
+            'cpid' => config('cp_id'),
+            'albumid' => $id,
+            'albumname' => $info['title'],
+            'videoid' => $id,
+            'videoname' => $info['title'],
+            'csource' => $csource,
+            'fee_type' => $info['is_pay'] == 1 ? 1 : 4
+        ];
+
+        if ($content['csource'] == 5) {
+            $content['trace_id'] = $trace_id;
+        }
+
+        $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);
+        $finish_filename = date('Ymd') . '_' . config('cp_id') . '_userplaydata.finish';
+        error_log('', 3, './jiankang/' . $finish_filename);
+    }
 }

+ 138 - 0
application/api/controller/Notify.php

@@ -1084,4 +1084,142 @@ class Notify extends Api
         echo 'wan bi';
         die;
     }
+
+    //媒资数据专辑粒度
+    public function mediadataalbum() {
+        $hu_video = Db::name('video');
+        $list = $hu_video->where(['search_status' => 1])->order('id')->select();
+
+        if (!$list) {
+            echo 'mei shu ju';
+            die;
+        }
+
+        foreach ($list as $key => &$param) {
+            $content = [
+                'Updatetype' => 1,
+                'cpid' =>  config('cp_id'),
+                'channelid' => '1000013',
+                'albumid' => $param['id'],
+                'albumname' => $param['title'],
+                'cornersign' => $param['is_pay'],
+                'picurl' => config('upload.cdnurl') . $param['image'],
+                'gotourl' => json_encode([
+                    'action' => 'com.huxiu.heh.tv.ui.splash.SplashActivity',
+                    'package' => 'com.huxiu.heh.tv',
+                    'component' => [
+                        'pkg' => 'com.huxiu.heh.tv',
+                        'cls' => 'com.huxiu.heh.tv.ui.splash.SplashActivity'
+                    ],
+                    'extras' => [
+//                        'cmd' => '',
+//                        'from' => '',
+//                        'media_id' => ''
+                        'type_id' => $param['video_type_id'],
+                        'id' => $param['id']
+                    ]
+                ], 320)
+            ];
+
+            $content = json_encode($content, 320);
+            $filename = date('Ymd').'_'.config('cp_id').'_albumsdata_1.dat';
+            $check_filename = date('Ymd').'_'.config('cp_id').'_albumsdata_1.chk';
+
+            error_log(print_r($content, 1) . PHP_EOL, 3, './jiankang/' . $filename);
+            error_log('', 3, './jiankang/' . $check_filename);
+
+            if ($key == count($list) - 1) {
+                $finish_filename = date('Ymd') . '_' . config('cp_id') . '_albumsdata.finish';
+                error_log('', 3, './jiankang/' . $finish_filename);
+            }
+        }
+    }
+
+    //媒资数据节目/内容粒度
+    public function mediadatavideo() {
+        $hu_video = Db::name('video');
+        $list = $hu_video->where(['search_status' => 1])->order('id')->select();
+
+        if (!$list) {
+            echo 'mei shu ju';
+            die;
+        }
+
+        foreach ($list as $key => &$param) {
+            $content = [
+                'Updatetype' => 1,
+                'cpid' =>  config('cp_id'),
+                'channelid' => '1000013',
+                'albumid' => $param['id'],
+                'albumname' => $param['title'],
+                'videoid' => $param['id'],
+                'videoname' => $param['title'],
+                'Contenttype' => 1,
+                'cornersign' => $param['is_pay']
+            ];
+
+            $content = json_encode($content, 320);
+            $filename = date('Ymd').'_'.config('cp_id').'_videosdata_1.dat';
+            $check_filename = date('Ymd').'_'.config('cp_id').'_videosdata_1.chk';
+
+            error_log(print_r($content, 1) . PHP_EOL, 3, './jiankang/' . $filename);
+            error_log('', 3, './jiankang/' . $check_filename);
+
+            if ($key == count($list) - 1) {
+                $finish_filename = date('Ymd') . '_' . config('cp_id') . '_videosdata.finish';
+                error_log('', 3, './jiankang/' . $finish_filename);
+            }
+        }
+    }
+
+    //产品包
+    public function product() {
+        $content = [
+            'prod_code' => config('product_code'),
+            'prod_name' => '月包会员',
+            'prod_type' => 0,
+            'cpid' => config('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';
+
+        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);
+    }
+
+    //产品包和媒资所属关系
+    public function productmediarelation() {
+        $hu_video = Db::name('video');
+        $list = $hu_video->where(['search_status' => 1])->order('id')->select();
+
+        if (!$list) {
+            echo 'mei shu ju';
+            die;
+        }
+
+        foreach ($list as $key => &$param) {
+            $content = [
+                'Updatetype' => 1,
+                'prod_code' => config('product_code'),
+                'cpid' =>  config('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';
+
+            error_log(print_r($content, 1) . PHP_EOL, 3, './jiankang/' . $filename);
+            error_log('', 3, './jiankang/' . $check_filename);
+
+            if ($key == count($list) - 1) {
+                $finish_filename = date('Ymd') . '_' . config('cp_id') . '_productalbumdata.finish';
+                error_log('', 3, './jiankang/' . $finish_filename);
+            }
+        }
+    }
 }