From 4712826e8be67ba388cf189e315a82816d90dc94 Mon Sep 17 00:00:00 2001 From: wangjinlei <751475802@qq.com> Date: Tue, 9 Feb 2021 14:49:29 +0800 Subject: [PATCH] 20201112 --- application/master/controller/Article.php | 45 +++++++++++++++++++++++ application/master/controller/Journal.php | 43 ++++++++++++++++++++-- 2 files changed, 84 insertions(+), 4 deletions(-) diff --git a/application/master/controller/Article.php b/application/master/controller/Article.php index 84ba9c0..b270d02 100644 --- a/application/master/controller/Article.php +++ b/application/master/controller/Article.php @@ -23,6 +23,8 @@ class Article extends Controller { protected $journal_stage_obj = ''; protected $journal_special_obj = ''; protected $country_obj = ''; + protected $subscribe_journal_obj = ''; + protected $subscribe_topic_obj = ''; public function __construct(\think\Request $request = null) { parent::__construct($request); @@ -38,6 +40,8 @@ class Article extends Controller { $this->journal_stage_obj = Db::name('journal_stage'); $this->journal_special_obj = Db::name('journal_special'); $this->country_obj = Db::name('country'); + $this->subscribe_journal_obj = Db::name('subscribe_journal'); + $this->subscribe_topic_obj = Db::name('subscribe_topic'); } /** @@ -615,6 +619,47 @@ class Article 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 = $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'].'


'; + + $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']; + + 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"); + } + } + private function getAuthor($article) { + $where['article_id'] = $article['article_id']; + $where['state'] = 0; + $list = $this->article_author_obj->where($where)->select(); + $frag = ''; + foreach ($list as $k => $v) { + $frag = $frag == '' ? '' . $v['author_name'] : $frag . ', ' . $v['author_name']; + } + return $frag; + } + /** * @title 删除文章话题 * @description 删除文章话题 diff --git a/application/master/controller/Journal.php b/application/master/controller/Journal.php index 09ef636..c19a894 100644 --- a/application/master/controller/Journal.php +++ b/application/master/controller/Journal.php @@ -753,7 +753,7 @@ class Journal extends Controller { $res = $this->journal_stage_obj->update($data); //是否提醒订阅者 if($old['is_publish']==0&&$data['is_publish']==1){ - $this->msg_subscript_journal($old['journal_id']); + $this->msg_subscript_journal($data['journal_stage_id'],$old['journal_id']); } if($res){ return json(['code'=>0,'msg'=>'success']); @@ -762,11 +762,46 @@ class Journal extends Controller { } } - private function msg_subscript_journal($journal_id){ + private function msg_subscript_journal($journal_stage_id,$journal_id){ + $articles = $this->article_obj->where('journal_stage_id',$journal_stage_id)->where('state',0)->select(); + $stage_info = $this->journal_stage_obj->where('journal_stage_id', $journal_stage_id)->find(); + $journal_info = $this->journal_obj->where('journal_id',$journal_id)->find(); $list = $this->subscribe_journal_obj->where('journal_id',$journal_id)->where('state',0)->select(); - foreach ($list as $v){ - + + //组成文章信息 + $tt1 = $journal_info['title'].'

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

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


'; } + $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']; + + 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"); + } + } + private function getAuthor($article) { + $where['article_id'] = $article['article_id']; + $where['state'] = 0; + $list = $this->article_author_obj->where($where)->select(); + $frag = ''; + foreach ($list as $k => $v) { + $frag = $frag == '' ? '' . $v['author_name'] : $frag . ', ' . $v['author_name']; + } + return $frag; } /**