123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038 |
- <?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').'_ottuserviewdata_1.dat';
- $check_filename = date('YmdH', time() - 3600).'_'.config('cp_id').'_ottuserviewdata_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;
- }
- }
- }
|