diff --git a/application/api/controller/Article.php b/application/api/controller/Article.php index 0dfe39c..20bb4be 100644 --- a/application/api/controller/Article.php +++ b/application/api/controller/Article.php @@ -138,6 +138,7 @@ class Article extends Controller { ->join(array(['j_article', 'j_article_to_topic.article_id = j_article.article_id', 'LEFT'], ['j_journal_stage', 'j_article.journal_stage_id = j_journal_stage.journal_stage_id', 'LEFT'])) ->where('j_article_to_topic.topic_id', $data['topic_id']) ->where('j_article_to_topic.state', 0) + ->order('j_article.journal_stage_id desc , j_article.article_id desc') ->limit($limit_start,$data['pageSize']) ->select(); $count = $this->article_to_topic_obj diff --git a/application/api/controller/Journal.php b/application/api/controller/Journal.php index b3269ba..a900999 100644 --- a/application/api/controller/Journal.php +++ b/application/api/controller/Journal.php @@ -369,8 +369,9 @@ class Journal extends Controller { ->join('j_journal_stage', 'j_article.journal_stage_id = j_journal_stage.journal_stage_id', 'LEFT') ->where('j_article.journal_stage_id', 'in', $stages) ->where('j_article.state', 0) + ->where('j_journal_stage.stage_year','>','2018') ->where('j_article.type', ['like', 'News'], ['like', 'Comment'], 'or') - ->order('j_journal_stage.journal_stage_id desc') + ->order('j_journal_stage.stage_year desc,j_journal_stage.stage_vol desc,j_journal_stage.stage_no desc,j_article.article_id desc') ->select(); //获取作者 foreach ($list as $k => $v) { diff --git a/application/api/controller/Main.php b/application/api/controller/Main.php index 1f0bfd6..eb937b8 100644 --- a/application/api/controller/Main.php +++ b/application/api/controller/Main.php @@ -24,6 +24,7 @@ class Main extends Controller { protected $article_to_topic_obj = ''; protected $sys_scient_obj = ''; protected $sys_book_obj = ''; + protected $article_ltai_obj = ''; public function __construct(\think\Request $request = null) { parent::__construct($request); @@ -38,6 +39,7 @@ class Main extends Controller { $this->article_to_topic_obj = Db::name('article_to_topic'); $this->sys_scient_obj = Db::name('system_scient'); $this->sys_book_obj = Db::name('system_books'); + $this->article_ltai_obj = Db::name('article_ltai'); } /** @@ -107,6 +109,208 @@ class Main extends Controller { $re['book'] = $info; return jsonSuccess($re); } + + /** + * @title 获取首页文章列表 + * @description 获取首页文章列表 + * @author wangjinlei + * @url /api/Main/getMainArticles + * @method POST + * + * @return articles:文章信息array# + */ + public function getMainArticles(){ + $list_tmr = $this->article_obj->field('j_article.*,j_journal_stage.*,j_journal.title journal_title,j_journal.jabbr journal_short')->join(array(['j_journal_stage', 'j_article.journal_stage_id = j_journal_stage.journal_stage_id', 'LEFT'],['j_journal','j_article.journal_id = j_journal.journal_id','LEFT']))->where('j_article.journal_id',1)->where('j_journal_stage.is_publish',1)->where('j_article.state',0)->order('j_article.article_id desc')->limit(3)->select(); + $list_zh = $this->article_obj->field('j_article.*,j_journal_stage.*,j_journal.title journal_title,j_journal.jabbr journal_short')->join(array(['j_journal_stage', 'j_article.journal_stage_id = j_journal_stage.journal_stage_id', 'LEFT'],['j_journal','j_article.journal_id = j_journal.journal_id','LEFT']))->where('j_article.journal_id',17)->where('j_journal_stage.is_publish',1)->where('j_article.state',0)->order('j_article.article_id desc')->limit(1)->select(); + $list_life = $this->article_obj->field('j_article.*,j_journal_stage.*,j_journal.title journal_title,j_journal.jabbr journal_short')->join(array(['j_journal_stage', 'j_article.journal_stage_id = j_journal_stage.journal_stage_id', 'LEFT'],['j_journal','j_article.journal_id = j_journal.journal_id','LEFT']))->where('j_article.journal_id',14)->where('j_journal_stage.is_publish',1)->where('j_article.state',0)->order('j_article.article_id desc')->limit(1)->select(); + $list_fyw = $this->article_obj->field('j_article.*,j_journal_stage.*,j_journal.title journal_title,j_journal.jabbr journal_short')->join(array(['j_journal_stage', 'j_article.journal_stage_id = j_journal_stage.journal_stage_id', 'LEFT'],['j_journal','j_article.journal_id = j_journal.journal_id','LEFT']))->where('j_article.journal_id',20)->where('j_journal_stage.is_publish',1)->where('j_article.state',0)->order('j_article.article_id desc')->limit(1)->select(); + $list_ywlh = $this->article_obj->field('j_article.*,j_journal_stage.*,j_journal.title journal_title,j_journal.jabbr journal_short')->join(array(['j_journal_stage', 'j_article.journal_stage_id = j_journal_stage.journal_stage_id', 'LEFT'],['j_journal','j_article.journal_id = j_journal.journal_id','LEFT']))->where('j_article.journal_id',6)->where('j_journal_stage.is_publish',1)->where('j_article.state',0)->order('j_article.article_id desc')->limit(1)->select(); + $list_zy = $this->article_obj->field('j_article.*,j_journal_stage.*,j_journal.title journal_title,j_journal.jabbr journal_short')->join(array(['j_journal_stage', 'j_article.journal_stage_id = j_journal_stage.journal_stage_id', 'LEFT'],['j_journal','j_article.journal_id = j_journal.journal_id','LEFT']))->where('j_article.journal_id',18)->where('j_journal_stage.is_publish',1)->where('j_article.state',0)->order('j_article.article_id desc')->limit(1)->select(); + $list = $list_tmr; + $list[] = $list_zh[0]; + $list[] = $list_life[0]; + $list[] = $list_fyw[0]; + $list[] = $list_ywlh[0]; + $list[] = $list_zy[0]; + foreach ($list as $k => $v) { + $list[$k]['authortitle'] = $this->getAuthor($v); + } + $re['articles'] = $list; + return jsonSuccess($re); + } + + /** + * @title 获取文章more列表 + * @description 获取文章more列表 + * @author wangjinlei + * @url /api/Main/getMoreArticles + * @method POST + * + * @return articles:文章信息array# + */ + public function getMoreArticles(){ + $sql = "select a.* from (select MAX(article_id) aid from j_article WHERE state = 0 GROUP BY journal_id) c left join j_article a on a.article_id = c.aid"; + $list = Db::query($sql); + + //获取作者 + foreach ($list as $k => $v) { + $stage_info = $this->journal_stage_obj->where('journal_stage_id', $v['journal_stage_id'])->find(); + $journal_info = $this->journal_obj->where('journal_id', $v['journal_id'])->find(); + //组合cite信息 + $no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):'; + $cite = $v['abbr'] . '. ' . $v['title'] . '. ' . $journal_info['jabbr'] . '. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi']; + $list[$k]['cite'] = $cite; + $list[$k]['authortitle'] = $this->getAuthor($v); + $list[$k] = array_merge($list[$k],$stage_info); + $list[$k]['journal_title'] = $journal_info['title']; + $list[$k]['journal_short'] = $journal_info['jabbr']; + } + + //标题斜体 + foreach ($list as $k => $v) { + $caches = $this->article_ltai_obj->where('article_id', $v['article_id'])->where('state', 0)->column('content'); + $cache_title = $v['title']; + foreach ($caches as $val) { + $cache_title = str_replace($val, '' . $val . '', $cache_title); + } + $list[$k]['title'] = $cache_title; + } +// foreach ($list as $k => $v) { +// $list[$k]['authortitle'] = $this->getAuthor($v); +// } + $re['articles'] = $list; + return jsonSuccess($re); + } + + /** + * @title 获取onlinefirst文章列表 + * @description 获取onlinefirst文章列表 + * @author wangjinlei + * @url /api/Main/getOnlineFirstArticles + * @method POST + * + * @return articles:文章信息array# + */ + public function getOnlineFirstArticles(){ + $list = $this->article_obj + ->field('j_article.*,j_journal_stage.*,j_journal.title journal_title,j_journal.jabbr journal_short') + ->join(array(['j_journal_stage', 'j_article.journal_stage_id = j_journal_stage.journal_stage_id', 'LEFT'],['j_journal','j_article.journal_id = j_journal.journal_id','LEFT'])) + ->where('j_article.state',0) + ->where('j_journal_stage.is_publish',0) + ->where('j_article.journal_id','in','1,10,6,14,11,15,17,20,21,22') + ->order('j_article.article_id desc')->select(); + foreach ($list as $k => $v) { + $list[$k]['authortitle'] = $this->getAuthor($v); + } + $re['articles'] = $list; + return jsonSuccess($re); + } + + /** + * @title 获取news/commons文章列表 + * @description 获取news/commons文章列表 + * @author wangjinlei + * @url /api/Main/getNewsArticles + * @method POST + * + * @param name:type require:1 type:string desc:(News/Comment) + * + * @return articles:文章信息array# + */ + public function getNewsArticles(){ + $data = $this->request->post(); + if($data['type']=='News'){ + $type = 'News'; + }else{ + $type = 'Comment'; + } + $list = $this->article_obj + ->field('j_article.*,j_journal_stage.*,j_journal.title journal_title,j_journal.jabbr journal_short') + ->join(array(['j_journal_stage', 'j_article.journal_stage_id = j_journal_stage.journal_stage_id', 'LEFT'],['j_journal','j_article.journal_id = j_journal.journal_id','LEFT'])) + ->where('j_article.state',0) + ->where('j_journal_stage.is_publish',1) + ->where('j_article.journal_id','in','1,10,6,14,11,15,17,20,21,22') + ->where('j_article.type', $type) + ->order('j_article.article_id desc') + ->select(); + //获取作者 + foreach ($list as $k => $v) { + $stage_info = $this->journal_stage_obj->where('journal_stage_id', $v['journal_stage_id'])->find(); + $journal_info = $this->journal_obj->where('journal_id', $v['journal_id'])->find(); + //组合cite信息 + $no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):'; + $cite = $v['abbr'] . '. ' . $v['title'] . '. ' . $journal_info['jabbr'] . '. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi']; + $list[$k]['cite'] = $cite; + $list[$k]['authortitle'] = $this->getAuthor($v); + } + + //标题斜体 + foreach ($list as $k => $v) { + $caches = $this->article_ltai_obj->where('article_id', $v['article_id'])->where('state', 0)->column('content'); + $cache_title = $v['title']; + foreach ($caches as $val) { + $cache_title = str_replace($val, '' . $val . '', $cache_title); + } + $list[$k]['title'] = $cache_title; + } + $re['articles'] = $list; + return jsonSuccess($re); + } + + /** + * @title 获取3top文章列表 + * @description 获取3top文章列表 + * @author wangjinlei + * @url /api/Main/getThireTopArticles + * @method POST + * + * @param name:type require:1 type:string desc:类型(cite/read/download) + * + * @return articles:文章信息array# + */ + public function getThireTopArticles(){ + $data = $this->request->post(); + if($data['type'] == 'cite'){ + $order = 'j_article.cited desc'; + }else if($data['type'] == 'read'){ + $order = 'j_article.abs_num desc'; + }else if($data['type'] == 'download'){ + $order = 'j_article.pdf_num desc'; + }else{ + return jsonError('Please make sure type in "cite/read/download"'); + } + $list = $this->article_obj->field('j_article.*,j_journal_stage.*,j_journal.title journal_title,j_journal.jabbr journal_short') + ->join(array(['j_journal_stage', 'j_article.journal_stage_id = j_journal_stage.journal_stage_id', 'LEFT'],['j_journal','j_article.journal_id = j_journal.journal_id','LEFT'])) + ->where('j_article.state', 0) + ->where('j_journal_stage.is_publish',1) +// ->orderRaw('j_article.cited+j_article.abs_num+j_article.pdf_num desc') + ->order($order) + ->limit(20) + ->select(); + + //获取作者 + foreach ($list as $k => $v) { + $stage_info = $this->journal_stage_obj->where('journal_stage_id', $v['journal_stage_id'])->find(); + $journal_info = $this->journal_obj->where('journal_id', $v['journal_id'])->find(); + //组合cite信息 + $no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):'; + $cite = $v['abbr'] . '. ' . $v['title'] . '. ' . $journal_info['jabbr'] . '. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi']; + $list[$k]['cite'] = $cite; + $list[$k]['authortitle'] = $this->getAuthor($v); + } + + //标题斜体 + foreach ($list as $k => $v) { + $caches = $this->article_ltai_obj->where('article_id', $v['article_id'])->where('state', 0)->column('content'); + $cache_title = $v['title']; + foreach ($caches as $val) { + $cache_title = str_replace($val, '' . $val . '', $cache_title); + } + $list[$k]['title'] = $cache_title; + } + return jsonSuccess(['articles' => $list]); + + } /** * @title 获取首页Highlights diff --git a/application/master/controller/Article.php b/application/master/controller/Article.php index b270d02..48c371c 100644 --- a/application/master/controller/Article.php +++ b/application/master/controller/Article.php @@ -3,6 +3,7 @@ namespace app\master\controller; use think\Controller; use think\Db; +use think\Queue; /** * @title 文章接口 @@ -612,6 +613,7 @@ class Article extends Controller { $insert['article_id'] = $data['article_id']; $insert['topic_id'] = $data['topic_id']; $res = $this->article_to_topic_obj->insert($insert); + $this->msg_subscript_topic($data['topic_id'], $data['article_id']); if($res){ return json(['code'=>0,'msg'=>'success']); }else{ @@ -626,18 +628,33 @@ class Article extends Controller { $journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find(); $list = $this->subscribe_topic_obj->where('topic_id',$topic_id)->where('state',0)->select(); //组成文章信息 - $tt1 = $journal_info['title'].'

'; + $tt1 = '
+
+
+ +


'; + $tt1 .= $journal_info['title'].'

'; $tt1 .= 'The following new articles have just been published in Topic "'.$topic_info['title'].'" of '.$journal_info['title'].'

'; $tt1 .= $article_info['type'].'
'; - $tt1 .= $article_info['title'].'
'; + $tt1 .= ''.$article_info['title'].'
'; $tt1 .= $this->getAuthor($article_info).'
'; - $tt1 .= $journal_info['title'].' '.$stage_info['stage_year'].' '.$stage_info['stage_vol']."(".$stage_info['stage_no']."). https://doi.org/".$article_info['doi'].'


'; + $tt1 .= $journal_info['title'].' '.$stage_info['stage_year'].' '.$stage_info['stage_vol']."(".$stage_info['stage_no']."). https://doi.org/".$article_info['doi'].'
'; + $tt1 .= 'Download pdf


'; - $tt2 = 'TMR Publishing Group Ltd.
'; + $tt2 = 'Email: '.$journal_info['email'].'
'; + $tt2 .= 'Website: https://www.tmrjournals.com/'.$journal_info['usx'].'
'; + $tt2 .= 'TMR Publishing Group Ltd.
'; $tt2 .= '11 Cockle Bay Rd, Cockle Bay, Auckland, New Zealand
'; - $tt2 .= 'Tel: +64 02108293806.
'; - $tt2 .= 'Email: '.$journal_info['email'].'
'; - $tt2 .= 'Web: https://www.tmrjournals.com/'.$journal_info['usx']; + $tt2 .= 'Tel: +64 02108293806.'; + $tt2 .= '
+
'; foreach ($list as $v){ $cache = $tt1.'Unsubscribe

'.$tt2; diff --git a/application/master/controller/Journal.php b/application/master/controller/Journal.php index f6226a2..de4ef77 100644 --- a/application/master/controller/Journal.php +++ b/application/master/controller/Journal.php @@ -461,6 +461,7 @@ class Journal extends Controller { $insert['article_id'] = $data['article_id']; $insert['topic_id'] = $data['topic_id']; $res = $this->article_to_topic_obj->insert($insert); + $this->msg_subscript_topic($data['topic_id'], $data['article_id']); if($res){ return json(['code'=>0,'msg'=>'success']); }else{ @@ -468,6 +469,52 @@ class Journal extends Controller { } } + private function msg_subscript_topic($topic_id,$article_id){ + $article_info = $this->article_obj->where('article_id',$article_id)->find(); + $stage_info = $this->journal_stage_obj->where('journal_stage_id', $article_info['journal_stage_id'])->find(); + $topic_info = $this->journal_topic_obj->where('journal_topic_id',$topic_id)->find(); + $journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find(); + $list = $this->subscribe_topic_obj->where('topic_id',$topic_id)->where('state',0)->select(); + //组成文章信息 + $tt1 = '
+
+
+ +


'; + $tt1 .= $journal_info['title'].'

'; + $tt1 .= 'The following new articles have just been published in Topic "'.$topic_info['title'].'" of '.$journal_info['title'].'

'; + $tt1 .= $article_info['type'].'
'; + $tt1 .= ''.$article_info['title'].'
'; + $tt1 .= $this->getAuthor($article_info).'
'; + $tt1 .= $journal_info['title'].' '.$stage_info['stage_year'].' '.$stage_info['stage_vol']."(".$stage_info['stage_no']."). https://doi.org/".$article_info['doi'].'
'; + $tt1 .= 'Download pdf


'; + + $tt2 = 'Email: '.$journal_info['email'].'
'; + $tt2 .= 'Website: https://www.tmrjournals.com/'.$journal_info['usx'].'
'; + $tt2 .= 'TMR Publishing Group Ltd.
'; + $tt2 .= '11 Cockle Bay Rd, Cockle Bay, Auckland, New Zealand
'; + $tt2 .= 'Tel: +64 02108293806.'; + $tt2 .= '
+
'; + + foreach ($list as $v){ + $cache = $tt1.'Unsubscribe

'.$tt2; + $maidata['email'] = $v['email']; + $maidata['title'] = $journal_info['title']; + $maidata['content'] = $cache; + $maidata['tmail'] = 'publicrelations@tmrjournals.com'; + $maidata['tpassword'] = 'pRWU999999'; + Queue::push('app\api\job\mail@fire', $maidata, "mail"); + } + } + /** * @title 获取当前话题的文章 * @description 获取当前话题的文章