success('请求成功'); } //视频分类列表 public function videotype() { $type = input('type', 0, 'intval'); //分类类型:0=老年大学,1=普法课堂 if (!in_array($type, [0, 1])) { $this->error('参数错误'); } $list = Db::name('video_type')->field('id, name, image')->where(['type' => $type]) ->page($this->page, $this->pagenum)->order('weigh, id')->select(); $list = list_domain_image($list, ['image']); $this->success('分类', $list); } //视频列表 public function video() { $type_id = input('type_id', 0, 'intval'); //分类id if (!$type_id) { $this->error('您的网络开小差了~'); } $list = Db::name('video')->field('id, title, image, is_pay')->where(['video_type_id' => $type_id, 'status' => 1, 'inject_status' => 2])->page($this->page, $this->pagenum)->order('weigh, id desc')->select(); $list = list_domain_image($list, ['image']); $this->success('视频', $list); } //视频详情 public function videoinfo() { /*$id = 0; $session_video_id_time = Cache::get('session_video_id_time' . $this->auth->id); if ($session_video_id_time) { $session_video_id_time = explode('-', $session_video_id_time); $times = $session_video_id_time[1]; if ($times > 0) { $id = $session_video_id_time[0]; $next_times = $times - 1; cache('session_video_id_time' . $this->auth->id, $session_video_id_time[0] . '-' . $next_times, 10); } else { cache('session_video_id_time' . $this->auth->id, 0, 10); } } if (!$id) {*/ $id = input('id', 0, 'intval'); //视频id // } if (!$id) { $this->error('您的网络开小差了'); } $info = Db::name('video')->field('id, title, image, desc, is_pay, status, inject_status, seriesid, programid, movieid') ->where(['id' => $id])->find(); if (!$info) { $this->error('数据不存在'); } if ($info['status'] != 1) { $this->error('视频丢失'); } if ($info['inject_status'] != 2) { $this->error('视频丢失'); } $info['neirong']='内容如有侵权,请联系删除'; $info['neirong1']='为您推荐'; $info['image'] = one_domain_image($info['image']); $info['is_collection'] = Db::name('video_collection')->where(['user_id' => $this->auth->id, 'video_id' => $id])->count('id'); $this->success('详情', $info); } /** * * @param string $string 需要加密的字符串 * @param string $key 密钥 * @return string */ public function encrypt($string, $key) { // $key = substr(openssl_digest(openssl_digest($key, 'sha1', true), 'sha1', true), 0, 16); $data = openssl_encrypt($string, 'AES-128-ECB', $key, OPENSSL_RAW_DATA); $data = bin2hex($data); return $data; } /** * @param string $string 需要解密的字符串 * @param string $key 密钥 * @return string */ public function decrypt($string, $key) { // $key = substr(openssl_digest(openssl_digest($key, 'sha1', true), 'sha1', true), 0, 16); $decrypted = openssl_decrypt(hex2bin($string), 'AES-128-ECB', $key, OPENSSL_RAW_DATA); return $decrypted; } //视频播放记录 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://meta-history.unso.gitv.tv/OTT/jscmcc/addThirdPartyHistoryRecord'; $content = [ 'cpPrvdName' => '健康e家', 'cpPrvCode' => '41000144', 'cpPrvType' => '1006', 'contentName' => $info['title'], 'ChnName' => '健康', 'ChnCode' => '1000020', 'contentId' => (string)$info['movieid'], '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' => $this->encrypt($this->auth->mobile, '!@#$%^&*FJGFJT78'), 'cpPermission' => 'GITV', 'intent' => [ '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' => $info['video_type_id'], 'id' => $info['id'] ] ], 'imageURL' => $info['image'] ]; $content = json_encode($content, 320); $rt = httpRequest($url, 'POST', $content); file_put_contents('bofang.txt',$id.'_'.$rt.PHP_EOL, FILE_APPEND); if (!$rt) { // $this->error('同步失败'); } $rt = json_decode($rt, true); if ($rt['code'] != 0) { // $this->error('同步失败'); } $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('数据不存在'); } //var_dump($info);exit; $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://meta-history.unso.gitv.tv/OTT/jscmcc/addThirdPartyCollectionRecord'; $content = [ 'cpPrvdName' => '健康e家', 'cpPrvCode' => '41000144', 'cpPrvType' => '1006', 'content' => $info['title'], 'ChnCode' => '1000020', 'contentId' => (string)$info['movieid'], '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.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' => $info['video_type_id'], 'id' => $info['id'] ] ], 'imageURL' => $info['image'] ]; $content = json_encode($content, 320); $rt = httpRequest($url, 'POST', $content); file_put_contents('shoucang.txt',$id.'_'.$rt.PHP_EOL, FILE_APPEND); if (!$rt) { Db::rollback(); $this->error('操作失败'); } $rt = json_decode($rt, true); if ($rt['code'] != 0) { Db::rollback(); $this->error('操作失败'); } //大数据上报 $data = [ '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('data_cp_id'), 'albumid' => $id, 'albumname' => $info['title'] ]; $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, './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('操作成功'); } //用户观看行为(大数据) public function userplay() { $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('您的网络开小差了'); } $info = Db::name('video')->where(['id' => $id])->find(); if (!$info) { $this->error('数据不存在'); } $content = [ 'playid' => (string)(config('data_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('data_cp_id'), 'albumid' => $id, 'albumname' => $info['title'], 'videoid' => $id, 'videoname' => $info['title'], 'csource' => $csource, 'trace_id' => $trace_id, 'fee_type' => $info['is_pay'] == 1 ? 1 : 4, 'istry' => $istry, 'iscon' => 0, 'start_posi' => $start_posi ]; $content = join(json_decode('"\u0001"', true), $content); $filename = date('Ymd').'_'.config('data_cp_id').'_userplaydata_1.dat'; $check_filename = date('Ymd').'_'.config('data_cp_id').'_userplaydata_1.chk'; 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') . '_userplaydata.finish'; error_log('', 3, './dashuju/' . $finish_filename); $this->success(''); } //用户行为feedback //前端没用到,废弃 public function userfeedback() { $type = input('type', '', 'trim'); //曝光display/播放play/点击click/订购order/搜索 search/收藏 fav $itemid = input('itemid', '', 'trim'); //视频id,研究院推荐内容上报 $otherid = input('otherid', '', 'trim'); //视频id,非研究院推荐内容上报 $prodid = input('prodid', '', 'trim'); //订购行为必填;其余行为可选 $trace_id = input('trace_id', '', 'trim'); //大数据推荐内容有trace_id $signal = input('signal', '', 'trim'); //所属板块编号,0异形、1头部、3电影,后续查看服务接口标识;非推荐内容所有行为为空;推荐内容所有行为必填 $pos = input('pos', '', 'trim'); //所在位置编号,从左至右第1、2…个推荐位; 非推荐内容所有行为为空;推荐内容所有行为必填 $play_duration = input('play_duration', 0, 'trim'); //单位毫秒,在播放结束时反馈该值 $url = 'http://jscp.agency.gitv.tv/v2/feedback'; $content['userid'] = $this->auth->mobile; $content['type'] = $type; if ($itemid) { $content['itemid'] = config('data_cp_id') . '|' . $itemid; } if ($otherid) { $content['otherid'] = config('data_cp_id') . '|' . $otherid; } if ($prodid) { $content['prodid'] = $prodid; } if ($trace_id) { $content['trace_id'] = 'v2_1_2_1000035_' . $this->auth->mobile . '_153672384859_123456_01'; } else { $content['trace_id'] = ''; } if ($signal) { $content['signal'] = $signal; } else { $content['signal'] = ''; } if ($pos) { $content['pos'] = $pos; } else { $content['pos'] = ''; } if ($play_duration) { $content['play_duration'] = $play_duration; } else { $content['play_duration'] = ''; } $content['operate_time'] = getMillisecond(); $content = http_build_query($content); $url = $url . '?' . $content; $rt = file_get_contents($url); if (!$rt) { $this->error('上报失败'); } $this->success('上报成功'); } //用户观看行为(支付) public function payuserplay() { $id = input('id', 0, 'intval'); //视频id $sn = input('sn', '', 'trim'); //SN号 $start_time = input('start_time', '', 'trim'); //yyyymmddhhmmss (24小时制),节目开始播放时间 $end_time = input('end_time', '', 'trim'); //yyyymmddhhmmss (24小时制),节目结束播放时间,如果播放未结束,但是此时需要同步数据,填当前时间 $csource = input('csource', 0, ''); //1:从搜索结果访问2:从用户收藏/书签访问3:从EPG访问4:从推荐页面访问5、其他 if (!$id) { $this->error('您的网络开小差了'); } $info = Db::name('video')->where(['id' => $id])->find(); if (!$info) { $this->error('数据不存在'); } $content = [ 'UserID' => $this->auth->mobile, 'city' => '14', 'start_time' => $start_time, 'end_time' => $end_time, 'service_type' => 1, 'albumid' => $id, 'albumname' => $info['title'], 'csource' => $csource, 'SN' => $sn, 'ip' => request()->ip(), 'fee_type' => $info['is_pay'] == 1 ? 1 : '', 'flow' => '', 'product' => '', 'product_name' => '', 'info_source' => '02' ]; $content = join('|', $content); $filename = date('YmdH').'_'.config('cp_id').'_userviewdata_1.dat'; $check_filename = date('YmdH').'_'.config('cp_id').'_userviewdata_1.chk'; error_log(print_r($content, 1) . PHP_EOL, 3, './dashuju/' . $filename); error_log('', 3, './dashuju/' . $check_filename); $this->success(''); } //首页数据范返回 public function indexdata() { $data = []; $data['logo'] = 'https://jiankang-1304634122.cos.ap-nanjing.myqcloud.com/home/logo.webp'; $data['tuiding'] ='退订咨询'; $data['vip']='https://jiankang-1304634122.cos.ap-nanjing.myqcloud.com/home/vip.webp'; $data['free']='https://jiankang-1304634122.cos.ap-nanjing.myqcloud.com/home/free.webp'; $data['banner1'] = 'https://jiankang-1304634122.cos.ap-nanjing.myqcloud.com/home%2Fleft1.webp'; //$data['vip1'] = '0'; //字符串 0 免费 $data['banner2'] = 'https://jiankang-1304634122.cos.ap-nanjing.myqcloud.com/home%2Fleft2.webp'; $data['banner3'] = 'https://jiankang-1304634122.cos.ap-nanjing.myqcloud.com/home%2Fcenter1.webp'; $data['banner4'] = 'https://jiankang-1304634122.cos.ap-nanjing.myqcloud.com/home%2Fright1.webp'; $data['banner5'] = 'https://jiankang-1304634122.cos.ap-nanjing.myqcloud.com/home%2Fright2.webp'; $data['banner6'] = 'https://jiankang-1304634122.cos.ap-nanjing.myqcloud.com/home%2Fleft3.webp'; $data['banner7'] = 'https://jiankang-1304634122.cos.ap-nanjing.myqcloud.com/home%2Fcenter2.webp'; $data['banner8'] = 'https://jiankang-1304634122.cos.ap-nanjing.myqcloud.com/home%2Fcenter3.webp'; $data['banner9'] = 'https://jiankang-1304634122.cos.ap-nanjing.myqcloud.com/home%2Fright3.webp'; $data['rightcontent'] = ['服务电话:13625150009','服务时间:周一至周五8:00-18:00','收视路径:首页-应用中心-健康e家']; $data['leftbottom'] = '内容如有侵权,请联系删除'; $data['beian']['top'] = ''; $data['beian']['bottom'] = ''; $this->success('', $data); } //生活服务 public function life_service() { $list = Db::name('life_service')->field('id, name, images')->where(['status' => 1])->page($this->page, $this->pagenum)->order('weigh, id')->select(); $list = list_domain_image($list, ['images']); if(!empty($list)) { foreach ($list as &$key) { $key['bcontent'] = '本信息由"淮安天职天利家政服务有限公司"提供'; } } $this->success('生活服务', $list); } //退订服务 public function tudingc() { $data = ['亲爱的用户:','如果您想退订健康e家业务,可以通过以下方式:','1、电视屏 一家庭专区一个人中心-我的订单,点击退订取消订购','2、收到成功订购健康e家业务短信的1小时内,根据短信内容,发送指定数字至10086901,即可取消业务不再收取费用','3、发送0000至10086获取最新的增值业务订购信息,根据短信内容回复“业务序号”取消对应业务','4、就近的营业厅办理增值业务退订','5、拨打10086客服热线进行退订 ','6、登录中国移动网上营业厅:http://10086.cn 掌上营业厅:wap.10086.cn“已开服务一增值业务”进行退订']; $this->success('', $data); } //获取特殊机型 public function special_models() { $special_models = config('site.special_models'); $special_models = explode(',', $special_models); $this->success('获取特殊机型', $special_models); } //前端报错记录 public function app_error() { $this->success(''); } }