diff --git a/application/api/controller/Article.php b/application/api/controller/Article.php
index a6fc5a9..afb2a24 100644
--- a/application/api/controller/Article.php
+++ b/application/api/controller/Article.php
@@ -459,8 +459,8 @@ class Article extends Controller {
$tt .= 'Dear '.($user_rev_info==null||$user_rev_info['technical']=="Others"||$user_rev_info['technical']==""?"Dr.":$user_rev_info['technical']).($user_info['realname']==''?$user_info['account']:$user_info['realname']).',
';
$tt .= 'Thank you for submitting your paper to '.$journal_info['title'].'. Your manuscript has undergone review.
';
- $tt .= 'Unfortunately the editors feel that '.$journal_info['title'].' is not the appropriate venue for your manuscript. You munuscript will transfer to journal - '.$tran_journal['title'].' as you co-submitting chose order.If you have questions about the Co-submission process, please contact publisher@tmrjournals.com within 48 hours.
Yours sincerely,
';
- $tt .= 'Sincerely,
Editorial Office
';
+ $tt .= 'Unfortunately the editors feel that '.$journal_info['title'].' is not the appropriate venue for your manuscript. You munuscript will transfer to journal - '.$tran_journal['title'].' as you co-submitting chose order.If you have questions about the Co-submission process, please contact publisher@tmrjournals.com within 48 hours.
Yours sincerely,
';
+ $tt .= 'Editorial Office
';
$tt .= $journal_info['title'].'
';
$tt .= 'Subscribe to this journal
';
$tt .= 'Email: '.$journal_info['email'].'
';
@@ -1117,6 +1117,12 @@ class Article extends Controller {
$re['articles'] = $list;
return jsonSuccess($re);
}
+
+
+
+ public function getMajors(){
+
+ }
/**
* 存储article文件历史信息
diff --git a/application/api/controller/Auto.php b/application/api/controller/Auto.php
index 5d87928..07d1f2a 100644
--- a/application/api/controller/Auto.php
+++ b/application/api/controller/Auto.php
@@ -17,22 +17,20 @@ class Auto extends Controller {
protected $article_obj = '';
protected $article_reviewer_obj = '';
protected $user_obj = '';
-
protected $rev_to_jour_obj = '';
protected $reviewer_obj = '';
protected $journal_obj = '';
protected $article_msg_obj = '';
protected $user_log_obj = '';
protected $reviewer_info_obj = '';
-
public function __construct(\think\Request $request = null) {
parent::__construct($request);
$this->article_obj = Db::name('article');
$this->article_reviewer_obj = Db::name('article_reviewer');
$this->user_obj = Db::name('user');
-
-
+
+
$this->rev_to_jour_obj = Db::name('reviewer_to_journal');
$this->journal_obj = Db::name('journal');
$this->reviewer_obj = Db::name('article_reviewer');
@@ -40,39 +38,39 @@ class Auto extends Controller {
$this->user_log_obj = Db::name('user_log');
$this->reviewer_info_obj = Db::name('user_reviewer_info');
}
-
+
/**
* 推送邮件给审稿人提醒审稿人
*/
- public function pushEmailForReviewer(){
+ public function pushEmailForReviewer() {
//筛选数据
- $list = $this->article_reviewer_obj->where("state","in",[0,5])->select();
- foreach ($list as $v){
- $cache_article = $this->article_obj->where("article_id",$v['article_id'])->find();
- if($cache_article["state"]!=2){
+ $list = $this->article_reviewer_obj->where("state", "in", [0, 5])->select();
+ foreach ($list as $v) {
+ $cache_article = $this->article_obj->where("article_id", $v['article_id'])->find();
+ if ($cache_article["state"] != 2) {
continue;
}
- $cache_t = intval((time()-$v["ctime"])/86400);
- if($cache_t==14||$cache_t==21||$cache_t==28){
- $cache_journal = $this->journal_obj->where("journal_id",$cache_article['journal_id'])->find();
+ $cache_t = intval((time() - $v["ctime"]) / 86400);
+ if ($cache_t == 14 || $cache_t == 21 || $cache_t == 28) {
+ $cache_journal = $this->journal_obj->where("journal_id", $cache_article['journal_id'])->find();
//查找审稿人信息
$cache_reviewer = $this->user_obj
- ->join("t_user_reviewer_info","t_user_reviewer_info.reviewer_id = t_user.user_id","left")
- ->where("t_user.user_id",$v['reviewer_id'])->find();
-
- $tt = "Manuscript ID: ".$cache_article['accept_sn']."
";
- $tt .= "Title:".$cache_article['title']."
";
- $tt .= "Dear ".($cache_reviewer['technical']==""||$cache_reviewer['technical']=="Others"?"Dr.":$cache_reviewer['technical'])." ".($cache_reviewer["realname"]==""?$cache_reviewer["account"]:$cache_reviewer["realname"])."
";
- $tt .= "On ".date("d D Y",$v["ctime"])." we sent you a request to review a paper title ".$cache_article['title'].".
";
+ ->join("t_user_reviewer_info", "t_user_reviewer_info.reviewer_id = t_user.user_id", "left")
+ ->where("t_user.user_id", $v['reviewer_id'])->find();
+
+ $tt = "Manuscript ID: " . $cache_article['accept_sn'] . "
";
+ $tt .= "Title:" . $cache_article['title'] . "
";
+ $tt .= "Dear " . ($cache_reviewer['technical'] == "" || $cache_reviewer['technical'] == "Others" ? "Dr." : $cache_reviewer['technical']) . " " . ($cache_reviewer["realname"] == "" ? $cache_reviewer["account"] : $cache_reviewer["realname"]) . "
";
+ $tt .= "On " . date("d D Y", $v["ctime"]) . " we sent you a request to review a paper title " . $cache_article['title'] . ".
";
$tt .= "We have not yet received a response from you, possibly because the original invitation went astray. We would be grateful if you could let us know if you can carry out this review.
";
$tt .= "If you would like to review this paper, please click this link.
";
- $tt .= "If you do not wish to review this paper, please click this link.
";
- $tt .= 'Sincerely,
Editorial Office
'.$cache_journal['title'].'
';
- $tt .= 'Email: '.$cache_journal['email'].'
';
- $tt .= 'Website:'.$cache_journal['website'].'';
-
+ $tt .= "If you do not wish to review this paper, please click this link.
";
+ $tt .= 'Sincerely,
Editorial Office
' . $cache_journal['title'] . '
';
+ $tt .= 'Email: ' . $cache_journal['email'] . '
';
+ $tt .= 'Website:' . $cache_journal['website'] . '';
+
$maidata['email'] = $cache_reviewer['email'];
- $maidata['title'] = "Invitation to review manuscript for ".$cache_journal['title']." - Reminder";
+ $maidata['title'] = "Invitation to review manuscript for " . $cache_journal['title'] . " - Reminder";
$maidata['content'] = $tt;
$maidata['tmail'] = $cache_journal['email'];
$maidata['tpassword'] = $cache_journal['epassword'];
@@ -80,38 +78,61 @@ class Auto extends Controller {
}
}
}
-
+
/**
* 推送邮件提醒作者修回稿件
*/
- public function pushEmailForAuthor(){
+ public function pushEmailForAuthor() {
//筛选数据
- $list = $this->article_obj->where("state",4)->select();
- foreach ($list as $v){
- $cache_t = intval((time()-$v["ttime"])/86400);
- if($cache_t==14||$cache_t==21||$cache_t==28){
- //查找文章内容
- $cache_journal = $this->journal_obj->where("journal_id",$v['journal_id'])->find();
- //查找作者信息
- $cache_author = $this->user_obj->where("user_id",$v['user_id'])->find();
-
- $tt = "Dear Author,
";
- $tt .= "We have send you the email about revision of your manuscript. According to our records you are almost reaching the deadline now. We look forward to receiving your revised article.
";
- $tt .= "When preparing your revised manuscript, you are asked to carefully consider the reviewers' comments which are attached, and submit a revised versionand a list of responses to the comments before deadline. The revised parts in the manuscript should be highlighted with blue color.
";
- $tt .= "If you feel that you will require more time to complete your revision, please let me know and I will update our records accordingly. If I can provide any further advice or assistance, please do not hesitate to contact me.
";
- $tt .= 'Sincerely,
Editorial Office
'.$cache_journal['title'].'
';
- $tt .= 'Email: '.$cache_journal['email'].'
';
- $tt .= 'Website:'.$cache_journal['website'].'';
-
- $maidata['email'] = $cache_author['email'];
- $maidata['title'] = "Deadline for your revision of ".$cache_journal['title']." -Reminder";
- $maidata['content'] = $tt;
- $maidata['tmail'] = $cache_journal['email'];
- $maidata['tpassword'] = $cache_journal['epassword'];
- Queue::push('app\api\job\mail@fire', $maidata, "tmail");
+ $list = $this->article_obj->where("state", 4)->select();
+ foreach ($list as $v) {
+ $cache_t = intval((time() - $v["ttime"]) / 86400);
+ if ($v['type'] == 'A') {
+ if ($cache_t == 28 || $cache_t == 42 || $cache_t == 56) {
+ //查找文章内容
+ $cache_journal = $this->journal_obj->where("journal_id", $v['journal_id'])->find();
+ //查找作者信息
+ $cache_author = $this->user_obj->where("user_id", $v['user_id'])->find();
+
+ $tt = "Dear Author,
";
+ $tt .= "We have send you the email about revision of your manuscript. According to our records you are almost reaching the deadline now. We look forward to receiving your revised article.
";
+ $tt .= "When preparing your revised manuscript, you are asked to carefully consider the reviewers' comments which are attached, and submit a revised versionand a list of responses to the comments before deadline. The revised parts in the manuscript should be highlighted with blue color.
";
+ $tt .= "If you feel that you will require more time to complete your revision, please let me know and I will update our records accordingly. If I can provide any further advice or assistance, please do not hesitate to contact me.
";
+ $tt .= 'Sincerely,
Editorial Office
' . $cache_journal['title'] . '
';
+ $tt .= 'Email: ' . $cache_journal['email'] . '
';
+ $tt .= 'Website:' . $cache_journal['website'] . '';
+
+ $maidata['email'] = $cache_author['email'];
+ $maidata['title'] = "Deadline for your revision of " . $cache_journal['title'] . " -Reminder";
+ $maidata['content'] = $tt;
+ $maidata['tmail'] = $cache_journal['email'];
+ $maidata['tpassword'] = $cache_journal['epassword'];
+ Queue::push('app\api\job\mail@fire', $maidata, "tmail");
+ }
+ } else {
+ if ($cache_t == 14 || $cache_t == 21 || $cache_t == 28) {
+ //查找文章内容
+ $cache_journal = $this->journal_obj->where("journal_id", $v['journal_id'])->find();
+ //查找作者信息
+ $cache_author = $this->user_obj->where("user_id", $v['user_id'])->find();
+
+ $tt = "Dear Author,
";
+ $tt .= "We have send you the email about revision of your manuscript. According to our records you are almost reaching the deadline now. We look forward to receiving your revised article.
";
+ $tt .= "When preparing your revised manuscript, you are asked to carefully consider the reviewers' comments which are attached, and submit a revised versionand a list of responses to the comments before deadline. The revised parts in the manuscript should be highlighted with blue color.
";
+ $tt .= "If you feel that you will require more time to complete your revision, please let me know and I will update our records accordingly. If I can provide any further advice or assistance, please do not hesitate to contact me.
";
+ $tt .= 'Sincerely,
Editorial Office
' . $cache_journal['title'] . '
';
+ $tt .= 'Email: ' . $cache_journal['email'] . '
';
+ $tt .= 'Website:' . $cache_journal['website'] . '';
+
+ $maidata['email'] = $cache_author['email'];
+ $maidata['title'] = "Deadline for your revision of " . $cache_journal['title'] . " -Reminder";
+ $maidata['content'] = $tt;
+ $maidata['tmail'] = $cache_journal['email'];
+ $maidata['tpassword'] = $cache_journal['epassword'];
+ Queue::push('app\api\job\mail@fire', $maidata, "tmail");
+ }
}
}
-
}
/**
@@ -124,9 +145,9 @@ class Auto extends Controller {
Queue::push('app\api\job\review@fire', $v, "emailtest");
}
}
-
- public function testrev(){
- $a = $this->article_obj->where('article_id',261)->find();
+
+ public function testrev() {
+ $a = $this->article_obj->where('article_id', 261)->find();
// $this->checkrev($a);
}
@@ -148,29 +169,27 @@ class Auto extends Controller {
public function testmail() {
$maidata['email'] = '751475802@qq.com';
- $maidata['title'] = 'testdsdsasaddsasdaadsasd'.date('Ymd His', time());
+ $maidata['title'] = 'testdsdsasaddsasdaadsasd' . date('Ymd His', time());
$maidata['content'] = 'dsadsaas';
$maidata['tmail'] = 'tmrcancer@tmrjournals.com';
$maidata['tpassword'] = 'Wu999999tmrcance';
Queue::push('app\api\job\mail@fire', $maidata, "tmail");
}
-
- public function mytest(){
+
+ public function mytest() {
echo 'okokokook!!!!';
}
-
-
-
+
/**
* 审查文章审稿人状态,返回结果
*/
public function checkrev($data) {
die;
//查找审稿案例状态
- $rev_list = $this->reviewer_obj->where('article_id', $data['article_id'])->where('state','<>',4)->select();
- $journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find();
- $user_info = $this->user_obj->where('user_id',$data['user_id'])->find();
- $editor_info = $this->user_obj->where('user_id',$data['editor_id'])->find();
+ $rev_list = $this->reviewer_obj->where('article_id', $data['article_id'])->where('state', '<>', 4)->select();
+ $journal_info = $this->journal_obj->where('journal_id', $data['journal_id'])->find();
+ $user_info = $this->user_obj->where('user_id', $data['user_id'])->find();
+ $editor_info = $this->user_obj->where('user_id', $data['editor_id'])->find();
//分析审稿人状况
$all = count($rev_list);
$s_num = 0; //初始数量
@@ -201,7 +220,7 @@ class Auto extends Controller {
}
if ($p_num == 2) {//通过
//更新文章状态
- $this->article_obj->where('article_id', $data['article_id'])->update(['state'=>4,'editor_act'=>1]);
+ $this->article_obj->where('article_id', $data['article_id'])->update(['state' => 4, 'editor_act' => 1]);
//添加文章msg信息
$insert_data['article_id'] = $data['article_id'];
$insert_data['content'] = 'Review completed';
@@ -212,24 +231,24 @@ class Auto extends Controller {
//添加通知信息
add_usermsg($data['user_id'], 'Your manuscript has new process', '/articleDetail?id=' . $data['article_id']);
//发送邮件通知编辑
- $tt = $data['accept_sn'].'
';
- $tt .= 'Dear '.($user_info['realname']==''?'Authors':$user_info['realname']).',
';
- $tt .= 'Thank you for submitting the manuscript to '.$journal_info['title'].'.
';
- $tt .= 'Please find the new comments in the "Author Center", Please submit your revised manuscript within two weeks.
';
+ $tt = $data['accept_sn'] . '
';
+ $tt .= 'Dear ' . ($user_info['realname'] == '' ? 'Authors' : $user_info['realname']) . ',
';
+ $tt .= 'Thank you for submitting the manuscript to ' . $journal_info['title'] . '.
';
+ $tt .= 'Please find the new comments in the "Author Center", Please submit your revised manuscript within two weeks.
';
$tt .= 'If you need more time to revise, you can send E-mial to tell us.
';
$tt .= 'Sincerely,
Editorial Office
';
- $tt .= $journal_info['title'].'
';
- $tt .= 'Subscribe to this journal
';
- $tt .= 'Email: '.$journal_info['email'].'
';
- $tt .= 'Website: '.$journal_info['website'];
+ $tt .= $journal_info['title'] . '
';
+ $tt .= 'Subscribe to this journal
';
+ $tt .= 'Email: ' . $journal_info['email'] . '
';
+ $tt .= 'Website: ' . $journal_info['website'];
sendEmail($user_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
} elseif ($np_num == 2) {//不通过
//发送邮件通知编辑
- $tt = 'Reviewers final opinions on the manuscript ID'.$data['accept_sn'].' are rejection. Please login and deal with the next step of this manuscript manually.';
+ $tt = 'Reviewers final opinions on the manuscript ID' . $data['accept_sn'] . ' are rejection. Please login and deal with the next step of this manuscript manually.';
sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
} else {//一样一个增加一个审稿案例
$this->add_reviewer($data);
- return true;
+ return true;
}
} elseif ($all == 3) {
if ($s_num > 0) {//不做任何处理
@@ -237,7 +256,7 @@ class Auto extends Controller {
}
if ($p_num == 2) {//通过
//更新文章状态
- $this->article_obj->where('article_id', $data['article_id'])->update(['state'=>4,'editor_act'=>1]);
+ $this->article_obj->where('article_id', $data['article_id'])->update(['state' => 4, 'editor_act' => 1]);
//添加文章msg信息
$insert_data['article_id'] = $data['article_id'];
$insert_data['content'] = 'Review completed';
@@ -248,22 +267,21 @@ class Auto extends Controller {
//添加通知信息
add_usermsg($data['user_id'], 'Your manuscript has new process', '/articleDetail?id=' . $data['article_id']);
//发送邮件通知编辑
- $tt = $data['accept_sn'].'
';
- $tt .= 'Dear '.($user_info['realname']==''?'Authors':$user_info['realname']).',
';
- $tt .= 'Thank you for submitting the manuscript to '.$journal_info['title'].'.
';
- $tt .= 'Please find the new comments in the "Author Center", Please submit your revised manuscript within two weeks.
';
+ $tt = $data['accept_sn'] . '
';
+ $tt .= 'Dear ' . ($user_info['realname'] == '' ? 'Authors' : $user_info['realname']) . ',
';
+ $tt .= 'Thank you for submitting the manuscript to ' . $journal_info['title'] . '.
';
+ $tt .= 'Please find the new comments in the "Author Center", Please submit your revised manuscript within two weeks.
';
$tt .= 'If you need more time to revise, you can send E-mial to tell us.
';
$tt .= 'Sincerely,
Editorial Office
';
- $tt .= $journal_info['title'].'
';
- $tt .= 'Subscribe to this journal
';
- $tt .= 'Email: '.$journal_info['email'].'
';
- $tt .= 'Website: '.$journal_info['website'];
+ $tt .= $journal_info['title'] . '
';
+ $tt .= 'Subscribe to this journal
';
+ $tt .= 'Email: ' . $journal_info['email'] . '
';
+ $tt .= 'Website: ' . $journal_info['website'];
sendEmail($user_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
} else {//不通过
//发送邮件通知编辑
- $tt = 'Reviewers final opinions on the manuscript ID'.$data['accept_sn'].' are rejection. Please login and deal with the next step of this manuscript manually.';
+ $tt = 'Reviewers final opinions on the manuscript ID' . $data['accept_sn'] . ' are rejection. Please login and deal with the next step of this manuscript manually.';
sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
-
}
}
}
@@ -342,17 +360,16 @@ class Auto extends Controller {
public function chose_reviewer($article) {
//筛选符合期刊
$rev_list = $this->rev_to_jour_obj->where('journal_id', $article['journal_id'])->column('reviewer_id');
- $fie_list = $this->reviewer_info_obj->where('major',$article['major_id'])->column('reviewer_id');
+ $fie_list = $this->reviewer_info_obj->where('major', $article['major_id'])->column('reviewer_id');
$u_list = $this->user_obj
- ->where('user_id',['in',$rev_list],['in',$fie_list])//审核人属于某期刊,并且属于某个领域
- ->where('rtime','<',time() - 3600 * 24 * 15)//审核人间隔时间
- ->order('rs_num desc')->select();
+ ->where('user_id', ['in', $rev_list], ['in', $fie_list])//审核人属于某期刊,并且属于某个领域
+ ->where('rtime', '<', time() - 3600 * 24 * 15)//审核人间隔时间
+ ->order('rs_num desc')->select();
if ($u_list) {
return $u_list[0];
} else {
return null;
}
}
-
}
diff --git a/application/api/controller/Major.php b/application/api/controller/Major.php
index 5e0733e..b88077d 100644
--- a/application/api/controller/Major.php
+++ b/application/api/controller/Major.php
@@ -16,7 +16,8 @@ use think\Queue;
* @title 领域接口
* @description 领域接口
*/
-class Major extends Controller{
+class Major extends Controller {
+
protected $article_obj = '';
protected $user_obj = '';
protected $user_act_obj = '';
@@ -34,7 +35,8 @@ class Major extends Controller{
protected $chief_to_journal_obj = '';
protected $login_auto_obj = '';
protected $major_obj = "";
-
+ protected $major_to_journal_obj = '';
+ protected $sync_obj = '';
public function __construct(\think\Request $request = null) {
parent::__construct($request);
@@ -55,8 +57,10 @@ class Major extends Controller{
$this->chief_to_journal_obj = Db::name('chief_to_journal');
$this->login_auto_obj = Db::name('login_auto');
$this->major_obj = Db::name("major");
+ $this->major_to_journal_obj = Db::name('major_to_journal');
+ $this->sync_obj = Db::name("sync");
}
-
+
/**
* @title 添加领域
* @description 添加领域
@@ -70,27 +74,27 @@ class Major extends Controller{
* @param name:pid type:int require:1 desc:父级id(0代表顶级)
*
*/
- public function addMajor(){
+ public function addMajor() {
$data = $this->request->post();
$insert['major_title'] = trim($data['major_title']);
$insert['pid'] = $data['pid'];
- if(isset($data['nickname'])){
+ if (isset($data['nickname'])) {
$insert['nickname'] = trim($data['nickname']);
}
- if(isset($data['major_sort'])){
+ if (isset($data['major_sort'])) {
$insert['major_sort'] = $data['major_sort'];
}
- if($data['pid']==0){
+ if ($data['pid'] == 0) {
$insert['major_level'] = 1;
- }else{
- $p_major = $this->major_obj->where('major_id',$data['pid'])->find();
- $insert['major_level'] = $p_major['major_level']+1;
+ } else {
+ $p_major = $this->major_obj->where('major_id', $data['pid'])->find();
+ $insert['major_level'] = $p_major['major_level'] + 1;
}
$insert['major_ctime'] = time();
$this->major_obj->insert($insert);
return jsonSuccess([]);
}
-
+
/**
* @title 编辑领域
* @description 编辑领域
@@ -104,19 +108,45 @@ class Major extends Controller{
* @param name:major_sort type:int require:0 desc:权重
*
*/
- public function editMajor(){
+ public function editMajor() {
$data = $this->request->post();
$update['major_title'] = trim($data['major_title']);
- if(isset($data['nickname'])){
+ if (isset($data['nickname'])) {
$update['nickname'] = trim($data['nickname']);
}
- if(isset($data['major_sort'])){
+ if (isset($data['major_sort'])) {
$update['major_sort'] = $data['major_sort'];
}
- $this->major_obj->where("major_id",$data['major_id'])->update($update);
+ $this->major_obj->where("major_id", $data['major_id'])->update($update);
return jsonSuccess([]);
}
-
+
+ /**
+ * @title 删除大池子领域
+ * @description 删除大池子领域
+ * @author wangjinlei
+ * @url /api/Major/delMajor
+ * @method POST
+ *
+ * @param name:major_id type:int require:1 desc:领域id
+ *
+ */
+ public function delMajor() {
+ $data = $this->request->post();
+ //判断是否有子集
+ $check_child = $this->major_obj->where('pid', $data['major_id'])->where('major_state', 0)->select();
+ if ($check_child) {
+ return jsonError("存在子集不能删除");
+ }
+ //判断是否存在引用
+ $check_journal = $this->major_to_journal_obj->where('major_id', $data['major_id'])->where("mtj_state", 0)->select();
+ if ($check_journal) {
+ return jsonError("期刊存在引用,不能删除");
+ }
+ $this->major_obj->where("major_id", $data['major_id'])->update(['major_state' => 1]);
+ return jsonSuccess([]);
+ }
+
/**
* @title 获取领域树
* @description 获取领域树
@@ -126,20 +156,20 @@ class Major extends Controller{
*
* @return majors:领域树
*/
- public function getMajorList(){
+ public function getMajorList() {
//查询顶级
- $list = $this->major_obj->where('pid',0)->where('major_state',0)->order('major_sort desc')->select();
- foreach ($list as $k => $v){
+ $list = $this->major_obj->where('pid', 0)->where('major_state', 0)->order('major_sort desc')->select();
+ foreach ($list as $k => $v) {
$cache_child = $this->getMajorChild($v);
- if($cache_child!=null){
+ if ($cache_child != null) {
$list[$k]['children'] = $cache_child;
}
}
-
+
$re['majors'] = $list;
return jsonSuccess($re);
}
-
+
/**
* @title 添加期刊领域
* @description 添加期刊领域
@@ -148,30 +178,204 @@ class Major extends Controller{
* @method POST
*
* @param name:major_id type:int require:1 desc:领域id
- * @param name:jou $name Description
+ * @param name:journal_issn type:string require:1 desc:期刊issn
*
- * @return majors:领域树
*/
- public function addJournalMajor(){
+ public function addJournalMajor() {
+ $data = $this->request->post();
+ //判断major父级是否存在
+ $major_info = $this->major_obj->where('major_id', $data['major_id'])->where("major_state", 0)->find();
+ $check_major = $this->major_to_journal_obj->where('major_id', $major_info['pid'])->where('journal_issn',trim($data['journal_issn']))->where('mtj_state', 0)->find();
+ if ($major_info['pid'] != 0 && $check_major == null) {
+ return jsonError("父级必须存在");
+ }
+ //判断是否重复添加
+ $check = $this->major_to_journal_obj->where('major_id', $data['major_id'])->where('journal_issn', trim($data['journal_issn']))->where('mtj_state', 0)->find();
+ if ($check) {
+ return jsonError("重复添加");
+ }
+
+ $has = $this->major_to_journal_obj->where('major_id', $data['major_id'])->where('journal_issn', trim($data['journal_issn']))->where('mtj_state', 1)->find();
+
+ if ($has) {
+ $this->major_to_journal_obj->where('major_id', $data['major_id'])->where('journal_issn', trim($data['journal_issn']))->where('mtj_state', 1)->update(['mtj_state' => 0]);
+ } else {
+ $insert['major_id'] = $data['major_id'];
+ $insert['journal_issn'] = trim($data['journal_issn']);
+ $insert['mtj_ctime'] = time();
+ $this->major_to_journal_obj->insert($insert);
+ }
+
+ return jsonSuccess([]);
+ }
+
+ /**
+ * @title 删除期刊领域
+ * @description 删除期刊领域
+ * @author wangjinlei
+ * @url /api/Major/delJournalMajor
+ * @method POST
+ *
+ * @param name:major_id type:int require:1 desc:领域id
+ * @param name:journal_issn type:string require:1 desc:期刊issn
+ *
+ */
+ public function delJournalMajor() {
+ $data = $this->request->post();
+ //判断是否有子集
+ $check = $this->major_to_journal_obj
+ ->join("t_major","t_major.major_id = t_major_to_journal.major_id","left")
+ ->where("t_major_to_journal.journal_issn", trim($data['journal_issn']))
+ ->where("t_major_to_journal.mtj_state",0)
+ ->where("t_major.pid",$data['major_id'])
+ ->select();
+ if($check){
+ return jsonError("存在子集不能删除");
+ }
+ $this->major_to_journal_obj->where('major_id', $data['major_id'])->where('journal_issn', $data['journal_issn'])->update(['mtj_state'=> 1]);
+ return jsonSuccess([]);
+ }
+
+ /**
+ * @title 获取期刊领域树
+ * @description 获取期刊领域树
+ * @author wangjinlei
+ * @url /api/Major/getJournalMajorList
+ * @method POST
+ *
+ * @param name:journal_issn type:string require:1 desc:期刊issn号
+ *
+ * @return majors:领域信息#
+ */
+ public function getJournalMajorList() {
+ $data = $this->request->post();
+ if (!isset($data['journal_issn'])) {
+ return jsonError("参数异常");
+ }
+// $data['journal_issn'] = '2815-7125';
+ //获取主节点
+ $list = $this->major_to_journal_obj
+ ->field('t_major.*')
+ ->join("t_major", 't_major.major_id = t_major_to_journal.major_id', 'left')
+ ->where("t_major_to_journal.journal_issn", trim($data['journal_issn']))
+ ->where("t_major.pid", 0)
+ ->where("t_major_to_journal.mtj_state", 0)
+ ->select();
+ foreach ($list as $k => $v) {
+ $cache_child = $this->getJournalMajorChild($v, trim($data['journal_issn']));
+ if ($cache_child != null) {
+ $list[$k]['children'] = $cache_child;
+ }
+ }
+ $re['majors'] = $list;
+ return jsonSuccess($re);
+ }
+
+ /**
+ * @title 获取全部期刊
+ * @description 获取全部期刊
+ * @author wangjinlei
+ * @url /api/Major/getAllJournals
+ * @method POST
+ *
+ * @return journals:期刊信息#
+ */
+ public function getAllJournals() {
+ $list = $this->journal_obj->where('state', 0)->select();
+
+ $re['journals'] = $list;
+ return jsonSuccess($re);
}
+ /**
+ * @title 同步大池子数据
+ * @description 同步大池子数据
+ * @author wangjinlei
+ * @url /api/Major/synchronization
+ * @method POST
+ *
+ */
+ public function synchronization(){
+ $url = "http://journalapi.tmrjournals.com/public/index.php/master/Major/sync_all";
+ $url1 = "http://api.tmrjournals.cn/public/index.php/master/Major/sync_all";
+ $list = $this->major_obj->select();
+ myPost($url, ['majors'=> json_encode($list)]);
+ myPost($url1, ['majors'=> json_encode($list)]);
+ $this->sync_obj->where('akey',1)->update(['all_major'=> time()]);
+ return jsonSuccess([]);
+ }
+ /**
+ * @title 同步小池子数据
+ * @description 同步小池子数据
+ * @author wangjinlei
+ * @url /api/Major/synchronizationJournal
+ * @method POST
+ *
+ */
+ public function synchronizationJournal(){
+ $url = "http://journalapi.tmrjournals.com/public/index.php/master/Major/sync_journal";
+ $url1 = "http://api.tmrjournals.cn/public/index.php/master/Major/sync_journal";
+ $list = $this->major_to_journal_obj->select();
+ myPost($url, ['majors'=> json_encode($list)]);
+ myPost($url1, ['majors'=> json_encode($list)]);
+ $this->sync_obj->where('akey',1)->update(['journal_major'=> time()]);
+ return jsonSuccess([]);
+ }
+
+ /**
+ * @title 获取大池子最后同步时间
+ * @description 获取大池子最后同步时间
+ * @author wangjinlei
+ * @url /api/Major/getLastSyncTime
+ * @method POST
+ *
+ * @return sync:同步时间记录#
+ */
+ public function getLastSyncTime(){
+ $d = $this->sync_obj->where('akey',1)->find();
+ $re['sync'] = $d;
+ return jsonSuccess($re);
+ }
+
/**
* 获取领域子树
*/
- private function getMajorChild($major){
- $list = $this->major_obj->where('pid',$major['major_id'])->where('major_state',0)->order("major_sort desc")->select();
- if($list == null){
+ private function getMajorChild($major) {
+ $list = $this->major_obj->where('pid', $major['major_id'])->where('major_state', 0)->order("major_sort desc")->select();
+ if ($list == null) {
return null;
}
- foreach ($list as $k => $v){
+ foreach ($list as $k => $v) {
$cache_child = $this->getMajorChild($v);
- if($cache_child!=null){
+ if ($cache_child != null) {
$list[$k]['children'] = $cache_child;
}
}
return $list;
}
-
+
+ /**
+ * 获取期刊领域树子集
+ * @param type $major
+ * @param type $issn
+ */
+ private function getJournalMajorChild($major, $issn) {
+ $list = $this->major_to_journal_obj
+ ->field("t_major.*")
+ ->join("t_major", "t_major_to_journal.major_id=t_major.major_id", 'left')
+ ->where("pid", $major['major_id'])
+ ->where("t_major_to_journal.journal_issn", $issn)
+ ->where("t_major_to_journal.mtj_state", 0)
+ ->select();
+ foreach ($list as $k => $v) {
+ $cache_child = $this->getJournalMajorChild($v, $issn);
+ if ($cache_child != null) {
+ $list[$k]['children'] = $cache_child;
+ }
+ }
+ return $list;
+ }
+
}