Notify.php 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. use wxpay;
  6. use addons\epay\library\Service;
  7. /**
  8. * 支付回调
  9. */
  10. class Notify extends Api
  11. {
  12. protected $noNeedLogin = ['*'];
  13. protected $noNeedRight = ['*'];
  14. //视频转码
  15. public function transcode() {
  16. set_time_limit(0);
  17. $where = array(
  18. 'transcode_status' => 0
  19. );
  20. $hu_video = Db::name('video');
  21. $list = $hu_video->where($where)->limit(50)->select();
  22. if (!$list) {
  23. echo 'mei shu ju';
  24. die;
  25. }
  26. $url = 'http://api.trans.gitv.tv/upload';
  27. $data['cp_id'] = config('cp_id');
  28. $data['media_type'] = 'mp4';
  29. foreach ($list as &$v) {
  30. $data['uri'] = urlencode(config('upload.cdnurl') . $v['videofile']);
  31. $data['file_name'] = urlencode($v['title']);
  32. $request_url = $url . '?' . http_build_query($data);
  33. $rs = file_get_contents($request_url);
  34. if (!$rs) {
  35. continue;
  36. }
  37. $rs = json_decode($rs);
  38. if ($rs['code'] == 'A000000') {
  39. $hu_video->where(['id' => $v['id'], 'transcode_status' => 0])->setField(['transcode_status' => 1, 'task_id' => $rs['task_id']]);
  40. }
  41. }
  42. echo 'wan bi';
  43. die;
  44. }
  45. //视频转码回执
  46. public function transcodecallback() {
  47. $cp_id = input('cp_id', 0, 'intval');
  48. $file_url = input('file_url', '', 'trim');
  49. $task_id = input('task_id', '', 'trim');
  50. if ($cp_id != config('cp_id')) {
  51. $this->error('错误1');
  52. }
  53. $info = Db::name('video')->where(['task_id' => $task_id])->find();
  54. if (!$info) {
  55. $this->error('错误2');
  56. }
  57. if ($info['transcode_status'] != 1) {
  58. $this->success('已完成');
  59. }
  60. $file_url = urldecode($file_url);
  61. $rs = Db::name('video')->where(['id' => $info['id'], 'transcode_status' => 1])->setField(['transcode_status' => 2, 'file_url' => $file_url]);
  62. if (!$rs) {
  63. $this->error('失败');
  64. }
  65. $this->success('成功');
  66. }
  67. //视频注入
  68. public function inject() {
  69. set_time_limit(0);
  70. $where = array(
  71. 'transcode_status' => 2,
  72. 'inject_status' => 0
  73. );
  74. $hu_video = Db::name('video');
  75. $list = $hu_video->where($where)->limit(50)->select();
  76. if (!$list) {
  77. echo 'mei shu ju';
  78. die;
  79. }
  80. $url = 'http://api.gs.gitv.tv/upload';
  81. $data['cp_id'] = config('cp_id');
  82. $data['bit_id'] = 5;
  83. $data['file_type'] = 'm3u8';
  84. foreach ($list as &$v) {
  85. $data['album_id'] = (string)$v['id'];
  86. $data['video_id'] = (string)$v['id'];
  87. $data['uri'] = $v['file_url'];
  88. $rs = httpRequest($url, 'POST', $data);
  89. if (!$rs) {
  90. continue;
  91. }
  92. $rs = json_decode($rs);
  93. if ($rs['code'] == 'A000000') {
  94. $hu_video->where(['id' => $v['id'], 'inject_status' => 0])->setField(['inject_status' => 1]);
  95. }
  96. }
  97. echo 'wan bi';
  98. die;
  99. }
  100. //视频注入回执
  101. public function injectcallback() {
  102. $cp_id = input('cp_id', 0, 'intval');
  103. $album_id = input('album_id', '', 'trim'); //专辑 ID
  104. $video_id = input('video_id', '', 'trim'); //剧集 ID
  105. $code = input('code', '', 'trim'); //状态码
  106. if ($cp_id != config('cp_id')) {
  107. $this->error('错误1');
  108. }
  109. $info = Db::name('video')->where(['id' => $video_id])->find();
  110. if (!$info) {
  111. $this->error('错误2');
  112. }
  113. if ($info['inject_status'] != 1) {
  114. $this->success('已完成');
  115. }
  116. if ($code == 'A000000') {
  117. $inject_status = 2;
  118. } else {
  119. $inject_status = 3;
  120. }
  121. $rs = Db::name('video')->where(['id' => $info['id'], 'inject_status' => 1])->setField(['inject_status' => $inject_status]);
  122. if (!$rs) {
  123. $this->error('失败');
  124. }
  125. $this->success('成功');
  126. }
  127. //视频注入结果查询
  128. public function injectquery() {
  129. set_time_limit(0);
  130. $time = strtotime(date('Y-m-d', time()));
  131. $where = array(
  132. 'inject_status' => 1,
  133. // 'updatetime' => ['egt', $time]
  134. );
  135. $hu_video = Db::name('video');
  136. // $list = $hu_video->where($where)->count('id');
  137. $list = $hu_video->where($where)->limit(50)->select();
  138. if (!$list) {
  139. echo 'mei shu ju';
  140. die;
  141. }
  142. /*$starttime = date('Ymd000000', time());
  143. $endtime = date('Ymd235959', time());
  144. // $url = 'http://'.config('inject_ip').':'.config('inject_port').'/injectResult/v1/queryAdd?cspId=' . config('cspid') . '&startTime='.$starttime.'&endTime='.$endtime;
  145. $url = 'http://jscp.agency.gitv.tv/injectResult/v1/queryAdd?cspId=' . config('cspid') . '&startTime='.$starttime.'&endTime='.$endtime;
  146. $header = [
  147. 'Content-Type: application/json'
  148. ];
  149. $rs = httpRequest($url, 'POST', [], $header);
  150. if (!$rs) {
  151. echo 'cuo wu1';
  152. die;
  153. }
  154. $list = json_decode($rs, true);
  155. if ($list['code'] != 'A000000') {
  156. echo 'cuo wu2';
  157. die;
  158. }
  159. foreach ($list['data'] as &$v) {
  160. if ($v['taskStatus'] == 2) {
  161. $hu_video->where(['id' => $v['cpTvId'], 'inject_status' => 1])->setField(['inject_status' => 2]);
  162. }
  163. }*/
  164. $header = [
  165. 'Content-Type: application/json'
  166. ];
  167. //生成ftp文件
  168. $content = [
  169. 'cpPrvdName' => '健康e家',
  170. 'cpPrvCode' => '41000144',
  171. 'cpPrvType' => '1006',
  172. 'ChnName' => '健康',
  173. 'ChnCode' => '1000020',
  174. 'actors' => '无',
  175. 'directors' => '无',
  176. 'contentYear' => date('Y'),
  177. 'tags' => '',
  178. 'contentTime' => date('Y-m-d H:i:s'),
  179. 'formatType' => '超清'
  180. ];
  181. //增量接口
  182. $insert_url = 'http://test.meta.unso.gitv.tv/sendMeta';
  183. $method = 'POST';
  184. foreach ($list as &$v) {
  185. //查询华为注入结果
  186. $url = 'http://jscp.agency.gitv.tv/injectResult/v1/queryTv?cspId=' . config('cspid') . '&cpAlbumId=' . $v['id'] . '&cpTvId=' . $v['id'];
  187. $rs = httpRequest($url, 'GET', [], $header);
  188. if (!$rs) {
  189. continue;
  190. }
  191. $rs = json_decode($rs, true);
  192. if ($rs['code'] != 'A000000') {
  193. continue;
  194. }
  195. $data = $rs['data'][0];
  196. if ($data['taskStatus'] == 2) {
  197. /*//生成ftp文件
  198. $content['contentId'] = $v['movieid'];
  199. $content['extraContentID'] = $v['movieid'];
  200. $content['content'] = $v['title'];
  201. $content['intent'] = [
  202. 'action' => 'com.huxiu.heh.tv.ui.splash.SplashActivity',
  203. 'package' => 'com.huxiu.heh.tv',
  204. 'component' => [
  205. 'pkg' => 'com.huxiu.heh.tv',
  206. 'cls' => 'com.huxiu.heh.tv.ui.splash.SplashActivity'
  207. ],
  208. 'extras' => [
  209. // 'cmd' => '',
  210. // 'from' => '',
  211. // 'media_id' => ''
  212. 'type_id' => $v['video_type_id'],
  213. 'id' => $v['id']
  214. ]
  215. ];
  216. $content['isEffective'] = $v['status'];
  217. $content['pic'] = one_domain_image($v['image']);
  218. $content['isPaid'] = $v['is_pay'];
  219. $content = json_encode($content, 320);
  220. $filename = 'shipin_'.date('Ymd').'_'.date('His').'_increment'.'.json';
  221. error_log(print_r($content, 1) . PHP_EOL, 3, './jiankang/' . $filename);
  222. //调用增量注入接口
  223. $postfields = [
  224. 'priKey' => config('cspid'),
  225. 'data' => [$content]
  226. ];
  227. $rt = httpRequest($insert_url, $method, $postfields, $header);
  228. if (!$rt) {
  229. continue;
  230. }
  231. $rt = json_decode($rt, true);
  232. if ($rt['code'] != 'A000000') {
  233. continue;
  234. }*/
  235. //查询中兴注入结果
  236. $url2 = 'http://jscp.agency.gitv.tv/injectResult/v1/queryTv?cspId=' . config('cspid_zx') . '&cpAlbumId=' . $v['id'] . '&cpTvId=' . $v['id'];
  237. $rs2 = httpRequest($url2, 'GET', [], $header);
  238. if (!$rs2) {
  239. continue;
  240. }
  241. $rs2 = json_decode($rs2, true);
  242. if ($rs2['code'] != 'A000000') {
  243. continue;
  244. }
  245. $data2 = $rs2['data'][0];
  246. if ($data2['taskStatus'] == 2) {
  247. $hu_video->where(['id' => $v['id'], 'inject_status' => 1])->setField(['inject_status' => 2, 'seriesid' => $data['seriesId'], 'programid' => $data['programId'], 'movieid' => $data['movieId']]);
  248. } elseif ($data2['taskStatus'] == -1 || $data2['taskStatus'] == -3 || $data2['taskStatus'] == -4) {
  249. $hu_video->where(['id' => $v['id'], 'inject_status' => 1])->setField(['inject_status' => 3, 'seriesid' => $data['seriesId'], 'programid' => $data['programId'], 'movieid' => $data['movieId']]);
  250. }
  251. } elseif ($data['taskStatus'] == -1 || $data['taskStatus'] == -3 || $data['taskStatus'] == -4) {
  252. $hu_video->where(['id' => $v['id'], 'inject_status' => 1])->setField(['inject_status' => 3, 'seriesid' => $data['seriesId'], 'programid' => $data['programId'], 'movieid' => $data['movieId']]);
  253. }
  254. }
  255. echo 'wan bi';
  256. die;
  257. }
  258. //视频统一搜索生成ftp文件
  259. public function videosearch() {
  260. set_time_limit(0);
  261. // $time = strtotime(date('Y-m-d', time()));
  262. $where = array(
  263. 'inject_status' => 2,
  264. 'search_status' => 0,
  265. // 'updatetime' => ['egt', $time]
  266. );
  267. $hu_video = Db::name('video');
  268. $list = $hu_video->where($where)->limit(50)->select();
  269. if (!$list) {
  270. echo 'mei shu ju';
  271. die;
  272. }
  273. $header = [
  274. 'Content-Type: application/json'
  275. ];
  276. //生成ftp文件
  277. $data_content = [
  278. 'cpPrvdName' => '健康e家',
  279. 'cpPrvCode' => '41000144',
  280. 'cpPrvType' => '1006',
  281. 'ChnName' => '健康',
  282. 'ChnCode' => '1000020',
  283. 'actors' => '无',
  284. 'directors' => '无',
  285. 'contentYear' => date('Y'),
  286. 'tags' => '',
  287. 'contentTime' => date('Y-m-d H:i:s'),
  288. 'formatType' => '超清'
  289. ];
  290. //增量接口
  291. $insert_url = 'http://test.meta.unso.gitv.tv/sendMeta';
  292. $method = 'POST';
  293. foreach ($list as &$v) {
  294. //生成ftp文件
  295. $content = $data_content;
  296. $content['contentId'] = $v['movieid'];
  297. $content['extraContentID'] = $v['movieid'];
  298. $content['content'] = $v['title'];
  299. $intent = json_encode([
  300. 'action' => 'com.huxiu.heh.tv.ui.splash.SplashActivity',
  301. 'package' => 'com.huxiu.heh.tv',
  302. 'component' => [
  303. 'pkg' => 'com.huxiu.heh.tv',
  304. 'cls' => 'com.huxiu.heh.tv.ui.splash.SplashActivity'
  305. ],
  306. 'extras' => [
  307. // 'cmd' => '',
  308. // 'from' => '',
  309. // 'media_id' => ''
  310. 'type_id' => $v['video_type_id'],
  311. 'id' => $v['id']
  312. ]
  313. ], 320);
  314. $content['intent'] = "$intent";
  315. $content['isEffective'] = $v['status'];
  316. $content['pic'] = one_domain_image($v['image']);
  317. $content['isPaid'] = $v['is_pay'];
  318. $content = json_encode($content, 320);
  319. $filename = 'shipin_'.date('Ymd').'_'.date('His').'_increment'.'.json';
  320. error_log(print_r($content, 1) . PHP_EOL, 3, './jiankang/' . $filename);
  321. //调用增量注入接口
  322. /*$postfields = [
  323. 'priKey' => config('cspid'),
  324. 'data' => [$content]
  325. ];
  326. $rt = httpRequest($insert_url, $method, $postfields, $header);
  327. if (!$rt) {
  328. continue;
  329. }
  330. $rt = json_decode($rt, true);
  331. if ($rt['code'] != 'A000000') {
  332. continue;
  333. }*/
  334. $hu_video->where(['id' => $v['id'], 'search_status' => 0])->setField(['search_status' => 1]);
  335. }
  336. echo 'wan bi';
  337. die;
  338. }
  339. //订购关系同步地址
  340. public function ordersync() {
  341. $data = file_get_contents('php://input');
  342. file_put_contents('chen_tui.txt', $data, FILE_APPEND);
  343. if (!$data) {
  344. $this->error('参数缺失');
  345. }
  346. $jsonxml = json_encode(simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA));
  347. $data = json_decode($jsonxml, true);
  348. if (!$data) {
  349. $this->error('参数缺失');
  350. }
  351. $phoneNumber = $data['orderRelationSyncRequest']['phoneNumber']; //手机号
  352. $apppId = $data['orderRelationSyncRequest']['apppId']; //订购的HDC业务产品编码
  353. if ($apppId != config('product_code')) {
  354. echo 'meiyou';
  355. exit;
  356. }
  357. //用户增值产品包当前订购快照
  358. $content = [
  359. 'UserID' => $phoneNumber,
  360. 'prod_code' => $apppId,
  361. 'prod_name' => '月包会员',
  362. 'eff_time' => date('Y-m-d H:i:s', time()),
  363. 'exp_time' => date('Y-m-d H:i:s', time() + 30 * 86400),
  364. 'price' => 2900
  365. ];
  366. $content = join(json_decode('"\u0001"', true), $content);
  367. $filename = date('Ymd').'_'.config('data_cp_id').'_userefforderdata_1.dat';
  368. $check_filename = date('Ymd').'_'.config('data_cp_id').'_userefforderdata_1.chk';
  369. error_log(print_r($content, 1) . PHP_EOL, 3, './dashuju/' . $filename);
  370. error_log('', 3, './dashuju/' . $check_filename);
  371. $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_userefforderdata.finish';
  372. error_log('', 3, './dashuju/' . $finish_filename);
  373. //用户增值产品包订购行为数据
  374. $user_id = Db::name('user')->where(['mobile' => $phoneNumber])->value('id');
  375. $order_info = Db::name('rechar_order')->where(['user_id' => $user_id, 'purpose' => 3, 'pay_type' => 'zhuowang', 'status' => 1])->order('id desc')->find();
  376. $content = [
  377. 'orderid' => $order_info['order_no'],
  378. 'order_time' => date('Y-m-d H:i:s', time()),
  379. 'order_type' => 1,
  380. 'UserID' => $phoneNumber,
  381. 'prod_code' => $apppId,
  382. 'prod_name' => '月包会员',
  383. 'eff_time' => date('Y-m-d H:i:s', time()),
  384. 'exp_time' => date('Y-m-d H:i:s', time() + 30 * 86400),
  385. 'csource' => 99,
  386. 'trace_id' => '',
  387. 'price' => 2900,
  388. 'paytype' => 0,
  389. 'cpid' => config('data_cp_id'),
  390. 'albumid' => '',
  391. 'albumname' => ''
  392. ];
  393. $content = join(json_decode('"\u0001"', true), $content);
  394. $filename = date('Ymd').'_'.config('data_cp_id').'_userorderdata_1.dat';
  395. $check_filename = date('Ymd').'_'.config('data_cp_id').'_userorderdata_1.chk';
  396. error_log(print_r($content, 1) . PHP_EOL, 3, './dashuju/' . $filename);
  397. error_log('', 3, './dashuju/' . $check_filename);
  398. $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_userorderdata.finish';
  399. error_log('', 3, './dashuju/' . $finish_filename);
  400. }
  401. //(补漏)视频注入中兴
  402. public function injectzx() {
  403. set_time_limit(0);
  404. $hu_video = Db::name('video');
  405. $list = $hu_video->where(['id' => 107])->limit(50)->select();
  406. if (!$list) {
  407. echo 'mei shu ju';
  408. die;
  409. }
  410. $cspid = config('cspid_zx');
  411. $url = 'http://jscp.agency.gitv.tv/epgDataSync/v1/' . $cspid . '/';
  412. foreach ($list as &$params) {
  413. //内容同步
  414. $videofile = $params['videofile'];
  415. $videofile = explode('/', $videofile);
  416. $video_url = $videofile[3];
  417. $data = [
  418. // 'cspId' => $cspid,
  419. 'cpAlbumId' => $params['id'],
  420. 'albumName' => $params['title'],
  421. 'tvSets' => 1,
  422. 'updateToSet' => 1,
  423. 'isPurchase' => $params['is_pay'],
  424. 'isEffective' => $params['status'],
  425. 'isOnline' => $params['status'],
  426. 'albumTypes' => '健康',
  427. 'picBox' => config('upload.cdnurl') . $params['image'],
  428. 'albumUpdateTime' => date('YmdHis', time()),
  429. 'albumCreateTime' => date('YmdHis', time()),
  430. 'tvlist' => [
  431. [
  432. 'cpAlbumId' => $params['id'],
  433. 'cpTvId' => $params['id'],
  434. 'tvName' => $params['title'],
  435. 'tvIsEffective' => $params['status'],
  436. 'tvIsOnline' => $params['status'],
  437. 'isPurchase' => $params['is_pay'],
  438. 'playOrder' => 1,
  439. 'tvUrl' => 'ftp://'.config('ftp_user').':'.config('ftp_pwd').'@'.config('ftp_ip').':'.config('ftp_port').'/inject/'.$video_url
  440. ]
  441. ]
  442. ];
  443. $data = json_encode($data, 320);
  444. $header = [
  445. 'Content-Type: application/json'
  446. ];
  447. $rs = httpRequest($url, 'POST', $data, $header);
  448. if ($rs) {
  449. $rs = json_decode($rs, true);
  450. if ($rs['code'] != 'A000000') {
  451. continue;
  452. }
  453. }
  454. }
  455. echo 'wan bi';
  456. die;
  457. }
  458. //(补漏)删除注入中兴视频
  459. public function delinjectzx() {
  460. set_time_limit(0);
  461. $hu_video = Db::name('video');
  462. $list = $hu_video->where(['id' => 107])->limit(1)->order('id')->select();
  463. if (!$list) {
  464. echo 'mei shu ju';
  465. die;
  466. }
  467. $cspid = config('cspid_zx');
  468. $url = 'http://jscp.agency.gitv.tv/epgDeleteSync/v1/' . $cspid . '/';
  469. foreach ($list as &$params) {
  470. //内容同步
  471. $videofile = $params['videofile'];
  472. $videofile = explode('/', $videofile);
  473. $video_url = $videofile[3];
  474. $data = [
  475. // 'cspId' => $cspid,
  476. 'cpAlbumId' => $params['id'],
  477. 'albumName' => $params['title'],
  478. 'tvSets' => 1,
  479. 'updateToSet' => 1,
  480. 'isPurchase' => $params['is_pay'],
  481. 'isEffective' => 0,
  482. 'isOnline' => 2,
  483. 'albumTypes' => '健康',
  484. 'picBox' => config('upload.cdnurl') . $params['image'],
  485. 'albumUpdateTime' => date('YmdHis', time()),
  486. // 'albumCreateTime' => date('YmdHis', time()),
  487. 'tvlist' => [
  488. [
  489. 'cpAlbumId' => $params['id'],
  490. 'cpTvId' => $params['id'],
  491. 'tvName' => $params['title'],
  492. 'tvIsEffective' => 0,
  493. 'tvIsOnline' => 2,
  494. 'isPurchase' => $params['is_pay'],
  495. 'playOrder' => 1,
  496. 'tvUrl' => 'ftp://'.config('ftp_user').':'.config('ftp_pwd').'@'.config('ftp_ip').':'.config('ftp_port').'/inject/'.$video_url
  497. ]
  498. ]
  499. ];
  500. $data = json_encode($data, 320);
  501. $header = [
  502. 'Content-Type: application/json'
  503. ];
  504. $rs = httpRequest($url, 'POST', $data, $header);
  505. if ($rs) {
  506. $rs = json_decode($rs, true);
  507. if ($rs['code'] != 'A000000') {
  508. continue;
  509. }
  510. }
  511. }
  512. echo 'wan bi';
  513. die;
  514. }
  515. //媒资数据专辑粒度
  516. public function mediadataalbum() {
  517. $hu_video = Db::name('video');
  518. $list = $hu_video->where(['inject_status' => 2, 'mediaalbum_status' => 0])->order('id')->select();
  519. if (!$list) {
  520. echo 'mei shu ju';
  521. die;
  522. }
  523. foreach ($list as $key => &$param) {
  524. $content = [
  525. 'Updatetype' => 1,
  526. 'cpid' => config('data_cp_id'),
  527. 'channelid' => '1000035',
  528. 'albumid' => $param['id'],
  529. 'albumname' => $param['title'],
  530. 'albumnum' => 1,
  531. 'tag' => '',
  532. 'onlinetime' => '',
  533. 'bref' => '',
  534. 'onebref' => '',
  535. 'cornersign' => $param['is_pay'],
  536. 'director' => '',
  537. 'actor' => '',
  538. 'year' => '',
  539. 'area' => '',
  540. 'language' => '',
  541. 'score' => '',
  542. 'picurl' => config('upload.cdnurl') . $param['image'],
  543. 'picurl_v' => '',
  544. 'gotourl' => json_encode([
  545. 'action' => 'com.huxiu.heh.tv.ui.splash.SplashActivity',
  546. 'package' => 'com.huxiu.heh.tv',
  547. 'component' => [
  548. 'pkg' => 'com.huxiu.heh.tv',
  549. 'cls' => 'com.huxiu.heh.tv.ui.splash.SplashActivity'
  550. ],
  551. 'extras' => [
  552. // 'cmd' => '',
  553. // 'from' => '',
  554. // 'media_id' => ''
  555. 'type_id' => $param['video_type_id'],
  556. 'id' => $param['id']
  557. ]
  558. ], 320),
  559. 'is_politics' => '',
  560. 'second_type' => ''
  561. ];
  562. $content = join(json_decode('"\u0001"', true), $content);
  563. $filename = date('Ymd').'_'.config('data_cp_id').'_albumsdata_1.dat';
  564. $check_filename = date('Ymd').'_'.config('data_cp_id').'_albumsdata_1.chk';
  565. error_log(print_r($content, 1) . PHP_EOL, 3, './dashuju/' . $filename);
  566. error_log('', 3, './dashuju/' . $check_filename);
  567. if ($key == count($list) - 1) {
  568. $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_albumsdata.finish';
  569. error_log('', 3, './dashuju/' . $finish_filename);
  570. }
  571. $hu_video->where(['id' => $param['id'], 'mediaalbum_status' => 0])->setField('mediaalbum_status', 1);
  572. }
  573. echo 'wan bi';
  574. }
  575. //媒资数据节目/内容粒度
  576. public function mediadatavideo() {
  577. $hu_video = Db::name('video');
  578. $list = $hu_video->where(['inject_status' => 2, 'mediavideo_status' => 0])->order('id')->select();
  579. if (!$list) {
  580. echo 'mei shu ju';
  581. die;
  582. }
  583. foreach ($list as $key => &$param) {
  584. $content = [
  585. 'Updatetype' => 1,
  586. 'cpid' => config('data_cp_id'),
  587. 'channelid' => '1000035',
  588. 'albumid' => $param['id'],
  589. 'albumname' => $param['title'],
  590. 'videoid' => $param['id'],
  591. 'videoname' => $param['title'],
  592. 'videonum' => 1,
  593. 'Contenttype' => 1,
  594. 'duration' => '',
  595. 'quality' => ''
  596. ];
  597. $content = join(json_decode('"\u0001"', true), $content);
  598. $filename = date('Ymd').'_'.config('data_cp_id').'_videosdata_1.dat';
  599. $check_filename = date('Ymd').'_'.config('data_cp_id').'_videosdata_1.chk';
  600. error_log(print_r($content, 1) . PHP_EOL, 3, './dashuju/' . $filename);
  601. error_log('', 3, './dashuju/' . $check_filename);
  602. if ($key == count($list) - 1) {
  603. $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_videosdata.finish';
  604. error_log('', 3, './dashuju/' . $finish_filename);
  605. }
  606. $hu_video->where(['id' => $param['id'], 'mediavideo_status' => 0])->setField('mediavideo_status', 1);
  607. }
  608. }
  609. //产品包
  610. public function product() {
  611. $content = [
  612. 'prod_code' => config('product_code'),
  613. 'prod_name' => '月包会员',
  614. 'prod_type' => 0,
  615. 'cpid' => config('data_cp_id')
  616. ];
  617. $content = join(json_decode('"\u0001"', true), $content);
  618. $filename = date('Ymd').'_'.config('data_cp_id').'_productsdata_1.dat';
  619. $check_filename = date('Ymd').'_'.config('data_cp_id').'_productsdata_1.chk';
  620. error_log(print_r($content, 1) . PHP_EOL, 3, './dashuju/' . $filename);
  621. error_log('', 3, './dashuju/' . $check_filename);
  622. $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_productsdata.finish';
  623. error_log('', 3, './dashuju/' . $finish_filename);
  624. //连接ftp
  625. $host = config('data_ftp_ip');
  626. $port = config('data_ftp_port');
  627. $username = config('data_ftp_user');
  628. $password = config('data_ftp_pwd');
  629. $conn = ftp_connect($host, $port) or die("Could not connect");
  630. //登录
  631. ftp_login($conn,$username,$password);
  632. //开启被动模式
  633. ftp_pasv($conn, true);
  634. //利用ftp创建目录
  635. /*$path = "home/2021-12-08";
  636. $this->make_directory($conn,$path);
  637. //利用ftp选择进入目录
  638. ftp_chdir($conn,$path);*/
  639. //开始上传 ftp_put(ftp链接,服务器地址,本地地址,上传模式);
  640. if(ftp_put($conn,$filename,'./dashuju/' . $filename,FTP_BINARY)){
  641. //上传成功
  642. }
  643. if(ftp_put($conn,$check_filename,'./dashuju/' . $check_filename,FTP_BINARY)){
  644. //上传成功
  645. }
  646. if(ftp_put($conn,$finish_filename,'./dashuju/' . $finish_filename,FTP_BINARY)){
  647. //上传成功
  648. }
  649. ftp_close($conn);
  650. //注意上传端的ftp权限设置
  651. echo 'wanbi';
  652. }
  653. //产品包和媒资所属关系
  654. public function productmediarelation() {
  655. $hu_video = Db::name('video');
  656. $list = $hu_video->where(['inject_status' => 2, 'productmedia_status' => 0])->order('id')->select();
  657. if (!$list) {
  658. echo 'mei shu ju';
  659. die;
  660. }
  661. foreach ($list as $key => &$param) {
  662. $content = [
  663. 'Updatetype' => 1,
  664. 'prod_code' => config('product_code'),
  665. 'cpid' => config('data_cp_id'),
  666. 'albumid' => $param['id']
  667. ];
  668. $content = join(json_decode('"\u0001"', true), $content);
  669. $filename = date('Ymd').'_'.config('data_cp_id').'_productalbumdata_1.dat';
  670. $check_filename = date('Ymd').'_'.config('data_cp_id').'_productalbumdata_1.chk';
  671. error_log(print_r($content, 1) . PHP_EOL, 3, './dashuju/' . $filename);
  672. error_log('', 3, './dashuju/' . $check_filename);
  673. if ($key == count($list) - 1) {
  674. $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_productalbumdata.finish';
  675. error_log('', 3, './dashuju/' . $finish_filename);
  676. }
  677. $hu_video->where(['id' => $param['id'], 'productmedia_status' => 0])->setField('productmedia_status', 1);
  678. }
  679. }
  680. //用户观看行为数据文件上传到卓望ftp(每小时第10分钟提供)
  681. public function uploadpayftp() {
  682. set_time_limit(0);
  683. $host = config('pay_ftp_ip');
  684. $port = config('pay_ftp_port');
  685. $username = config('pay_ftp_user');
  686. $password = config('pay_ftp_pwd');
  687. $filename = date('YmdH', time() - 3600).'_'.config('cp_id').'_userviewdata_1.dat';
  688. $check_filename = date('YmdH', time() - 3600).'_'.config('cp_id').'_userviewdata_1.chk';
  689. //判断文件是否存在, 不存在则创建
  690. if (!file_exists('./dashuju/' . $filename)) {
  691. @touch('./dashuju/' . $filename);
  692. }
  693. if (!file_exists('./dashuju/' . $check_filename)) {
  694. @touch('./dashuju/' . $check_filename);
  695. }
  696. //连接ftp
  697. $conn = ftp_connect($host, $port) or die("Could not connect");
  698. //登录
  699. ftp_login($conn,$username,$password);
  700. //开启被动模式
  701. ftp_pasv($conn, true);
  702. //利用ftp创建目录
  703. /*$path = "home/2021-12-08";
  704. $this->make_directory($conn,$path);
  705. //利用ftp选择进入目录
  706. ftp_chdir($conn,$path);*/
  707. //开始上传 ftp_put(ftp链接,服务器地址,本地地址,上传模式);
  708. if(ftp_put($conn,$filename,'./dashuju/' . $filename,FTP_BINARY)){
  709. //上传成功
  710. }
  711. if(ftp_put($conn,$check_filename,'./dashuju/' . $check_filename,FTP_BINARY)){
  712. //上传成功
  713. }
  714. ftp_close($conn);
  715. //注意上传端的ftp权限设置
  716. echo 'wanbi';
  717. }
  718. //大数据文件上传到大数据ftp(每天一点提供)
  719. public function uploaddataftp() {
  720. set_time_limit(0);
  721. $host = config('data_ftp_ip');
  722. $port = config('data_ftp_port');
  723. $username = config('data_ftp_user');
  724. $password = config('data_ftp_pwd');
  725. $time = date('Ymd', time() - 86400);
  726. // 专辑粒度媒资
  727. $albumsdata_filename = $time.'_'.config('data_cp_id').'_albumsdata_1.dat';
  728. $albumsdata_check_filename = $time.'_'.config('data_cp_id').'_albumsdata_1.chk';
  729. $albumsdata_finish_filename = $time.'_'.config('data_cp_id').'_albumsdata_1.finish';
  730. // 节目/内容粒度媒资
  731. $videosdata_filename = $time.'_'.config('data_cp_id').'_videosdata_1.dat';
  732. $videosdata_check_filename = $time.'_'.config('data_cp_id').'_videosdata_1.chk';
  733. $videosdata_finish_filename = $time.'_'.config('data_cp_id').'_videosdata_1.finish';
  734. // 产品包和媒资所属关系
  735. $productalbumdata_filename = $time.'_'.config('data_cp_id').'_productalbumdata_1.dat';
  736. $productalbumdata_check_filename = $time.'_'.config('data_cp_id').'_productalbumdata_1.chk';
  737. $productalbumdata_finish_filename = $time.'_'.config('data_cp_id').'_productalbumdata_1.finish';
  738. // 用户增值产品包当前订购快照
  739. $userefforderdata_filename = $time.'_'.config('data_cp_id').'_userefforderdata_1.dat';
  740. $userefforderdata_check_filename = $time.'_'.config('data_cp_id').'_userefforderdata_1.chk';
  741. $userefforderdata_finish_filename = $time.'_'.config('data_cp_id').'_userefforderdata_1.finish';
  742. // 用户增值产品包订购行为
  743. $userorderdata_filename = $time.'_'.config('data_cp_id').'_userorderdata_1.dat';
  744. $userorderdata_check_filename = $time.'_'.config('data_cp_id').'_userorderdata_1.chk';
  745. $userorderdata_finish_filename = $time.'_'.config('data_cp_id').'_userorderdata_1.finish';
  746. // 用户观看行为
  747. $userplaydata_filename = $time.'_'.config('data_cp_id').'_userplaydata_1.dat';
  748. $userplaydata_check_filename = $time.'_'.config('data_cp_id').'_userplaydata_1.chk';
  749. $userplaydata_finish_filename = $time.'_'.config('data_cp_id').'_userplaydata_1.finish';
  750. // 用户收藏行为
  751. $userfavdata_filename = $time.'_'.config('data_cp_id').'_userfavdata_1.dat';
  752. $userfavdata_check_filename = $time.'_'.config('data_cp_id').'_userfavdata_1.chk';
  753. $userfavdata_finish_filename = $time.'_'.config('data_cp_id').'_userfavdata_1.finish';
  754. //判断文件是否存在, 不存在则创建
  755. if (!file_exists('./dashuju/' . $albumsdata_filename)) {
  756. @touch('./dashuju/' . $albumsdata_filename);
  757. }
  758. if (!file_exists('./dashuju/' . $albumsdata_check_filename)) {
  759. @touch('./dashuju/' . $albumsdata_check_filename);
  760. }
  761. if (!file_exists('./dashuju/' . $albumsdata_finish_filename)) {
  762. @touch('./dashuju/' . $albumsdata_finish_filename);
  763. }
  764. if (!file_exists('./dashuju/' . $videosdata_filename)) {
  765. @touch('./dashuju/' . $videosdata_filename);
  766. }
  767. if (!file_exists('./dashuju/' . $videosdata_check_filename)) {
  768. @touch('./dashuju/' . $videosdata_check_filename);
  769. }
  770. if (!file_exists('./dashuju/' . $videosdata_finish_filename)) {
  771. @touch('./dashuju/' . $videosdata_finish_filename);
  772. }
  773. if (!file_exists('./dashuju/' . $productalbumdata_filename)) {
  774. @touch('./dashuju/' . $productalbumdata_filename);
  775. }
  776. if (!file_exists('./dashuju/' . $productalbumdata_check_filename)) {
  777. @touch('./dashuju/' . $productalbumdata_check_filename);
  778. }
  779. if (!file_exists('./dashuju/' . $productalbumdata_finish_filename)) {
  780. @touch('./dashuju/' . $productalbumdata_finish_filename);
  781. }
  782. if (!file_exists('./dashuju/' . $userefforderdata_filename)) {
  783. @touch('./dashuju/' . $userefforderdata_filename);
  784. }
  785. if (!file_exists('./dashuju/' . $userefforderdata_check_filename)) {
  786. @touch('./dashuju/' . $userefforderdata_check_filename);
  787. }
  788. if (!file_exists('./dashuju/' . $userefforderdata_finish_filename)) {
  789. @touch('./dashuju/' . $userefforderdata_finish_filename);
  790. }
  791. if (!file_exists('./dashuju/' . $userorderdata_filename)) {
  792. @touch('./dashuju/' . $userorderdata_filename);
  793. }
  794. if (!file_exists('./dashuju/' . $userorderdata_check_filename)) {
  795. @touch('./dashuju/' . $userorderdata_check_filename);
  796. }
  797. if (!file_exists('./dashuju/' . $userorderdata_finish_filename)) {
  798. @touch('./dashuju/' . $userorderdata_finish_filename);
  799. }
  800. if (!file_exists('./dashuju/' . $userplaydata_filename)) {
  801. @touch('./dashuju/' . $userplaydata_filename);
  802. }
  803. if (!file_exists('./dashuju/' . $userplaydata_check_filename)) {
  804. @touch('./dashuju/' . $userplaydata_check_filename);
  805. }
  806. if (!file_exists('./dashuju/' . $userplaydata_finish_filename)) {
  807. @touch('./dashuju/' . $userplaydata_finish_filename);
  808. }
  809. if (!file_exists('./dashuju/' . $userfavdata_filename)) {
  810. @touch('./dashuju/' . $userfavdata_filename);
  811. }
  812. if (!file_exists('./dashuju/' . $userfavdata_check_filename)) {
  813. @touch('./dashuju/' . $userfavdata_check_filename);
  814. }
  815. if (!file_exists('./dashuju/' . $userfavdata_finish_filename)) {
  816. @touch('./dashuju/' . $userfavdata_finish_filename);
  817. }
  818. //连接ftp
  819. $conn = ftp_connect($host, $port) or die("Could not connect");
  820. //登录
  821. ftp_login($conn,$username,$password);
  822. //开启被动模式
  823. ftp_pasv($conn, true);
  824. //利用ftp创建目录
  825. /*$path = "home/2021-12-08";
  826. $this->make_directory($conn,$path);
  827. //利用ftp选择进入目录
  828. ftp_chdir($conn,$path);*/
  829. //开始上传 ftp_put(ftp链接,服务器地址,本地地址,上传模式);
  830. if(ftp_put($conn,$albumsdata_filename,'./dashuju/' . $albumsdata_filename,FTP_BINARY)){
  831. //上传成功
  832. }
  833. if(ftp_put($conn,$albumsdata_check_filename,'./dashuju/' . $albumsdata_check_filename,FTP_BINARY)){
  834. //上传成功
  835. }
  836. if(ftp_put($conn,$albumsdata_finish_filename,'./dashuju/' . $albumsdata_finish_filename,FTP_BINARY)){
  837. //上传成功
  838. }
  839. if(ftp_put($conn,$videosdata_filename,'./dashuju/' . $videosdata_filename,FTP_BINARY)){
  840. //上传成功
  841. }
  842. if(ftp_put($conn,$videosdata_check_filename,'./dashuju/' . $videosdata_check_filename,FTP_BINARY)){
  843. //上传成功
  844. }
  845. if(ftp_put($conn,$videosdata_finish_filename,'./dashuju/' . $videosdata_finish_filename,FTP_BINARY)){
  846. //上传成功
  847. }
  848. if(ftp_put($conn,$productalbumdata_filename,'./dashuju/' . $productalbumdata_filename,FTP_BINARY)){
  849. //上传成功
  850. }
  851. if(ftp_put($conn,$productalbumdata_check_filename,'./dashuju/' . $productalbumdata_check_filename,FTP_BINARY)){
  852. //上传成功
  853. }
  854. if(ftp_put($conn,$productalbumdata_finish_filename,'./dashuju/' . $productalbumdata_finish_filename,FTP_BINARY)){
  855. //上传成功
  856. }
  857. if(ftp_put($conn,$userefforderdata_filename,'./dashuju/' . $userefforderdata_filename,FTP_BINARY)){
  858. //上传成功
  859. }
  860. if(ftp_put($conn,$userefforderdata_check_filename,'./dashuju/' . $userefforderdata_check_filename,FTP_BINARY)){
  861. //上传成功
  862. }
  863. if(ftp_put($conn,$userefforderdata_finish_filename,'./dashuju/' . $userefforderdata_finish_filename,FTP_BINARY)){
  864. //上传成功
  865. }
  866. if(ftp_put($conn,$userorderdata_filename,'./dashuju/' . $userorderdata_filename,FTP_BINARY)){
  867. //上传成功
  868. }
  869. if(ftp_put($conn,$userorderdata_check_filename,'./dashuju/' . $userorderdata_check_filename,FTP_BINARY)){
  870. //上传成功
  871. }
  872. if(ftp_put($conn,$userorderdata_finish_filename,'./dashuju/' . $userorderdata_finish_filename,FTP_BINARY)){
  873. //上传成功
  874. }
  875. if(ftp_put($conn,$userplaydata_filename,'./dashuju/' . $userplaydata_filename,FTP_BINARY)){
  876. //上传成功
  877. }
  878. if(ftp_put($conn,$userplaydata_check_filename,'./dashuju/' . $userplaydata_check_filename,FTP_BINARY)){
  879. //上传成功
  880. }
  881. if(ftp_put($conn,$userplaydata_finish_filename,'./dashuju/' . $userplaydata_finish_filename,FTP_BINARY)){
  882. //上传成功
  883. }
  884. if(ftp_put($conn,$userfavdata_filename,'./dashuju/' . $userfavdata_filename,FTP_BINARY)){
  885. //上传成功
  886. }
  887. if(ftp_put($conn,$userfavdata_check_filename,'./dashuju/' . $userfavdata_check_filename,FTP_BINARY)){
  888. //上传成功
  889. }
  890. if(ftp_put($conn,$userfavdata_finish_filename,'./dashuju/' . $userfavdata_finish_filename,FTP_BINARY)){
  891. //上传成功
  892. }
  893. ftp_close($conn);
  894. //注意上传端的ftp权限设置
  895. echo 'wanbi';
  896. }
  897. public function make_directory($ftp_stream, $dir){
  898. // if directory already exists or can be immediately created return true
  899. if ($this->ftp_is_dir($ftp_stream, $dir) || @ftp_mkdir($ftp_stream, $dir)) return true;
  900. // otherwise recursively try to make the directory
  901. if (!$this->make_directory($ftp_stream, dirname($dir))) return false;
  902. // final step to create the directory
  903. return ftp_mkdir($ftp_stream, $dir);
  904. }
  905. public function ftp_is_dir($ftp_stream, $dir){
  906. // get current directory
  907. $original_directory = ftp_pwd($ftp_stream);
  908. // test if you can change directory to $dir
  909. // suppress errors in case $dir is not a file or not a directory
  910. if ( @ftp_chdir( $ftp_stream, $dir ) ) {
  911. // If it is a directory, then change the directory back to the original directory
  912. ftp_chdir( $ftp_stream, $original_directory );
  913. return true;
  914. } else {
  915. return false;
  916. }
  917. }
  918. }