Journal_v1.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854
  1. <?php
  2. # 电子刊基本信息接口 本类下所有接口,均生成缓存
  3. namespace Main\Src;
  4. use Dever;
  5. use Main\Lib\Core;
  6. class Journal_v1 extends Core
  7. {
  8. public function getCate()
  9. {
  10. $id = Dever::input('system', 1);
  11. $cate = array();
  12. if ($id > 0) {
  13. $cate = Dever::db('journal/cate')->one($id);
  14. $this->data['cate'] = $cate;
  15. }
  16. return $cate;
  17. }
  18. # 根据分类获取小刊列表
  19. public function getList()
  20. {
  21. if ($this->app) {
  22. return $this->getAppList();
  23. }
  24. $data = array();
  25. if ($data) {
  26. return $data;
  27. }
  28. $cate = $this->getCate();
  29. # 小刊列表
  30. $where = array();
  31. if (isset($cate['id'])) {
  32. $where['cate_id'] = $cate['id'];
  33. }
  34. $where['publish'] = 1;
  35. $this->data['button'] = array();
  36. # 热门电子刊
  37. $this->data['push'] = Dever::db('journal/info')->getHot($where);
  38. if ($this->data['push']) {
  39. foreach ($this->data['push'] as $k => $v) {
  40. $this->data['push'][$k] = $this->info($v);
  41. $this->data['push'][$k] = $this->getButton($this->data['push'][$k]);
  42. }
  43. $this->data['push'] = $this->data['push'][0];
  44. }
  45. $data = Dever::db('journal/info')->getAllByPage($where);
  46. if ($data) {
  47. foreach ($data as $k => $v) {
  48. $data[$k] = $this->info($v);
  49. $data[$k] = $this->getButton($data[$k]);
  50. }
  51. $this->data['journal'] = $data;
  52. } else {
  53. $this->data['journal'] = array();
  54. }
  55. $this->data['end']['call'] = 'main/journal_v1.getList_noCache';
  56. $this->data['code'] = 1;
  57. if (checkVersion()->journal_buy == 2) {
  58. $this->data['code'] = 2;
  59. }
  60. return $this->data;
  61. }
  62. public function getList_noCache($data)
  63. {
  64. if ($data['push'] && isset($data['push'][0])) {
  65. foreach ($data['push'] as $k => $v) {
  66. $num_ding = Dever::load('act/lib/num')->getCounter($v['id']);
  67. if ($num_ding && $num_ding >= $v['num_ding']) {
  68. $data['push'][$k]['num_ding'] = $num_ding;
  69. $data['push'][$k] = $this->ding($data['push'][$k]);
  70. }
  71. }
  72. }
  73. if ($data['journal']) {
  74. foreach ($data['journal'] as $k => $v) {
  75. if ($v['hot'] == 1) {
  76. $num_ding = Dever::load('act/lib/num')->getCounter($v['id']);
  77. if ($num_ding && $num_ding >= $v['num_ding']) {
  78. $data['journal'][$k]['num_ding'] = $num_ding;
  79. $data['journal'][$k] = $this->ding($data['journal'][$k]);
  80. }
  81. }
  82. }
  83. }
  84. return $data;
  85. }
  86. public function getList_noCache_old($data)
  87. {
  88. if ($data['push'] && $data['push']['hot'] == 1) {
  89. $num_ding = Dever::load('act/lib/num')->getCounter($data['push']['id']);
  90. if ($num_ding && $num_ding >= $data['push']['num_ding']) {
  91. $data['push']['num_ding'] = $num_ding;
  92. $data['push'] = $this->ding($data['push']);
  93. }
  94. }
  95. if ($data['journal']) {
  96. foreach ($data['journal'] as $k => $v) {
  97. if ($v['hot'] == 1) {
  98. $num_ding = Dever::load('act/lib/num')->getCounter($v['id']);
  99. if ($num_ding && $num_ding >= $v['num_ding']) {
  100. $data['journal'][$k]['num_ding'] = $num_ding;
  101. $data['journal'][$k] = $this->ding($data['journal'][$k]);
  102. }
  103. }
  104. }
  105. }
  106. return $data;
  107. }
  108. # 根据分类获取小刊列表 app
  109. public function getAppList()
  110. {
  111. $data = array();
  112. if ($data) {
  113. return $data;
  114. }
  115. $cate = $this->getCate();
  116. # 小刊列表
  117. $where = array();
  118. if (isset($cate['id'])) {
  119. $where['cate_id'] = $cate['id'];
  120. }
  121. $cateList = Dever::db('journal/cate')->getAll();
  122. $this->data['cateList'] = $cateList;
  123. $time = time();
  124. $day = (7 * 86400);
  125. $where['cate_id_1'] = 1;
  126. $where['time'] = $time - $day;
  127. $where['publish'] = 2;
  128. # 获取最新的小刊
  129. $this->data['push'] = Dever::db('journal/info')->getNew($where);
  130. $this->data['push'] = $this->ding($this->data['push']);
  131. $this->data['button'] = array();
  132. ////$this->data['push'] = $this->getButton($this->data['push']);
  133. ////$this->data['push'] = $this->getAppSet($this->data['push']);
  134. # 热门电子刊
  135. /*
  136. $this->data['push'] = Dever::db('journal/info')->getHot($where);
  137. if ($this->data['push']) {
  138. foreach ($this->data['push'] as $k => $v) {
  139. $this->data['push'][$k] = $this->info($v);
  140. $this->data['push'][$k] = $this->getButton($this->data['push'][$k]);
  141. }
  142. }
  143. */
  144. $data = Dever::db('journal/info')->getAllByPage($where);
  145. if ($data) {
  146. foreach ($data as $k => $v) {
  147. $data[$k] = $this->info($v);
  148. //$data[$k] = $this->getButton($data[$k]);
  149. //$data[$k] = $this->getAppSet($data[$k]);
  150. }
  151. $this->data['journal'] = $data;
  152. } else {
  153. $this->data['journal'] = array();
  154. }
  155. return $this->data;
  156. }
  157. public function ding($data)
  158. {
  159. $data = Dever::load('journal/api')->ding($data);
  160. return $data;
  161. }
  162. # 获取详细信息
  163. private function info($data, $subscribe = true)
  164. {
  165. if ($data['pdate'] > 0) {
  166. $data['pdate_time'] = date('Y-m-d H:i:s', $data['pdate']);
  167. }
  168. # 已开始
  169. $data['ytype'] = 1;
  170. if (isset($data['pdate']) && $data['pdate'] > 0) {
  171. if ($data['pdate'] >= time()) {
  172. # 未到时间
  173. $data['ytype'] = 2;
  174. }
  175. $data['ydate_time'] = date('Y-m-d H:i:s', $data['pdate']);
  176. }
  177. $data = $this->ding($data);
  178. if ($data['pic_view_bg']) {
  179. $data['pic_view_bg'] = explode(',', $data['pic_view_bg']);
  180. } else {
  181. $data['pic_view_bg'] = array();
  182. }
  183. $data['buy'] = intval($data['buy']);
  184. return $data;
  185. }
  186. # 小刊查看详情 即将废弃
  187. public function view()
  188. {
  189. $id = $this->check();
  190. $this->data['info'] = $this->info($this->data['info'], false);
  191. $this->button($this->data['info']);
  192. return $this->data;
  193. }
  194. # 按钮设置 即将废弃
  195. private function button($info)
  196. {
  197. $this->data['button'] = array();
  198. $this->setButton();
  199. $uid = $this->data['uid'];
  200. # 查看是否订阅
  201. $subscribe = 2;
  202. if ($uid) {
  203. $subscribe = Dever::load('act/lib/subscribe')->get($info['id'], $uid, 4);
  204. }
  205. $this->data['info']['subscribe'] = 2;
  206. # 查看是否有排行榜
  207. $this->data['info']['active'] = $info['top'];
  208. # 查看是否有活动
  209. /*
  210. $active = Dever::db('journal/active')->one(array('id' => $info['id']));
  211. $this->data['info']['active'] = 2;
  212. if ($active && $active['status'] == 1) {
  213. $this->data['info']['active'] = 1;
  214. }
  215. $time = time();
  216. if ($active && $time >= $active['start'] && $time < $active['end']) {
  217. $this->data['info']['active'] = 1;
  218. }
  219. */
  220. if ($this->data['info']['active'] == 1) {
  221. $this->setButton('share', 1);
  222. } else {
  223. $this->setButton('share', -1);
  224. }
  225. if ($info['buy'] == 2) {
  226. # 免费的
  227. $this->setButton('read', 1);
  228. $this->setButton('buy', -1);
  229. $this->setButton('share', -1);
  230. } elseif ($subscribe == 1) {
  231. $this->data['info']['subscribe'] = 1;
  232. # 已订阅
  233. if ($info['ytype'] == 2) {
  234. # 预售
  235. $this->setButton('read', 3);
  236. } else {
  237. # 需要购买
  238. $this->setButton('read', 1);
  239. }
  240. $this->setButton('buy', 1);
  241. if (checkVersion()->journal_buy == 2) {
  242. $this->setButton('share', -1);
  243. }
  244. } else {
  245. if ($info['ytype'] == 2) {
  246. # 预售
  247. $this->setButton('read', 3);
  248. } else {
  249. # 需要购买
  250. $this->setButton('read', 2);
  251. }
  252. $this->setButton('buy', 1);
  253. if (checkVersion()->journal_buy == 2) {
  254. $this->setButton('buy', -1);
  255. $this->setButton('share', -1);
  256. }
  257. }
  258. # 仅app有效
  259. if ($this->app) {
  260. # 分享相关
  261. if (isset($this->data['info']['share_content'])) {
  262. $source = Dever::db('source/info')->one(1);
  263. $this->data['info']['share_link'] = $source['code'];
  264. }
  265. # 会员状态
  266. $this->data['info']['vip_state'] = 1;
  267. $this->data['info']['code_state'] = 1;
  268. $version_code = Dever::input('version_code');
  269. if ($version_code) {
  270. $source_type = Dever::input('source_type');
  271. $version_where['source_type'] = $source_type;
  272. $version_where['name'] = $version_code;
  273. $version = Dever::db('main/version')->getOne($version_where);
  274. if ($version && $version['vip'] > 0) {
  275. $this->data['info']['vip_state'] = $version['vip'];
  276. $this->data['info']['code_state'] = $version['button'];
  277. if ($this->source_type == 'ios' && $this->data['info']['code_state'] == 2) {
  278. $this->setButton('read', 1);
  279. }
  280. }
  281. }
  282. # 会员随便看
  283. if ($uid > 0) {
  284. $this->data['info']['vip'] = 2;
  285. $vip = Dever::load('vip/lib/member')->get($uid, $info['cate_id']);
  286. if ($vip > 0) {
  287. $this->data['info']['subscribe'] = 1;
  288. $this->data['info']['vip'] = 1;
  289. $this->setButton('read', 1);
  290. }
  291. # 是否在外站订阅过
  292. $user = Dever::db('passport/user')->one($uid);
  293. if ($user && $user['mobile']) {
  294. $mobileWhere['mobile'] = $user['mobile'];
  295. $mobileWhere['product_id'] = $info['id'];
  296. $mobile = Dever::db('journal/mobile')->one($mobileWhere);
  297. if ($mobile) {
  298. $this->data['info']['subscribe'] = 1;
  299. $this->setButton('read', 1);
  300. }
  301. }
  302. }
  303. if ($this->source_type == 'ios' && $this->data['info']['id'] == 26) {
  304. $this->setButton('share', -1);
  305. }
  306. } else {
  307. # 小程序下的判断,ios里关闭支付
  308. $applet_type = Dever::input('applet_type');
  309. if ($applet_type == 2 && isset($this->data['config']['ios_pay']) && $this->data['config']['ios_pay'] == 1 && $info['buy'] == 1) {
  310. $this->setButton('buy', -1);
  311. //$this->setButton('share', -1);
  312. }
  313. }
  314. }
  315. private function setButton($key = false, $status = false, $name = false)
  316. {
  317. # 按钮状态,-1为不显示
  318. if (!$this->data['button']) {
  319. $this->data['button'] = array
  320. (
  321. # 第一个按钮 1为阅读、2为兑换、3为预售
  322. 'read' => array('status' => -1, 'name' => '阅读'),
  323. # 第二个按钮
  324. 'buy' => array('status' => -1, 'name' => '订阅'),
  325. # 第三个按钮
  326. 'share' => array('status' => 1, 'name' => '订阅排行榜'),
  327. );
  328. if ($key == -1) {
  329. unset($this->data['button']['buy']);
  330. }
  331. }
  332. if ($key && isset($this->data['button'][$key])) {
  333. if ($status) {
  334. $this->data['button'][$key]['status'] = $status;
  335. }
  336. if ($name) {
  337. $this->data['button'][$key]['name'] = $name;
  338. }
  339. }
  340. }
  341. # 验证小刊是否可以阅读
  342. public function subscribe()
  343. {
  344. $subscribe = 2;
  345. $id = Dever::input('id');
  346. $id = $this->check();
  347. $this->data['info'] = $this->info($this->data['info'], false);
  348. if ($this->data['info']['ytype'] == 2) {
  349. $subscribe = 3;
  350. } elseif ($this->data['uid'] > 0) {
  351. $cache = false;
  352. if ($this->data['info']['hot'] == 1) {
  353. $cache = false;
  354. }
  355. $subscribe = Dever::load('act/lib/subscribe')->get($id, $this->data['uid'], 4, $cache);
  356. }
  357. return array('subscribe' => $subscribe);
  358. }
  359. # 小刊查看详情
  360. public function getView()
  361. {
  362. $this->check();
  363. $this->data['button'] = array();
  364. $this->data['info'] = $this->getButton($this->info($this->data['info'], false));
  365. return $this->data;
  366. }
  367. # 按钮设置
  368. private function getButton($info)
  369. {
  370. //$info['subscribe'] = 2;
  371. # 查看是否有排行榜
  372. $info['active'] = $info['top'];
  373. if ($info['active'] == 1) {
  374. $this->setButton('share', 1);
  375. } else {
  376. $this->setButton('share', -1);
  377. }
  378. if ($info['buy'] == 2) {
  379. # 免费的
  380. $this->setButton('read', 1);
  381. $this->setButton('buy', -1);
  382. $this->setButton('share', -1);
  383. } else {
  384. if ($info['ytype'] == 2) {
  385. # 预售
  386. $this->setButton('read', 3);
  387. } else {
  388. # 需要购买 这里需要调用info_check接口了
  389. $this->setButton('read', 2);
  390. }
  391. $this->setButton('buy', 1);
  392. /*
  393. if (checkVersion()->journal_buy == 2) {
  394. $this->setButton('buy', -1);
  395. $this->setButton('share', -1);
  396. }
  397. */
  398. }
  399. # 小程序下的判断,ios里关闭支付
  400. $applet_type = Dever::input('applet_type');
  401. if ($applet_type == 2 && isset($this->data['config']['ios_pay']) && $this->data['config']['ios_pay'] == 1 && $info['buy'] == 1) {
  402. $this->setButton('buy', -1);
  403. //$this->setButton('share', -1);
  404. }
  405. $info['button'] = $this->data['button'];
  406. return $info;
  407. }
  408. # 小刊查看详情 app下查看,仅仅为了区分缓存
  409. public function getAppView()
  410. {
  411. $this->info();
  412. $this->data['info'] = $this->getAppSet($this->data['info']);
  413. return $this->data;
  414. }
  415. private function getAppSet($info)
  416. {
  417. # 分享相关
  418. if (isset($info['share_content'])) {
  419. $source = Dever::db('source/info')->one(1);
  420. $info['share_link'] = $source['code'];
  421. }
  422. # 会员状态
  423. $info['vip_state'] = 1;
  424. $info['code_state'] = 1;
  425. $version_code = Dever::input('version_code');
  426. if ($version_code) {
  427. $source_type = Dever::input('source_type');
  428. $version_where['source_type'] = $source_type;
  429. $version_where['name'] = $version_code;
  430. $version = Dever::db('main/version')->getOne($version_where);
  431. if ($version && $version['vip'] > 0) {
  432. $info['vip_state'] = $version['vip'];
  433. $info['code_state'] = $version['button'];
  434. if ($this->source_type == 'ios' && $info['code_state'] == 2) {
  435. $this->setButton('read', 1);
  436. }
  437. }
  438. }
  439. # 会员随便看
  440. if ($this->data['uid'] > 0) {
  441. $info['vip'] = 2;
  442. $vip = Dever::load('vip/lib/member')->get($this->data['uid'], $info['cate_id']);
  443. if ($vip > 0) {
  444. $info['subscribe'] = 1;
  445. $info['vip'] = 1;
  446. $this->setButton('read', 1);
  447. }
  448. # 是否在外站订阅过 防止缓存失效,这里先注释
  449. /*
  450. $user = Dever::db('passport/user')->one($this->data['uid']);
  451. if ($user && $user['mobile']) {
  452. $mobileWhere['mobile'] = $user['mobile'];
  453. $mobileWhere['product_id'] = $info['id'];
  454. $mobile = Dever::db('journal/mobile')->one($mobileWhere);
  455. if ($mobile) {
  456. $info['subscribe'] = 1;
  457. $this->setButton('read', 1);
  458. }
  459. }
  460. */
  461. }
  462. if ($this->source_type == 'ios' && $info['id'] == 26) {
  463. $this->setButton('share', -1);
  464. }
  465. $info['button'] = $this->data['button'];
  466. return $info;
  467. }
  468. # 购买阅读页
  469. public function buy()
  470. {
  471. if (!$this->data['uid']) {
  472. Dever::alert('错误的用户信息');
  473. }
  474. $id = $this->check();
  475. $this->data['buy_desc'] = $this->data['info']['buy_content'];
  476. # 获取购买说明
  477. $buy = Dever::db('journal/buy')->one(array('id' => $id));
  478. if ($buy && $buy['buy_content']) {
  479. $this->data['buy_desc'] = $buy['buy_content'];
  480. }
  481. $this->data['buy_applet_notice'] = '在此购买单本可直接阅读电子刊,购买多本,直接累计积分,不会生成兑换码。';
  482. if ($buy && isset($buy['buy_applet_notice']) && $buy['buy_applet_notice']) {
  483. $this->data['buy_applet_notice'] = $buy['buy_applet_notice'];
  484. }
  485. if ($this->data['info']['buy'] == 2) {
  486. $this->data['buy_list'] = array();
  487. return $this->data;
  488. }
  489. # 获取购买列表
  490. $this->data['buy_list'] = Dever::db('journal/buy_num')->getAll(array('info_id' => $id));
  491. if ($this->data['info']['cash'] <= 0) {
  492. $this->data['info']['cash'] = 100000;
  493. }
  494. if ($this->data['buy_list']) {
  495. foreach ($this->data['buy_list'] as $k => $v) {
  496. if (!$v['name']) {
  497. $this->data['buy_list'][$k]['name'] = '购买' . $v['num'] . '本';
  498. }
  499. $price = $v['num'] * $this->data['info']['cash'];
  500. if (!$v['price']) {
  501. $this->data['buy_list'][$k]['price'] = $price;
  502. }
  503. $this->data['buy_list'][$k]['cash'] = $price;
  504. }
  505. }
  506. return $this->data;
  507. }
  508. # 明星列表页
  509. public function star()
  510. {
  511. if (!$this->data['uid']) {
  512. Dever::alert('错误的用户信息');
  513. }
  514. $id = $this->check();
  515. $this->data['star'] = Dever::db('journal/star')->getAll(array('info_id' => $id));
  516. if ($this->data['star']) {
  517. foreach ($this->data['star'] as $k => $v) {
  518. $this->data['star'][$k] = Dever::load('journal/api')->starDing($v);
  519. }
  520. }
  521. return $this->data;
  522. }
  523. # 修改为本数排行榜
  524. public function top()
  525. {
  526. $id = $this->check();
  527. $config_id = 31;
  528. if ($id > $config_id || $id == 26 || $id == 30) {
  529. $this->data['top'] = Dever::load('act/lib/num')->getList($id);
  530. } else {
  531. $this->data['score'] = Dever::load('act/lib/score')->getList($id);
  532. }
  533. # 获取活动说明
  534. $this->data['active'] = Dever::db('journal/active')->one(array('id' => $id));
  535. if (!$this->data['active']) {
  536. $this->data['active'] = (object) array();
  537. return $this->data;
  538. }
  539. /*
  540. $time = time();
  541. if ($this->data['active'] && $time >= $this->data['active']['start'] && $time < $this->data['active']['end']) {
  542. $this->data['active']['status'] = 1;
  543. } else {
  544. $this->data['active']['status'] = 2;
  545. }
  546. if ($time < $this->data['active']['start']) {
  547. $this->data['active']['status'] = 3;
  548. }
  549. */
  550. return $this->data;
  551. }
  552. # 小刊阅读页
  553. public function read()
  554. {
  555. if (!$this->data['uid']) {
  556. Dever::alert('错误的用户信息');
  557. }
  558. # 验证是否可以阅读
  559. $id = $this->check();
  560. $this->data['info'] = $this->info($this->data['info'], false);
  561. # 默认不能看 为1则可以直接看了,为2则不能看,要验证权限,为了高效并发,暂时去掉验证
  562. $subscribe = 1;
  563. $add_num = false;
  564. if ($subscribe == 2) {
  565. # APP专用
  566. if ($this->app) {
  567. # 会员随便看
  568. $vip = Dever::load('vip/lib/member')->get($this->data['uid'], $this->data['info']['cate_id']);
  569. if ($vip <= 0) {
  570. # 是否在外站订阅过
  571. $user = Dever::db('passport/user')->one($this->data['uid']);
  572. if ($user && $user['mobile']) {
  573. $mobileWhere['mobile'] = $user['mobile'];
  574. $mobileWhere['product_id'] = $id;
  575. $mobile = Dever::db('journal/mobile')->one($mobileWhere);
  576. if ($mobile) {
  577. $vip = 1;
  578. }
  579. }
  580. }
  581. if ($vip > 0) {
  582. $subscribe = 1;
  583. }
  584. }
  585. if ($subscribe == 2) {
  586. $subscribe = Dever::load('act/lib/subscribe')->get($id, $this->data['uid'], 4);
  587. }
  588. if ($this->data['info']['buy'] == 1 && $subscribe == 2) {
  589. Dever::alert('未订阅');
  590. }
  591. }
  592. if ($this->data['info']['buy'] == 2 && $this->data['info']['status'] == 2) {
  593. # 免费刊,增加订阅量
  594. $add_num = true;
  595. }
  596. # 获取最新10条内容
  597. $where = array();
  598. $where['info_id'] = $id;
  599. $data = Dever::db('journal/content')->getAll($where);
  600. if ($data) {
  601. foreach ($data as $k => $v) {
  602. $data[$k] = $this->readContent($v);
  603. }
  604. $this->data['content'] = $data;
  605. } else {
  606. $this->data['content'] = array();
  607. }
  608. $this->data['end']['id'] = $id;
  609. $this->data['end']['uid'] = $this->data['uid'];
  610. $this->data['end']['add_num'] = $add_num;
  611. return $this->data;
  612. }
  613. public function readContent($info)
  614. {
  615. $name = $info['name'];
  616. $focus = $info['focus'];
  617. $author_id = $info['author_id'];
  618. $content = $info['content'];
  619. unset($info['name']);
  620. unset($info['focus']);
  621. unset($info['author_id']);
  622. unset($info['content']);
  623. if (($info['type'] == 1 || $info['type'] == 7 || $info['type'] == 8) && $info['text']) {
  624. $info['text'] = Dever::array_decode($info['text']);
  625. if ($info['text']) {
  626. foreach ($info['text'] as $k => $v) {
  627. if (isset($info['text'][$k]['bgcolor_type']) && $info['text'][$k]['bgcolor_type'] == array(2)) {
  628. $info['text'][$k]['bgcolor'] = '';
  629. }
  630. }
  631. }
  632. } else {
  633. unset($info['text']);
  634. }
  635. if ($info['type'] == 10 && $info['palaces']) {
  636. $info['palaces'] = Dever::array_decode($info['palaces']);
  637. } else {
  638. unset($info['palaces']);
  639. }
  640. if ($info['type'] == 21 && $info['talk']) {
  641. $info['talk'] = Dever::array_decode($info['talk']);
  642. foreach ($info['talk'] as $k => $v) {
  643. $info['talk'][$k]['talk_type'] = implode(',', $v['talk_type']);
  644. $info['talk'][$k]['talk_location'] = implode(',', $v['talk_location']);
  645. }
  646. } else {
  647. unset($info['talk']);
  648. }
  649. if ($info['type'] == 3) {
  650. $info['info'] = array();
  651. $info['info']['name'] = $name;
  652. $info['info']['focus'] = $focus;
  653. $info['info']['author_id'] = $author_id;
  654. $info['info']['content'] = $content;
  655. $info['info'] = Dever::load('content/lib/article')->getContent($info['info'], $this->data['uid']);
  656. } elseif ($info['type'] == 4 || $info['type'] == 5) {
  657. $info['video'] = convert($info['video'], 'mp4', 'journal/content', $info['id'], 'video');
  658. if ($info['video']) {
  659. $info = Dever::load('video/lib/vod')->avinfo($info, 'video', 'journal/content');
  660. if ($info['type'] == 5) {
  661. $info['name'] = $name;
  662. }
  663. }
  664. } elseif ($info['type'] == 6) {
  665. $info['name'] = $name;
  666. //音频先不转码
  667. //$info['music'] = convert($info['music'], 'mp3', 'journal/content', $info['id'], 'music');
  668. } elseif ($info['type'] == 11) {
  669. $info['info'] = Dever::load('content/lib/article')->get($info['article_id']);
  670. } elseif ($info['type'] == 12) {
  671. $info['info'] = Dever::load('video/lib/vod')->get($info['vod_id']);
  672. } elseif ($info['type'] == 13) {
  673. $info['info'] = Dever::load('video/lib/live')->get($info['live_id']);
  674. if ($this->data['uid'] > 0) {
  675. $info['info']['note'] = Dever::load('act/lib/note')->get($this->data['uid'], $info['info']['id'], 3);
  676. } else {
  677. $info['info']['note'] = 2;
  678. }
  679. }
  680. if (isset($info['info']['author_id']) && $info['info']['author_id']) {
  681. $info['info']['author'] = Dever::db('content/author')->one($info['info']['author_id']);
  682. }
  683. if (isset($info['pic']) && $info['pic']) {
  684. $info['pic'] = str_replace('http://', 'https://', $info['pic']);
  685. }
  686. return $info;
  687. }
  688. private function check()
  689. {
  690. $id = Dever::input('id');
  691. if (!$id) {
  692. Dever::alert('小刊已下架');
  693. }
  694. $status = false;
  695. if (strstr($id, 'preview_')) {
  696. $id = str_replace('preview_', '', $id);
  697. $status = true;
  698. }
  699. $this->data['info'] = Dever::load('act/order')->getJournal($id);
  700. if (!$this->data['info']) {
  701. Dever::alert('小刊已下架');
  702. }
  703. if ($status) {
  704. $this->data['info']['status'] = '2';
  705. }
  706. return $id;
  707. }
  708. }