1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- use wxpay;
- use addons\epay\library\Service;
- /**
- * 支付回调
- */
- class Notify extends Api
- {
- protected $noNeedLogin = ['*'];
- protected $noNeedRight = ['*'];
- //视频转码
- public function transcode() {
- set_time_limit(0);
- $where = array(
- 'transcode_status' => 0
- );
- $hu_video = Db::name('video');
- $list = $hu_video->where($where)->limit(50)->select();
- if (!$list) {
- echo 'mei shu ju';
- die;
- }
- $url = 'http://api.trans.gitv.tv/upload';
- $data['cp_id'] = config('cp_id');
- $data['media_type'] = 'mp4';
- foreach ($list as &$v) {
- $data['uri'] = urlencode(config('upload.cdnurl') . $v['videofile']);
- $data['file_name'] = urlencode($v['title']);
- $request_url = $url . '?' . http_build_query($data);
- $rs = file_get_contents($request_url);
- if (!$rs) {
- continue;
- }
- $rs = json_decode($rs);
- if ($rs['code'] == 'A000000') {
- $hu_video->where(['id' => $v['id'], 'transcode_status' => 0])->setField(['transcode_status' => 1, 'task_id' => $rs['task_id']]);
- }
- }
- echo 'wan bi';
- die;
- }
- //视频转码回执
- public function transcodecallback() {
- $cp_id = input('cp_id', 0, 'intval');
- $file_url = input('file_url', '', 'trim');
- $task_id = input('task_id', '', 'trim');
- if ($cp_id != config('cp_id')) {
- $this->error('错误1');
- }
- $info = Db::name('video')->where(['task_id' => $task_id])->find();
- if (!$info) {
- $this->error('错误2');
- }
- if ($info['transcode_status'] != 1) {
- $this->success('已完成');
- }
- $file_url = urldecode($file_url);
- $rs = Db::name('video')->where(['id' => $info['id'], 'transcode_status' => 1])->setField(['transcode_status' => 2, 'file_url' => $file_url]);
- if (!$rs) {
- $this->error('失败');
- }
- $this->success('成功');
- }
- //视频注入
- public function inject() {
- set_time_limit(0);
- $where = array(
- 'transcode_status' => 2,
- 'inject_status' => 0
- );
- $hu_video = Db::name('video');
- $list = $hu_video->where($where)->limit(50)->select();
- if (!$list) {
- echo 'mei shu ju';
- die;
- }
- $url = 'http://api.gs.gitv.tv/upload';
- $data['cp_id'] = config('cp_id');
- $data['bit_id'] = 5;
- $data['file_type'] = 'm3u8';
- foreach ($list as &$v) {
- $data['album_id'] = (string)$v['id'];
- $data['video_id'] = (string)$v['id'];
- $data['uri'] = $v['file_url'];
- $rs = httpRequest($url, 'POST', $data);
- if (!$rs) {
- continue;
- }
- $rs = json_decode($rs);
- if ($rs['code'] == 'A000000') {
- $hu_video->where(['id' => $v['id'], 'inject_status' => 0])->setField(['inject_status' => 1]);
- }
- }
- echo 'wan bi';
- die;
- }
- //视频注入回执
- public function injectcallback() {
- $cp_id = input('cp_id', 0, 'intval');
- $album_id = input('album_id', '', 'trim'); //专辑 ID
- $video_id = input('video_id', '', 'trim'); //剧集 ID
- $code = input('code', '', 'trim'); //状态码
- if ($cp_id != config('cp_id')) {
- $this->error('错误1');
- }
- $info = Db::name('video')->where(['id' => $video_id])->find();
- if (!$info) {
- $this->error('错误2');
- }
- if ($info['inject_status'] != 1) {
- $this->success('已完成');
- }
- if ($code == 'A000000') {
- $inject_status = 2;
- } else {
- $inject_status = 3;
- }
- $rs = Db::name('video')->where(['id' => $info['id'], 'inject_status' => 1])->setField(['inject_status' => $inject_status]);
- if (!$rs) {
- $this->error('失败');
- }
- $this->success('成功');
- }
- //视频注入结果查询
- public function injectquery() {
- set_time_limit(0);
- $time = strtotime(date('Y-m-d', time()));
- $where = array(
- 'inject_status' => 1,
- // 'updatetime' => ['egt', $time]
- );
- $hu_video = Db::name('video');
- // $list = $hu_video->where($where)->count('id');
- $list = $hu_video->where($where)->limit(50)->select();
- if (!$list) {
- echo 'mei shu ju';
- die;
- }
- /*$starttime = date('Ymd000000', time());
- $endtime = date('Ymd235959', time());
- // $url = 'http://'.config('inject_ip').':'.config('inject_port').'/injectResult/v1/queryAdd?cspId=' . config('cspid') . '&startTime='.$starttime.'&endTime='.$endtime;
- $url = 'http://jscp.agency.gitv.tv/injectResult/v1/queryAdd?cspId=' . config('cspid') . '&startTime='.$starttime.'&endTime='.$endtime;
- $header = [
- 'Content-Type: application/json'
- ];
- $rs = httpRequest($url, 'POST', [], $header);
- if (!$rs) {
- echo 'cuo wu1';
- die;
- }
- $list = json_decode($rs, true);
- if ($list['code'] != 'A000000') {
- echo 'cuo wu2';
- die;
- }
- foreach ($list['data'] as &$v) {
- if ($v['taskStatus'] == 2) {
- $hu_video->where(['id' => $v['cpTvId'], 'inject_status' => 1])->setField(['inject_status' => 2]);
- }
- }*/
- $header = [
- 'Content-Type: application/json'
- ];
- //生成ftp文件
- $content = [
- 'cpPrvdName' => '健康e家',
- 'cpPrvCode' => '41000144',
- 'cpPrvType' => '1006',
- 'ChnName' => '健康',
- 'ChnCode' => '1000020',
- 'actors' => '无',
- 'directors' => '无',
- 'contentYear' => date('Y'),
- 'tags' => '',
- 'contentTime' => date('Y-m-d H:i:s'),
- 'formatType' => '超清'
- ];
- //增量接口
- $insert_url = 'http://test.meta.unso.gitv.tv/sendMeta';
- $method = 'POST';
- foreach ($list as &$v) {
- //查询华为注入结果
- $url = 'http://jscp.agency.gitv.tv/injectResult/v1/queryTv?cspId=' . config('cspid') . '&cpAlbumId=' . $v['id'] . '&cpTvId=' . $v['id'];
- $rs = httpRequest($url, 'GET', [], $header);
- if (!$rs) {
- continue;
- }
- $rs = json_decode($rs, true);
- if ($rs['code'] != 'A000000') {
- continue;
- }
- $data = $rs['data'][0];
- if ($data['taskStatus'] == 2) {
- /*//生成ftp文件
- $content['contentId'] = $v['movieid'];
- $content['extraContentID'] = $v['movieid'];
- $content['content'] = $v['title'];
- $content['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' => $v['video_type_id'],
- 'id' => $v['id']
- ]
- ];
- $content['isEffective'] = $v['status'];
- $content['pic'] = one_domain_image($v['image']);
- $content['isPaid'] = $v['is_pay'];
- $content = json_encode($content, 320);
- $filename = 'shipin_'.date('Ymd').'_'.date('His').'_increment'.'.json';
- error_log(print_r($content, 1) . PHP_EOL, 3, './jiankang/' . $filename);
- //调用增量注入接口
- $postfields = [
- 'priKey' => config('cspid'),
- 'data' => [$content]
- ];
- $rt = httpRequest($insert_url, $method, $postfields, $header);
- if (!$rt) {
- continue;
- }
- $rt = json_decode($rt, true);
- if ($rt['code'] != 'A000000') {
- continue;
- }*/
- //查询中兴注入结果
- $url2 = 'http://jscp.agency.gitv.tv/injectResult/v1/queryTv?cspId=' . config('cspid_zx') . '&cpAlbumId=' . $v['id'] . '&cpTvId=' . $v['id'];
- $rs2 = httpRequest($url2, 'GET', [], $header);
- if (!$rs2) {
- continue;
- }
- $rs2 = json_decode($rs2, true);
- if ($rs2['code'] != 'A000000') {
- continue;
- }
- $data2 = $rs2['data'][0];
- if ($data2['taskStatus'] == 2) {
- $hu_video->where(['id' => $v['id'], 'inject_status' => 1])->setField(['inject_status' => 2, 'seriesid' => $data['seriesId'], 'programid' => $data['programId'], 'movieid' => $data['movieId']]);
- } elseif ($data2['taskStatus'] == -1 || $data2['taskStatus'] == -3 || $data2['taskStatus'] == -4) {
- $hu_video->where(['id' => $v['id'], 'inject_status' => 1])->setField(['inject_status' => 3, 'seriesid' => $data['seriesId'], 'programid' => $data['programId'], 'movieid' => $data['movieId']]);
- }
- } elseif ($data['taskStatus'] == -1 || $data['taskStatus'] == -3 || $data['taskStatus'] == -4) {
- $hu_video->where(['id' => $v['id'], 'inject_status' => 1])->setField(['inject_status' => 3, 'seriesid' => $data['seriesId'], 'programid' => $data['programId'], 'movieid' => $data['movieId']]);
- }
- }
- echo 'wan bi';
- die;
- }
- //视频统一搜索生成ftp文件
- public function videosearch() {
- set_time_limit(0);
- // $time = strtotime(date('Y-m-d', time()));
- $where = array(
- 'inject_status' => 2,
- 'search_status' => 0,
- // 'updatetime' => ['egt', $time]
- );
- $hu_video = Db::name('video');
- $list = $hu_video->where($where)->limit(50)->select();
- if (!$list) {
- echo 'mei shu ju';
- die;
- }
- $header = [
- 'Content-Type: application/json'
- ];
- //生成ftp文件
- $data_content = [
- 'cpPrvdName' => '健康e家',
- 'cpPrvCode' => '41000144',
- 'cpPrvType' => '1006',
- 'ChnName' => '健康',
- 'ChnCode' => '1000020',
- 'actors' => '无',
- 'directors' => '无',
- 'contentYear' => date('Y'),
- 'tags' => '',
- 'contentTime' => date('Y-m-d H:i:s'),
- 'formatType' => '超清'
- ];
- //增量接口
- $insert_url = 'http://test.meta.unso.gitv.tv/sendMeta';
- $method = 'POST';
- foreach ($list as &$v) {
- //生成ftp文件
- $content = $data_content;
- $content['contentId'] = $v['movieid'];
- $content['extraContentID'] = $v['movieid'];
- $content['content'] = $v['title'];
- $intent = 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' => $v['video_type_id'],
- 'id' => $v['id']
- ]
- ], 320);
- $content['intent'] = "$intent";
- $content['isEffective'] = $v['status'];
- $content['pic'] = one_domain_image($v['image']);
- $content['isPaid'] = $v['is_pay'];
- $content = json_encode($content, 320);
- $filename = 'shipin_'.date('Ymd').'_'.date('His').'_increment'.'.json';
- error_log(print_r($content, 1) . PHP_EOL, 3, './jiankang/' . $filename);
- //调用增量注入接口
- /*$postfields = [
- 'priKey' => config('cspid'),
- 'data' => [$content]
- ];
- $rt = httpRequest($insert_url, $method, $postfields, $header);
- if (!$rt) {
- continue;
- }
- $rt = json_decode($rt, true);
- if ($rt['code'] != 'A000000') {
- continue;
- }*/
- $hu_video->where(['id' => $v['id'], 'search_status' => 0])->setField(['search_status' => 1]);
- }
- echo 'wan bi';
- die;
- }
-
- //订购关系同步地址
- public function ordersync() {
- $data = file_get_contents('php://input');
- file_put_contents('chen_tui.txt', $data, FILE_APPEND);
- if (!$data) {
- $this->error('参数缺失');
- }
- $jsonxml = json_encode(simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA));
- $data = json_decode($jsonxml, true);
- if (!$data) {
- $this->error('参数缺失');
- }
- $phoneNumber = $data['orderRelationSyncRequest']['phoneNumber']; //手机号
- $apppId = $data['orderRelationSyncRequest']['apppId']; //订购的HDC业务产品编码
- if ($apppId != config('product_code')) {
- echo 'meiyou';
- exit;
- }
- //用户增值产品包当前订购快照
- $content = [
- 'UserID' => $phoneNumber,
- 'prod_code' => $apppId,
- 'prod_name' => '月包会员',
- 'eff_time' => date('Y-m-d H:i:s', time()),
- 'exp_time' => date('Y-m-d H:i:s', time() + 30 * 86400),
- 'price' => 2900
- ];
- $content = join(json_decode('"\u0001"', true), $content);
- $filename = date('Ymd').'_'.config('data_cp_id').'_userefforderdata_1.dat';
- $check_filename = date('Ymd').'_'.config('data_cp_id').'_userefforderdata_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') . '_userefforderdata.finish';
- error_log('', 3, './dashuju/' . $finish_filename);
- //用户增值产品包订购行为数据
- $user_id = Db::name('user')->where(['mobile' => $phoneNumber])->value('id');
- $order_info = Db::name('rechar_order')->where(['user_id' => $user_id, 'purpose' => 3, 'pay_type' => 'zhuowang', 'status' => 1])->order('id desc')->find();
- $content = [
- 'orderid' => $order_info['order_no'],
- 'order_time' => date('Y-m-d H:i:s', time()),
- 'order_type' => 1,
- 'UserID' => $phoneNumber,
- 'prod_code' => $apppId,
- 'prod_name' => '月包会员',
- 'eff_time' => date('Y-m-d H:i:s', time()),
- 'exp_time' => date('Y-m-d H:i:s', time() + 30 * 86400),
- 'csource' => 99,
- 'trace_id' => '',
- 'price' => 2900,
- 'paytype' => 0,
- 'cpid' => config('data_cp_id'),
- 'albumid' => '',
- 'albumname' => ''
- ];
- $content = join(json_decode('"\u0001"', true), $content);
- $filename = date('Ymd').'_'.config('data_cp_id').'_userorderdata_1.dat';
- $check_filename = date('Ymd').'_'.config('data_cp_id').'_userorderdata_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') . '_userorderdata.finish';
- error_log('', 3, './dashuju/' . $finish_filename);
- }
- //(补漏)视频注入中兴
- public function injectzx() {
- set_time_limit(0);
- $hu_video = Db::name('video');
- $list = $hu_video->where(['id' => 107])->limit(50)->select();
- if (!$list) {
- echo 'mei shu ju';
- die;
- }
- $cspid = config('cspid_zx');
- $url = 'http://jscp.agency.gitv.tv/epgDataSync/v1/' . $cspid . '/';
- foreach ($list as &$params) {
- //内容同步
- $videofile = $params['videofile'];
- $videofile = explode('/', $videofile);
- $video_url = $videofile[3];
- $data = [
- // 'cspId' => $cspid,
- 'cpAlbumId' => $params['id'],
- 'albumName' => $params['title'],
- 'tvSets' => 1,
- 'updateToSet' => 1,
- 'isPurchase' => $params['is_pay'],
- 'isEffective' => $params['status'],
- 'isOnline' => $params['status'],
- 'albumTypes' => '健康',
- 'picBox' => config('upload.cdnurl') . $params['image'],
- 'albumUpdateTime' => date('YmdHis', time()),
- 'albumCreateTime' => date('YmdHis', time()),
- 'tvlist' => [
- [
- 'cpAlbumId' => $params['id'],
- 'cpTvId' => $params['id'],
- 'tvName' => $params['title'],
- 'tvIsEffective' => $params['status'],
- 'tvIsOnline' => $params['status'],
- 'isPurchase' => $params['is_pay'],
- 'playOrder' => 1,
- 'tvUrl' => 'ftp://'.config('ftp_user').':'.config('ftp_pwd').'@'.config('ftp_ip').':'.config('ftp_port').'/inject/'.$video_url
- ]
- ]
- ];
- $data = json_encode($data, 320);
- $header = [
- 'Content-Type: application/json'
- ];
- $rs = httpRequest($url, 'POST', $data, $header);
- if ($rs) {
- $rs = json_decode($rs, true);
- if ($rs['code'] != 'A000000') {
- continue;
- }
- }
- }
- echo 'wan bi';
- die;
- }
- //(补漏)删除注入中兴视频
- public function delinjectzx() {
- set_time_limit(0);
- $hu_video = Db::name('video');
- $list = $hu_video->where(['id' => 107])->limit(1)->order('id')->select();
- if (!$list) {
- echo 'mei shu ju';
- die;
- }
- $cspid = config('cspid_zx');
- $url = 'http://jscp.agency.gitv.tv/epgDeleteSync/v1/' . $cspid . '/';
- foreach ($list as &$params) {
- //内容同步
- $videofile = $params['videofile'];
- $videofile = explode('/', $videofile);
- $video_url = $videofile[3];
- $data = [
- // 'cspId' => $cspid,
- 'cpAlbumId' => $params['id'],
- 'albumName' => $params['title'],
- 'tvSets' => 1,
- 'updateToSet' => 1,
- 'isPurchase' => $params['is_pay'],
- 'isEffective' => 0,
- 'isOnline' => 2,
- 'albumTypes' => '健康',
- 'picBox' => config('upload.cdnurl') . $params['image'],
- 'albumUpdateTime' => date('YmdHis', time()),
- // 'albumCreateTime' => date('YmdHis', time()),
- 'tvlist' => [
- [
- 'cpAlbumId' => $params['id'],
- 'cpTvId' => $params['id'],
- 'tvName' => $params['title'],
- 'tvIsEffective' => 0,
- 'tvIsOnline' => 2,
- 'isPurchase' => $params['is_pay'],
- 'playOrder' => 1,
- 'tvUrl' => 'ftp://'.config('ftp_user').':'.config('ftp_pwd').'@'.config('ftp_ip').':'.config('ftp_port').'/inject/'.$video_url
- ]
- ]
- ];
- $data = json_encode($data, 320);
- $header = [
- 'Content-Type: application/json'
- ];
- $rs = httpRequest($url, 'POST', $data, $header);
- if ($rs) {
- $rs = json_decode($rs, true);
- if ($rs['code'] != 'A000000') {
- continue;
- }
- }
- }
- echo 'wan bi';
- die;
- }
- //媒资数据专辑粒度
- public function mediadataalbum() {
- $hu_video = Db::name('video');
- $list = $hu_video->where(['inject_status' => 2, 'mediaalbum_status' => 0])->order('id')->select();
- if (!$list) {
- echo 'mei shu ju';
- die;
- }
- foreach ($list as $key => &$param) {
- $content = [
- 'Updatetype' => 1,
- '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',
- '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),
- 'is_politics' => '',
- 'second_type' => ''
- ];
- $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, './dashuju/' . $filename);
- error_log('', 3, './dashuju/' . $check_filename);
- if ($key == count($list) - 1) {
- $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_albumsdata.finish';
- error_log('', 3, './dashuju/' . $finish_filename);
- }
- $hu_video->where(['id' => $param['id'], 'mediaalbum_status' => 0])->setField('mediaalbum_status', 1);
- }
- echo 'wan bi';
- }
- //媒资数据节目/内容粒度
- public function mediadatavideo() {
- $hu_video = Db::name('video');
- $list = $hu_video->where(['inject_status' => 2, 'mediavideo_status' => 0])->order('id')->select();
- if (!$list) {
- echo 'mei shu ju';
- die;
- }
- foreach ($list as $key => &$param) {
- $content = [
- 'Updatetype' => 1,
- 'cpid' => config('data_cp_id'),
- 'channelid' => '1000035',
- 'albumid' => $param['id'],
- 'albumname' => $param['title'],
- 'videoid' => $param['id'],
- 'videoname' => $param['title'],
- 'videonum' => 1,
- 'Contenttype' => 1,
- 'duration' => '',
- 'quality' => ''
- ];
- $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, './dashuju/' . $filename);
- error_log('', 3, './dashuju/' . $check_filename);
- if ($key == count($list) - 1) {
- $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_videosdata.finish';
- error_log('', 3, './dashuju/' . $finish_filename);
- }
- $hu_video->where(['id' => $param['id'], 'mediavideo_status' => 0])->setField('mediavideo_status', 1);
- }
- }
- //产品包
- public function product() {
- $content = [
- 'prod_code' => config('product_code'),
- 'prod_name' => '月包会员',
- 'prod_type' => 0,
- 'cpid' => config('data_cp_id')
- ];
- $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, './dashuju/' . $filename);
- error_log('', 3, './dashuju/' . $check_filename);
- $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_productsdata.finish';
- error_log('', 3, './dashuju/' . $finish_filename);
- //连接ftp
- $host = config('data_ftp_ip');
- $port = config('data_ftp_port');
- $username = config('data_ftp_user');
- $password = config('data_ftp_pwd');
- $conn = ftp_connect($host, $port) or die("Could not connect");
- //登录
- ftp_login($conn,$username,$password);
- //开启被动模式
- ftp_pasv($conn, true);
- //利用ftp创建目录
- /*$path = "home/2021-12-08";
- $this->make_directory($conn,$path);
- //利用ftp选择进入目录
- ftp_chdir($conn,$path);*/
- //开始上传 ftp_put(ftp链接,服务器地址,本地地址,上传模式);
- if(ftp_put($conn,$filename,'./dashuju/' . $filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$check_filename,'./dashuju/' . $check_filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$finish_filename,'./dashuju/' . $finish_filename,FTP_BINARY)){
- //上传成功
- }
- ftp_close($conn);
- //注意上传端的ftp权限设置
- echo 'wanbi';
- }
- //产品包和媒资所属关系
- public function productmediarelation() {
- $hu_video = Db::name('video');
- $list = $hu_video->where(['inject_status' => 2, 'productmedia_status' => 0])->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('data_cp_id'),
- 'albumid' => $param['id']
- ];
- $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, './dashuju/' . $filename);
- error_log('', 3, './dashuju/' . $check_filename);
- if ($key == count($list) - 1) {
- $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_productalbumdata.finish';
- error_log('', 3, './dashuju/' . $finish_filename);
- }
- $hu_video->where(['id' => $param['id'], 'productmedia_status' => 0])->setField('productmedia_status', 1);
- }
- }
- //用户观看行为数据文件上传到卓望ftp(每小时第10分钟提供)
- public function uploadpayftp() {
- set_time_limit(0);
- $host = config('pay_ftp_ip');
- $port = config('pay_ftp_port');
- $username = config('pay_ftp_user');
- $password = config('pay_ftp_pwd');
- $filename = date('YmdH', time() - 3600).'_'.config('cp_id').'_userviewdata_1.dat';
- $check_filename = date('YmdH', time() - 3600).'_'.config('cp_id').'_userviewdata_1.chk';
- //判断文件是否存在, 不存在则创建
- if (!file_exists('./dashuju/' . $filename)) {
- @touch('./dashuju/' . $filename);
- }
- if (!file_exists('./dashuju/' . $check_filename)) {
- @touch('./dashuju/' . $check_filename);
- }
- //连接ftp
- $conn = ftp_connect($host, $port) or die("Could not connect");
- //登录
- ftp_login($conn,$username,$password);
- //开启被动模式
- ftp_pasv($conn, true);
- //利用ftp创建目录
- /*$path = "home/2021-12-08";
- $this->make_directory($conn,$path);
- //利用ftp选择进入目录
- ftp_chdir($conn,$path);*/
- //开始上传 ftp_put(ftp链接,服务器地址,本地地址,上传模式);
- if(ftp_put($conn,$filename,'./dashuju/' . $filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$check_filename,'./dashuju/' . $check_filename,FTP_BINARY)){
- //上传成功
- }
- ftp_close($conn);
- //注意上传端的ftp权限设置
- echo 'wanbi';
- }
- //大数据文件上传到大数据ftp(每天一点提供)
- public function uploaddataftp() {
- set_time_limit(0);
- $host = config('data_ftp_ip');
- $port = config('data_ftp_port');
- $username = config('data_ftp_user');
- $password = config('data_ftp_pwd');
- $time = date('Ymd', time() - 86400);
- // 专辑粒度媒资
- $albumsdata_filename = $time.'_'.config('data_cp_id').'_albumsdata_1.dat';
- $albumsdata_check_filename = $time.'_'.config('data_cp_id').'_albumsdata_1.chk';
- $albumsdata_finish_filename = $time.'_'.config('data_cp_id').'_albumsdata_1.finish';
- // 节目/内容粒度媒资
- $videosdata_filename = $time.'_'.config('data_cp_id').'_videosdata_1.dat';
- $videosdata_check_filename = $time.'_'.config('data_cp_id').'_videosdata_1.chk';
- $videosdata_finish_filename = $time.'_'.config('data_cp_id').'_videosdata_1.finish';
- // 产品包和媒资所属关系
- $productalbumdata_filename = $time.'_'.config('data_cp_id').'_productalbumdata_1.dat';
- $productalbumdata_check_filename = $time.'_'.config('data_cp_id').'_productalbumdata_1.chk';
- $productalbumdata_finish_filename = $time.'_'.config('data_cp_id').'_productalbumdata_1.finish';
- // 用户增值产品包当前订购快照
- $userefforderdata_filename = $time.'_'.config('data_cp_id').'_userefforderdata_1.dat';
- $userefforderdata_check_filename = $time.'_'.config('data_cp_id').'_userefforderdata_1.chk';
- $userefforderdata_finish_filename = $time.'_'.config('data_cp_id').'_userefforderdata_1.finish';
- // 用户增值产品包订购行为
- $userorderdata_filename = $time.'_'.config('data_cp_id').'_userorderdata_1.dat';
- $userorderdata_check_filename = $time.'_'.config('data_cp_id').'_userorderdata_1.chk';
- $userorderdata_finish_filename = $time.'_'.config('data_cp_id').'_userorderdata_1.finish';
- // 用户观看行为
- $userplaydata_filename = $time.'_'.config('data_cp_id').'_userplaydata_1.dat';
- $userplaydata_check_filename = $time.'_'.config('data_cp_id').'_userplaydata_1.chk';
- $userplaydata_finish_filename = $time.'_'.config('data_cp_id').'_userplaydata_1.finish';
- // 用户收藏行为
- $userfavdata_filename = $time.'_'.config('data_cp_id').'_userfavdata_1.dat';
- $userfavdata_check_filename = $time.'_'.config('data_cp_id').'_userfavdata_1.chk';
- $userfavdata_finish_filename = $time.'_'.config('data_cp_id').'_userfavdata_1.finish';
- //判断文件是否存在, 不存在则创建
- if (!file_exists('./dashuju/' . $albumsdata_filename)) {
- @touch('./dashuju/' . $albumsdata_filename);
- }
- if (!file_exists('./dashuju/' . $albumsdata_check_filename)) {
- @touch('./dashuju/' . $albumsdata_check_filename);
- }
- if (!file_exists('./dashuju/' . $albumsdata_finish_filename)) {
- @touch('./dashuju/' . $albumsdata_finish_filename);
- }
- if (!file_exists('./dashuju/' . $videosdata_filename)) {
- @touch('./dashuju/' . $videosdata_filename);
- }
- if (!file_exists('./dashuju/' . $videosdata_check_filename)) {
- @touch('./dashuju/' . $videosdata_check_filename);
- }
- if (!file_exists('./dashuju/' . $videosdata_finish_filename)) {
- @touch('./dashuju/' . $videosdata_finish_filename);
- }
- if (!file_exists('./dashuju/' . $productalbumdata_filename)) {
- @touch('./dashuju/' . $productalbumdata_filename);
- }
- if (!file_exists('./dashuju/' . $productalbumdata_check_filename)) {
- @touch('./dashuju/' . $productalbumdata_check_filename);
- }
- if (!file_exists('./dashuju/' . $productalbumdata_finish_filename)) {
- @touch('./dashuju/' . $productalbumdata_finish_filename);
- }
- if (!file_exists('./dashuju/' . $userefforderdata_filename)) {
- @touch('./dashuju/' . $userefforderdata_filename);
- }
- if (!file_exists('./dashuju/' . $userefforderdata_check_filename)) {
- @touch('./dashuju/' . $userefforderdata_check_filename);
- }
- if (!file_exists('./dashuju/' . $userefforderdata_finish_filename)) {
- @touch('./dashuju/' . $userefforderdata_finish_filename);
- }
- if (!file_exists('./dashuju/' . $userorderdata_filename)) {
- @touch('./dashuju/' . $userorderdata_filename);
- }
- if (!file_exists('./dashuju/' . $userorderdata_check_filename)) {
- @touch('./dashuju/' . $userorderdata_check_filename);
- }
- if (!file_exists('./dashuju/' . $userorderdata_finish_filename)) {
- @touch('./dashuju/' . $userorderdata_finish_filename);
- }
- if (!file_exists('./dashuju/' . $userplaydata_filename)) {
- @touch('./dashuju/' . $userplaydata_filename);
- }
- if (!file_exists('./dashuju/' . $userplaydata_check_filename)) {
- @touch('./dashuju/' . $userplaydata_check_filename);
- }
- if (!file_exists('./dashuju/' . $userplaydata_finish_filename)) {
- @touch('./dashuju/' . $userplaydata_finish_filename);
- }
- if (!file_exists('./dashuju/' . $userfavdata_filename)) {
- @touch('./dashuju/' . $userfavdata_filename);
- }
- if (!file_exists('./dashuju/' . $userfavdata_check_filename)) {
- @touch('./dashuju/' . $userfavdata_check_filename);
- }
- if (!file_exists('./dashuju/' . $userfavdata_finish_filename)) {
- @touch('./dashuju/' . $userfavdata_finish_filename);
- }
- //连接ftp
- $conn = ftp_connect($host, $port) or die("Could not connect");
- //登录
- ftp_login($conn,$username,$password);
- //开启被动模式
- ftp_pasv($conn, true);
- //利用ftp创建目录
- /*$path = "home/2021-12-08";
- $this->make_directory($conn,$path);
- //利用ftp选择进入目录
- ftp_chdir($conn,$path);*/
- //开始上传 ftp_put(ftp链接,服务器地址,本地地址,上传模式);
- if(ftp_put($conn,$albumsdata_filename,'./dashuju/' . $albumsdata_filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$albumsdata_check_filename,'./dashuju/' . $albumsdata_check_filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$albumsdata_finish_filename,'./dashuju/' . $albumsdata_finish_filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$videosdata_filename,'./dashuju/' . $videosdata_filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$videosdata_check_filename,'./dashuju/' . $videosdata_check_filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$videosdata_finish_filename,'./dashuju/' . $videosdata_finish_filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$productalbumdata_filename,'./dashuju/' . $productalbumdata_filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$productalbumdata_check_filename,'./dashuju/' . $productalbumdata_check_filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$productalbumdata_finish_filename,'./dashuju/' . $productalbumdata_finish_filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$userefforderdata_filename,'./dashuju/' . $userefforderdata_filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$userefforderdata_check_filename,'./dashuju/' . $userefforderdata_check_filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$userefforderdata_finish_filename,'./dashuju/' . $userefforderdata_finish_filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$userorderdata_filename,'./dashuju/' . $userorderdata_filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$userorderdata_check_filename,'./dashuju/' . $userorderdata_check_filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$userorderdata_finish_filename,'./dashuju/' . $userorderdata_finish_filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$userplaydata_filename,'./dashuju/' . $userplaydata_filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$userplaydata_check_filename,'./dashuju/' . $userplaydata_check_filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$userplaydata_finish_filename,'./dashuju/' . $userplaydata_finish_filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$userfavdata_filename,'./dashuju/' . $userfavdata_filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$userfavdata_check_filename,'./dashuju/' . $userfavdata_check_filename,FTP_BINARY)){
- //上传成功
- }
- if(ftp_put($conn,$userfavdata_finish_filename,'./dashuju/' . $userfavdata_finish_filename,FTP_BINARY)){
- //上传成功
- }
- ftp_close($conn);
- //注意上传端的ftp权限设置
- echo 'wanbi';
- }
- public function make_directory($ftp_stream, $dir){
- // if directory already exists or can be immediately created return true
- if ($this->ftp_is_dir($ftp_stream, $dir) || @ftp_mkdir($ftp_stream, $dir)) return true;
- // otherwise recursively try to make the directory
- if (!$this->make_directory($ftp_stream, dirname($dir))) return false;
- // final step to create the directory
- return ftp_mkdir($ftp_stream, $dir);
- }
- public function ftp_is_dir($ftp_stream, $dir){
- // get current directory
- $original_directory = ftp_pwd($ftp_stream);
- // test if you can change directory to $dir
- // suppress errors in case $dir is not a file or not a directory
- if ( @ftp_chdir( $ftp_stream, $dir ) ) {
- // If it is a directory, then change the directory back to the original directory
- ftp_chdir( $ftp_stream, $original_directory );
- return true;
- } else {
- return false;
- }
- }
- }
|