This commit is contained in:
wangjinlei
2021-06-25 15:25:42 +08:00
parent 7d216a169d
commit a34439b183
5 changed files with 445 additions and 214 deletions

View File

@@ -160,6 +160,9 @@ class Article extends Controller {
//组合cite信息 //组合cite信息
$no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):'; $no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):';
$cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi']; $cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi'];
$cache_topic = $this->article_to_topic_obj->field('j_journal_topic.*')->join('j_journal_topic','j_journal_topic.journal_topic_id = j_article_to_topic.topic_id','left')->where('j_article_to_topic.article_id',$v['article_id'])->where('j_article_to_topic.state',0)->select();
$list[$k]['topic'] = $cache_topic;
$list[$k]['cite'] = $cite; $list[$k]['cite'] = $cite;
$list[$k]['authortitle'] = $this->getAuthor($v); $list[$k]['authortitle'] = $this->getAuthor($v);
} }
@@ -227,6 +230,9 @@ class Article extends Controller {
//组合cite信息 //组合cite信息
$no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):'; $no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):';
$cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi']; $cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi'];
$cache_topic = $this->article_to_topic_obj->field('j_journal_topic.*')->join('j_journal_topic','j_journal_topic.journal_topic_id = j_article_to_topic.topic_id','left')->where('j_article_to_topic.article_id',$v['article_id'])->where('j_article_to_topic.state',0)->select();
$list[$k]['topic'] = $cache_topic;
$list[$k]['cite'] = $cite; $list[$k]['cite'] = $cite;
$list[$k]['authortitle'] = $this->getAuthor($v); $list[$k]['authortitle'] = $this->getAuthor($v);
} }
@@ -258,6 +264,7 @@ class Article extends Controller {
*/ */
public function addArticleNum(){ public function addArticleNum(){
$data = $this->request->post(); $data = $this->request->post();
$this->article_obj->where('article_id',$data['article_id'])->setInc($data['type'].'_num'); $this->article_obj->where('article_id',$data['article_id'])->setInc($data['type'].'_num');
$article_info = $this->article_obj->where('article_id',$data['article_id'])->find(); $article_info = $this->article_obj->where('article_id',$data['article_id'])->find();
@@ -330,6 +337,9 @@ class Article extends Controller {
//组合cite信息 //组合cite信息
$no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):'; $no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):';
$cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi']; $cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi'];
$cache_topic = $this->article_to_topic_obj->field('j_journal_topic.*')->join('j_journal_topic','j_journal_topic.journal_topic_id = j_article_to_topic.topic_id','left')->where('j_article_to_topic.article_id',$v['article_id'])->where('j_article_to_topic.state',0)->select();
$list[$k]['topic'] = $cache_topic;
$list[$k]['cite'] = $cite; $list[$k]['cite'] = $cite;
$list[$k]['authortitle'] = $this->getAuthor($v); $list[$k]['authortitle'] = $this->getAuthor($v);
} }

View File

