Notify.php 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038
  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. //订购关系同步地址
  341. public function ordersync() {
  342. $data = file_get_contents('php://input');
  343. file_put_contents('chen_tui.txt', $data, FILE_APPEND);
  344. if (!$data) {
  345. $this->error('参数缺失');
  346. }
  347. $jsonxml = json_encode(simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA));
  348. $data = json_decode($jsonxml, true);
  349. if (!$data) {
  350. $this->error('参数缺失');
  351. }
  352. $phoneNumber = $data['orderRelationSyncRequest']['phoneNumber']; //手机号
  353. $apppId = $data['orderRelationSyncRequest']['apppId']; //订购的HDC业务产品编码
  354. if ($apppId != config('product_code')) {
  355. echo 'meiyou';
  356. exit;
  357. }
  358. //用户增值产品包当前订购快照
  359. $content = [
  360. 'UserID' => $phoneNumber,
  361. 'prod_code' => $apppId,
  362. 'prod_name' => '月包会员',
  363. 'eff_time' => date('Y-m-d H:i:s', time()),
  364. 'exp_time' => date('Y-m-d H:i:s', time() + 30 * 86400),
  365. 'price' => 2900
  366. ];
  367. $content = join(json_decode('"\u0001"', true), $content);
  368. $filename = date('Ymd').'_'.config('data_cp_id').'_userefforderdata_1.dat';
  369. $check_filename = date('Ymd').'_'.config('data_cp_id').'_userefforderdata_1.chk';
  370. error_log(print_r($content, 1) . PHP_EOL, 3, './dashuju/' . $filename);
  371. error_log('', 3, './dashuju/' . $check_filename);
  372. $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_userefforderdata.finish';
  373. error_log('', 3, './dashuju/' . $finish_filename);
  374. //用户增值产品包订购行为数据
  375. $user_id = Db::name('user')->where(['mobile' => $phoneNumber])->value('id');
  376. $order_info = Db::name('rechar_order')->where(['user_id' => $user_id, 'purpose' => 3, 'pay_type' => 'zhuowang', 'status' => 1])->order('id desc')->find();
  377. $content = [
  378. 'orderid' => $order_info['order_no'],
  379. 'order_time' => date('Y-m-d H:i:s', time()),
  380. 'order_type' => 1,
  381. 'UserID' => $phoneNumber,
  382. 'prod_code' => $apppId,
  383. 'prod_name' => '月包会员',
  384. 'eff_time' => date('Y-m-d H:i:s', time()),
  385. 'exp_time' => date('Y-m-d H:i:s', time() + 30 * 86400),
  386. 'csource' => 99,
  387. 'trace_id' => '',
  388. 'price' => 2900,
  389. 'paytype' => 0,
  390. 'cpid' => config('data_cp_id'),
  391. 'albumid' => '',
  392. 'albumname' => ''
  393. ];
  394. $content = join(json_decode('"\u0001"', true), $content);
  395. $filename = date('Ymd').'_'.config('data_cp_id').'_userorderdata_1.dat';
  396. $check_filename = date('Ymd').'_'.config('data_cp_id').'_userorderdata_1.chk';
  397. error_log(print_r($content, 1) . PHP_EOL, 3, './dashuju/' . $filename);
  398. error_log('', 3, './dashuju/' . $check_filename);
  399. $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_userorderdata.finish';
  400. error_log('', 3, './dashuju/' . $finish_filename);
  401. }
  402. //没用到
  403. //(补漏)视频注入中兴
  404. public function injectzx() {
  405. set_time_limit(0);
  406. $hu_video = Db::name('video');
  407. $list = $hu_video->where(['id' => 107])->limit(50)->select();
  408. if (!$list) {
  409. echo 'mei shu ju';
  410. die;
  411. }
  412. $cspid = config('cspid_zx');
  413. $url = 'http://jscp.agency.gitv.tv/epgDataSync/v1/' . $cspid . '/';
  414. foreach ($list as &$params) {
  415. //内容同步
  416. $videofile = $params['videofile'];
  417. $videofile = explode('/', $videofile);
  418. $video_url = $videofile[3];
  419. $data = [
  420. // 'cspId' => $cspid,
  421. 'cpAlbumId' => $params['id'],
  422. 'albumName' => $params['title'],
  423. 'tvSets' => 1,
  424. 'updateToSet' => 1,
  425. 'isPurchase' => $params['is_pay'],
  426. 'isEffective' => $params['status'],
  427. 'isOnline' => $params['status'],
  428. 'albumTypes' => '健康',
  429. 'picBox' => config('upload.cdnurl') . $params['image'],
  430. 'albumUpdateTime' => date('YmdHis', time()),
  431. 'albumCreateTime' => date('YmdHis', time()),
  432. 'tvlist' => [
  433. [
  434. 'cpAlbumId' => $params['id'],
  435. 'cpTvId' => $params['id'],
  436. 'tvName' => $params['title'],
  437. 'tvIsEffective' => $params['status'],
  438. 'tvIsOnline' => $params['status'],
  439. 'isPurchase' => $params['is_pay'],
  440. 'playOrder' => 1,
  441. 'tvUrl' => 'ftp://'.config('ftp_user').':'.config('ftp_pwd').'@'.config('ftp_ip').':'.config('ftp_port').'/inject/'.$video_url
  442. ]
  443. ]
  444. ];
  445. $data = json_encode($data, 320);
  446. $header = [
  447. 'Content-Type: application/json'
  448. ];
  449. $rs = httpRequest($url, 'POST', $data, $header);
  450. if ($rs) {
  451. $rs = json_decode($rs, true);
  452. if ($rs['code'] != 'A000000') {
  453. continue;
  454. }
  455. }
  456. }
  457. echo 'wan bi';
  458. die;
  459. }
  460. //没用到
  461. //(补漏)删除注入中兴视频
  462. public function delinjectzx() {
  463. set_time_limit(0);
  464. $hu_video = Db::name('video');
  465. $list = $hu_video->where(['id' => 107])->limit(1)->order('id')->select();
  466. if (!$list) {
  467. echo 'mei shu ju';
  468. die;
  469. }
  470. $cspid = config('cspid_zx');
  471. $url = 'http://jscp.agency.gitv.tv/epgDeleteSync/v1/' . $cspid . '/';
  472. foreach ($list as &$params) {
  473. //内容同步
  474. $videofile = $params['videofile'];
  475. $videofile = explode('/', $videofile);
  476. $video_url = $videofile[3];
  477. $data = [
  478. // 'cspId' => $cspid,
  479. 'cpAlbumId' => $params['id'],
  480. 'albumName' => $params['title'],
  481. 'tvSets' => 1,
  482. 'updateToSet' => 1,
  483. 'isPurchase' => $params['is_pay'],
  484. 'isEffective' => 0,
  485. 'isOnline' => 2,
  486. 'albumTypes' => '健康',
  487. 'picBox' => config('upload.cdnurl') . $params['image'],
  488. 'albumUpdateTime' => date('YmdHis', time()),
  489. // 'albumCreateTime' => date('YmdHis', time()),
  490. 'tvlist' => [
  491. [
  492. 'cpAlbumId' => $params['id'],
  493. 'cpTvId' => $params['id'],
  494. 'tvName' => $params['title'],
  495. 'tvIsEffective' => 0,
  496. 'tvIsOnline' => 2,
  497. 'isPurchase' => $params['is_pay'],
  498. 'playOrder' => 1,
  499. 'tvUrl' => 'ftp://'.config('ftp_user').':'.config('ftp_pwd').'@'.config('ftp_ip').':'.config('ftp_port').'/inject/'.$video_url
  500. ]
  501. ]
  502. ];
  503. $data = json_encode($data, 320);
  504. $header = [
  505. 'Content-Type: application/json'
  506. ];
  507. $rs = httpRequest($url, 'POST', $data, $header);
  508. if ($rs) {
  509. $rs = json_decode($rs, true);
  510. if ($rs['code'] != 'A000000') {
  511. continue;
  512. }
  513. }
  514. }
  515. echo 'wan bi';
  516. die;
  517. }
  518. //媒资数据专辑粒度
  519. public function mediadataalbum() {
  520. $hu_video = Db::name('video');
  521. $list = $hu_video->where(['inject_status' => 2, 'mediaalbum_status' => 0])->order('id')->select();
  522. if (!$list) {
  523. echo 'mei shu ju';
  524. die;
  525. }
  526. foreach ($list as $key => &$param) {
  527. $content = [
  528. 'Updatetype' => 1,
  529. 'cpid' => config('data_cp_id'),
  530. 'channelid' => '1000035',
  531. 'albumid' => $param['id'],
  532. 'albumname' => $param['title'],
  533. 'albumnum' => 1,
  534. 'tag' => '',
  535. 'onlinetime' => '',
  536. 'bref' => '',
  537. 'onebref' => '',
  538. 'cornersign' => $param['is_pay'],
  539. 'director' => '',
  540. 'actor' => '',
  541. 'year' => '',
  542. 'area' => '',
  543. 'language' => '',
  544. 'score' => '',
  545. 'picurl' => config('upload.cdnurl') . $param['image'],
  546. 'picurl_v' => '',
  547. 'gotourl' => json_encode([
  548. 'action' => 'com.huxiu.heh.tv.ui.splash.SplashActivity',
  549. 'package' => 'com.huxiu.heh.tv',
  550. 'component' => [
  551. 'pkg' => 'com.huxiu.heh.tv',
  552. 'cls' => 'com.huxiu.heh.tv.ui.splash.SplashActivity'
  553. ],
  554. 'extras' => [
  555. // 'cmd' => '',
  556. // 'from' => '',
  557. // 'media_id' => ''
  558. 'type_id' => $param['video_type_id'],
  559. 'id' => $param['id']
  560. ]
  561. ], 320),
  562. 'is_politics' => '',
  563. 'second_type' => ''
  564. ];
  565. $content = join(json_decode('"\u0001"', true), $content);
  566. $filename = date('Ymd').'_'.config('data_cp_id').'_albumsdata_1.dat';
  567. $check_filename = date('Ymd').'_'.config('data_cp_id').'_albumsdata_1.chk';
  568. error_log(print_r($content, 1) . PHP_EOL, 3, './dashuju/' . $filename);
  569. error_log('', 3, './dashuju/' . $check_filename);
  570. if ($key == count($list) - 1) {
  571. $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_albumsdata.finish';
  572. error_log('', 3, './dashuju/' . $finish_filename);
  573. }
  574. $hu_video->where(['id' => $param['id'], 'mediaalbum_status' => 0])->setField('mediaalbum_status', 1);
  575. }
  576. echo 'wan bi';
  577. }
  578. //媒资数据节目/内容粒度
  579. public function mediadatavideo() {
  580. $hu_video = Db::name('video');
  581. $list = $hu_video->where(['inject_status' => 2, 'mediavideo_status' => 0])->order('id')->select();
  582. if (!$list) {
  583. echo 'mei shu ju';
  584. die;
  585. }
  586. foreach ($list as $key => &$param) {
  587. $content = [
  588. 'Updatetype' => 1,
  589. 'cpid' => config('data_cp_id'),
  590. 'channelid' => '1000035',
  591. 'albumid' => $param['id'],
  592. 'albumname' => $param['title'],
  593. 'videoid' => $param['id'],
  594. 'videoname' => $param['title'],
  595. 'videonum' => 1,
  596. 'Contenttype' => 1,
  597. 'duration' => '',
  598. 'quality' => ''
  599. ];
  600. $content = join(json_decode('"\u0001"', true), $content);
  601. $filename = date('Ymd').'_'.config('data_cp_id').'_videosdata_1.dat';
  602. $check_filename = date('Ymd').'_'.config('data_cp_id').'_videosdata_1.chk';
  603. error_log(print_r($content, 1) . PHP_EOL, 3, './dashuju/' . $filename);
  604. error_log('', 3, './dashuju/' . $check_filename);
  605. if ($key == count($list) - 1) {
  606. $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_videosdata.finish';
  607. error_log('', 3, './dashuju/' . $finish_filename);
  608. }
  609. $hu_video->where(['id' => $param['id'], 'mediavideo_status' => 0])->setField('mediavideo_status', 1);
  610. }
  611. }
  612. //没用到
  613. //产品包
  614. public function product() {
  615. $content = [
  616. 'prod_code' => config('product_code'),
  617. 'prod_name' => '月包会员',
  618. 'prod_type' => 0,
  619. 'cpid' => config('data_cp_id')
  620. ];
  621. $content = join(json_decode('"\u0001"', true), $content);
  622. $filename = date('Ymd').'_'.config('data_cp_id').'_productsdata_1.dat';
  623. $check_filename = date('Ymd').'_'.config('data_cp_id').'_productsdata_1.chk';
  624. error_log(print_r($content, 1) . PHP_EOL, 3, './dashuju/' . $filename);
  625. error_log('', 3, './dashuju/' . $check_filename);
  626. $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_productsdata.finish';
  627. error_log('', 3, './dashuju/' . $finish_filename);
  628. //连接ftp
  629. $host = config('data_ftp_ip');
  630. $port = config('data_ftp_port');
  631. $username = config('data_ftp_user');
  632. $password = config('data_ftp_pwd');
  633. $conn = ftp_connect($host, $port) or die("Could not connect");
  634. //登录
  635. ftp_login($conn,$username,$password);
  636. //开启被动模式
  637. ftp_pasv($conn, true);
  638. //利用ftp创建目录
  639. /*$path = "home/2021-12-08";
  640. $this->make_directory($conn,$path);
  641. //利用ftp选择进入目录
  642. ftp_chdir($conn,$path);*/
  643. //开始上传 ftp_put(ftp链接,服务器地址,本地地址,上传模式);
  644. if(ftp_put($conn,$filename,'./dashuju/' . $filename,FTP_BINARY)){
  645. //上传成功
  646. }
  647. if(ftp_put($conn,$check_filename,'./dashuju/' . $check_filename,FTP_BINARY)){
  648. //上传成功
  649. }
  650. if(ftp_put($conn,$finish_filename,'./dashuju/' . $finish_filename,FTP_BINARY)){
  651. //上传成功
  652. }
  653. ftp_close($conn);
  654. //注意上传端的ftp权限设置
  655. echo 'wanbi';
  656. }
  657. //产品包和媒资所属关系
  658. public function productmediarelation() {
  659. $hu_video = Db::name('video');
  660. $list = $hu_video->where(['inject_status' => 2, 'productmedia_status' => 0])->order('id')->select();
  661. if (!$list) {
  662. echo 'mei shu ju';
  663. die;
  664. }
  665. foreach ($list as $key => &$param) {
  666. $content = [
  667. 'Updatetype' => 1,
  668. 'prod_code' => config('product_code'),
  669. 'cpid' => config('data_cp_id'),
  670. 'albumid' => $param['id']
  671. ];
  672. $content = join(json_decode('"\u0001"', true), $content);
  673. $filename = date('Ymd').'_'.config('data_cp_id').'_productalbumdata_1.dat';
  674. $check_filename = date('Ymd').'_'.config('data_cp_id').'_productalbumdata_1.chk';
  675. error_log(print_r($content, 1) . PHP_EOL, 3, './dashuju/' . $filename);
  676. error_log('', 3, './dashuju/' . $check_filename);
  677. if ($key == count($list) - 1) {
  678. $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_productalbumdata.finish';
  679. error_log('', 3, './dashuju/' . $finish_filename);
  680. }
  681. $hu_video->where(['id' => $param['id'], 'productmedia_status' => 0])->setField('productmedia_status', 1);
  682. }
  683. }
  684. //用户观看行为数据文件上传到卓望ftp(每小时第10分钟提供)
  685. public function uploadpayftp() {
  686. set_time_limit(0);
  687. $host = config('pay_ftp_ip');
  688. $port = config('pay_ftp_port');
  689. $username = config('pay_ftp_user');
  690. $password = config('pay_ftp_pwd');
  691. $filename = date('YmdH', time() - 3600).'_'.config('cp_id').'_ottuserviewdata_1.dat';
  692. $check_filename = date('YmdH', time() - 3600).'_'.config('cp_id').'_ottuserviewdata_1.chk';
  693. //判断文件是否存在, 不存在则创建
  694. if (!file_exists('./dashuju/' . $filename)) {
  695. @touch('./dashuju/' . $filename);
  696. }
  697. if (!file_exists('./dashuju/' . $check_filename)) {
  698. @touch('./dashuju/' . $check_filename);
  699. }
  700. //连接ftp
  701. $conn = ftp_connect($host, $port) or die("Could not connect");
  702. //登录
  703. ftp_login($conn,$username,$password);
  704. //开启被动模式
  705. ftp_pasv($conn, true);
  706. //利用ftp创建目录
  707. /*$path = "home/2021-12-08";
  708. $this->make_directory($conn,$path);
  709. //利用ftp选择进入目录
  710. ftp_chdir($conn,$path);*/
  711. //开始上传 ftp_put(ftp链接,服务器地址,本地地址,上传模式);
  712. if(ftp_put($conn,$filename,'./dashuju/' . $filename,FTP_BINARY)){
  713. //上传成功
  714. }
  715. if(ftp_put($conn,$check_filename,'./dashuju/' . $check_filename,FTP_BINARY)){
  716. //上传成功
  717. }
  718. ftp_close($conn);
  719. //注意上传端的ftp权限设置
  720. echo 'wanbi';
  721. }
  722. //没用到
  723. //大数据文件上传到大数据ftp(每天一点提供)
  724. public function uploaddataftp() {
  725. set_time_limit(0);
  726. $host = config('data_ftp_ip');
  727. $port = config('data_ftp_port');
  728. $username = config('data_ftp_user');
  729. $password = config('data_ftp_pwd');
  730. $time = date('Ymd', time() - 86400);
  731. // 专辑粒度媒资
  732. $albumsdata_filename = $time.'_'.config('data_cp_id').'_albumsdata_1.dat';
  733. $albumsdata_check_filename = $time.'_'.config('data_cp_id').'_albumsdata_1.chk';
  734. $albumsdata_finish_filename = $time.'_'.config('data_cp_id').'_albumsdata_1.finish';
  735. // 节目/内容粒度媒资
  736. $videosdata_filename = $time.'_'.config('data_cp_id').'_videosdata_1.dat';
  737. $videosdata_check_filename = $time.'_'.config('data_cp_id').'_videosdata_1.chk';
  738. $videosdata_finish_filename = $time.'_'.config('data_cp_id').'_videosdata_1.finish';
  739. // 产品包和媒资所属关系
  740. $productalbumdata_filename = $time.'_'.config('data_cp_id').'_productalbumdata_1.dat';
  741. $productalbumdata_check_filename = $time.'_'.config('data_cp_id').'_productalbumdata_1.chk';
  742. $productalbumdata_finish_filename = $time.'_'.config('data_cp_id').'_productalbumdata_1.finish';
  743. // 用户增值产品包当前订购快照
  744. $userefforderdata_filename = $time.'_'.config('data_cp_id').'_userefforderdata_1.dat';
  745. $userefforderdata_check_filename = $time.'_'.config('data_cp_id').'_userefforderdata_1.chk';
  746. $userefforderdata_finish_filename = $time.'_'.config('data_cp_id').'_userefforderdata_1.finish';
  747. // 用户增值产品包订购行为
  748. $userorderdata_filename = $time.'_'.config('data_cp_id').'_userorderdata_1.dat';
  749. $userorderdata_check_filename = $time.'_'.config('data_cp_id').'_userorderdata_1.chk';
  750. $userorderdata_finish_filename = $time.'_'.config('data_cp_id').'_userorderdata_1.finish';
  751. // 用户观看行为
  752. $userplaydata_filename = $time.'_'.config('data_cp_id').'_userplaydata_1.dat';
  753. $userplaydata_check_filename = $time.'_'.config('data_cp_id').'_userplaydata_1.chk';
  754. $userplaydata_finish_filename = $time.'_'.config('data_cp_id').'_userplaydata_1.finish';
  755. // 用户收藏行为
  756. $userfavdata_filename = $time.'_'.config('data_cp_id').'_userfavdata_1.dat';
  757. $userfavdata_check_filename = $time.'_'.config('data_cp_id').'_userfavdata_1.chk';
  758. $userfavdata_finish_filename = $time.'_'.config('data_cp_id').'_userfavdata_1.finish';
  759. //判断文件是否存在, 不存在则创建
  760. if (!file_exists('./dashuju/' . $albumsdata_filename)) {
  761. @touch('./dashuju/' . $albumsdata_filename);
  762. }
  763. if (!file_exists('./dashuju/' . $albumsdata_check_filename)) {
  764. @touch('./dashuju/' . $albumsdata_check_filename);
  765. }
  766. if (!file_exists('./dashuju/' . $albumsdata_finish_filename)) {
  767. @touch('./dashuju/' . $albumsdata_finish_filename);
  768. }
  769. if (!file_exists('./dashuju/' . $videosdata_filename)) {
  770. @touch('./dashuju/' . $videosdata_filename);
  771. }
  772. if (!file_exists('./dashuju/' . $videosdata_check_filename)) {
  773. @touch('./dashuju/' . $videosdata_check_filename);
  774. }
  775. if (!file_exists('./dashuju/' . $videosdata_finish_filename)) {
  776. @touch('./dashuju/' . $videosdata_finish_filename);
  777. }
  778. if (!file_exists('./dashuju/' . $productalbumdata_filename)) {
  779. @touch('./dashuju/' . $productalbumdata_filename);
  780. }
  781. if (!file_exists('./dashuju/' . $productalbumdata_check_filename)) {
  782. @touch('./dashuju/' . $productalbumdata_check_filename);
  783. }
  784. if (!file_exists('./dashuju/' . $productalbumdata_finish_filename)) {
  785. @touch('./dashuju/' . $productalbumdata_finish_filename);
  786. }
  787. if (!file_exists('./dashuju/' . $userefforderdata_filename)) {
  788. @touch('./dashuju/' . $userefforderdata_filename);
  789. }
  790. if (!file_exists('./dashuju/' . $userefforderdata_check_filename)) {
  791. @touch('./dashuju/' . $userefforderdata_check_filename);
  792. }
  793. if (!file_exists('./dashuju/' . $userefforderdata_finish_filename)) {
  794. @touch('./dashuju/' . $userefforderdata_finish_filename);
  795. }
  796. if (!file_exists('./dashuju/' . $userorderdata_filename)) {
  797. @touch('./dashuju/' . $userorderdata_filename);
  798. }
  799. if (!file_exists('./dashuju/' . $userorderdata_check_filename)) {
  800. @touch('./dashuju/' . $userorderdata_check_filename);
  801. }
  802. if (!file_exists('./dashuju/' . $userorderdata_finish_filename)) {
  803. @touch('./dashuju/' . $userorderdata_finish_filename);
  804. }
  805. if (!file_exists('./dashuju/' . $userplaydata_filename)) {
  806. @touch('./dashuju/' . $userplaydata_filename);
  807. }
  808. if (!file_exists('./dashuju/' . $userplaydata_check_filename)) {
  809. @touch('./dashuju/' . $userplaydata_check_filename);
  810. }
  811. if (!file_exists('./dashuju/' . $userplaydata_finish_filename)) {
  812. @touch('./dashuju/' . $userplaydata_finish_filename);
  813. }
  814. if (!file_exists('./dashuju/' . $userfavdata_filename)) {
  815. @touch('./dashuju/' . $userfavdata_filename);
  816. }
  817. if (!file_exists('./dashuju/' . $userfavdata_check_filename)) {
  818. @touch('./dashuju/' . $userfavdata_check_filename);
  819. }
  820. if (!file_exists('./dashuju/' . $userfavdata_finish_filename)) {
  821. @touch('./dashuju/' . $userfavdata_finish_filename);
  822. }
  823. //连接ftp
  824. $conn = ftp_connect($host, $port) or die("Could not connect");
  825. //登录
  826. ftp_login($conn,$username,$password);
  827. //开启被动模式
  828. ftp_pasv($conn, true);
  829. //利用ftp创建目录
  830. /*$path = "home/2021-12-08";
  831. $this->make_directory($conn,$path);
  832. //利用ftp选择进入目录
  833. ftp_chdir($conn,$path);*/
  834. //开始上传 ftp_put(ftp链接,服务器地址,本地地址,上传模式);
  835. if(ftp_put($conn,$albumsdata_filename,'./dashuju/' . $albumsdata_filename,FTP_BINARY)){
  836. //上传成功
  837. }
  838. if(ftp_put($conn,$albumsdata_check_filename,'./dashuju/' . $albumsdata_check_filename,FTP_BINARY)){
  839. //上传成功
  840. }
  841. if(ftp_put($conn,$albumsdata_finish_filename,'./dashuju/' . $albumsdata_finish_filename,FTP_BINARY)){
  842. //上传成功
  843. }
  844. if(ftp_put($conn,$videosdata_filename,'./dashuju/' . $videosdata_filename,FTP_BINARY)){
  845. //上传成功
  846. }
  847. if(ftp_put($conn,$videosdata_check_filename,'./dashuju/' . $videosdata_check_filename,FTP_BINARY)){
  848. //上传成功
  849. }
  850. if(ftp_put($conn,$videosdata_finish_filename,'./dashuju/' . $videosdata_finish_filename,FTP_BINARY)){
  851. //上传成功
  852. }
  853. if(ftp_put($conn,$productalbumdata_filename,'./dashuju/' . $productalbumdata_filename,FTP_BINARY)){
  854. //上传成功
  855. }
  856. if(ftp_put($conn,$productalbumdata_check_filename,'./dashuju/' . $productalbumdata_check_filename,FTP_BINARY)){
  857. //上传成功
  858. }
  859. if(ftp_put($conn,$productalbumdata_finish_filename,'./dashuju/' . $productalbumdata_finish_filename,FTP_BINARY)){
  860. //上传成功
  861. }
  862. if(ftp_put($conn,$userefforderdata_filename,'./dashuju/' . $userefforderdata_filename,FTP_BINARY)){
  863. //上传成功
  864. }
  865. if(ftp_put($conn,$userefforderdata_check_filename,'./dashuju/' . $userefforderdata_check_filename,FTP_BINARY)){
  866. //上传成功
  867. }
  868. if(ftp_put($conn,$userefforderdata_finish_filename,'./dashuju/' . $userefforderdata_finish_filename,FTP_BINARY)){
  869. //上传成功
  870. }
  871. if(ftp_put($conn,$userorderdata_filename,'./dashuju/' . $userorderdata_filename,FTP_BINARY)){
  872. //上传成功
  873. }
  874. if(ftp_put($conn,$userorderdata_check_filename,'./dashuju/' . $userorderdata_check_filename,FTP_BINARY)){
  875. //上传成功
  876. }
  877. if(ftp_put($conn,$userorderdata_finish_filename,'./dashuju/' . $userorderdata_finish_filename,FTP_BINARY)){
  878. //上传成功
  879. }
  880. if(ftp_put($conn,$userplaydata_filename,'./dashuju/' . $userplaydata_filename,FTP_BINARY)){
  881. //上传成功
  882. }
  883. if(ftp_put($conn,$userplaydata_check_filename,'./dashuju/' . $userplaydata_check_filename,FTP_BINARY)){
  884. //上传成功
  885. }
  886. if(ftp_put($conn,$userplaydata_finish_filename,'./dashuju/' . $userplaydata_finish_filename,FTP_BINARY)){
  887. //上传成功
  888. }
  889. if(ftp_put($conn,$userfavdata_filename,'./dashuju/' . $userfavdata_filename,FTP_BINARY)){
  890. //上传成功
  891. }
  892. if(ftp_put($conn,$userfavdata_check_filename,'./dashuju/' . $userfavdata_check_filename,FTP_BINARY)){
  893. //上传成功
  894. }
  895. if(ftp_put($conn,$userfavdata_finish_filename,'./dashuju/' . $userfavdata_finish_filename,FTP_BINARY)){
  896. //上传成功
  897. }
  898. ftp_close($conn);
  899. //注意上传端的ftp权限设置
  900. echo 'wanbi';
  901. }
  902. public function make_directory($ftp_stream, $dir){
  903. // if directory already exists or can be immediately created return true
  904. if ($this->ftp_is_dir($ftp_stream, $dir) || @ftp_mkdir($ftp_stream, $dir)) return true;
  905. // otherwise recursively try to make the directory
  906. if (!$this->make_directory($ftp_stream, dirname($dir))) return false;
  907. // final step to create the directory
  908. return ftp_mkdir($ftp_stream, $dir);
  909. }
  910. public function ftp_is_dir($ftp_stream, $dir){
  911. // get current directory
  912. $original_directory = ftp_pwd($ftp_stream);
  913. // test if you can change directory to $dir
  914. // suppress errors in case $dir is not a file or not a directory
  915. if ( @ftp_chdir( $ftp_stream, $dir ) ) {
  916. // If it is a directory, then change the directory back to the original directory
  917. ftp_chdir( $ftp_stream, $original_directory );
  918. return true;
  919. } else {
  920. return false;
  921. }
  922. }
  923. }