Bladeren bron

增加收藏

15954078560 2 jaren geleden
bovenliggende
commit
eeefee750a
1 gewijzigde bestanden met toevoegingen van 75 en 0 verwijderingen
  1. 75 0
      application/api/controller/Index.php

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

@@ -1336,4 +1336,79 @@ class Index extends Api
 
         $this->success('同步成功');
     }
+
+    //视频收藏/取消收藏
+    public function collectionrecord() {
+        $id = input('id', 0, 'intval');
+        if (!$id) {
+            $this->error('您的网络开小差了');
+        }
+
+        $info = Db::name('video')->where(['id' => $id])->find();
+        if (!$info) {
+            $this->error('数据不存在');
+        }
+
+        $info['image'] = one_domain_image($info['image']);
+        //查询是否收藏
+        $count = Db::name('video_collection')->where(['user_id' => $this->auth->id, 'video_id' => $id])->count('id');
+        //开启事务
+        if ($count) {
+            $result = Db::name('video_collection')->where(['user_id' => $this->auth->id, 'video_id' => $id])->delete();
+        } else {
+            $result = Db::name('video_collection')->insertGetId(['user_id' => $this->auth->id, 'video_id' => $id, 'createtime' => time()]);
+        }
+        if (!$result) {
+            Db::rollback();
+            $this->error('操作失败');
+        }
+
+        $url = 'http://jscp.agency.gitv.tv/OTT/jscmcc/addThirdPartyCollectionRecord';
+        $content = [
+            'cpPrvdName' => '健康e家',
+            'cpPrvCode' => '41000144',
+            'cpPrvType' => '1006',
+            'content' => $info['title'],
+            'ChnCode' => '1000020',
+            'contentId' => (string)$info['id'],
+            'extraContentID' => '',
+            'isEffective' => $info['status'],
+            'isPaid' => $info['is_pay'],
+            'collectionFlag' => $count ? 0 : 1,
+            'account' => $this->encrypt($this->auth->mobile, '!@#$%^&*FJGFJT78'),
+            '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) {
+            Db::rollback();
+            $this->error('操作失败');
+        }
+        $rt = json_decode($rt, true);
+        if ($rt['code'] != 0) {
+            Db::rollback();
+            $this->error('操作失败');
+        }
+
+        Db::commit();
+        $this->success('操作成功');
+    }
 }