Cms.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. namespace app\api\controller;
  3. use app\admin\model\cms\Archives;
  4. use app\admin\model\cms\AuthorManuscript;
  5. use app\admin\model\cms\Channel;
  6. use app\admin\model\cms\Conference;
  7. use app\common\controller\Api;
  8. use app\common\library\Ems as Emslib;
  9. use app\common\model\User;
  10. use think\Hook;
  11. /**
  12. * cms系统
  13. */
  14. class Cms extends Api
  15. {
  16. protected $noNeedLogin = '*';
  17. protected $noNeedRight = '*';
  18. public function _initialize()
  19. {
  20. parent::_initialize();
  21. }
  22. /**
  23. * 获取期刊的录取率
  24. *
  25. * @return void
  26. * @throws \think\Exception
  27. */
  28. public function getChannelCycle()
  29. {
  30. $params = $this->request->param();
  31. if ($params['channel_id']) {
  32. // 获取当前期刊下所有手稿数量
  33. $manuscript_count = AuthorManuscript::where(['journal' => $params['channel_id']])->count();
  34. // 获取录用状态下的期刊数量
  35. $correct_manuscript_status = config('site.correct_manuscript_status');
  36. $correct_manuscript_count = 0;
  37. foreach ($correct_manuscript_status as $correct_status) {
  38. $correct_manuscript_count += AuthorManuscript::where(['journal' => $params['channel_id'], 'status' => $correct_status])->count();
  39. }
  40. }
  41. if ($correct_manuscript_count > 0) {
  42. $channel_rate = $correct_manuscript_count / $manuscript_count * 100;
  43. }
  44. $this->success('', round($channel_rate, 2) ?? 0);
  45. }
  46. public function getChannelDiyname()
  47. {
  48. $params = $this->request->param();
  49. if ($params['channel_id']) {
  50. $channel = Channel::where(['id' => $params['channel_id']])->find();
  51. }
  52. $this->success('', $channel);
  53. }
  54. /**
  55. * 根据时间获取对应会议列表
  56. *
  57. * @return void
  58. * @throws \think\db\exception\DataNotFoundException
  59. * @throws \think\db\exception\ModelNotFoundException
  60. * @throws \think\exception\DbException
  61. */
  62. public function getConference()
  63. {
  64. $params = $this->request->param();
  65. $year = $params['year'];
  66. $month = $params['month'];
  67. if (empty($year)) {
  68. $year = date('Y', time());
  69. }
  70. if (empty($month)) {
  71. $month = date('m', time());
  72. }
  73. $start_time = $year . '-' . $month;
  74. $end_time = date('Y-m-d', strtotime("$start_time +1 month -1 day"));
  75. $conferences = Conference::whereTime('createtime', 'between', [$start_time, $end_time])->select();
  76. $this->success('', $conferences);
  77. }
  78. /**
  79. * 获取对应期刊文章信息
  80. *
  81. * @return void
  82. */
  83. public function getArticle()
  84. {
  85. $channel_id = $this->request->get('channel_id');
  86. $archives = Archives::where(['p_channel_id' => $channel_id, 'channel_id' => 34])->order('weigh', 'DESC')->limit(4)->select();
  87. $this->success('', $archives);
  88. }
  89. }