Browse Source

增加播放记录

15954078560 2 years ago
parent
commit
d14d80ffa2
1 changed files with 73 additions and 0 deletions
  1. 73 0
      application/api/controller/Index.php

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

@@ -1248,4 +1248,77 @@ class Index extends Api
 
         $this->success('详情', $info);
     }
+
+    //视频播放记录
+    public function playrecord() {
+        $id = input('id', 0, 'intval');
+        $total_time = input('total_time', 0, 'intval'); //总时长
+        $start_time = input('start_time', 0, 'intval'); //开始看时间:相对时间
+        $end_time = input('end_time', 0, 'intval'); //结束看时间:相对时间
+        $log_type = input('log_type', 'watching', 'trim'); //begin:开始播放;watching:正在播放;end:结束播放
+
+        if (!$id) {
+            $this->error('您的网络开小差了');
+        }
+
+        $info = Db::name('video')->where(['id' => $id])->find();
+        if (!$info) {
+            $this->error('数据不存在');
+        }
+        if ($info['inject_status'] != 2) {
+            $this->error('视频丢失');
+        }
+
+        $info['image'] = one_domain_image($info['image']);
+
+        $url = 'http://jscp.agency.gitv.tv/OTT/jscmcc/addThirdPartyHistoryRecord';
+        $content = [
+            'cpPrvdName' => '健康e家',
+            'cpPrvCode' => '41000144',
+            'cpPrvType' => '1006',
+            'contentName' => $info['title'],
+            'ChnName' => '健康',
+            'ChnCode' => '1000020',
+            'contentId' => (string)$info['id'],
+            'extraContentID' => '',
+            'isEffective' => $info['status'],
+            'isPaid' => $info['is_pay'],
+            'contentTotalTime' => $total_time,
+            'startWatchTime' => $start_time,
+            'endWatchTime' => $end_time,
+            'playTime' => $end_time - $start_time,
+            'logType' => $log_type,
+            'account' => aes_en($this->auth->mobile),
+            'cpPermission' => 'GITV',
+            'intent' => [
+                'action' => 'com.huxiu.heh.tv.ui.video.detail.VideoDetailActivity',
+                'package' => 'com.huxiu.heh.tv',
+                'component' => [
+                    'pkg' => 'com.huxiu.heh.tv',
+                    'cls' => 'com.huxiu.heh.tv.ui.video.detail.VideoDetailActivity'
+                ],
+                'extras' => [
+                    /*'cmd' => '',
+                    'from' => '',
+                    'media_id' => ''*/
+                    'type_id' => $info['video_type_id'],
+                    'id' => $info['id']
+                ]
+            ],
+            'imageURL' => $info['image']
+        ];
+
+        $content = json_encode($content, 320);
+
+        $rt = httpRequest($url, 'POST', $content);
+        if (!$rt) {
+            $this->error('同步失败');
+        }
+        $rt = json_decode($rt, true);
+        if ($rt['code'] != 0) {
+            $this->error('同步失败');
+        }
+
+        $this->success('同步成功');
+    }
 }