@@ -233,6 +233,9 @@ class Journal extends Controller {
//组合cite信息 //组合cite信息
$no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):'; $no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):';
$cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi']; $cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi'];
$cache_topic = $this->article_to_topic_obj->field('j_journal_topic.*')->join('j_journal_topic','j_journal_topic.journal_topic_id = j_article_to_topic.topic_id','left')->where('j_article_to_topic.article_id',$v['article_id'])->where('j_article_to_topic.state',0)->select();
$list[$k]['topic'] = $cache_topic;
$list[$k]['cite'] = $cite; $list[$k]['cite'] = $cite;
$list[$k]['authortitle'] = $this->getAuthor($v); $list[$k]['authortitle'] = $this->getAuthor($v);
} }
@@ -287,8 +290,9 @@ class Journal extends Controller {
} else { } else {
$cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi']; $cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi'];
} }
$cache_topic = $this->article_to_topic_obj->field('j_journal_topic.*')->join('j_journal_topic','j_journal_topic.journal_topic_id = j_article_to_topic.topic_id','left')->where('j_article_to_topic.article_id',$v['article_id'])->where('j_article_to_topic.state',0)->select();
// $cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi']; $list[$k]['topic'] = $cache_topic;
$list[$k]['cite'] = $cite; $list[$k]['cite'] = $cite;
$list[$k]['authortitle'] = $this->getAuthor($v); $list[$k]['authortitle'] = $this->getAuthor($v);
} }
@@ -355,6 +359,9 @@ class Journal extends Controller {
//组合cite信息 //组合cite信息
$no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):'; $no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):';
$cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi']; $cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi'];
$cache_topic = $this->article_to_topic_obj->field('j_journal_topic.*')->join('j_journal_topic','j_journal_topic.journal_topic_id = j_article_to_topic.topic_id','left')->where('j_article_to_topic.article_id',$v['article_id'])->where('j_article_to_topic.state',0)->select();
$list[$k]['topic'] = $cache_topic;
$list[$k]['cite'] = $cite; $list[$k]['cite'] = $cite;
$list[$k]['authortitle'] = $this->getAuthor($v); $list[$k]['authortitle'] = $this->getAuthor($v);
} }
@@ -392,6 +399,9 @@ class Journal extends Controller {
//组合cite信息 //组合cite信息
$no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):'; $no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):';
$cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi']; $cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi'];
$cache_topic = $this->article_to_topic_obj->field('j_journal_topic.*')->join('j_journal_topic','j_journal_topic.journal_topic_id = j_article_to_topic.topic_id','left')->where('j_article_to_topic.article_id',$v['article_id'])->where('j_article_to_topic.state',0)->select();
$list[$k]['topic'] = $cache_topic;
$list[$k]['cite'] = $cite; $list[$k]['cite'] = $cite;
$list[$k]['authortitle'] = $this->getAuthor($v); $list[$k]['authortitle'] = $this->getAuthor($v);
} }
@@ -448,6 +458,9 @@ class Journal extends Controller {
//组合cite信息 //组合cite信息
$no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):'; $no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):';
$cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi']; $cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi'];
$cache_topic = $this->article_to_topic_obj->field('j_journal_topic.*')->join('j_journal_topic','j_journal_topic.journal_topic_id = j_article_to_topic.topic_id','left')->where('j_article_to_topic.article_id',$v['article_id'])->where('j_article_to_topic.state',0)->select();
$list[$k]['topic'] = $cache_topic;
$list[$k]['cite'] = $cite; $list[$k]['cite'] = $cite;
$list[$k]['authortitle'] = $this->getAuthor($v); $list[$k]['authortitle'] = $this->getAuthor($v);
} }
@@ -531,6 +544,9 @@ class Journal extends Controller {
//组合cite信息 //组合cite信息
$no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):'; $no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):';
$cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi']; $cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi'];
$cache_topic = $this->article_to_topic_obj->field('j_journal_topic.*')->join('j_journal_topic','j_journal_topic.journal_topic_id = j_article_to_topic.topic_id','left')->where('j_article_to_topic.article_id',$v['article_id'])->where('j_article_to_topic.state',0)->select();
$list[$k]['topic'] = $cache_topic;
$list[$k]['cite'] = $cite; $list[$k]['cite'] = $cite;
$list[$k]['authortitle'] = $this->getAuthor($v); $list[$k]['authortitle'] = $this->getAuthor($v);
} }
@@ -703,7 +719,7 @@ class Journal extends Controller {
*/ */
public function getTopicForSubscribe() { public function getTopicForSubscribe() {
$data = $this->request->post(); $data = $this->request->post();
$list = $this->journal_topic_obj->where('journal_id', $data['journal_id'])->where('state', 0)->where('level', 2)->select(); $list = $this->journal_topic_obj->where('journal_id', $data['journal_id'])->where('state', 0)->where('is_final', 1)->select();
$re['topics'] = $list; $re['topics'] = $list;
return jsonSuccess($re); return jsonSuccess($re);
@@ -751,6 +767,57 @@ class Journal extends Controller {
return jsonSuccess([]); return jsonSuccess([]);
} }
/**
* @title 添加期刊话题订阅(批量)
* @description 添加期刊话题订阅(批量)
* @author wangjinlei
* @url /api/Journal/addSubscribeTopics
* @method POST
*
* @param name:topic_ids type:string require:1 desc:期刊话题id(1,2,3,4)
* @param name:email type:string require:1 desc:邮箱地址
*/
public function addSubscribeTopics() {
$data = $this->request->post();
// $topics = explode(',', $data['topic_ids']);
$topics = $data['topic_ids'];
$str = '';
foreach ($topics as $k => $v) {
//去重
$repeat = $this->subscribe_topic_obj
->where('topic_id', $v)
->where('email', $data['email'])
->where('state', 0)
->find();
if ($repeat) {
continue;
}
$insert['topic_id'] = $v;
$insert['email'] = $data['email'];
$id = $this->subscribe_topic_obj->insertGetId($insert);
$cache_info = $this->journal_topic_obj->where('journal_topic_id',$v)->find();
$str .= '<a href="http://journalapi.tmrjournals.com/public/index.php/api/Journal/UnsubscribeTopic/snum/' . $id . '">Unsubscribe topic->'.$cache_info['title'].'</a><br>';
}
if($str==''){
return jsonError('repeat subscribe!');
}
//发送邮件感谢
$tt = 'Dear Researcher,<br><br>';
$tt .= 'Welcome you to the email alert for the latest research and more. Thank you for your interest in our publications and topics.<br>';
$tt .= $str;
$tt .= 'This service is provided by TMR Publishing Group | New Zealand<br>';
$tt .= 'Telephone: +64 02108293806';
$tt .= 'Email: publisher@tmrjournals.com';
$tt .= 'www.tmrjournals.com';
$maidata['email'] = $data['email'];
$maidata['title'] = 'Thank you for subscribing.';
$maidata['content'] = $tt;
$maidata['tmail'] = 'publicrelations@tmrjournals.com';
$maidata['tpassword'] = 'pRWU999999';
Queue::push('app\api\job\mail@fire', $maidata, "mail");
return jsonSuccess([]);
}
/** /**
* @title 添加期刊话题订阅 * @title 添加期刊话题订阅
* @description 添加期刊话题订阅 * @description 添加期刊话题订阅
@@ -863,6 +930,9 @@ class Journal extends Controller {
//组合cite信息 //组合cite信息
$no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):'; $no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):';
$cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi']; $cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi'];
$cache_topic = $this->article_to_topic_obj->field('j_journal_topic.*')->join('j_journal_topic','j_journal_topic.journal_topic_id = j_article_to_topic.topic_id','left')->where('j_article_to_topic.article_id',$v['article_id'])->where('j_article_to_topic.state',0)->select();
$list[$k]['topic'] = $cache_topic;
$list[$k]['cite'] = $cite; $list[$k]['cite'] = $cite;
$list[$k]['authortitle'] = $this->getAuthor($v); $list[$k]['authortitle'] = $this->getAuthor($v);
@@ -922,6 +992,9 @@ class Journal extends Controller {
//组合cite信息 //组合cite信息
$no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):'; $no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):';
$cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi']; $cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi'];
$cache_topic = $this->article_to_topic_obj->field('j_journal_topic.*')->join('j_journal_topic','j_journal_topic.journal_topic_id = j_article_to_topic.topic_id','left')->where('j_article_to_topic.article_id',$v['article_id'])->where('j_article_to_topic.state',0)->select();
$list[$k]['topic'] = $cache_topic;
$list[$k]['cite'] = $cite; $list[$k]['cite'] = $cite;
$list[$k]['authortitle'] = $this->getAuthor($v); $list[$k]['authortitle'] = $this->getAuthor($v);
//斜体变红 //斜体变红
@@ -978,7 +1051,7 @@ class Journal extends Controller {
} }
//组装作者 //组装作者
$arts = []; $arts = [];
if(isset($data['author']) && $data['author'] != ''){ if (isset($data['author']) && $data['author'] != '') {
$arts = $this->article_author_obj->where('state', 0)->where('author_name', 'like', '%' . trim($data['author']) . '%')->column('article_id'); $arts = $this->article_author_obj->where('state', 0)->where('author_name', 'like', '%' . trim($data['author']) . '%')->column('article_id');
if (count($arts) == 0) { if (count($arts) == 0) {
$re['articles'] = []; $re['articles'] = [];
@@ -986,7 +1059,7 @@ class Journal extends Controller {
return jsonSuccess($re); return jsonSuccess($re);
} }
} }
//构造查询语句 //构造查询语句
$where_str = ''; $where_str = '';
if (isset($data['term']) && $data['term'] != '') { if (isset($data['term']) && $data['term'] != '') {
@@ -1002,7 +1075,7 @@ class Journal extends Controller {
$c_str = '(' . implode(',', $stages) . ')'; $c_str = '(' . implode(',', $stages) . ')';
$where_str = $where_str == '' ? 'journal_stage_id in ' . $c_str : 'journal_stage_id in ' . $c_str . ' and ' . $where_str; $where_str = $where_str == '' ? 'journal_stage_id in ' . $c_str : 'journal_stage_id in ' . $c_str . ' and ' . $where_str;
} }
if (count($arts) > 0) { if (count($arts) > 0) {
$a_str = '(' . implode(',', $arts) . ')'; $a_str = '(' . implode(',', $arts) . ')';
$where_str = $where_str == '' ? 'article_id in ' . $a_str : 'article_id in ' . $a_str . ' and ' . $where_str; $where_str = $where_str == '' ? 'article_id in ' . $a_str : 'article_id in ' . $a_str . ' and ' . $where_str;
@@ -1043,7 +1116,7 @@ class Journal extends Controller {
$re['count'] = $count; $re['count'] = $count;
return jsonSuccess($re); return jsonSuccess($re);
} }
/** /**
* @title 查找文章精确查找(新) * @title 查找文章精确查找(新)
* @description 查找文章精确查找(新) * @description 查找文章精确查找(新)
@@ -1063,54 +1136,54 @@ class Journal extends Controller {
* @return articles:文章信息# * @return articles:文章信息#
* @return count:总数 * @return count:总数
*/ */
public function searchArticleMenu(){ public function searchArticleMenu() {
$data = $this->request->post(); $data = $this->request->post();
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize']; $limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
//组合where语句 //组合where语句
$where_str = ''; $where_str = '';
if($data['key1'] == 'author'){ if ($data['key1'] == 'author') {
$arts = $this->article_author_obj->where('state', 0)->where('author_name', 'like', '%' . trim($data['val1']) . '%')->column('article_id'); $arts = $this->article_author_obj->where('state', 0)->where('author_name', 'like', '%' . trim($data['val1']) . '%')->column('article_id');
$a_str = '(' . implode(',', $arts) . ')'; $a_str = '(' . implode(',', $arts) . ')';
$where_str = '(article_id in '. $a_str; $where_str = '(article_id in ' . $a_str;
}else{ } else {
$where_str = '('.$data['key1'].' like "%'.$data['val1'].'%"'; $where_str = '(' . $data['key1'] . ' like "%' . $data['val1'] . '%"';
} }
if(isset($data['key2'])&&$data['key2']!=''){ if (isset($data['key2']) && $data['key2'] != '') {
if($data['oper'] == 'and'){ if ($data['oper'] == 'and') {
$where_str = $where_str . ' and '; $where_str = $where_str . ' and ';
}else{ } else {
$where_str = $where_str . ' or '; $where_str = $where_str . ' or ';
} }
if($data['key2'] == 'author'){ if ($data['key2'] == 'author') {
$arts = $this->article_author_obj->where('state', 0)->where('author_name', 'like', '%' . trim($data['val2']) . '%')->column('article_id'); $arts = $this->article_author_obj->where('state', 0)->where('author_name', 'like', '%' . trim($data['val2']) . '%')->column('article_id');
$a_str = '(' . implode(',', $arts) . ')'; $a_str = '(' . implode(',', $arts) . ')';
$where_str = $where_str.' article_id in '. $a_str; $where_str = $where_str . ' article_id in ' . $a_str;
}else{ } else {
$where_str = $where_str.' '.$data['key2'].' like "%'.$data['val2'].'%"'; $where_str = $where_str . ' ' . $data['key2'] . ' like "%' . $data['val2'] . '%"';
} }
} }
//处理journal_id //处理journal_id
$where_str = $where_str . ') and journal_id in ('.trim($data['journal_id']).') and state = 0 '; $where_str = $where_str . ') and journal_id in (' . trim($data['journal_id']) . ') and state = 0 ';
//处理order //处理order
$order_str = ''; $order_str = '';
if($data['key1']=='title'&&(isset($data['key2'])&&$data['key2']=='title')){ if ($data['key1'] == 'title' && (isset($data['key2']) && $data['key2'] == 'title')) {
$order_str = "((CASE WHEN title LIKE '%" . trim($data['val1']) . "%' THEN 1 ELSE 0 END) + (CASE WHEN title LIKE '%" . trim($data['val2']) . "%' THEN 1 ELSE 0 END)) desc"; $order_str = "((CASE WHEN title LIKE '%" . trim($data['val1']) . "%' THEN 1 ELSE 0 END) + (CASE WHEN title LIKE '%" . trim($data['val2']) . "%' THEN 1 ELSE 0 END)) desc";
}elseif($data['key1']=='title'||(isset($data['key2'])&&$data['key2']=='title')){ } elseif ($data['key1'] == 'title' || (isset($data['key2']) && $data['key2'] == 'title')) {
if($data['key1']=='title'){ if ($data['key1'] == 'title') {
$order_str = "(CASE WHEN title LIKE '%" . trim($data['val1']) . "%' THEN 1 ELSE 0 END) desc"; $order_str = "(CASE WHEN title LIKE '%" . trim($data['val1']) . "%' THEN 1 ELSE 0 END) desc";
}else{ } else {
$order_str = "(CASE WHEN title LIKE '%" . trim($data['val2']) . "%' THEN 1 ELSE 0 END) desc"; $order_str = "(CASE WHEN title LIKE '%" . trim($data['val2']) . "%' THEN 1 ELSE 0 END) desc";
} }
}else{ } else {
$order_str = "article_id desc"; $order_str = "article_id desc";
} }
$list = $this->article_obj $list = $this->article_obj
->where($where_str) ->where($where_str)
->orderRaw($order_str) ->orderRaw($order_str)
->limit($limit_start,$data['pageSize']) ->limit($limit_start, $data['pageSize'])
->select(); ->select();
$count = $this->article_obj $count = $this->article_obj
->where($where_str) ->where($where_str)
@@ -1124,6 +1197,9 @@ class Journal extends Controller {
//组合cite信息 //组合cite信息
$no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):'; $no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):';
$cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi']; $cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi'];
$cache_topic = $this->article_to_topic_obj->field('j_journal_topic.*')->join('j_journal_topic','j_journal_topic.journal_topic_id = j_article_to_topic.topic_id','left')->where('j_article_to_topic.article_id',$v['article_id'])->where('j_article_to_topic.state',0)->select();
$list[$k]['topic'] = $cache_topic;
$list[$k]['cite'] = $cite; $list[$k]['cite'] = $cite;
$list[$k]['authortitle'] = $this->getAuthor($v); $list[$k]['authortitle'] = $this->getAuthor($v);
//斜体变红 //斜体变红
@@ -1132,10 +1208,10 @@ class Journal extends Controller {
foreach ($caches as $val) { foreach ($caches as $val) {
$cache_title = str_replace($val, '<i>' . $val . '</i>', $cache_title); $cache_title = str_replace($val, '<i>' . $val . '</i>', $cache_title);
} }
if ($data['key1']=='title') { if ($data['key1'] == 'title') {
$cache_title = str_replace(trim($data['val1']), '<b style="color:#c00">' . $data['val1'] . '</b>', $cache_title); $cache_title = str_replace(trim($data['val1']), '<b style="color:#c00">' . $data['val1'] . '</b>', $cache_title);
} }
if (isset($data['key2'])&&$data['key2']=='title') { if (isset($data['key2']) && $data['key2'] == 'title') {
$cache_title = str_replace(trim($data['val2']), '<b style="color:#c00">' . $data['val2'] . '</b>', $cache_title); $cache_title = str_replace(trim($data['val2']), '<b style="color:#c00">' . $data['val2'] . '</b>', $cache_title);
} }
$list[$k]['title'] = $cache_title; $list[$k]['title'] = $cache_title;
@@ -1144,7 +1220,6 @@ class Journal extends Controller {
$re['articles'] = $list; $re['articles'] = $list;
$re['count'] = $count; $re['count'] = $count;
return jsonSuccess($re); return jsonSuccess($re);
} }
} }

View File

@@ -578,5 +578,6 @@ class Main extends Controller {
// echo '</pre>'; // echo '</pre>';
// die; // die;
// } // }
} }

View File

@@ -1,177 +1,213 @@
<?php <?php
use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\PHPMailer;
use think\Db; use think\Db;
//use TCPDF; //use TCPDF;
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ] // | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved. // | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com> // | Author: 流年 <liu21st@gmail.com>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// 应用公共文件 // 应用公共文件
function authcode($str) { function authcode($str) {
$key = substr(md5('ThinkPHP.CN'), 5, 8); $key = substr(md5('ThinkPHP.CN'), 5, 8);
$str1 = substr(md5($str), 8, 10); $str1 = substr(md5($str), 8, 10);
return md5($key . $str1); return md5($key . $str1);
} }
/** /**
* @function sendEmail * @function sendEmail
* @intro 发送邮件(带附件) * @intro 发送邮件(带附件)
* @param $email 接收邮箱 * @param $email 接收邮箱
* @param $title 邮件标题 * @param $title 邮件标题
* @param $from_name 发件人 * @param $from_name 发件人
* @param $content 邮件内容 * @param $content 邮件内容
* @param $memail 邮件内容 * @param $memail 邮件内容
* @param $mpassword 邮件内容 * @param $mpassword 邮件内容
* @param $attachmentFile 附件 string | array * @param $attachmentFile 附件 string | array
* @return array * @return array
*/ */
function sendEmail($email = '', $title = '', $from_name = '', $content = '', $memail = '', $mpassword = '', $attachmentFile = '') { function sendEmail($email = '', $title = '', $from_name = '', $content = '', $memail = '', $mpassword = '', $attachmentFile = '') {
date_default_timezone_set('PRC'); date_default_timezone_set('PRC');
//Create a new PHPMailer instance //Create a new PHPMailer instance
$mail = new PHPMailer; $mail = new PHPMailer;
//Tell PHPMailer to use SMTP //Tell PHPMailer to use SMTP
$mail->isSMTP(); $mail->isSMTP();
//Enable SMTP debugging //Enable SMTP debugging
// 0 = off (for production use) // 0 = off (for production use)
// 1 = client messages // 1 = client messages
// 2 = client and server messages // 2 = client and server messages
$mail->SMTPDebug = 0; $mail->SMTPDebug = 0;
//Ask for HTML-friendly debug output //Ask for HTML-friendly debug output
$mail->Debugoutput = 'html'; $mail->Debugoutput = 'html';
//charset //charset
$mail->CharSet = 'UTF-8'; $mail->CharSet = 'UTF-8';
//Set the hostname of the mail server //Set the hostname of the mail server
$mail->Host = "smtp.qiye.aliyun.com"; //请填写你的邮箱服务器 $mail->Host = "smtp.qiye.aliyun.com"; //请填写你的邮箱服务器
//Set the SMTP port number - likely to be 25, 465 or 587 //Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 25; //端口号 $mail->Port = 25; //端口号
//Whether to use SMTP authentication //Whether to use SMTP authentication
$mail->SMTPAuth = true; $mail->SMTPAuth = true;
//Username to use for SMTP authentication //Username to use for SMTP authentication
$mail->Username = $memail == '' ? "tmrweb@tmrjournals.com" : $memail; //发件邮箱用户名 $mail->Username = $memail == '' ? "tmrweb@tmrjournals.com" : $memail; //发件邮箱用户名
//Password to use for SMTP authentication //Password to use for SMTP authentication
$mail->Password = $mpassword == '' ? "Wu999999tmrwe" : $mpassword; //发件邮箱密码 $mail->Password = $mpassword == '' ? "Wu999999tmrwe" : $mpassword; //发件邮箱密码
//Set who the message is to be sent from //Set who the message is to be sent from
$mail->setFrom($memail == '' ? "tmrweb@tmrjournals.com" : $memail, $from_name); $mail->setFrom($memail == '' ? "tmrweb@tmrjournals.com" : $memail, $from_name);
//Set an alternative reply-to address(用户直接回复邮件的地址) //Set an alternative reply-to address(用户直接回复邮件的地址)
$mail->addReplyTo($memail == '' ? "tmrweb@tmrjournals.com" : $memail, $from_name); $mail->addReplyTo($memail == '' ? "tmrweb@tmrjournals.com" : $memail, $from_name);
//Set who the message is to be sent to //Set who the message is to be sent to
$mail->addAddress($email); $mail->addAddress($email);
//Set the subject line //Set the subject line
$mail->Subject = $title; $mail->Subject = $title;
//Read an HTML message body from an external file, convert referenced images to embedded, //Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body //convert HTML into a basic plain-text alternative body
$mail->msgHTML($content); $mail->msgHTML($content);
//Replace the plain text body with one created manually //Replace the plain text body with one created manually
$mail->AltBody = ''; $mail->AltBody = '';
if (is_array($attachmentFile)) { if (is_array($attachmentFile)) {
for ($i = 0; $i < count($attachmentFile); $i++) { for ($i = 0; $i < count($attachmentFile); $i++) {
$mail->addAttachment($attachmentFile[$i], 'thanks.pdf' . $i); //这里可以是多维数组,然后循环附件的文件和名称 $mail->addAttachment($attachmentFile[$i], 'thanks.pdf' . $i); //这里可以是多维数组,然后循环附件的文件和名称
} }
} else { } else {
if ($attachmentFile != '') { if ($attachmentFile != '') {
//Attach an image file //Attach an image file
$mail->addAttachment($attachmentFile, 'thanks.pdf'); $mail->addAttachment($attachmentFile, 'thanks.pdf');
} }
} }
//send the message, check for errors //send the message, check for errors
if (!$mail->send()) { if (!$mail->send()) {
$status = 0; $status = 0;
$data = "邮件发送失败" . $mail->ErrorInfo; $data = "邮件发送失败" . $mail->ErrorInfo;
; ;
} else { } else {
$status = 1; $status = 1;
$data = "邮件发送成功"; $data = "邮件发送成功";
} }
return ['status' => $status, 'data' => $data]; //返回值(可选) return ['status' => $status, 'data' => $data]; //返回值(可选)
} }
/** /**
* 生成文章sn号 * 生成文章sn号
* @return type * @return type
*/ */
function getArticleSN($abbr,$type) { function getArticleSN($abbr,$type) {
$str = $abbr; $str = $abbr;
$str .= date('Y', time()).$type.date('md', time()); $str .= date('Y', time()).$type.date('md', time());
$where['accept_sn'] = ['like', "$str%"]; $where['accept_sn'] = ['like', "$str%"];
$nowres = Db::name('article')->where($where)->select(); $nowres = Db::name('article')->where($where)->select();
$last_num = 1; $last_num = 1;
if ($nowres) { if ($nowres) {
foreach ($nowres as $v) { foreach ($nowres as $v) {
$now_num = intval(substr($v['accept_sn'], -3)); $now_num = intval(substr($v['accept_sn'], -3));
$last_num = $now_num > $last_num ? $now_num : $last_num; $last_num = $now_num > $last_num ? $now_num : $last_num;
} }
$last_num += 1; $last_num += 1;
} }
$last_str = sprintf("%03d", $last_num); $last_str = sprintf("%03d", $last_num);
$str .= $last_str; $str .= $last_str;
return $str; return $str;
} }
/** /**
* 增加usermsg * 增加usermsg
*/ */
function add_usermsg($userid, $content, $url) { function add_usermsg($userid, $content, $url) {
$msg_obj = Db::name('user_msg'); $msg_obj = Db::name('user_msg');
$msg_info = $msg_obj->where('user_id', $userid) $msg_info = $msg_obj->where('user_id', $userid)
->where('url', $url) ->where('url', $url)
->where('state', 0) ->where('state', 0)
->find(); ->find();
if ($msg_info) { if ($msg_info) {
return true; return true;
} }
$msgdata['user_id'] = $userid; $msgdata['user_id'] = $userid;
$msgdata['content'] = $content; $msgdata['content'] = $content;
$msgdata['url'] = $url; $msgdata['url'] = $url;
$msgdata['ctime'] = time(); $msgdata['ctime'] = time();
return $msg_obj->insert($msgdata); return $msg_obj->insert($msgdata);
} }
function jsonSuccess($data){ function jsonSuccess($data){
return json(['code'=>0,'msg'=>'success','data'=>$data]); return json(['code'=>0,'msg'=>'success','data'=>$data]);
} }
function jsonError($msg){ function jsonError($msg){
return json(['code'=>1,'msg'=>$msg]); return json(['code'=>1,'msg'=>$msg]);
} }
function myPost($url, $param=array()){ function myPost($url, $param=array()){
if(!is_array($param)){ if(!is_array($param)){
throw new Exception("参数必须为array"); throw new Exception("参数必须为array");
} }
$httph =curl_init($url); $httph =curl_init($url);
// curl_setopt($httph, CURLOPT_SSL_VERIFYPEER, 0); // curl_setopt($httph, CURLOPT_SSL_VERIFYPEER, 0);
// curl_setopt($httph, CURLOPT_SSL_VERIFYHOST, 1); // curl_setopt($httph, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($httph,CURLOPT_RETURNTRANSFER,1); curl_setopt($httph,CURLOPT_RETURNTRANSFER,1);
curl_setopt($httph, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"); curl_setopt($httph, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
curl_setopt($httph, CURLOPT_POST, 1);//设置为POST方式 curl_setopt($httph, CURLOPT_POST, 1);//设置为POST方式
curl_setopt($httph, CURLOPT_POSTFIELDS, $param); curl_setopt($httph, CURLOPT_POSTFIELDS, $param);
// curl_setopt($httph, CURLOPT_RETURNTRANSFER,0); // curl_setopt($httph, CURLOPT_RETURNTRANSFER,0);
// curl_setopt($httph, CURLOPT_HEADER,1); // curl_setopt($httph, CURLOPT_HEADER,1);
$rst=curl_exec($httph); $rst=curl_exec($httph);
curl_close($httph); curl_close($httph);
return $rst; return $rst;
} }
function ORCIDPost($url, $param=array()){
if(!is_array($param)){
throw new Exception("参数必须为array");
}
$headerArray = ['Content-Type: application/x-www-form-urlencoded'];
$httph =curl_init($url);
curl_setopt($httph, CURLOPT_SSL_VERIFYPEER, false);
// curl_setopt($httph, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($httph,CURLOPT_RETURNTRANSFER,1);
curl_setopt($httph, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
curl_setopt($httph, CURLOPT_POST, 1);//设置为POST方式
curl_setopt($httph, CURLOPT_POSTFIELDS, $param);
curl_setopt($httph, CURLOPT_HTTPHEADER,$headerArray);
// curl_setopt($httph, CURLOPT_RETURNTRANSFER,0);
// curl_setopt($httph, CURLOPT_HEADER,1);
$rst=curl_exec($httph);
curl_close($httph);
return $rst;
}

View File

@@ -434,9 +434,6 @@ class Article extends Controller {
* @param name:doi type:string require:1 desc:doi * @param name:doi type:string require:1 desc:doi
* @param name:abstract type:string require:1 desc:简介 * @param name:abstract type:string require:1 desc:简介
* @param name:keywords type:string require:1 desc:关键字 * @param name:keywords type:string require:1 desc:关键字
* @param name:abs_num type:int require:1 desc:简介数量
* @param name:pdf_num type:int require:1 desc:pdf数量
* @param name:html_num type:int require:1 desc:html数量
* @param name:ltai type:string require:0 desc:标题斜体(demo1,demo2) * @param name:ltai type:string require:0 desc:标题斜体(demo1,demo2)
* @param name:npp type:strng require:1 desc:文章页码 * @param name:npp type:strng require:1 desc:文章页码
* @param name:type type:string require:1 desc:类型 * @param name:type type:string require:1 desc:类型
@@ -462,9 +459,9 @@ class Article extends Controller {
$updata['doi'] = $data['doi']; $updata['doi'] = $data['doi'];
$updata['abstract'] = $data['abstract']; $updata['abstract'] = $data['abstract'];
$updata['keywords'] = $data['keywords']; $updata['keywords'] = $data['keywords'];
$updata['abs_num'] = $data['abs_num']; // $updata['abs_num'] = $data['abs_num'];
$updata['pdf_num'] = $data['pdf_num']; // $updata['pdf_num'] = $data['pdf_num'];
$updata['html_num'] = $data['html_num']; // $updata['html_num'] = $data['html_num'];
$updata['npp'] = $data['npp']; $updata['npp'] = $data['npp'];
$updata['type'] = $data['type']; $updata['type'] = $data['type'];
$updata['cited'] = $data['cited']; $updata['cited'] = $data['cited'];
@@ -1018,4 +1015,116 @@ class Article extends Controller {
$re['cites'] = $list; $re['cites'] = $list;
return jsonSuccess($re); return jsonSuccess($re);
} }
/**
* @title 注册doi
* @description 注册doi
* @author wangjinlei
* @url /master/Article/agentDOI
* @method POST
*
* @param name:doi type:string require:1 desc:doi号
* @param name:article_id type:int require:1 desc:文章id
*/
public function agentDOI(){
$data = $this->request->post();
$data['doi'] = '10.12032/TMR20210301222';
$data['article_id'] = 1333;
$xml = '';
//create xml 头
$xml .= '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL;
$xml .= '<doi_batch version="1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="D:\jboss-4.0.3SP1\wanfang\jboss-4.0.3SP1\server\default\deploy\WanFang.war\check.xsd">'.PHP_EOL.PHP_EOL;
$xml .= '<head>'.PHP_EOL;
$xml .= '<doi_batch_id>'.date('Ymd').'</doi_batch_id>'.PHP_EOL;
$xml .= '<timestamp>'.date('YmdHis').'</timestamp>'.PHP_EOL;
$xml .= '<depositor>'.PHP_EOL;
$xml .= '<name>TMR2015@163.com</name>'.PHP_EOL;
$xml .= '<email_address>TMR2015@163.com</email_address>'.PHP_EOL;
$xml .= '</depositor>'.PHP_EOL;
$xml .= '<registrant>传统医学研究(英文版)</registrant>'.PHP_EOL;
$xml .= '</head>'.PHP_EOL;
//组装主体信息部分
$article_info = $this->article_obj->where('article_id',$data['article_id'])->find();
$journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
$stage_info = $this->journal_stage_obj->where('journal_stage_id',$article_info['journal_stage_id'])->find();
$xml .= '<body>'.PHP_EOL;
$xml .= '<journal>'.PHP_EOL;
$xml .= '<journal_metadata>'.PHP_EOL;
$xml .= '<journal_id>'.$journal_info['usx'].'</journal_id>'.PHP_EOL;
$xml .= '<full_title>'.$journal_info['title'].'</full_title>'.PHP_EOL;
$xml .= '<issn media_type="print">'.$journal_info['issn'].'</issn>'.PHP_EOL;
$xml .= '<cn media_type="print"></cn>'.PHP_EOL;
$xml .= '</journal_metadata>'.PHP_EOL;
$xml .= '<journal_issue>'.PHP_EOL;
$xml .= '<publication_date media_type="print">'.PHP_EOL;
$xml .= '<year>'.$stage_info['stage_year'].'</year>'.PHP_EOL;
$xml .= '<month/>'.PHP_EOL;
$xml .= '<day/>'.PHP_EOL;
$xml .= '</publication_date>'.PHP_EOL;
$xml .= '<journal_volume>'.PHP_EOL;
$xml .= '<volume>'.$stage_info['stage_vol'].'</volume>'.PHP_EOL;
$xml .= '</journal_volume>'.PHP_EOL;
$xml .= '<issue>'.$stage_info['stage_no'].'</issue>'.PHP_EOL;
$xml .= '</journal_issue>'.PHP_EOL;
$xml .= '<journal_article>'.PHP_EOL;
$xml .= '<titles>'.PHP_EOL;
$xml .= '<title>'.$article_info['title'].'</title>'.PHP_EOL;
$xml .= '<subtitle></subtitle>'.PHP_EOL;
$xml .= '</titles>'.PHP_EOL;
$xml .= '<contributors>'.PHP_EOL;
$xml .= '<contributors>'.PHP_EOL;
$authors = $this->article_author_obj->where('article_id',$data['article_id'])->where('state',0)->select();
$address = '';
$author = '';
foreach ($authors as $v){
if($v['is_first']==1){
$ca = $this->author_to_organ_obj->where('article_author_id',$v['article_author_id'])->where('article_id',$data['article_id'])->find();
$ca_organ = $this->article_organ_obj->where('article_organ_id',$ca['article_organ_id'])->find();
$address = $ca_organ['organ_name'];
}
$author .= $v['author_name'].',';
}
$xml .= '<person_name sequence="first" contributor_role="author">'.substr($author,-1).'</person_name>'.PHP_EOL;
$xml .= '<organization sequence="first" contributor_role="author">'.$address.'</organization>'.PHP_EOL;
$xml .= '</contributors>'.PHP_EOL;
$xml .= '<keywords></keywords>'.PHP_EOL;
$xml .= '<keywords>'. str_replace(',', ' ', $article_info['keywords']).'</keywords>'.PHP_EOL;
$xml .= '<abstract></abstract>'.PHP_EOL;
$xml .= '<abstract>'.str_replace('Abstract','',strip_tags(str_replace("&nbsp;","",htmlspecialchars_decode($article_info['abstract'])))).'</abstract>'.PHP_EOL;
$xml .= '<doi_data>'.PHP_EOL;
$xml .= '<doi>'.$article_info['doi'].'</doi>'.PHP_EOL;
$xml .= '<resource><![CDATA[https://www.tmrjournals.com/article.html?J_num='.$journal_info['journal_id'].'&a_id='.$article_info['article_id'].']]></resource>'.PHP_EOL;
$xml .= '</doi_data>'.PHP_EOL;
$xml .= '<pages>'.PHP_EOL;
$start = '';
$end = '';
if(stripos($article_info['npp'],'-')>0){
$ca_list = explode('-', $article_info['npp']);
$start = $ca_list[0];
$end = $ca_list[1];
}else{
$start = $article_info['npp'];
}
$xml .= '<first_page>'.$start.'</first_page>'.PHP_EOL;
$xml .= '<last_page>'.$end.'</last_page>'.PHP_EOL;
$xml .= '</pages>'.PHP_EOL;
$xml .= '</journal_article>'.PHP_EOL;
$txt = ROOT_PATH . 'public' . DS . 'xml'.DS.$article_info['article_id'].'.xml';
file_put_contents($txt, $xml);
}
public function upXML(){
vendor("chinadoi.UPXML2");
$up_obj = new \UpXml;
$xmlfile = ROOT_PATH . 'public' . DS . 'xml'.DS.'1333.xml';
$result = $up_obj->upload($xmlfile);
echo '<pre>';
var_dump($result);
echo '</pre>';
die;
}
} }