request->post();
$rule = new Validate([
"password" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$password = $data['password'];
if (function_exists('openssl_random_pseudo_bytes')) {
$salt = substr(str_replace('+', '.', base64_encode(openssl_random_pseudo_bytes(6))), 0, 8);
} else {
// 使用 mt_rand 作为后备方法
$salt = '';
for ($i = 0; $i < 8; $i++) {
$salt .= chr(mt_rand(33, 126)); // 生成随机字符
}
}
$hashed_password = crypt($password, '$1$' . $salt . '$');
return jsonSuccess(["result" => $hashed_password]);
// return $hashed_password;
}
/**
* 获取文章列表(作者)
*/
/**
* @title 获取文章列表(作者)
* @description 获取文章列表(作者)
* @param name:username type:string require:1 desc:用户名
* @param name:journal type:int require:1 desc:期刊id
* @param name:state type:int require:1 desc:状态id0全部
* @param name:name type:string require:1 desc:查询条件
* @param name:pageIndex type:int require:1 desc:页码
* @param name:pageSize type:int require:1 desc:单页条数
*
* @return article:文章信息#
* @return msg:文章跟踪信息#
* @return authors:作者信息#
* @return suggest:建议信息#
* @return transfer:转投信息#
* @return transinfo:建议转投信息#
* @return major:领域信息#
*
* @author wangjinlei
* @url /api/Article/getArticle
* @method POST
*
*/
public function getArticle()
{
//接收参数
$data = $this->request->post();
//构造查询条件
$userres = $this->user_obj->where(['account' => $data['username']])->column('user_id');
$where['user_id'] = $userres[0];
$where['t_article.state'] = ['>', -1];
if ($data['journal'] != 0) {
$where['t_article.journal_id'] = $data['journal'];
}
if ($data['state'] != 0) {
$where['t_article.state'] = $data['state'];
}
if ($data['name'] != '') {
$where['t_article.title'] = array('like', "%" . $data['name'] . "%");
}
//分页查询数据
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$res = $this->article_obj->field('t_article.*,t_journal.title journalname')
->join('t_journal', 't_journal.journal_id = t_article.journal_id', 'LEFT')
->where($where)
->order('article_id desc')
->limit($limit_start, $data['pageSize'])->select();
$count = $this->article_obj->where($where)->count();
foreach ($res as $key => $val) {
//查询建议转投详情
$transfer_info = $this->article_transfer_obj
->field('t_article_transfer.*,t_journal.title jourtitle')
->join('t_journal', 't_journal.journal_id = t_article_transfer.journal_id', 'LEFT')
->where('t_article_transfer.article_id', $val['article_id'])
->where('t_article_transfer.state', 2)
->find();
$res[$key]['transinfo'] = $transfer_info;
//查询作者信息
// $res[$key]['author'] = $this->article_author_obj->where('article_id',$val['article_id'])->where('state',0)->select();
//对于接受的文章查询后续状态
$proof_state = 0;
if ($val['state'] == 5 || $val['state'] == 6) {
proofState($val['article_id']);
$p_info = $this->production_article_obj->where('article_id', $val['article_id'])->where('state', 0)->find();
if ($p_info && $p_info['proof_state'] == 1) {
$proof_state = 1;
// $res[$key]['state'] = 7;
}
}
$res[$key]['proof'] = $proof_state;
}
//返回数据
return json(['total' => $count, 'data' => $res]);
}
/**
* 获取预接收文章详情
* @return \think\response\Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getPreacceptArticleDetail()
{
$data = $this->request->post();
$rule = new Validate([
"article_id" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$article_info = $this->article_obj->where('article_id', $data['article_id'])->find();
$production_info = $this->production_article_obj->where("article_id", $article_info['article_id'])->where("state", 0)->find();
if (!$production_info) {
$this->addProductionEx($data['article_id']);
$production_info = $this->production_article_obj->where("article_id", $article_info['article_id'])->where("state", 0)->find();
}
$refers = $this->production_article_refer_obj->where('p_article_id', $production_info['p_article_id'])->where('state', 0)->select();
$re['production'] = $production_info;
$re['refers'] = $refers;
return jsonSuccess($re);
}
public function myttt()
{
$res = $this->addProductionEx("3689");
echo "
";
var_dump($res);
echo "";
die;
}
/**获取预接收内容状态
* @return void
*/
public function getPreacceptStatus()
{
$data = $this->request->post();
$rule = new Validate([
"article_id" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$article_info = $this->article_obj->where('article_id', $data['article_id'])->find();
$production_info = $this->production_article_obj->where('article_id', $article_info['article_id'])->where('state', 0)->find();
//refer状态获取
$refers = $this->production_article_refer_obj->where('p_article_id', $production_info['p_article_id'])->where('state', 0)->select();
$re_state = !(count($refers) == 0);
foreach ($refers as $v) {
if ($v['refer_doi'] == "" || $v['author'] == "") {
$re_state = false;
}
}
$refer_state['state'] = $re_state;
$refer_state['num'] = count($refers);
$re['refer_state'] = $refer_state;
return jsonSuccess($re);
}
/**接收文章
* @return void
*/
public function articleAccept()
{
$data = $this->request->post();
$rule = new Validate([
"article_id" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$article_info = $this->article_obj->where("article_id", $data['article_id'])->find();
if ($article_info['is_buy'] == 0) {
return jsonError("Unpaid");
}
$journal_info = $this->journal_obj->where("journal_id", $article_info['journal_id'])->find();
$user_info = $this->user_obj->where('user_id', $article_info['user_id'])->find();
$editor_info = $this->user_obj->where('user_id', $article_info['editor_id'])->find();
//接收后为用户增加积分
if ($journal_info['level'] == 'A') {
$score = 1;
} elseif ($journal_info['level'] == 'B') {
$score = 0.5;
} else {
$score = 0.3;
}
addUserScoreLog($user_info['user_id'], $score, "add score " . $score . " for submit article :" . $article_info['accept_sn'], time());
$this->user_obj->where('user_id', $user_info['user_id'])->setInc('score', $score);
//添加文章状态信息(如果状态未更新可做通话用,并结束操作)
$insert_data['article_id'] = $data['article_id'];
$insert_data['state_from'] = $article_info['state'];
$insert_data['state_to'] = 5;
$insert_data['ctime'] = time();
$this->article_msg_obj->insert($insert_data);
$update_data['state'] = 5;
$update_data['rtime'] = time();
$update_data['editor_act'] = 1;
$this->article_obj->where("article_id", $data['article_id'])->update($update_data);
//拒稿或者录用 - 发送审稿意见
$this->sendEmailToReviewer($data['article_id'], 5);
// $this->article_obj->where('article_id', $article_info['article_id'])->update(['rtime' => time()]);
$tt = 'Manuscript ID: ' . $article_info['accept_sn'] . '
';
$tt .= 'Manuscript Title: ' . $article_info['title'] . '
';
$tt .= 'Authors’ Name: ' . self::getArticleAuthors($article_info['article_id']) . '
';
$tt .= 'Dear Dr. ' . ($user_info['realname'] == '' ? $user_info['account'] : $user_info['realname']) . ',
It is a distinct pleasure to inform you that your manuscript has been accepted for publication in ' . $journal_info['title'] . ' (ISSN ' . $journal_info['issn'] . ').
The editor will contact you further by email soon.
';
$tt .= 'Sincerely,
Editorial Office
';
$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']);
//增加用户操作log
$log_data['user_id'] = $editor_info['user_id'];
$log_data['type'] = 1;
$log_data['content'] = $editor_info['account'] . "(" . $editor_info['realname'] . "),更改了一篇文章:(" . $article_info['title'] . ")的状态,更改时间是:" . date('Y-m-d H:i:s', time());
$log_data['ctime'] = time();
$this->user_log_obj->insert($log_data);
//增加usermsg
add_usermsg($article_info['user_id'], 'Your manuscript has new process: ' . $article_info['title'], '/articleDetail?id=' . $article_info['article_id']);
return json(['code' => 0]);
}
/**
* @title 获取文章列表(编辑)
* @description 获取文章列表(编辑)
* @param name:username type:string require:1 desc:编辑用户名
* @param name:journal type:int require:1 desc:期刊id
* @param name:state type:int require:1 desc:状态
* @param name:act type:int require:1 desc:1进行中2已完成
* @param name:sn type:string require:0 desc:流水号
* @param name:special_num type:int require:1 desc:客座num
* @param name:pageIndex type:int require:1 desc:当前页码
* @param name:pageSize type:int require:1 desc:每个页面的数据条数
*
* @return articles:文章列表#
* @return count:总数#
* @author wangjinlei
* @url /api/Article/getArticleForEditor
* @method POST
*
*/
public function getArticleForEditor()
{
//接受参数
$data = $this->request->post();
if (isset($data['sn']) && trim($data['sn']) != "") {
$where["t_article.accept_sn"] = trim($data['sn']);
$sn_info = $this->article_obj->where('accept_sn', trim($data['sn']))->find();
if (!$sn_info) {
return jsonError("Article not found");
}
$data['journal'] = $sn_info['journal_id'];
$data['state'] = $sn_info['state'];
}
//构造查询条件
if ($data['journal'] == 0) { //全部期刊
$userres = $this->user_obj->where(['account' => $data['username']])->column('user_id');
$journal_list = $this->journal_obj->where(['editor_id' => $userres[0]])->column('journal_id');
$where['t_article.journal_id'] = ['in', $journal_list];
$where_s['t_article.journal_id'] = ['in', $journal_list];
} else {
$where['t_article.journal_id'] = $data['journal'];
$where_s['t_article.journal_id'] = $data['journal'];
}
if ($data['state'] >= 0) {
$where['t_article.state'] = $data['state'];
} else {
if ($data['act'] == 1) {
$where['t_article.state'] = array('in', [0, 1, 2, 4, 6]);
} else if ($data['act'] == 2) {
$where['t_article.state'] = array('in', [3, 5]);
}
}
if ($data['name'] != '') {
$where['t_article.title'] = array('like', "%" . $data['name'] . "%");
}
if ($data['special_num'] != 0) {
$where['t_article.special_num'] = $data['special_num'];
}
//分页查询数据
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$res = $this->article_obj
->field('t_article.*,t_journal.title journalname,t_user.email,t_user.realname,t_user.phone,t_paystation.request_time pay_time,t_paystation.amount pay_mount')
->join('t_journal', 't_journal.journal_id = t_article.journal_id', 'LEFT')
->join('t_user', "t_user.user_id = t_article.user_id", 'left')
->join("t_order","t_order.article_id = t_article.article_id","left")
->join("t_paystation","t_paystation.ps_id = t_order.ps_id","left")
->where($where)
->order('t_article.article_id desc')
->limit($limit_start, $data['pageSize'])
->select();
//查询AI审核内容 chengxiaoling 20250328 start
$aAiReview = array();
if (!empty($res)) {
$aArticleId = array_column($res, 'article_id');
$aAiReview = Db::table('t_article_ai_review')->field('article_id,content')->whereIn('article_id', $aArticleId)->where('journal_scope_assessment','<>','')->column('article_id,content');
}
//查询AI审核内容 chengxiaoling 20250328 end
//增加审稿意见信息
foreach ($res as $key => $val) {
$cache_review = $this->article_reviewer_obj
->field("t_article_reviewer.*,t_article_reviewer_question.rated,t_user.realname")
->join("t_article_reviewer_question", "t_article_reviewer_question.art_rev_id = t_article_reviewer.art_rev_id", 'left')
->join("t_user", "t_user.user_id = t_article_reviewer.reviewer_id", "left")
->where("t_article_reviewer.article_id", $val['article_id'])
->where("t_article_reviewer.state", 'in', [0, 1, 2, 3])
->select();
//添加复审信息
foreach ($cache_review as $k => $v) {
$repeat = $this->article_reviewer_repeat_obj->where('art_rev_id', $v['art_rev_id'])->select();
if ($repeat) {
$last = count($repeat) - 1;
$cache_review[$k]['can_repeat'] = ($repeat[$last]['state'] == 1 && $repeat[$last]['recommend'] == 3) ? 1 : 0;
$cache_review[$k]['repeat'] = $repeat;
} else {//不存在复审实例,可添加
$cache_review[$k]['can_repeat'] = 1;
$cache_review[$k]['repeat'] = [];
}
}
$res[$key]['review'] = $cache_review;
//查询作者信息
$res[$key]['author'] = $this->article_author_obj->where('article_id', $val['article_id'])->where('state', 0)->select();
//查询H指数添加人信息
$res[$key]['H'] = $this->getHPerson($val['article_id']);
//查询文章通讯作者的账号信息
$res[$key]['reports'] = $this->getReportAuthors($val['article_id']);
$res_file = $this->article_file_obj->where("article_id", $val['article_id'])->select();
$file_frag = [];
foreach ($res_file as $v) {
$file_frag[$v['type_name']][] = $v;
}
$res[$key]['file'] = $file_frag;
//返回AI审核内容 chengxiaoling 20250328 start
$res[$key]['ai_review'] = empty($aAiReview[$val['article_id']]) ? '' : $aAiReview[$val['article_id']];
//返回AI审核内容 chengxiaoling 20250328 end
}
//添加国家信息
foreach ($res as $k => $v) {
$cache_author_list = $this->article_author_obj->where('article_id', $v['article_id'])->where("state", 0)->select();
$cache_country = [];
foreach ($cache_author_list as $key => $val) {
if ($val['country'] != '' && !in_array($val['country'], $cache_country)) {
$cache_country[] = $val['country'];
}
}
$res[$k]['countrys'] = $cache_country;
}
//增加邮件历史记录
foreach ($res as $k => $v) {
$cache = $this->email_log_obj->where('article_id', $v['article_id'])->where('is_success', 1)->select();
$res[$k]['emailh'] = $cache ? 1 : 0;
}
//添加各个状态下文章的数量
$state_num = $this->article_obj->field("t_article.state,count(*) as num")->where($where_s)->group("state")->select();
foreach ($state_num as $item) {
$num_arr[$item['state']] = $item['num'];
}
for ($i = 0; $i <= 8; $i++) {
$num_frag[$i] = isset($num_arr[$i]) ? $num_arr[$i] : 0;
}
$count = $this->article_obj->where($where)->count();
return json(['total' => $count, 'data' => $res, "state_num" => $num_frag]);
}
private function getReportAuthors($article_id)
{
$article_info = $this->article_obj->where('article_id', $article_id)->find();
$authors = $this->article_author_obj->where('article_id', $article_id)->where('is_report', 1)->where('state', 0)->select();
foreach ($authors as $k => $v) {
$c_user = $this->user_obj->where('email', $v['email'])->find();
$authors[$k]['author_account'] = $c_user;
}
return $authors;
}
private function getHPerson($article_id)
{
$article_info = $this->article_obj->where('article_id', $article_id)->find();
$authors = $this->article_author_obj->where('article_id', $article_id)->where('is_report', 1)->where('state', 0)->select();
$user_id = $article_info['user_id'];
$g_index = 0;
foreach ($authors as $v) {
$c_user = $this->user_obj->where('email', $v['email'])->find();
if ($c_user['google_index'] >= $g_index) {
$user_id = $c_user['user_id'];
$g_index = $c_user['google_index'];
}
}
$user_info = $this->user_obj->where('user_id', $user_id)->find();
return $user_info;
}
/**
* 获取文章的用户详情
*/
public function getArticleUserDetail()
{
$data = $this->request->post();
$rule = new Validate([
'article_id' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$article_info = $this->article_obj->where('article_id', $data['article_id'])->find();
$user_info = $this->user_obj->where('user_id', $article_info['user_id'])->find();
$re['userDetail'] = $user_info;
return jsonSuccess($re);
}
/**
* @title 获取文章详情(作者,编辑)
* @description 获取文章详情(作者,编辑)
* @param name:articleId type:int require:1 desc:文章id
* @param name:human type:string require:1 desc:editor/author
*
* @return article:文章信息#
* @return msg:文章跟踪信息#
* @return authors:作者信息#
* @return suggest:建议信息#
* @return transfer:转投信息#
* @return transinfo:建议转投信息#
* @return major:领域信息#
*
* @author wangjinlei
* @url /api/Article/getArticleDetail
* @method POST
*
*/
public function getArticleDetail()
{
$data = $this->request->post();
//查询文章基础数据
$where['t_article.article_id'] = $data['articleId'];
$article_res = $this->article_obj->field('t_article.*,t_journal.title journalname,t_user.account')->join(array(['t_journal', 't_journal.journal_id = t_article.journal_id', 'LEFT'], ['t_user', 't_user.user_id = t_article.user_id', 'LEFT']))->where($where)->find();
//查询文章状态跟踪信息
$article_msg = $this->article_msg_obj->where(['article_id' => $data['articleId']])->where('state', 0)->select();
//查询审稿人审稿建议
// $suggest = $this->article_reviewer_obj->field('t_article_reviewer.*,t_article_reviewer_question.qu9_contents,t_article_reviewer_question.qu10_contents,t_article_reviewer_question.qu11_contents,t_article_reviewer_question.qu12_contents,t_article_reviewer_question.qu13_contents,t_article_reviewer_question.qu14_contents,t_article_reviewer_question.qu15_contents,t_article_reviewer_question.comments comments')
// ->join('t_article_reviewer_question', 't_article_reviewer.art_rev_id=t_article_reviewer_question.art_rev_id', 'left')
// ->where('t_article_reviewer.state', '<', 4)
// ->where('t_article_reviewer.state', '>', 0)
// ->where('t_article_reviewer.article_id', $article_res['article_id'])
// ->select();
$suggest = $this->article_reviewer_obj->where("state", "in", [1, 2, 3])->where('article_id', $article_res['article_id'])->select();
foreach ($suggest as $k => $v) {
$fr = [];
$c = $this->article_reviewer_question_obj->where('art_rev_id', $v['art_rev_id'])->find();
$fr[] = $c;
$f = $this->article_reviewer_repeat_obj->where('art_rev_id', $v['art_rev_id'])->select();
foreach ($f as $val) {
$fr[] = $val;
}
$suggest[$k]['question'] = $fr;
}
// foreach ($suggest as $k => $v){
// $ca = $this->article_reviewer_repeat_obj->where('art_rev_id',$v['art_rev_id'])->select();
// $suggest[$k]['repeats'] = $ca;
// }
$major = $this->getMajorStr($article_res['major_id']);
$majors = $this->major_to_article_obj->where("article_id", $data['articleId'])->where("state", 0)->select();
foreach ($majors as $k => $v) {
$majors[$k]["major"] = getMajorShu($v['major_id']);
$majors[$k]['str'] = getMajorStr($v['major_id']);
}
$article_res['majors'] = $majors;
//查询文章作者信息
$author_res = $this->article_author_obj->where('article_id', $data['articleId'])->where('state', 0)->select();
//查询作者scopus chengxiaoling 20260924 start
if(!empty($author_res)){
$aEmail = array_unique(array_column($author_res, 'email'));
$aWhere = ['email' => ['in',$aEmail]];
$aUserData = Db::name('user')->field('user_id,email,scopus_index,scopus_website,google_index,wos_index')->where($aWhere)->select();
$aUserData = empty($aUserData) ? [] : array_column($aUserData, null,'email');
foreach ($author_res as $key => $value) {
$aUserInfo = empty($aUserData[$value['email']]) ? [] : $aUserData[$value['email']];
$author_res[$key]['scopus_index'] = isset($aUserInfo['scopus_index']) ? $aUserInfo['scopus_index'] : '';
$author_res[$key]['scopus_website'] = empty($aUserInfo['scopus_website']) ? '' : $aUserInfo['scopus_website'];
$author_res[$key]['google_index'] = isset($aUserInfo['google_index']) ? $aUserInfo['google_index'] : '';
$author_res[$key]['wos_index'] = isset($aUserInfo['wos_index']) ? $aUserInfo['wos_index'] : '';
$author_res[$key]['user_id'] = empty($aUserInfo['user_id']) ? 0 : $aUserInfo['user_id'];
}
}
//查询作者scopus chengxiaoling 20260924 end
//查询转投信息
$transfer_res = $this->article_transfer_obj->where('article_id', $data['articleId'])->select();
//查询建议转投详情
$transfer_info = $this->article_transfer_obj
->field('t_article_transfer.*,t_journal.title jourtitle')
->join('t_journal', 't_journal.journal_id = t_article_transfer.journal_id', 'LEFT')
->where('t_article_transfer.article_id', $data['articleId'])
->where('t_article_transfer.state', 2)
->find();
//更新文章操作记录状态
if ($data['human'] == 'editor') {
$up_data['author_act'] = 0;
} else {
$up_data['editor_act'] = 0;
}
$this->article_obj->where('article_id', $data['articleId'])->update($up_data);
//查询终审意见 chengxiaoling 20250828 start
$aFinal = [];
$iArticleId = empty($data['articleId']) ? 0 : $data['articleId'];
if(!empty($iArticleId)){
$aWhere = ['article_id' => $iArticleId,'state' => ['between',[1,3]]];
$aFinal = Db::name('article_reviewer_final')->where($aWhere)->select();
if(!empty($aFinal)){
//数据处理
foreach ($aFinal as $key => $value) {
$aFinal[$key]['review_time'] = empty($value['review_time']) ? '' : date('Y-m-d H:i:s',$value['review_time']);
}
}
}
//查询终审意见 chengxiaoling 20250828 end
return json(['article' => $article_res, 'msg' => $article_msg, 'authors' => $author_res, 'suggest' => $suggest, 'transfer' => $transfer_res, 'transinfo' => $transfer_info, "major" => $major,'suggest_final' => $aFinal]);
}
/**
* 作者同意转投
*/
public function trans_manu()
{
//接受参数
$data = $this->request->post();
$article_info = $this->article_obj->where('article_id', $data['article_id'])->find();
$journal_info = $this->journal_obj->where('journal_id', $data['journal_id'])->find();
$editor_info = $this->user_obj->where('user_id', $journal_info['editor_id'])->find();
//更新文章状态
$this->article_obj->where('article_id', $data['article_id'])->update(['journal_id' => $data['journal_id'], 'editor_id' => $journal_info['editor_id'], 'author_act' => 1, 'state' => 1]);
//跟新转投表状态
$this->article_transfer_obj->where('transfer_id', $data['transfer_id'])->update(['state' => 1]);
//添加文章状态信息
$insert_data['article_id'] = $data['article_id'];
$insert_data['content'] = 'manuscript transfer to :' . $journal_info['title'];
$insert_data['state_from'] = $article_info['state'];
$insert_data['state_to'] = 1;
$insert_data['ctime'] = time();
$this->article_msg_obj->insert($insert_data);
//发送邮件提醒编辑有新的转投稿件
$tt1 = 'Dear editor';
$tt1 .= 'Please check the new transfer manuscript in the submission system. sn'.$article_info['accept_sn'];
sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt1, $journal_info['email'], $journal_info['epassword']);
//发送消息给编辑
add_usermsg($journal_info['editor_id'], 'New transfer manuscript ', '/articleDetailEditor?id=' . $article_info['article_id']);
return json(['code' => 0]);
}
/**
* @title 作者拒绝转投
* @description 作者拒绝转投
* @param name:transfer_id type:int require:1 desc:转投id
*
* @author wangjinlei
* @url /api/Article/trans_manu_no
* @method POST
*
*/
public function trans_manu_no()
{
$data = $this->request->post();
//跟新转投表状态
$this->article_transfer_obj->where('transfer_id', $data['transfer_id'])->update(['state' => 1]);
//提醒编辑作者拒绝了转投,email
return jsonSuccess([]);
}
/**
* 修改文章详情(作者)
*/
public function editArticle()
{
//接受参数查询信息
$data = $this->request->post();
$username = $data['username'];
$user_res = $this->user_obj->where(['account' => $username])->find();
$article_old_info = $this->article_obj->where('article_id', $data['articleId'])->find();
//判断简介字符串长度是否不低于200 chengxiaoling 20250327 start
if (!$this->checkMinChars($data['abstrart'], 200)) {
return jsonError("The abstract should not be less than 200 Chinese characters or English words!");
}
//判断简介字符串长度是否不低于200 chengxiaoling 20250327 end
Db::startTrans();
//更新文章信息
$inset_data['keywords'] = $data['keyWords'];
$inset_data['fund'] = $data['fund'];
$inset_data['abstrart'] = $data['abstrart'];
$inset_data['author_act'] = 1;
$inset_data['state'] = $article_old_info['accept_sn'] == '' ? 0 : 1;
$where['article_id'] = $data['articleId'];
$up_res = $this->article_obj->where($where)->update($inset_data);
$article_info = $this->article_obj->where($where)->find();
$journal_info = $this->journal_obj->where("journal_id", $article_info["journal_id"])->find();
//更新作者信息
$aids = [];
foreach ($data['authorList'] as $v) {
if (isset($v['art_aut_id'])) { //改
$up['art_aut_id'] = $aids[] = $v['art_aut_id'];
$up['firstname'] = $v['firstname'];
$up['lastname'] = $v['lastname'];
$up['company'] = $v['company'];
$up['department'] = $v['department'];
$up['author_title'] = $v['title'];
$up['country'] = $v['country'];
$up['email'] = $v['email'];
$up['address'] = $v['address'];
$up['is_super'] = $v['isSuper'] == 'true' ? 1 : 0;
$up['is_report'] = $v['isReport'] == 'true' ? 1 : 0;
$this->article_author_obj->update($up);
} else { //增
if ($v['firstname'] == '') {
continue;
}
$ins['article_id'] = $data['articleId'];
$ins['firstname'] = $v['firstname'];
$ins['lastname'] = $v['lastname'];
$ins['company'] = $v['company'];
$ins['department'] = $v['department'];
$ins['author_title'] = $v['title'];
$ins['country'] = $v['country'];
$ins['email'] = $v['email'];
$ins['address'] = $v['address'];
$ins['is_super'] = $v['isSuper'] == 'true' ? 1 : 0;
$ins['is_report'] = $v['isReport'] == 'true' ? 1 : 0;
$aids[] = $this->article_author_obj->insertGetId($ins);
}
}
//删
$this->article_author_obj->where('article_id', $data['articleId'])->where('art_aut_id', 'not in', $aids)->update(['state' => 1]);
//增加article_msg
$insmsg_data['article_id'] = $data['articleId'];
$insmsg_data['content'] = '';
$insmsg_data['state_from'] = $article_old_info['state'];
$insmsg_data['state_to'] = $article_old_info['accept_sn'] == '' ? 0 : 1;
$insmsg_data['ctime'] = time();
$msg_res = $this->article_msg_obj->insert($insmsg_data);
//发送邮件
$journal_info = $this->journal_obj->where('journal_id', $article_old_info['journal_id'])->find();
$editor_info = $this->user_obj->where('user_id', $journal_info['editor_id'])->find();
$tt = 'Dear editor,
';
$tt .= 'The author changed the manuscript’s status, please check.
';
$tt .= 'TMR Publishing Group';
// $sendUser=[
// 'title'=> $journal_info['title'], // 邮件标题
// 'content'=>$tt,//邮件内容
// 'user_id'=>$user_res['user_id'], //收件人ID
// 'email'=>$editor_info['email'],// 收件人邮箱
// 'journal_id'=>$journal_info['journal_id'], // 期刊ID
// 'sendEmail'=>$journal_info['email'], // 期刊邮箱
// 'sendPassword'=>$journal_info['epassword'], // 期刊密码
// 'from_name'=>$journal_info['title']
// ];
// Queue::push('app\api\job\domail@fire',$sendUser,'domail');
sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
//记录历史file信息
$res1 = self::save_article_file($data['articleId'], $user_res['user_id'], $user_res['account'], $data['coverLetter'], 'coverLetter');
$res2 = true;
if (isset($data['picturesAndTables'])) {
foreach ($data['picturesAndTables'] as $v) {
$res2 = $res2 ? self::save_article_file($data['articleId'], $user_res['user_id'], $user_res['account'], $v, 'picturesAndTables') : false;
}
}
// self::save_article_file($data['articleId'], $user_res['user_id'], $user_res['account'], $data['picturesAndTables'], 'picturesAndTables');
$res3 = self::save_article_file($data['articleId'], $user_res['user_id'], $user_res['account'], $data['manuscirpt'], 'manuscirpt');
$res4 = self::save_article_file($data['articleId'], $user_res['user_id'], $user_res['account'], $data['totalpage'], 'totalpage');
//增加用户操作log
$log_data['user_id'] = $article_info['user_id'];
$log_data['type'] = 1;
$log_data['content'] = $data['username'] . "(" . $user_res['realname'] . "),修改了一篇文章:" . $article_info['title'] . ",时间是:" . date('Y-m-d H:i:s', time());
$log_data['ctime'] = time();
$log_res = $this->user_log_obj->insert($log_data);
//增加usermsg
$umsg_res = add_usermsg($journal_info['editor_id'], 'The manuscript has new process: ' . $article_info['title'], '/articleDetailEditor?id=' . $article_info['article_id']);
if ($up_res && $msg_res && $res1 && $res2 && $res3 && $res4 && $log_res && $umsg_res) {
Db::commit();
return json(['code' => 0]);
} else {
Db::rollback();
return json(['code' => 1]);
}
}
/**获取关联作者的信息
* @return \think\response\Json|void
*/
public function getRelationAuthor()
{
$data = $this->request->post();
$rule = new Validate([
"user_id" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$user_info = $this->user_obj->where("user_id", $data['user_id'])->find();
$authors = $this->article_obj->field("t_article_author.*")->join("t_article_author", "t_article_author.article_id = t_article.article_id", "left")
->where("t_article.user_id", $data['user_id'])->where("t_article_author.state", 0)
->order("t_article_author.email,t_article_author.art_aut_id")->select();
//查询作者机构 20251031 start
$cache_author = [];
if(!empty($authors)){
//查询作者机构
$aAutId = array_column($authors, 'art_aut_id');
$aWhere = ['art_aut_id' => ['in',$aAutId],'state' => 0];
$aAuthorOrganId = Db::name('article_author_organ')->field('art_aut_id,organ_id')->where($aWhere)->select();
if(!empty($aAuthorOrganId)){
//查询机构名称
$aOragnId = array_unique(array_column($aAuthorOrganId, 'organ_id'));
$aWhere = ['state' => 0,'organ_id' => ['in',$aOragnId]];
$aOragn = Db::name('article_organ')->where($aWhere)->column('organ_id,organ_name');
$aAuthorOrgan = [];
foreach ($aAuthorOrganId as $key => $value) {
if(empty($aOragn[$value['organ_id']])){
continue;
}
$aAuthorOrgan[$value['art_aut_id']][] = ['organ_id' => $value['organ_id'],'organ_name' => $aOragn[$value['organ_id']]];
}
}
foreach ($authors as $key => $value) {
if (empty($value['email'])) {
continue;
}
$value['organ_id'] = empty($aAuthorOrgan[$value['art_aut_id']]) ? [] : array_column($aAuthorOrgan[$value['art_aut_id']], 'organ_id');
$value['organ_name'] = empty($aAuthorOrgan[$value['art_aut_id']]) ? [] : array_column($aAuthorOrgan[$value['art_aut_id']], 'organ_name');
$cache_author[$value['email']][] = $value;
}
}
$authors = [];
foreach ($cache_author as $k => $v) {
$c = [];
$c['email'] = $k;
foreach ($v as $value) {
if ($value['firstname'] != "") {
$c['firstname'] = $value['firstname'];
}
if ($value['lastname'] != "") {
$c['lastname'] = $value['lastname'];
}
if ($value['company'] != "") {
$c['company'] = $value['company'];
}
if ($value['department'] != "") {
$c['department'] = $value['department'];
}
if ($value['author_title'] != "") {
$c['author_title'] = $value['author_title'];
}
if ($value['country'] != "") {
$c['country'] = $value['country'];
}
if ($value['address'] != "") {
$c['address'] = $value['address'];
}
}
$c['organ_id'] = empty($value['organ_id']) ? [] : $value['organ_id'];
$c['organ_name'] = empty($value['organ_name']) ? [] : $value['organ_name'];
$authors[] = $c;
}
$re['authors'] = $authors;
return jsonSuccess($re);
}
/**通过邮件地址获取相关作者信息
* @return void
*/
public function getRelationAuthorByEmail()
{
$data = $this->request->post();
$rule = new Validate([
"email" => "require",
"page" => "require",
"limit" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$es = explode("@", $data['email']);
if ($es == "") {
return jsonError("Email error");
}
$emails = $this->article_author_obj->field("email")->where("email", "like", "%" . $data['email'] . "%")->where('state', 0)->group("email")->page($data['page'], $data['limit'])->select();
$count = $this->article_author_obj->field("email")->where("email", "like", "%" . $data['email'] . "%")->where('state', 0)->group("email")->count();
$authors = [];
foreach ($emails as $v) {
$c = [];
$c['email'] = $v['email'];
$cl = $this->article_author_obj->where("email", $v['email'])->where('state', 0)->select();
foreach ($cl as $value) {
// if ($value['firstname'] != "") {
$c['firstname'] = empty($value['firstname']) ? '' : $value['firstname'];
// }
// if ($value['lastname'] != "") {
$c['lastname'] = empty($value['lastname']) ? '' : $value['lastname'];
// }
// if ($value['company'] != "") {
$c['company'] = empty($value['company']) ? '' : $value['company'];
// }
// if ($value['department'] != "") {
$c['department'] = empty($value['department']) ? '' : $value['department'];
// }
// if ($value['author_title'] != "") {
$c['author_title'] = empty($value['author_title']) ? '' : $value['author_title'];
// }
// if ($value['country'] != "") {
$c['country'] = empty($value['country']) ? '' : $value['country'];
// }
// if ($value['address'] != "") {
$c['address'] = empty($value['address']) ? '' : $value['address'];
// }
}
$authors[] = $c;
}
$re['authors'] = $authors;
$re['count'] = $count;
return jsonSuccess($re);
}
/**
* 获取全部作者反馈审稿人文件列表
*/
public function getArticleResponseFiles()
{
$data = $this->request->post();
$rule = new Validate([
'article_id' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$list = $this->article_response_to_reviewer_obj->where('article_id', $data['article_id'])->where('artr_state', 0)->select();
$re['files'] = $list;
return jsonSuccess($re);
}
public function getAllCompany()
{
$companys = $this->company_top_obj->select();
$re['companys'] = $companys;
return jsonSuccess($re);
}
/**
* @title 修回文章
* @description 修回文章
* @param name:username type:string require:1 desc:作者账号名
* @param name:articleId type:int require:1 desc:文章id
* @param name:picturesAndTables type:string require:1 desc:Figures
* @param name:manuscirpt type:string require:1 desc:文章文件
* @param name:responseFile type:string require:0 desc:作者反馈审稿人文件
*
* @author wangjinlei
* @url /api/Article/RepairBack
* @method POST
*
*/
public function RepairBack()
{
$data = $this->request->post();
$rule = new Validate([
"username" => "require",
"articleId" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$username = $data['username'];
$user_res = $this->user_obj->where(['account' => $username])->find();
$article_old_info = $this->article_obj->where('article_id', $data['articleId'])->find();
Db::startTrans();
$inset_data['author_act'] = 1;
$inset_data['state'] = 1;
$where['article_id'] = $data['articleId'];
//更新文章用户最新操作状态 chengxiaoling start 20251113
$inset_data['is_user_act'] = 1;
$inset_data['user_update_time'] = time();
//更新文章用户最新操作状态 chengxiaoling end 20251113
$up_res = $this->article_obj->where($where)->update($inset_data);
//更新文章用户最新操作状态 chengxiaoling start 20251113
$iArticleId = empty($data['articleId']) ? 0 : $data['articleId'];
if(!empty($iArticleId)){
//用户操作日志
$oUserActLog = new \app\common\UserActLog;
$aUserLog = ['article_id' => $iArticleId,'type' => 4,'act_id' => $iArticleId,'user_id' => empty($user_res['user_id'] )? 0 : $user_res['user_id'],'content' => 'Retired author resubmits manuscript'];
$aAddResult = $oUserActLog->addLog($aUserLog);
}
//更新文章用户最新操作状态 chengxiaoling end 20251113
$article_info = $this->article_obj->where($where)->find();
$journal_info = $this->journal_obj->where("journal_id", $article_info["journal_id"])->find();
//增加article_msg
$insmsg_data['article_id'] = $data['articleId'];
$insmsg_data['content'] = '';
$insmsg_data['state_from'] = $article_old_info['state'];
$insmsg_data['state_to'] = 1;
$insmsg_data['ctime'] = time();
$msg_res = $this->article_msg_obj->insert($insmsg_data);
//发送邮件
$editor_info = $this->user_obj->where('user_id', $journal_info['editor_id'])->find();
$tt = 'Dear editor,
';
$tt .= 'The author has repair, please check. SN:'.$article_info['accept_sn'].'
';
$tt .= 'TMR Publishing Group';
sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
$res2 = self::save_article_file($data['articleId'], $user_res['user_id'], $user_res['account'], $data['picturesAndTables'], 'picturesAndTables');
$res3 = self::save_article_file($data['articleId'], $user_res['user_id'], $user_res['account'], $data['manuscirpt'], 'manuscirpt');
$res4 = self::save_article_file($data['articleId'], $user_res['user_id'], $user_res['account'], $data['supplementary'], 'supplementary');
//作者反馈审稿人信息文件
$res_response = true;
if (isset($data['responseFile']) && $data['responseFile'] != '') {
$insert_response['article_id'] = $data['articleId'];
$insert_response['file_url'] = $data['responseFile'];
$insert_response['artr_ctime'] = time();
$res_response = $this->article_response_to_reviewer_obj->insert($insert_response);
}
//增加用户操作log
$log_data['user_id'] = $article_info['user_id'];
$log_data['type'] = 1;
$log_data['content'] = $data['username'] . "(" . $user_res['realname'] . "),修改了一篇文章:" . $article_info['title'] . ",时间是:" . date('Y-m-d H:i:s', time());
$log_data['ctime'] = time();
$log_res = $this->user_log_obj->insert($log_data);
//增加usermsg
$umsg_res = add_usermsg($journal_info['editor_id'], 'The manuscript has new process: ' . $article_info['title'], '/articleDetailEditor?id=' . $article_info['article_id']);
if ($msg_res && $res2 && $res3 && $res4 && $log_res && $umsg_res && $res_response) {
Db::commit();
return json(['code' => 0]);
} else {
Db::rollback();
return jsonError("system error!");
}
}
/**
* @title 发送留言板消息
* @description 发送留言板消息
* @param name:article_id type:int require:1 desc:文章id
* @param name:username type:String require:1 desc:发送者用户名
* @param name:ad_content type:String require:1 desc:内容
*
* @author wangjinlei
* @url /api/Article/pushArticleDialog
* @method POST
*
*/
public function pushArticleDialog()
{
$data = $this->request->post();
$user_info = $this->user_obj->where('account', $data['username'])->find();
$insert['article_id'] = $data['article_id'];
$insert['user_id'] = $user_info['user_id'];
$insert['ad_content'] = trim($data['ad_content']);
$insert['ad_ctime'] = time();
$iId = $this->article_dialog_obj->insertGetId($insert);
//留言红点提示并邮件
$this->messageTips($data['article_id'], $user_info['user_id'],$iId);
return jsonSuccess([]);
}
/**
* @title 获取留言板消息列表
* @description 获取留言板消息列表
* @param name:article_id type:int require:1 desc:文章id
*
* @return dialogs:消息列表@
* @dialogs ad_id:主键 article_id:文章id user_id:用户id username:用户名 ad_content:消息 ad_time:时间 ad_state:状态
*
* @author wangjinlei
* @url /api/Article/getArticleDialogs
* @method POST
*
*/
public function getArticleDialogs()
{
$data = $this->request->post();
$list = $this->article_dialog_obj
->field("t_article_dialog.*,t_user.account username")
->join("t_user", "t_user.user_id = t_article_dialog.user_id", "left")
->where("t_article_dialog.article_id", $data['article_id'])
->where('t_article_dialog.ad_state', 0)
->select();
$re['dialogs'] = $list;
return jsonSuccess($re);
}
/**
* @title 添加修回页修回意见(编辑)
* @description 添加修回页修回意见(编辑)
* @param name:article_id type:int require:1 desc:文章id
* @param name:proposal_file type:String require:1 desc:文件地址
*
* @author wangjinlei
* @url /api/Article/addArticleProposal
* @method POST
*
*/
public function addArticleProposal()
{
$data = $this->request->post();
$insert['article_id'] = $data['article_id'];
$insert['proposal_file'] = trim($data['proposal_file']);
$insert['ap_ctime'] = time();
$this->article_proposal_obj->insert($insert);
return jsonSuccess([]);
}
/**
* @title 获取修回页修回意见列表
* @description 获取修回页修回意见列表
* @param name:article_id type:int require:1 desc:文章id
*
* @return proposals:意见列表@
* @proposals proposal_id:主键 proposal_file:文件地址 ap_ctime:添加时间
* @author wangjinlei
* @url /api/Article/getArticleProposals
* @method POST
*
*/
public function getArticleProposals()
{
$data = $this->request->post();
$list = $this->article_proposal_obj->where('article_id', $data['article_id'])->where('ap_state', 0)->select();
$re['proposals'] = $list;
return jsonSuccess($re);
}
/**获取用户所投的文章
* @return \think\response\Json|void
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getArticlesByArticle()
{
$data = $this->request->post();
$rule = new Validate([
"article_id" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$article_info = $this->article_obj->where('article_id', $data['article_id'])->find();
$list = $this->article_obj->field("t_article.*,t_journal.title journal_title")->join("t_journal", "t_journal.journal_id = t_article.journal_id", "left")->where("t_article.user_id", $article_info['user_id'])->select();
$re['user_articles'] = $list;
$authors = $this->article_author_obj->where('article_id', $data['article_id'])->where('state', 0)->select();
foreach ($authors as $k => $v) {
if ($v['email'] != "" && $v['email'] != "empty") {
$as = $this->article_obj->field("t_article.*,t_journal.title journal_title")->join("t_article_author", "t_article.article_id = t_article_author.article_id", "left")->join("t_journal", "t_journal.journal_id = t_article.journal_id", "left")->where("t_article.article_id", "<>", $data['article_id'])->where("t_article_author.state", 0)->where("t_article_author.email", $v['email'])->select();
} else {
$as = null;
}
$authors[$k]["articles"] = $as;
}
$re['author_articles'] = $authors;
return jsonSuccess($re);
}
/**
* 修改文章的作者(作者)
*/
public function saveAuthor()
{
$data = $this->request->post();
$article_info = $this->article_obj->where('article_id', $data['articleId'])->find();
//更新作者(增删改)
$aids = [];
foreach ($data['authorList'] as $v) {
if (isset($v['art_aut_id'])) { //改
$up['art_aut_id'] = $aids[] = $v['art_aut_id'];
$up['author'] = $v['author'];
$up['company'] = $v['company'];
$up['email'] = $v['email'];
$up['address'] = $v['address'];
$up['is_super'] = $v['is_super'] == 'true' ? 1 : 0;
$up['is_report'] = $v['is_report'] == 'true' ? 1 : 0;
$this->article_author_obj->update($up);
} else { //增
if ($v['author'] == '') {
continue;
}
$ins['author'] = $v['author'];
$ins['article_id'] = $data['articleId'];
$ins['company'] = $v['company'];
$ins['email'] = $v['email'];
$ins['address'] = $v['address'];
$ins['is_super'] = $v['is_super'] == 'true' ? 1 : 0;
$ins['is_report'] = $v['is_report'] == 'true' ? 1 : 0;
$aids[] = $this->article_author_obj->insertGetId($ins);
}
}
//删
$this->article_author_obj->where('article_id', $data['articleId'])->where('art_aut_id', 'not in', $aids)->update(['state' => 1]);
//更新文章操作状态
$this->article_obj->where('article_id', $data['articleId'])->update(['author_act' => 1]);
//发送邮件通知编辑
$journal_info = $this->journal_obj->where('journal_id', $article_info['journal_id'])->find();
$editor_info = $this->user_obj->where('user_id', $journal_info['editor_id'])->find();
// $journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
$tt = 'Dear editor,
';
$tt .= 'The author changed the manuscript’s information, please check.';
$sendUser = [
'title' => $journal_info['title'], // 邮件标题
'content' => $tt, //邮件内容
'user_id' => $editor_info['user_id'], //收件人ID
'email' => $editor_info['email'], // 收件人邮箱
'journal_id' => $journal_info['journal_id'], // 期刊ID
'sendEmail' => $journal_info['email'], // 期刊邮箱
'sendPassword' => $journal_info['epassword'], // 期刊密码
'from_name' => $journal_info['title']
];
// Queue::push('app\api\job\domail@fire',$sendUser,'domail');
sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
//添加usermsg
add_usermsg($journal_info['editor_id'], 'Manuscript authors be changed,please contact the author to confirm.', 'articleDetailEditor?id=' . $data['articleId']);
return json(['code' => 0]);
}
public function checkArticleStart()
{
$data = $this->request->post();
$rule = new Validate([
"article_id" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$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();
if ($article_info['scoring'] < $journal_info['kfen']) {
return jsonError("The initial review score for " . $journal_info['title'] . " is " . $journal_info['kfen'] . ". The current article's initial review score is " . $article_info['scoring'] . ", and the manuscript will be automatically rejected while it is in the with editor status.");
} else {
return jsonSuccess([]);
}
}
/**
* @title 修改文章状态(编辑)
* @description 修改文章状态(编辑)
* @param name:editname type:String require:1 desc:编辑名字
* @param name:articleId type:int require:1 desc:文章id
* @param name:state type:int require:1 desc:状态代码
* @param name:editormsg type:String require:1 desc:携带的消息(以后会废除)
* @param name:trsjournal type:int require:0 desc:转投期刊id(拒稿时候是必传,不推荐转投的为0)
* @param name:proposal_content type:string require:0 desc:退修编辑意见文件
*
*
* @author wangjinlei
* @url /api/Article/editArticleEditor
* @method POST
*
*/
public function editArticleEditor()
{
//接受参数,查询信息
$data = $this->request->post();
$where_editor['account'] = $data['editname'];
$editor_info = $this->user_obj->where($where_editor)->find();
$where_article['article_id'] = $data['articleId'];
$article_info = $this->article_obj->where($where_article)->find();
$journal_info = $this->journal_obj->where('journal_id', $article_info['journal_id'])->find();
$transfer_list = $this->article_transfer_obj->where('article_id', $data['articleId'])->where('state', 0)->select();
$user_info = $this->user_obj->where(['user_id' => $article_info['user_id']])->find();
$user_rev_info = $this->user_reviewer_info_obj->where("reviewer_id", $user_info['user_id'])->find();
//防止编辑误操作其他期刊的文章
if ($editor_info['user_id'] != $journal_info['editor_id']) {
return jsonError("insufficient privilege");
}
//接收或拒绝文章后不可再更改文章状态
if ($article_info['state'] == 5 || $article_info['state'] == 3) {
return jsonError("Status cannot be changed");
}
//终审判断[3个审稿人审稿意见为:同意/1个审稿人审稿意见为:不同意] chengxiaoling 20250825 start
if(isset($data['state']) && $data['state'] == 8){
if($article_info['state'] != 1){
return jsonError("The article status is not with editor");
}
$iId = empty($data['articleId']) ? 0 : $data['articleId'];//文章ID
if(empty($iId)){
return jsonError("Please select an article");
}
//判断是否有审稿记录
$aReviewerParam = ['article_id' => $iId,'state' => ['between',[1,3]]];
$aReviewLists = Db::name('article_reviewer')->where($aReviewerParam)->column('state');
if(empty($aReviewLists)){
return jsonError("Reviewer did not conduct a review");
}
//判断审稿记录是否有拒稿
if(!in_array(2, $aReviewLists)){//拒稿
if(count($aReviewLists) < 2){
return jsonError("The number of reviewers is less than 2");
}
}
//更新文章状态
$aWhere = ['article_id' => $iId,'state' => 1];
$sUpateResult = $this->article_obj->where($aWhere)->limit(1)->update(['state' => 8]);
if($sUpateResult === false){
return jsonError("Status update failed");
}
//添加文章状态信息(如果状态未更新可做通话用,并结束操作)
$insert_data['article_id'] = $iId;
$insert_data['content'] = 'final decision';
$insert_data['state_from'] = $article_info['state'];
$insert_data['state_to'] = 8;
$insert_data['ctime'] = time();
if(!$this->article_msg_obj->insert($insert_data)){
return jsonError("article_msg insertion failed");
}
//增加用户操作log
$iEditorId = empty($editor_info['user_id']) ? 0 : $editor_info['user_id'];
$sEditorAccount = empty($editor_info['account']) ? '' : $editor_info['account'];
$sRealName = empty($editor_info['realname']) ? '' : $editor_info['realname'];
$sTitle = empty($article_info['title']) ? '' : $article_info['title'];
$iArticleUserId = empty($article_info['user_id']) ? 0 : $article_info['user_id'];
$log_data['user_id'] = $iEditorId;
$log_data['type'] = 1;
$log_data['content'] = $sEditorAccount . "(" . $sRealName . "),更改了一篇文章:(" . $sTitle . ")的状态,更改时间是:" . date('Y-m-d H:i:s', time());
$log_data['ctime'] = time();
$this->user_log_obj->insert($log_data);
//增加usermsg
add_usermsg($iArticleUserId, 'Your manuscript has new process: ' . $sTitle, '/articleDetail?id=' . $iId);
//发送邮件
$aEmailResult = $this->sendEmailForAuthor(['article' => $article_info,'user' => $user_info,'journal' => $journal_info]);
return json(['code' => 0]);
}
//终审判断[3个审稿人审稿意见为:同意/1个审稿人审稿意见为:不同意] chengxiaoling 20250825 end
//判断文章的h指数是否添加
$authors = $this->article_author_obj->where('article_id', $data['articleId'])->where('is_report', 1)->select();
// $h_check = false;
// foreach ($authors as $v) {
// $cache_report = $this->user_obj->where('email', $v['email'])->find();
// if ($cache_report == null || $article_info['state'] != 0 || $cache_report['google_time'] != 0 ||$cache_report['g_author']!=""|| $cache_report['google_index'] != 0 || $data['state'] == 3) {
// $h_check = true;
// break;
// }
// }
// if ($article_info['state'] == 0 && $authors && $h_check == false) {
// return jsonError('Please complete the H-index before proceeding');
// }
//初审分数不够,自动拒稿
if ($article_info['state'] == 0 && $data['state'] != 0 && $article_info['type'] != 'N' && $article_info['type'] != 'T') {
// if (($journal_info['journal_id'] == 1 && $article_info['scoring'] < 4) || (($journal_info['journal_id'] == 10 || $journal_info['journal_id'] == 23) && $article_info['scoring'] < 3) || ($journal_info['journal_id'] == 21 && $article_info['scoring'] < 0) || (($journal_info['journal_id'] == 16||$journal_info['journal_id'] == 6||$journal_info['journal_id'] == 12) && $article_info['scoring'] < 2) || ($journal_info['journal_id'] != 1 && $journal_info['journal_id'] != 6 && $journal_info['journal_id'] != 16 && $journal_info['journal_id'] != 12 && $journal_info['journal_id'] != 10 && $journal_info['journal_id'] != 21 && $journal_info['journal_id'] != 23 && $article_info['scoring'] < 1)) {
if ($article_info['scoring'] < $journal_info['kfen']) {//触发拒稿
if (count($transfer_list) > 0) {//如果有共同投稿
//查询转投期刊信息
$transfer_journal = $this->journal_obj->where('journal_id', $transfer_list[0]['journal_id'])->find();
//转投
$this->article_obj->where('article_id', $data['articleId'])->update(['state' => 0, 'journal_id' => $transfer_list[0]['journal_id'], 'author_act' => 1, 'editor_id' => $transfer_journal['editor_id']]);
//转投信息表信息状态改变
$this->article_transfer_obj->where('transfer_id', $transfer_list[0]['transfer_id'])->update(['state' => 1]);
//查找转投journal信息
$tran_journal = $this->journal_obj->where('journal_id', $transfer_list[0]['journal_id'])->find();
//转投后的作者信息
$trans_editor_info = $this->user_obj->where('user_id', $transfer_journal['editor_id'])->find();
//添加文章状态信息
$insert_data['article_id'] = $data['articleId'];
$insert_data['content'] = 'manuscript transfer to :' . $tran_journal['title'];
$insert_data['state_from'] = $article_info['state'];
$insert_data['state_to'] = 0;
$insert_data['ctime'] = time();
$this->article_msg_obj->insert($insert_data);
$user_rev_info = $this->user_reviewer_info_obj->where("reviewer_id", $user_info['user_id'])->find();
//发送邮件提醒转投给作者
$tt = '"' . $article_info['title'] . '"
';
$tt .= $article_info['accept_sn'] . '
';
$tt .= 'journal:' . $journal_info['title'] . '
';
$tt .= 'Dear Dr. ' . ($user_info['realname'] == '' ? $user_info['account'] : $user_info['realname']) . ',
';
$tt .= "Thank you for submitting your manuscript to " . $journal_info['title'] . ". After a thorough initial review by our editorial team, we regret to inform you that we are unable to move forwardwith your submission for further consideration.
";
$tt .= "Please know that this decision was made with careful deliberation,and we appreciate the effort and time you have invested in yourresearch. We encourage you to consider submitting your work to a journal that may be a better fit for your manuscript.
";
$tt .= "We sincerely thank you for considering " . $journal_info['title'] . " as a venue for your work, and we hope this outcome does not deter you fromsubmitting future manuscripts to our journal.
";
// $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,
";
$tt .= 'Editorial Office
';
$tt .= $journal_info['title'] . '
';
$tt .= 'Subscribe to this journal
';
$tt .= 'Email: ' . $journal_info['email'] . '
';
$tt .= 'Website: ' . $tran_journal['website'];
sendEmail($user_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
//发送邮件提醒编辑有新的转投稿件
$tt1 = 'Dear editor';
$tt1 .= 'Please check the new transfer manuscript in the submission system.sn'.$article_info['accept_sn'];
sendEmail($trans_editor_info['email'], $journal_info['title'], $journal_info['title'], $tt1, $journal_info['email'], $journal_info['epassword']);
//增加usermsg
add_usermsg($tran_journal['editor_id'], 'New transfer manuscript ', '/articleDetailEditor?id=' . $article_info['article_id']);
return json(['code' => 0]);
} else {//无共同投稿的情况下
$this->article_obj->where('article_id', $article_info['article_id'])->update(['state' => 3]);
$tt = '"' . $article_info['title'] . '"
';
$tt .= $article_info['accept_sn'] . '
';
$tt .= 'journal:' . $journal_info['title'] . '
';
$tt .= 'Dear Dr. ' . ($user_info['realname'] == '' ? $user_info['account'] : $user_info['realname']) . ',
';
$tt .= 'Thank you for submitting your paper to ' . $journal_info['title'] . '.
';
$tt .= 'Unfortunately the editors feel that ' . $journal_info['title'] . ' is not the appropriate venue for your manuscript,'
. ' and we are returning your manuscript to you so that you can submit it to another journal without delay. '
. '
Yours sincerely,
';
$tt .= 'Sincerely,
Editorial Office
';
$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']);
//添加文章状态信息(如果状态未更新可做通话用,并结束操作)
$insert_dataj['article_id'] = $data['articleId'];
$insert_dataj['state_from'] = $article_info['state'];
$insert_dataj['state_to'] = 3;
$insert_dataj['ctime'] = time();
$this->article_msg_obj->insert($insert_dataj);
return jsonSuccess([]);
}
}
}
//执行文章各方面相关的操作
if ($data['state'] == 3 && count($transfer_list) > 0) {//如果是拒稿。并且有共同投稿
//查询转投期刊信息
$transfer_journal = $this->journal_obj->where('journal_id', $transfer_list[0]['journal_id'])->find();
//转投
$this->article_obj->where('article_id', $data['articleId'])->update(['state' => 1, 'journal_id' => $transfer_list[0]['journal_id'], 'author_act' => 1, 'editor_id' => $transfer_journal['editor_id']]);
//转投信息表信息状态改变
$this->article_transfer_obj->where('transfer_id', $transfer_list[0]['transfer_id'])->update(['state' => 1]);
//查找转投journal信息
$tran_journal = $this->journal_obj->where('journal_id', $transfer_list[0]['journal_id'])->find();
//转投后的作者信息
$trans_editor_info = $this->user_obj->where('user_id', $transfer_journal['editor_id'])->find();
//添加文章状态信息
$insert_data['article_id'] = $data['articleId'];
$insert_data['content'] = 'manuscript transfer to :' . $tran_journal['title'];
$insert_data['state_from'] = $article_info['state'];
$insert_data['state_to'] = 1;
$insert_data['ctime'] = time();
$this->article_msg_obj->insert($insert_data);
$user_rev_info = $this->user_reviewer_info_obj->where("reviewer_id", $user_info['user_id'])->find();
//发送邮件提醒转投给作者
$tt = '"' . $article_info['title'] . '"
';
$tt .= $article_info['accept_sn'] . '
';
$tt .= 'journal:' . $journal_info['title'] . '
';
$tt .= 'Dear Dr. ' . ($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 platform for your manuscript. You manuscript 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'] . '
';
$tt .= 'Website: ' . $tran_journal['website'];
sendEmail($user_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
//发送邮件提醒编辑有新的转投稿件
$tt1 = 'Dear editor';
$tt1 .= 'Please check the new transfer manuscript in the submission system.sn'.$article_info['accept_sn'];
sendEmail($trans_editor_info['email'], $journal_info['title'], $journal_info['title'], $tt1, $journal_info['email'], $journal_info['epassword']);
//增加usermsg
add_usermsg($tran_journal['editor_id'], 'New transfer manuscript ', '/articleDetailEditor?id=' . $article_info['article_id']);
return json(['code' => 0]);
} else {//其他状态下的流程操作
//接收文章,必须有两个及以上的大于40个字的对作者的评论,除去news和comment类型的文章
if ($data['state'] == 6 && $article_info['type'] != "N" && $article_info['type'] != "T" && $article_info['type'] != "LTE" && $article_info['journal_id'] != 21) {
//定义符合条件的数量
$rev_real_num = 0;
//获取通过的审稿意见数,必须大于两个
$rev_list = $this->article_reviewer_obj
->field('t_article_reviewer_question.*')
->join("t_article_reviewer_question", 't_article_reviewer_question.art_rev_id = t_article_reviewer.art_rev_id', 'left')
->where('t_article_reviewer.article_id', $article_info['article_id'])
->where('t_article_reviewer.state', 'in', [1, 3])
->select();
$rev_list_t = $this->article_reviewer_obj
->field('t_article_reviewer_question.*')
->join("t_article_reviewer_question", 't_article_reviewer_question.art_rev_id = t_article_reviewer.art_rev_id', 'left')
->where('t_article_reviewer.article_id', $article_info['article_id'])
->where('t_article_reviewer.state', 2)
->select();
foreach ($rev_list as $v) {
$content = $v['qu9_contents'] . " " . $v['qu10_contents'] . " " . $v['qu11_contents'] . " " . $v['qu12_contents'] . " " . $v['qu13_contents'] . " " . $v['qu14_contents'] . " " . $v['qu15_contents'] . " " . $v['comments'];
if (preg_match('/[\x{4e00}-\x{9fa5}]/u', $content) > 0) { //含有中文
if (mb_strlen($content, 'UTF8') >= 60) {
$rev_real_num++;
}
} else { //不含中文
$carray = explode(" ", $content);
if (count($carray) >= 40) {
$rev_real_num++;
}
}
}
if ($rev_real_num < 2 && $rev_real_num > count($rev_list_t)) {
return json(['code' => 1, 'msg' => "Before proceeding to the next step, you need more than two available reviewer comments, and the total number of accept is greater than the total number of rejected."]);
}
}
//接收必须查重小于20%
if ($data['state'] == 6 && $article_info['repetition'] > 25) {
return jsonError("Submissions with a repetition rate greater than thirty percent will not be accepted");
}
//预接收有时间限定必须大于14天
if ($data["state"] == 6 && ($article_info['ctime'] + 3600 * 24 * 14) > time()) {
return jsonError("The receiving time must be greater than 14 days");
}
//接收后为用户增加积分
// if ($data['state'] == 5) {
// if ($journal_info['level'] == 'A') {
// $score = 1;
// } elseif ($journal_info['level'] == 'B') {
// $score = 0.5;
// } else {
// $score = 0.3;
// }
// addUserScoreLog($user_info['user_id'], $score, "add score " . $score . " for submit article :" . $article_info['accept_sn'], time());
// $this->user_obj->where('user_id', $user_info['user_id'])->setInc('score', $score);
// }
//添加文章状态信息(如果状态未更新可做通话用,并结束操作)
$insert_data['article_id'] = $data['articleId'];
$insert_data['content'] = $data['editormsg'];
$insert_data['state_from'] = $article_info['state'];
$insert_data['state_to'] = $data['state'];
$insert_data['ctime'] = time();
$this->article_msg_obj->insert($insert_data);
if ($article_info['state'] == $data['state']) {
$this->article_obj->where($where_article)->update(['editor_act' => 1]);
return json(['code' => 0]);
}
$update_data['state'] = $data['state'];
$update_data['editor_act'] = 1;
//更新文章状态
if ($data['state'] == 4) {
$update_data['ttime'] = time();
//退休状态,添加退修时编辑的意见
if (isset($data['proposal_content']) && $data['proposal_content'] != '') { //存在这个修回的文件
$insert_proposal['article_id'] = $data['articleId'];
$insert_proposal['proposal_content'] = trim($data['proposal_content']);
$insert_proposal['ap_ctime'] = time();
$this->article_proposal_obj->insert($insert_proposal);
}
}
if ($data['state'] == 3) {
$update_data['rstime'] = time();
}
$this->article_obj->where($where_article)->update($update_data);
//拒稿或者录用 - 发送审稿意见
if ($article_info['journal_id'] == 1 && ($data['state'] == 3 || $data['state'] == 5)) {
$this->sendEmailToReviewer($data['articleId'], $data['state']);
}
//为预接收的文章生成production实例
if ($data['state'] == 6) {
$this->addProductionEx($data['articleId']);
$this->addArticleMainEx($data['articleId']);
//处理缴费相关信息
if($journal_info['fee']==0){
$this->article_obj->where("article_id", $article_info['article_id'])->update(["is_buy" => 1]);
}else{
$this->article_obj->where("article_id", $article_info['article_id'])->update(["fee" => $journal_info['fee']]);
}
// if ($journal_info['fee'] == 0 || $article_info['ctime'] < 1735660800) {
// $this->article_obj->where("article_id", $article_info['article_id'])->update(["is_buy" => 1]);
// }
}
}
//发送文章状态更改邮件给作者
if ($data['state'] == 3) { //拒稿
if ($data['trsjournal'] == 0) {
//直接拒稿
$review_msg_has = $this->article_msg_obj->where("article_id", $article_info['article_id'])->where("state_to", 2)->find();
$tx_msg_has = $this->article_msg_obj->where("article_id", $article_info['article_id'])->where("state_to", 4)->find();
if ($review_msg_has && $tx_msg_has) {
$tt = 'Dear Dr. ' . ($user_info['realname'] == "" ? $user_info['account'] : $user_info['realname']) . '
';
$tt .= "Thank you for submitting your manuscript to " . $journal_info['title'] . ". We appreciate the time and effort you invested in revising your manuscript in response to the reviewers' comments.
";
$tt .= "After a thorough evaluation of the revised manuscript, including further feedback from our external reviewers, we regret to inform you that your manuscript has not been accepted for publication in our journal. While your revisions addressed many of the reviewers' concerns, there remain significant issues that prevent us from moving forward with publication.
";
$tt .= "We recognize that this decision is disappointing, especially given the effort you have put into this work. We encourage you to consider the reviewers' feedback as you continue to develop your manuscript for submission to another journal.
";
$tt .= "Thank you for considering " . $journal_info['title'] . " for your research. We wish you success in your future academic endeavors and hope that you will consider us again for future submissions.
";
$tt .= "Sincerely,
";
$tt .= 'Editorial Office
';
} elseif ($review_msg_has) {
$tt = 'Dear Dr. ' . ($user_info['realname'] == "" ? $user_info['account'] : $user_info['realname']) . '
';
$tt .= "Thank you for submitting your manuscript to " . $journal_info['title'] . ". After a thorough initial review by our editorial team, we regret to inform you that we are unable to move forwardwith your submission for further consideration.
";
$tt .= "Please know that this decision was made with careful deliberation,and we appreciate the effort and time you have invested in yourresearch. We encourage you to consider submitting your work to a journal that may be a better fit for your manuscript.
";
$tt .= "We sincerely thank you for considering " . $journal_info['title'] . " as a platform for your work, and we hope this outcome does not deter you from submitting future manuscripts to our journal.
";
$tt .= "Sincerely,
";
$tt .= 'Editorial Office
';
} else {
$tt = '"' . $article_info['title'] . '"
';
$tt .= $article_info['accept_sn'] . '
';
$tt .= 'journal:' . $journal_info['title'] . '
';
$tt .= 'Dear Dr. ' . ($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,'
. ' and we are returning your manuscript to you so that you can submit it to another journal without delay. '
. '
Yours sincerely,
';
$tt .= 'Sincerely,
Editorial Office
';
}
} else { //转投
//查找转投journal信息
$trans_journal = $this->journal_obj->where('journal_id', $data['trsjournal'])->find();
$tt = 'Dear Dr. ' . ($user_info['realname'] == "" ? $user_info['account'] : $user_info['realname']) . '
';
$tt .= 'Thank you very much for submitting your manuscript "' . $article_info['title'] . '" (' . $article_info['accept_sn'] . '). We had read your paper discussed it with our editorial team. Unfortunately, our opinion is that the paper would not be a strong candidate for ' . $journal_info['title'] . '. When a paper is turned down on editorial grounds, we aim to return it to the authors as quickly as possible, avoiding a time-consuming peer-review process.
';
$tt .= 'Nevertheless, thank you for giving us the opportunity to consider your work. I am sorry that we cannot be more positive on this occasion and hope you are soon able to find an alternative journal. Although we cannot offer to publish your paper in ' . $journal_info['title'] . ', the work may be appropriate for another journal in the TMR Publishing Group.
';
$tt .= 'I have asked the editor of ' . $trans_journal['title'] . ' (' . $trans_journal['website'] . '), and there is a good chance that your manuscript will be published there. If you wish to transfer your manuscript to a journal of your choice, please click on the agree button in the Submission System, you will not have to re-supply manuscript metadata and files.
';
$tt .= 'Yours Sincerely,
';
$tt .= $journal_info['title'] . ' | Editorial Office
';
}
} else if ($data['state'] == 5) { //录用
//录用后更新录用时间
$this->article_obj->where('article_id', $article_info['article_id'])->update(['rtime' => time()]);
$tt = 'Manuscript ID: ' . $article_info['accept_sn'] . '
';
$tt .= 'Manuscript Title: ' . $article_info['title'] . '
';
$tt .= 'Authors’ Name: ' . self::getArticleAuthors($article_info['article_id']) . '
';
$tt .= 'Dear Dr. ' . ($user_info['realname'] == '' ? $user_info['account'] : $user_info['realname']) . ',
It is a distinct pleasure to inform you that your manuscript has been accepted for publication in ' . $journal_info['title'] . ' (ISSN ' . $journal_info['issn'] . ').
The editor will contact you further by email soon.
';
$tt .= 'Sincerely,
Editorial Office
';
} else if ($data['state'] == 4) { //退修
$tt = $article_info['accept_sn'] . "——" . $article_info['title'] . "
";
$tt .= 'Dear Dr.
';
$tt .= "Thank you for submitting the manuscript to " . $journal_info['title'] . ".
";
$tt .= "The reviewers have given professional comments and suggestions on your manuscript which you can find in the Author Center. Please submit your revised manuscript within two weeks in the manuscript central. And please mark all modification in blue and reply the reviewer's comments one by one.
";
$tt .= "If you need more time or you have any other plans for this manuscript, please feel free to e-mail us in time.
";
$tt .= "Before submitting the revised manuscript, please check and complete the following items. If you want see more matters, please find the attached Manuscript Checklist.
";
$tt .= "1.Author Information:
";
$tt .= "(1)Each address,especially corresponding author’s address must be complete and include, at a minimum, the institution name, street number, district, city, postal code, and country. For example, School of Basic Medical Science, Tianjin Medical University, No. 22, Qixiangtai Road, Heping District, Tianjin 301617, China.
";
$tt .= "2.Article Information
";
$tt .= "(1)“Funding support” has been declared. If there is funding support, please add the fund name and number.
";
$tt .= "(2)“Abbreviations” has been listed in the following format: MD, Mean Difference; SMD, Standardized Mean Difference; …….
";
$tt .= "3.Table and Figure
";
$tt .= "(1)Table: Using three-line tables with title and headings.
";
$tt .= "(2)Figure: at least 300 dpi in TIFF format.
";
$tt .= "4.References
";
$tt .= "(1)The order of numbering is consecutive and will be contingent on the order in which you use that reference within your paper.
";
$tt .= "(2)All information of references are available, such as year, volume, page and URL.
";
$tt .= "(3)All reference has written in the standard format, for example,
";
$tt .= "1.Beurel E, Toups M, Nemeroff CB. The Bidirectional Relationship of Depression and Inflammation: Double Trouble. Neuron 2020;107(2):234–256. Available at:
http://doi.org/10.1016/j.neuron.2020.06.002
";
$tt .= "(4)Please ensure that every reference includes a DOI. Promptly remove or replace any references that lack a DOI.
";
} else if ($data['state'] == 6) { //终审
// $tt = 'Dear Dr. ' . ($user_info['realname'] == '' ? $user_info['account'] : $user_info['realname']) . ',
';
// $tt .= 'Manuscript status: Your manuscript "' . $article_info['title'] . '" is under reviewing by editorial member team of ' . $journal_info['title'] . '.';
$tt = $article_info['accept_sn'] . "——" . $article_info['title'] . "
";
$tt .= 'Dear Dr. ' . ($user_info['realname'] == '' ? $user_info['account'] : $user_info['realname']) . ',
';
$tt .= "We are delighted to inform you that your manuscript titled " . $article_info['title'] . " has been pre-accepted for publication in " . $journal_info['title'] . ". Congratulations!
";
$tt .= 'As per our publication requirements, as well as to ensure a smooth publication process, we kindly request you to log in to the "Author Center" and follow the instructions provided to complete the necessary information for your manuscript.
';
$tt .= "Please find below the steps to access your pre-accepted manuscript:
";
$tt .= "1. Please log in using your credentials at https://submission.tmrjournals.com.
";
$tt .= "2. Please find your pre-accepted manuscript list in the menu “My Manuscript” on the left.
";
$tt .= "3. Please click on the “Enter Pre-accept Process” to proceed.
";
$tt .= "If you encounter any difficulties or have any questions, please do not hesitate to contact our editorial team at " . $journal_info['title'] . ". Welcome your new excellent work!
";
} else {
$tt = '"' . $article_info['title'] . '"
';
$tt .= $article_info['accept_sn'] . '
';
$tt .= 'journal:' . $journal_info['title'] . '
';
$tt .= 'Dear Dr. ' . ($user_info['realname'] == '' ? $user_info['account'] : $user_info['realname']) . ',
Please check the new status of your manuscript online.
';
}
$tt .= $journal_info['title'] . '
';
$tt .= 'Subscribe to this journal
';
$tt .= 'Email: ' . $journal_info['email'] . '
';
$tt .= 'Website: ' . $journal_info['website'];
if ($data['state'] == 4) {
sendEmail($user_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword'], ROOT_PATH . 'public' . DS . 'system' . DS . 'Checklist_new.docx');
//给通讯作者也要发送
$authors = $this->article_author_obj->where("article_id", $article_info['article_id'])->where("state", 0)->where("is_report", 1)->select();
foreach ($authors as $vv) {
sendEmail($vv['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword'], ROOT_PATH . 'public' . DS . 'system' . DS . 'Checklist_new.docx');
}
} else {
sendEmail($user_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
}
// if ($data['state'] == 6) { //进入终审,通知主编邮件
// $chiefs = $this->chief_to_journal_obj->join('t_user', 't_user.user_id = t_chief_to_journal.user_id', 'left')->where('t_chief_to_journal.journal_id', $journal_info['journal_id'])->where('t_chief_to_journal.state', 0)->select();
// foreach ($chiefs as $v) {
// $tts = 'Dear Dr. ' . ($v['realname'] == '' ? $v['account'] : $v['realname']) . ',
';
// $tts .= 'The manuscript entitled “' . $article_info['title'] . '” has been peer-reviewed, revised and about to be published in ' . $journal_info['title'] . '.
';
// $tts .= 'If you want to review this article, you could use it Submission System (Plese click here).
';
// $tts .= 'Your username: ' . $v['account'] . '
';
// $tts .= 'Password: 123456qwe (Original password)
';
// $tts .= 'If you are unable to review it now, you may provide your comments at a later time at your convenience. Then ,there is no need to reply to this email.
';
// $tts .= 'Any comments you make will be valued by the editorial board. Please bring into our knowledge if there is any potential Conflict of Interest.
';
// $tts .= 'Sincerely,
Editorial Office
' . $journal_info['title'] . '
';
// $tts .= 'Email: ' . $journal_info['email'] . '
';
// $tts .= 'Website:' . $journal_info['website'] . '';
// $sendUser['user_id'] = $v['user_id'];
// $sendUser['email'] = $v['email'];
// $sendUser['content'] = $tts;
// // Queue::push('app\api\job\domail@fire',$sendUser,'domail');
// sendEmail($v['email'], $journal_info['title'], $journal_info['title'], $tts, $journal_info['email'], $journal_info['epassword']);
// }
// }
//转投操作
if ($data['trsjournal'] != 0) {
$tran_data['article_id'] = $data['articleId'];
$tran_data['journal_id'] = $data['trsjournal'];
$tran_data['ctime'] = time();
$tran_data['state'] = 2;
$this->article_transfer_obj->insert($tran_data);
}
//增加用户操作log
$log_data['user_id'] = $editor_info['user_id'];
$log_data['type'] = 1;
$log_data['content'] = $editor_info['account'] . "(" . $editor_info['realname'] . "),更改了一篇文章:(" . $article_info['title'] . ")的状态,更改时间是:" . date('Y-m-d H:i:s', time());
$log_data['ctime'] = time();
$this->user_log_obj->insert($log_data);
//增加usermsg
add_usermsg($article_info['user_id'], 'Your manuscript has new process: ' . $article_info['title'], '/articleDetail?id=' . $article_info['article_id']);
//文章状态修改为送审中时触发自动推荐审稿人 chengxiaoling 20250617 start
if ($data['state'] == 2) {
$iArticleId = empty($article_info['article_id']) ? 0 : $article_info['article_id'];
if (!empty($iArticleId)) {
$iSeconds = 180;//3分钟后执行
Queue::later($iSeconds, 'app\api\job\RecommendReviewer@fire', ['article_id' => $iArticleId], 'RecommendReviewer');
}
}
//文章状态修改为送审中时触发自动推荐审稿人 chengxiaoling 20250617 end
//文章状态修改为退修状态 给同意审稿但一直未审稿人发送邮件且扣减其分数值 chengxiaoling 20250617 start
if ($data['state'] == 4) {
$iArticleId = empty($article_info['article_id']) ? 0 : $article_info['article_id'];
if (!empty($iArticleId)) {
$iSeconds = 180;//三分钟后执行
Queue::later($iSeconds, 'app\api\job\RevisionReviewer@fire', ['article_id' => $iArticleId], 'RevisionReviewer');
}
}
//文章状态修改为退修状态 给同意审稿但一直未审稿人发送邮件且扣减其分数值 chengxiaoling 20250617 end
//文章状态修改为预接收 对作者提交的稿件内容进行校对 chengxiaoling 20251013 start
if ($data['state'] == 6) {
$iArticleId = empty($article_info['article_id']) ? 0 : $article_info['article_id'];
if (!empty($iArticleId)) {
$iSeconds = 120;//两分钟后执行
Queue::later($iSeconds,'app\api\job\ArticleProofRead@fire',['article_id' => $iArticleId], 'ArticleProofRead');
}
}
//文章状态修改为预接收 对作者提交的稿件内容进行校对 chengxiaoling 20251013 end
//重新计算审稿人的审稿质量 chengxiaoling start 0416
$this->reviewQuality($article_info['article_id']);
//重新计算审稿人的审稿质量 chengxiaoling end 0416
return json(['code' => 0]);
}
/**获取拒绝文章列表
* @return void
*/
public function getRejectArticles()
{
$data = $this->request->post();
$rule = new Validate([
"pageIndex" => "require",
"pageSize" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$list = $this->article_obj->where('state', 3)->page($data['pageIndex'], $data['pageSize'])->order('article_id desc')->select();
foreach ($list as $key => $val) {
$list[$key]['author'] = $this->article_author_obj->where('article_id', $val['article_id'])->where('state', 0)->select();
$list[$key]['user'] = $this->user_obj->where('user_id', $val['user_id'])->find();
}
$count = $this->article_obj->where('state', 3)->count();
$re['articles'] = $list;
$re['count'] = $count;
return jsonSuccess($re);
}
public function authorClear()
{
$author = "Ying Chen1 *,Shi-yi Tao2,Lu Zhou2,De-shuang Yang2,Chong-xiang Xue1 #,Li Huang3 #";
}
// public function emailtest()
// {
// $v = $this->user_obj->where('user_id', 54)->find();
// $journal_info = $this->journal_obj->where('journal_id', 1)->find();
// $trans_journal = $this->journal_obj->where('journal_id', 5)->find();
// $article_info = $this->article_obj->where('article_id', 1058)->find();
// $tts = 'Dear Dr. ' . ($v['realname'] == '' ? $v['account'] : $v['realname']) . ',
';
// $tts .= 'The manuscript entitled “' . $article_info['title'] . '” has been peer-reviewed, revised and about to be published in ' . $journal_info['title'] . '.
';
// $tts .= 'If you want to review this article, you could use it Submission System (Plese click here).
';
// $tts .= 'Your username: ' . $v['account'] . '
';
// $tts .= 'Password: 123456qwe (Original password)
';
// $tts .= 'If you are unable to review it now, you may provide your comments at a later time at your convenience. Then ,there is no need to reply to this email.
';
// $tts .= 'Any comments you make will be valued by the editorial board. Please bring into our knowledge if there is any potential Conflict of Interest.
';
// $tts .= 'Sincerely,
Editorial Office
' . $journal_info['title'] . '
';
// $tts .= 'Email: ' . $journal_info['email'] . '
';
// $tts .= 'Website:' . $journal_info['website'] . '';
// $sendReviewer = [
// 'title' => 'Your contribution is greatly appreciated', // 邮件标题
// 'content' => $tts, //邮件内容
// 'user_id' => $v['user_id'], //收件人ID
// 'email' => $v['email'], // 收件人邮箱
// 'journal_id' => $journal_info['journal_id'], // 期刊ID
// 'sendEmail' => $journal_info['email'], // 期刊邮箱
// 'sendPassword' => $journal_info['epassword'], // 期刊密码
// 'from_name' => $journal_info['title'],
// ];
// // Queue::push('app\api\job\domail@fire',$sendReviewer,'domail');
// $res = sendEmail($v['email'], $journal_info['title'], $journal_info['title'], $tts, $journal_info['email'], $journal_info['epassword']);
// dump($res);
// }
private function creatLoginUrlForChief($user, $article_id)
{
$code = md5(time() . rand(1000, 9999) . 'thinkphp');
$insert['user_id'] = $user['user_id'];
$insert['code'] = $code;
$insert['ctime'] = time();
$this->login_auto_obj->insert($insert);
$url = 'https://submission.tmrjournals.com/man_text?Art_id=' . $article_id . '&act=' . $code;
return $url;
}
public function creatLoginUrlForreviewer($user, $article_id)
{
$code = md5(time() . rand(1000, 9999) . 'thinkphp');
$insert['user_id'] = $user['user_id'];
$insert['code'] = $code;
$insert['ctime'] = time();
$this->login_auto_obj->insert($insert);
$url = 'https://submission.tmrjournals.com/per_text?Art_id=' . $article_id . '&act=' . $code;
return $url;
}
public function creatRejectUrlForReviewer($user, $article_id)
{
$code = md5(time() . rand(1000, 9999) . 'thinkphp');
$insert['user_id'] = $user['user_id'];
$insert['code'] = $code;
$insert['ctime'] = time();
$this->login_auto_obj->insert($insert);
$url = 'https://submission.tmrjournals.com/per_text_fail?Art_id=' . $article_id . '&act=' . $code;
return $url;
}
/**
* @title 获取期刊by领域
* @description 获取期刊by领域
* @param name:major_id type:int require:1 desc:领域id
*
* @return journals:期刊列表#
* @author wangjinlei
* @url /api/Article/getJournalsByMajor
* @method POST
*
*/
public function getJournalsByMajor()
{
$data = $this->request->post();
// $data['major_id'] = 60;
$list = $this->major_to_journal_obj
->field("t_journal.*")
->join("t_journal", "t_journal.issn = t_major_to_journal.journal_issn", "left")
->where("t_major_to_journal.major_id", $data['major_id'])
->where('t_major_to_journal.mtj_state', 0)
->where("t_journal.state", 0)
->select();
$re['journals'] = $list;
return jsonSuccess($re);
}
/**
* 编辑文章备注
*/
public function editArticleRemark()
{
//接受参数
$data = $this->request->post();
$this->article_obj->where('article_id', $data['articleId'])->update(['remarks' => $data['content']]);
return json(['code' => 0]);
}
/**
* @title 更改重复率(编辑)
* @description 更改重复率(编辑)
* @param name:articleId type:int require:1 desc:文章id
* @param name:repefen type:string require:1 desc:重复数字
* @param name:zipurl type:string require:1 desc:查重文件地址
*
* @author wangjinlei
* @url /api/Article/changeRepetition
* @method POST
*
*/
public function changeRepetition()
{
//接受参数
$data = $this->request->post();
$this->article_obj->where('article_id', $data['articleId'])->update(['repetition' => $data['repefen'], 'repeurl' => $data['zipurl']]);
//当文章重复率大于50%时,拒稿,拉作者进黑名单
if ($data['repefen'] >= 50) {
$article_info = $this->article_obj->where('article_id', $data['articleId'])->find();
$user_info = $this->user_obj->where('user_id', $article_info['user_id'])->find();
$insert['user_id'] = $data['user_id'];
$insert['reason'] = "The author was blacklisted due to the check rate exceeded 50%";
$insert['black_ctime'] = time();
$this->user_black_obj->insert($insert);
$this->article_obj->where('article_id', $data['articleId'])->update(['state' => 3]);
}
return json(['code' => 0]);
}
/**
* 更改文章详情(编辑)
*/
public function changeArticleFileEditor()
{
//接受参数查询信息
$data = $this->request->post();
$article_info = $this->article_obj->where(['article_id' => $data['articleId']])->find();
// $author_info = $this->user_obj->where('user_id',$article_info['user_id'])->find();
$journal_info = $this->journal_obj->where('journal_id', $article_info['journal_id'])->find();
$editor_info = $this->user_obj->where(['user_id' => $journal_info['editor_id']])->find();
// $journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
//存储文件入文件表
// self::save_article_file($data['articleId'], $editor_info['user_id'], $editor_info['account'], $data['coverLetter'], 'coverLetter');
// self::save_article_file($data['articleId'], $editor_info['user_id'], $editor_info['account'], $data['picturesAndTables'], 'picturesAndTables');
self::save_article_file($data['articleId'], $editor_info['user_id'], $editor_info['account'], $data['manuscirpt'], 'manuscirpt');
//更新文章状态(提醒用户)
$this->article_obj->where('article_id', $data['articleId'])->update(['editor_act' => 1]);
//添加article_msg信息
// $insmsg_data['article_id'] = $data['articleId'];
// $insmsg_data['content'] = '';
// $insmsg_data['state_from'] = $article_info['state'];
// $insmsg_data['state_to'] = 4;
// $insmsg_data['ctime'] = time();
// $this->article_msg_obj->insert($insmsg_data);
//发送email提醒用户
// $tt = $article_info['accept_sn'].'
';
// $tt .= 'Dear author,
';
// $tt .= 'Thanks for submitting the manuscript to '.$journal_info['title'].'.
';
// $tt .= 'Here are the comments in the "Author Center", Please submit your revised manuscript within two weeks.
';
// $tt .= 'Sincerely,
Editorial Office
';
// $tt .= $journal_info['title'].'
';
// $tt .= 'Email:'.$journal_info['email'].'
';
// $tt .= 'Website: '.$journal_info['website'];
// sendEmail($author_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
//增加用户操作log
$log_data['user_id'] = $editor_info['user_id'];
$log_data['type'] = 1;
$log_data['content'] = $editor_info['account'] . "(" . $editor_info['realname'] . "),更改了一篇文章:" . $data['title'] . ",上传时间是:" . date('Y-m-d H:i:s', time());
$log_data['ctime'] = time();
$this->user_log_obj->insert($log_data);
//增加usermsg
add_usermsg($article_info['user_id'], 'Your manuscript has new process: ' . $article_info['title'], '/articleDetail?id=' . $article_info['article_id']);
return json(['code' => 0]);
}
/**
* 获取文章文件
*/
public function getFilesForArticle()
{
$data = $this->request->post();
$rule = new Validate([
'article_id' => 'require',
'type' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$type = '';
switch ($data['type']) {
case "m":
$type = 'manuscirpt';
break;
case "c":
$type = 'coverLetter';
break;
case "p";
$type = 'picturesAndTables';
break;
default:
$type = 'manuscirpt';
break;
}
$files = $this->article_file_obj->where('article_id', $data['article_id'])->where('state', 0)->where('type_name', $type)->order('ctime')->select();
$re['files'] = $files;
return jsonSuccess($re);
}
/**
* 添加文章审稿实例(编辑)
*/
// public function addArticleReviewer()
// {
// //接收参数,查询数据
// $data = $this->request->post();
// $article_info = $this->article_obj->where('article_id', $data['articleId'])->find();
// $journal_info = $this->journal_obj->where('journal_id', $article_info['journal_id'])->find();
// $editor_info = $this->user_obj->where('user_id', $journal_info['editor_id'])->find();
// $reviewer_info = $this->user_obj->where('user_id', $data['uid'])->find();
// $reviewer_move = $this->user_reviewer_info_obj->where("reviewer_info_id", $reviewer_info['user_id'])->find();
// //排除自己审自己
// $check_self = $this->article_author_obj->where("email",$reviewer_info['email'])->where("article_id",$article_info['article_id'])->where("state",0)->find();
// if($check_self){
// return jsonError("Notice:Selected reviewers may be the authors for this paper!");
// }
// // $journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
// $check = $this->article_reviewer_obj->where('reviewer_id', $data['uid'])->where('article_id', $data['articleId'])->find();
// if ($check) {
// return jsonError("Invitation record already exists!");
// }
// if($article_info['state']==0){
// return jsonError("The article can only be added in state with editor at least");
// }
// //增加信息到文章审稿表
// $insert_data['reviewer_id'] = $data['uid'];
// $insert_data['article_id'] = $data['articleId'];
// $insert_data['editor_act'] = 1;
// $insert_data['ctime'] = time();
// $insert_data['state'] = 5;
// $res = $this->article_reviewer_obj->insertGetId($insert_data);
// //修改文章状态->审稿中
// $this->article_obj->where('article_id', $data['articleId'])->update(['state' => 2]);
// //添加article_msg信息
// if ($article_info['state'] != 2) {
// $insmsg_data['article_id'] = $data['articleId'];
// $insmsg_data['content'] = '';
// $insmsg_data['state_from'] = $article_info['state'];
// $insmsg_data['state_to'] = 2;
// $insmsg_data['ctime'] = time();
// $this->article_msg_obj->insert($insmsg_data);
// }
// //发送email提醒审稿员
// $tt = $article_info['accept_sn'] . '
';
// $tt .= 'Dear Dr. ' . ($reviewer_info['realname'] == "" ? $reviewer_info['account'] : $reviewer_info['realname']) . '
';
// $tt .= 'The manuscript entitled “' . $article_info['title'] . '” has'
// . ' been submitted to the journal ' . $journal_info['title'] . '. The Editor-in-Chief would'
// . ' be most grateful if you could offer an opinion regarding its suitability for publication'
// . ' in the journal ' . $journal_info['title'] . '.
';
// $tt .= 'Please bring into our knowledge if there is any potential Conflict of Interest. If you agree to review this manuscript, we ask you to complete your review and submit it by submission system within 14 days of receipt of the manuscript.
';
// $tt .= 'Thank you for your consideration.
Look forward for your reply.
';
// $tt .= 'Click here to accept the invitation to review
';
// // $tt .= 'Click here to review the article
';
// $tt .= 'Click here to decline the invitation to review
';
// $tt .= 'Your username:' . $reviewer_info['account'] . '
';
// $tt .= 'Your original password:123456qwe, if you have reset the password, please login with the new one or click the "forgot password".
';
// $tt .= 'Sincerely,
Editorial Office
';
// $tt .= 'Subscribe to this journal
';
// $tt .= $journal_info['title'] . '
';
// $tt .= 'Email:' . $journal_info['email'] . '
';
// $tt .= 'Website:' . $journal_info['website'];
// $email_title = "Invitation to review manuscript for ".$journal_info['title']."-[".$article_info['accept_sn']."]";
// sendEmail($reviewer_info['email'], $email_title, $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
// //记录userlog
// $log_data['user_id'] = $article_info['editor_id'];
// $log_data['type'] = 2;
// $log_data['content'] = $editor_info['account'] . "(" . $editor_info['realname'] . "),添加了一个文章审稿实例:(" . $article_info['title'] . "-----" . $reviewer_info['account'] . "),添加时间是:" . date('Y-m-d H:i:s', time());
// $log_data['ctime'] = time();
// $this->user_log_obj->insert($log_data);
// //添加usermsg
// add_usermsg($data['uid'], 'You have new manuscript to be approved', '/reviewerArticleDetail?id=' . $res);
// return json(['code' => 0]);
// }
public function addArticleReviewer()
{
//接收参数,查询数据
$data = $this->request->post();
$article_info = $this->article_obj->where('article_id', $data['articleId'])->find();
$journal_info = $this->journal_obj->where('journal_id', $article_info['journal_id'])->find();
$editor_info = $this->user_obj->where('user_id', $journal_info['editor_id'])->find();
$reviewer_info = $this->user_obj->where('user_id', $data['uid'])->find();
$reviewer_move = $this->user_reviewer_info_obj->where("reviewer_info_id", $reviewer_info['user_id'])->find();
//排除自己审自己
$check_self = $this->article_author_obj->where("email", $reviewer_info['email'])->where("article_id", $article_info['article_id'])->where("state", 0)->find();
if ($check_self) {
return jsonError("Notice:Selected reviewers may be the authors for this paper!");
}
// $journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
$check = $this->article_reviewer_obj->where('reviewer_id', $data['uid'])->where('article_id', $data['articleId'])->find();
if ($check) {
return jsonError("Invitation record already exists!");
}
if ($article_info['state'] == 0) {
return jsonError("The article can only be added in state with editor at least");
}
//获取审稿人最后一次邀请时间 chengxiaoling 20250724 start
$iUserId = empty($data['uid']) ? 0 : $data['uid'];
if(empty($iUserId)){
return jsonError("Please select the reviewers to invite!");
}
//判断距离上次邀请审稿是否超过10天
$aWhere = ['reviewer_id' => $iUserId];
$iTeenDaysLater = strtotime('-10 days');// 计算10天之前的时间戳
$aUserInfo = Db::name('user_reviewer_info')->field('last_invite_time')->where($aWhere)->where('t_user_reviewer_info.last_invite_time', '<', $iTeenDaysLater)
->whereOr('t_user_reviewer_info.last_invite_time', '=', 0)->find();
if(empty($aUserInfo)){
return jsonError("The time since the last invitation for review by the reviewer has not exceeded 10 days!");
}
//获取审稿人最后一次邀请时间 chengxiaoling 20250724 end
//增加信息到文章审稿表
$insert_data['reviewer_id'] = $data['uid'];
$insert_data['article_id'] = $data['articleId'];
$insert_data['editor_act'] = 1;
$insert_data['ctime'] = time();
$insert_data['state'] = 5;
$res = $this->article_reviewer_obj->insertGetId($insert_data);
//更新审稿人最后一次审稿时间 chengxiaoling 20250724 start
if(!empty($res) && !empty($insert_data['reviewer_id'])){
$aUpdate = ['last_invite_time'=>time()];
$aWhere = ['reviewer_id' => $iUserId];
$updateResult = Db::name('user_reviewer_info')->where($aWhere)->limit(1)->update($aUpdate);
}
//更新审稿人最后一次审稿时间 chengxiaoling 20250724 end
//修改文章状态->审稿中
$this->article_obj->where('article_id', $data['articleId'])->update(['state' => 2]);
//添加article_msg信息
if ($article_info['state'] != 2) {
$insmsg_data['article_id'] = $data['articleId'];
$insmsg_data['content'] = '';
$insmsg_data['state_from'] = $article_info['state'];
$insmsg_data['state_to'] = 2;
$insmsg_data['ctime'] = time();
$this->article_msg_obj->insert($insmsg_data);
}
//发送email提醒审稿员
$tt = 'Dear Dr. ' . ($reviewer_info['realname'] == "" ? $reviewer_info['account'] : $reviewer_info['realname']) . '
';
$tt .= 'The manuscript entitled "' . $article_info['title'] . '" has'
. ' been submitted to the journal ' . $journal_info['title'] . '. The Editor-in-Chief would'
. ' be most grateful if you could offer an opinion regarding its suitability for publication'
. ' in the journal ' . $journal_info['title'] . '.
';
$tt .= 'Abstract of the Manuscript:
';
$tt .= '' . $article_info['abstrart'] . '
';
$tt .= 'Please let us know if there are any potential conflicts of interest. If you agree to review this manuscript, we kindly request that you complete and submit your review through the submission system within 14 days of receiving the manuscript.
';
$tt .= 'Click here to accept the invitation to review
';
$tt .= 'Click here to decline the invitation to review
';
$tt .= 'Your username: ' . $reviewer_info['account'] . '
';
$tt .= 'Your original password:123456qwe, if you have reset the password, please login with the new one or click the "forgot password".
';
$tt .= 'Thank you for your continued support of our journal.
';
$tt .= 'Sincerely,
Editorial Office
';
$tt .= 'Subscribe to this journal
';
$tt .= $journal_info['title'] . '
';
$tt .= 'Email:' . $journal_info['email'] . '
';
$tt .= 'Website:' . $journal_info['website'];
//内容加头尾
$pre = \think\Env::get('emailtemplete.pre');
$net = \think\Env::get('emailtemplete.net');
$net1 = str_replace("{{email}}", trim($reviewer_info['email']), $net);
$tt = $pre . $tt . $net1;
$email_title = "Invitation to review a manuscript for " . $journal_info['title'] . "-[" . $article_info['accept_sn'] . "]";
sendEmail($reviewer_info['email'], $email_title, $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
//记录userlog
$log_data['user_id'] = $article_info['editor_id'];
$log_data['type'] = 2;
$log_data['content'] = $editor_info['account'] . "(" . $editor_info['realname'] . "),添加了一个文章审稿实例:(" . $article_info['title'] . "-----" . $reviewer_info['account'] . "),添加时间是:" . date('Y-m-d H:i:s', time());
$log_data['ctime'] = time();
$this->user_log_obj->insert($log_data);
//添加usermsg
add_usermsg($data['uid'], 'You have new manuscript to be approved', '/reviewerArticleDetail?id=' . $res);
return json(['code' => 0]);
}
// public function markArticleTable(){
// $data = $this->request->post();
// $rule = new Validate([
// "article_id"=>"require"
// ]);
// if(!$rule->check($data)){
// return jsonError($rule->getError());
// }
// $article_info = $this->article_obj->where("article_id",$data['article_id'])->find();
// //处理word的图片内容
// $files = $this->article_file_obj->where("article_id",$data['article_id'])->where("type_name","manuscirpt")->where("state",0)->order("ctime desc")->limit(1)->select();
// $file = '';
// if(isset($files[0])){
// $file = $files[0]['file_url'];
// }
// $dir = ROOT_PATH."public/articleTable/".$article_info['accept_sn'];
// if (!is_dir($dir)) {
// mkdir($dir, 0777, true);
// }
// $article_info = $this->article_obj->where("article_id",$data['article_id'])->find();
// $url = $this->ts_base_url."api/typeset/markTables";
// $program['file'] = $file;
// $program['sn'] = $article_info['accept_sn'];
// $res = object_to_array(json_decode(myPost($url, $program)));
// if(!isset($res['data']['list'])){
// return ;
// }
// $file_runs = $res['data']['list'];
// foreach ($file_runs as $v){
// $insert['article_id'] = $data['article_id'];
// $insert['image'] = $article_info['accept_sn']."/".$v;
// $insert['ctime'] = time();
// $this->article_image_obj->insert($insert);
// }
//
// }
public function addArticleTable()
{
$data = $this->request->post();
$rule = new Validate([
"article_id" => "require",
"list" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
foreach ($data['list'] as $v) {
$insert['article_id'] = $data['article_id'];
if ($v['type'] == 0) {
$insert['table'] = $v['table'];
$insert['html_data'] = $v['html_data'];
$insert['type'] = 0;
} else {
$insert['type'] = 1;
$insert['url'] = $v['url'];
}
$insert['ctime'] = time();
$this->article_table_obj->insert($insert);
}
return jsonSuccess([]);
}
public function reloadArticleTable()
{
$data = $this->request->post();
$rule = new Validate([
"article_id" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$this->article_table_obj->where("article_id", $data['article_id'])->update(['state' => 1]);
return jsonSuccess([]);
}
public function getArticleTable()
{
$data = $this->request->post();
$rule = new Validate([
"article_id" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$tables = $this->article_table_obj->where("article_id", $data['article_id'])->where("state", 0)->select();
$re['list'] = $tables;
return jsonSuccess($re);
}
public function myMarkTmage()
{
$data = $this->request->post();
$rule = new Validate([
"article_id" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$this->markArticleImage($data['article_id']);
}
/**分解文章的图片和表格
* @return void
*/
private function markArticleImage($article_id)
{
// $article_info = $this->article_obj->where("article_id",$article_id)->find();
//处理word的图片内容
$files = $this->article_file_obj->where("article_id", $article_id)->where("type_name", "manuscirpt")->where("state", 0)->order("ctime desc")->limit(1)->select();
$file = '';
if (isset($files[0])) {
$file = $files[0]['file_url'];
}
$dir = ROOT_PATH . "public/articleImage/" . $article_id;
if (!is_dir($dir)) {
mkdir($dir, 0777, true);
}
$this->markWord("https://submission.tmrjournals.com/public/" . $file, $article_id);
//处理压缩包等等的内容
$pics = $this->article_file_obj->where("article_id", $article_id)->where("type_name", "picturesAndTables")->where("state", 0)->order("file_id desc")->limit(1)->select();
foreach ($pics as $v) {
$extension = pathinfo($v['file_url'], PATHINFO_EXTENSION);
if ($extension == "zip") {
$this->markZip(ROOT_PATH . "public/" . $v['file_url'], $article_id);
}
}
return jsonSuccess([]);
}
// private function markZip($file,$article_id){
// $article_info = $this->article_obj->where("article_id",$article_id)->find();
// $zip = new \ZipArchive();
// // 打开 ZIP 文件
// if ($zip->open($file) === true) {
// $fileCount = $zip->numFiles;
// $num_rand = rand(1000,9999);
// for ($i = 0; $i < $fileCount; $i++) {
// $stat = $zip->statIndex($i);
// $fileName = $stat['name'];
// $fileContent = $zip->getFromIndex($i);
// $base_url = ROOT_PATH."public/articleImage/".$article_id."/";
// $extension = pathinfo($fileName, PATHINFO_EXTENSION);
// if($extension=="jpg"||$extension=="JPG"||$extension=="jpeg"){
// file_put_contents($base_url."zipimg".$num_rand.$i.".jpg", $fileContent);
// $insert['article_id'] = $article_id;
// $insert['image'] = $article_id."/"."zipimg".$num_rand.$i.".jpg";
// $insert['ctime'] = time();
// $this->article_image_obj->insert($insert);
// }elseif ($extension=="png"){
// file_put_contents($base_url."zipimg".$num_rand.$i.".png", $fileContent);
// $insert['article_id'] = $article_id;
// $insert['image'] = $article_id."/"."zipimg".$num_rand.$i.".png";
// $insert['ctime'] = time();
// $this->article_image_obj->insert($insert);
// }elseif ($extension=="tiff"||$extension=="tif"){
// file_put_contents($base_url."zipimg".$num_rand.$i.".".$extension, $fileContent);
// $imagick = new \Imagick();
// $imagick->readImage($fileContent);
// $imagick->setImageFormat('jpg');
// $imagick->writeImage($base_url."zipimg".$num_rand.$i.".jpg");
// $imagick->clear();
// $imagick->destroy();
// $insert['article_id'] = $article_id;
// $insert['image'] = $article_id."/"."zipimg".$num_rand.$i.".".$extension;
// $insert['jpg_url'] = $article_id."/"."zipimg".$num_rand.$i.".jpg";
// $insert['ctime'] = time();
// $this->article_image_obj->insert($insert);
// }elseif ($extension=="emf"||$extension=="EMF"){
// file_put_contents($base_url."zipimg".$num_rand.$i.".".$extension, $fileContent);
// $imagick = new \Imagick();
// $imagick->readImage($fileContent);
// $imagick->setImageFormat('jpg');
// $imagick->writeImage($base_url."zipimg".$num_rand.$i.".jpg");
// $imagick->clear();
// $imagick->destroy();
// $insert['article_id'] = $article_id;
// $insert['image'] = $article_id."/"."zipimg".$num_rand.$i.".".$extension;
// $insert['jpg_url'] = $article_id."/"."zipimg".$num_rand.$i.".jpg";
// $insert['ctime'] = time();
// $this->article_image_obj->insert($insert);
// }elseif ($extension=="docx"){
// $word_dir = ROOT_PATH."public/articleCache/".$article_id;
// if (!is_dir($word_dir)) {
// mkdir($word_dir, 0777, true);
// }
// $word_file = rand(1000,9999).$fileName;
// file_put_contents($word_dir."/".$word_file, $fileContent);
// $this->markWord("https://submission.tmrjournals.com/public/articleCache/".$article_id."/".$word_file,$article_id);
// }
//
// }
//
// // 关闭 ZIP 文件
// $zip->close();
//
// } else {
// return json(['error' => 'Unable to open ZIP file.']);
// }
// }
private function markZip($file, $article_id)
{
$article_info = $this->article_obj->where("article_id", $article_id)->find();
$zip = new \ZipArchive();
// 打开 ZIP 文件
if ($zip->open($file) === true) {
$fileCount = $zip->numFiles;
$num_rand = uniqid('', true); // 使用 uniqid 来生成更唯一的文件名
for ($i = 0; $i < $fileCount; $i++) {
$stat = $zip->statIndex($i);
$fileName = basename($stat['name']); // 获取文件名并去掉路径
$fileContent = $zip->getFromIndex($i);
$base_url = ROOT_PATH . "public/articleImage/" . $article_id . "/";
$extension = pathinfo($fileName, PATHINFO_EXTENSION);
// 创建文件名并确保唯一性
$newFileName = "zipimg" . $num_rand . $i . '.' . $extension;
if (in_array(strtolower($extension), ['jpg', 'jpeg', 'png'])) {
// 处理图片文件
file_put_contents($base_url . $newFileName, $fileContent);
$this->insertImageData($article_id, $newFileName);
} elseif (in_array(strtolower($extension), ['tiff', 'tif'])) {
// 处理 TIFF 和 EMF 文件并转换为 JPG
file_put_contents($base_url . $newFileName, $fileContent);
$this->insertImageData($article_id, $newFileName);
// $this->convertImageToJpg($base_url . $newFileName, $base_url, $num_rand, $i, $extension, $article_id);
} elseif ($extension == "docx") {
// 处理 DOCX 文件
$this->handleDocxFile($fileContent, $article_id, $fileName);
}
}
// 关闭 ZIP 文件
$zip->close();
} else {
return json(['error' => 'Unable to open ZIP file.']);
}
}
private function insertImageData($article_id, $newFileName)
{
$ff = "";
if (pathinfo($newFileName, PATHINFO_EXTENSION) == "tif" || pathinfo($newFileName, PATHINFO_EXTENSION) == "tiff") {
$ff = $this->crossTifToPng($article_id . "/" . $newFileName);
} else {
$ff = $article_id . "/" . $newFileName;
}
$insert = [
'article_id' => $article_id,
'image' => $ff,
'ctime' => time(),
];
$this->article_image_obj->insert($insert);
}
private function convertImageToJpg($inputPath, $base_url, $num_rand, $index, $extension, $article_id)
{
try {
$imagick = new \Imagick();
// 确保文件读取成功
$imagick->readImage($inputPath);
$outputPath = $base_url . "zipimg" . $num_rand . $index . ".jpg";
// 确保转换成功并写入文件
if ($imagick->setImageFormat('jpg') && $imagick->writeImage($outputPath)) {
echo "Image successfully written to: " . $outputPath; // Debugging output
$imagick->clear();
$imagick->destroy();
// 插入数据库记录
$insert = [
'article_id' => $article_id,
'image' => $article_id . "/zipimg" . $num_rand . $index . '.' . $extension,
'jpg_url' => $article_id . "/zipimg" . $num_rand . $index . ".jpg",
'ctime' => time(),
];
$this->article_image_obj->insert($insert);
} else {
echo "Image writing failed!"; // Debugging output
}
} catch (\ImagickException $e) {
// 错误处理,输出异常信息
return json(['error' => 'Image conversion failed: ' . $e->getMessage()]);
}
}
// private function convertImageToJpg($inputPath, $base_url, $num_rand, $index, $extension, $article_id)
// {
// try {
// $imagick = new \Imagick();
// $imagick->readImage($inputPath);
// $imagick->setImageFormat('jpg');
// $outputPath = $base_url . "zipimg" . $num_rand . $index . ".jpg";
// $res = $imagick->writeImage($outputPath);
// var_dump($res);
//
// $imagick->clear();
// $imagick->destroy();
//
// // 插入数据库记录
// $insert = [
// 'article_id' => $article_id,
// 'image' => $article_id . "/zipimg" . $num_rand . $index . '.' . $extension,
// 'jpg_url' => $article_id . "/zipimg" . $num_rand . $index . ".jpg",
// 'ctime' => time(),
// ];
// $this->article_image_obj->insert($insert);
// } catch (\Exception $e) {
// // 错误处理,可以记录日志或返回错误信息
// return json(['error' => 'Image conversion failed: ' . $e->getMessage()]);
// }
// }
private function handleDocxFile($fileContent, $article_id, $fileName)
{
$word_dir = ROOT_PATH . "public/articleCache/" . $article_id;
if (!is_dir($word_dir)) {
mkdir($word_dir, 0777, true);
}
$word_file = rand(1000, 9999) . $fileName;
file_put_contents($word_dir . "/" . $word_file, $fileContent);
$this->markWord("https://submission.tmrjournals.com/public/articleCache/" . $article_id . "/" . $word_file, $article_id);
}
private function markWord($file, $article_id)
{
$url = $this->ts_base_url . "api/typeset/markImages";
$program['file'] = $file;
$program['article_id'] = $article_id;
$res = object_to_array(json_decode(myPost($url, $program)));
if (!isset($res['data']['list'])) {
return;
}
$file_runs = $res['data']['list'];
foreach ($file_runs as $v) {
$insert['article_id'] = $article_id;
$insert['image'] = $article_id . "/" . $v;
if (pathinfo($v, PATHINFO_EXTENSION) == "tif" || pathinfo($v, PATHINFO_EXTENSION) == "tiff") {
$insert['jpg_url'] = $this->crossTifToPng($article_id . "/" . $v);
}
$insert['ctime'] = time();
$this->article_image_obj->insert($insert);
}
}
// public function testArticleImageEx(){
// $data = $this->request->post();
// $rule = new Validate([
// "article_id"=>"require"
// ]);
// if(!$rule->check($data)){
// return jsonError($rule->getError());
// }
// $this->addArticleMainEx($data['article_id']);
// return jsonSuccess([]);
// }
public function getArticleImages()
{
$data = $this->request->post();
$rule = new Validate([
"article_id" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$check = $this->article_image_obj->where("article_id", $data['article_id'])->where("state", 0)->find();
if (!$check) {
$this->markArticleImage($data['article_id']);
}
$list = $this->article_image_obj->where("article_id", $data['article_id'])->where("state", 0)->select();
$re['list'] = $list;
return jsonSuccess($re);
}
public function reloadArticleImages()
{
$data = $this->request->post();
$rule = new Validate([
"article_id" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$dir = ROOT_PATH . "public" . DS . "articleImage" . DS . $data['article_id'];
if (is_dir($dir)) {
$files = scandir($dir);
foreach ($files as $file) {
// 忽略"."和".."(代表当前目录和父级目录)
if ($file != '.' && $file != '..') {
$filePath = $dir . DS . $file;
// 如果是文件,则删除
if (is_file($filePath)) {
unlink($filePath);
}
}
}
}
//清除数据库数据
$this->article_image_obj->where("article_id", $data['article_id'])->update(['state' => 1]);
//重新获取
$this->markArticleImage($data['article_id']);
return jsonSuccess([]);
}
public function getArticleTables()
{
$data = $this->request->post();
$rule = new Validate([
"article_id" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$list = $this->article_table_obj->where("article_id", $data['article_id'])->where("state", 0)->select();
$re['list'] = $list;
return jsonSuccess($re);
}
public function addArticleTable1()
{
$data = $this->request->post();
$rule = new Validate([
"article_id" => "require",
"list" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
foreach ($data['list'] as $v) {
$insert['article_id'] = $data['article_id'];
$insert['table'] = $v['table'];
$insert['type'] = 0;
$insert['ctime'] = time();
$this->article_table_obj->insert($insert);
}
return jsonSuccess([]);
}
// public function reloadArticleTable(){
// $data = $this->request->post();
// $rule = new Validate([
// "article_id"=>"require",
// "list"=>"require"
// ]);
// if(!$rule->check($data)){
// return jsonError($rule->getError());
// }
// //清除原数据
// $this->article_table_obj->where("article_id",$data['article_id'])->update(['state'=>1]);
// //添加新数据
// foreach ($data['list'] as $v){
// $insert['article_id'] = $data['article_id'];
// $insert['table'] = $v['table'];
// $insert['type'] = 0;
// $insert['ctime'] = time();
// $this->article_table_obj->insert($insert);
// }
// return jsonSuccess([]);
// }
/**
* 编辑添加审稿实例(临时开启,为了补充审稿实例不够)
*/
public function addArtRev()
{
die("service stop!");
$data = $this->request->post();
//增加信息到文章审稿表
$insert['reviewer_id'] = $data['uid'];
$insert['article_id'] = $data['articleId'];
$insert['ctime'] = time();
$insert['state'] = 3;
$art_rev_id = $this->article_reviewer_obj->insertGetId($insert);
//添加问卷信息
$insert_data['art_rev_id'] = $art_rev_id;
$insert_data['qu1'] = $data['qu1'];
$insert_data['qu2'] = $data['qu2'];
$insert_data['qu3'] = $data['qu3'];
$insert_data['qu4'] = $data['qu4'];
$insert_data['qu5'] = $data['qu5'];
$insert_data['qu6'] = $data['qu6'];
$insert_data['qu7'] = $data['qu7'];
$insert_data['qu8'] = $data['qu8'];
$insert_data['qu9'] = $data['qu9'] ? 1 : 0;
$insert_data['qu9_contents'] = $data['qu9contents'];
$insert_data['qu10'] = $data['qu10'] ? 1 : 0;
$insert_data['qu10_contents'] = $data['qu10contents'];
$insert_data['qu11'] = $data['qu11'] ? 1 : 0;
$insert_data['qu11_contents'] = $data['qu11contents'];
$insert_data['qu12'] = $data['qu12'] ? 1 : 0;
$insert_data['qu12_contents'] = $data['qu12contents'];
$insert_data['qu13'] = $data['qu13'] ? 1 : 0;
$insert_data['qu13_contents'] = $data['qu13contents'];
$insert_data['qu14'] = $data['qu14'] ? 1 : 0;
$insert_data['qu14_contents'] = $data['qu14contents'];
$insert_data['qu15'] = $data['qu15'] ? 1 : 0;
$insert_data['qu15_contents'] = $data['qu15contents'];
$insert_data['rated'] = $data['rated'];
$insert_data['recommend'] = $data['recommend'];
$insert_data['other'] = $data['other'];
$insert_data['confidential'] = $data['confident'];
$insert_data['comments'] = $data['comment'];
$insert_data['ctime'] = time();
$res = $this->article_reviewer_question_obj->insert($insert_data);
$re['code'] = 0;
return json($re);
}
/**
* @title 添加文章(投稿)
* @description 添加文章(投稿)
* @param name:username type:string require:1 desc:用户名
* @param name:journal type:int require:1 desc:期刊id
* @param name:title type:int require:1 desc:标题
* @param name:keyWords type:String require:1 desc:关键字
* @param name:fund type:string require:0 desc:fund
* @param name:type type:String require:1 desc:类型缩写
* @param name:major type:int require:1 desc:领域id
* @param name:approval type:string require:1 desc:true/false
* @param name:abstrart type:string require:1 desc:简介
* @param name:authorList type:array require:1 desc:作者
*
* @return articles:文章列表#
* @return count:总数#
* @author wangjinlei
* @url /api/Article/addArticle
* @method POST
*
*/
public function addArticle()
{
die("Please update your browser cache and resubmit your submission (shortcut key: Ctrl+F5)");
//接受参数,查询信息
$data = $this->request->post();
$user_res = $this->user_obj->where('account', $data['username'])->find();
//确定用户是否属于黑名单
$black_check = $this->user_black_obj->where('user_id', $user_res['user_id'])->where('black_state', 0)->find();
if ($black_check) {
return jsonError("Your account has been blocked. Please contact the publisher for details: publisher@tmrjournals.com.");
}
// if($user_res['account']=='fariba'||$user_res['account']=='zc'||$user_res['account']=='Mohammad Hossein'||$user_res['account']=='xiaoyueyue'||$user_res['account']=='sethlee000'||$user_res['account']=='yuanying9908'){
// return json(['code'=>1,'msg'=>'Your account has been blocked. Please contact the publisher for details: publisher@tmrjournals.com.']);
// }
$journal_info = $this->journal_obj->where('journal_id', $data['journal'])->find();
//首先查重是否重复投稿
$checkArticle = $this->article_obj->where("title", trim($data['title']))->select();
foreach ($checkArticle as $v) {
if ($v['state'] != 3) {
return json(['code' => 1, 'msg' => 'Warning: you are re-submitting the article!']);
}
}
Db::startTrans();
//添加文章基础信息
$inset_data['user_id'] = $user_res['user_id'];
$inset_data['journal_id'] = $data['journal'];
$inset_data['editor_id'] = $journal_info['editor_id'];
$inset_data['title'] = trim($data['title']);
$inset_data['keywords'] = $data['keyWords'];
$inset_data['fund'] = trim($data['fund']);
$inset_data['accept_sn'] = getArticleSN($journal_info['abbr'], $data['type']);
$inset_data['type'] = $data['type'];
$inset_data['major_id'] = $data['major'];
// $inset_data['cmajor_id'] = $data['cmajor'];
$inset_data['approval'] = $data['approval'] == 'true' ? 1 : 0;
$inset_data['abstrart'] = $data['abstrart'];
$inset_data['author_act'] = 1;
$inset_data['ctime'] = time();
$res = $this->article_obj->insertGetId($inset_data);
//上传文章作者信息
$author_email = [];
$authors = [];
$res_add_user = true;
foreach ($data['authorList'] as $v) {
if ($v['firstname'] == '') {
continue;
}
$i['article_id'] = $res;
$i['firstname'] = trim($v['firstname']);
$i['lastname'] = trim($v['lastname']);
$i['orcid'] = trim($v['orcid']);
$i['company'] = trim($v['company']);
$i['department'] = trim($v['department']);
$i['author_title'] = $v['title'];
$i['country'] = $v['country'];
$i['email'] = trim($v['email']);
$i['address'] = trim($v['address']);
$i['is_super'] = $v['isSuper'] == 'true' ? 1 : 0;
$i['is_report'] = $v['isReport'] == 'true' ? 1 : 0;
$authors[] = $i;
$cache['email'] = trim($v['email']);
$cache['name'] = trim($v['firstname']) . ' ' . trim($v['lastname']);
$author_email[] = $cache;
//通讯作者用户添加
if ($v['isReport'] == "true") {
$re_user_check = $this->user_obj->where('account|email', trim($v['email']))->find();
if (!$re_user_check) {
$password = getRandPassword();
$inser_data['account'] = trim($v['email']);
$inser_data['password'] = md5($password);
$inser_data['email'] = trim($v['email']);
$inser_data['realname'] = trim($v['firstname']) . ' ' . trim($v['lastname']);
$inser_data['ctime'] = time();
$c_res_add_user = $this->user_obj->insertGetId($inser_data);
if ($res_add_user) {
$res_add_user = $c_res_add_user;
}
//发送提示邮件给通讯作者
$report_tt = "Dear " . $inser_data['realname'] . ',
';
$report_tt .= "We are delighted to welcome you as a new author for our journal, " . $journal_info['title'] . ". We have received your submission and are excited to review it for potential publication.
";
$report_tt .= "As a next step, we have created an account for you on our journal's website. Your account is [Username: " . trim($v['email']) . " password:$password]";
$report_tt .= "and you can access your account by visiting " . $journal_info['website'] . " and logging in.
";
$report_tt .= "If you have any questions or need assistance with accessing your account, please don't hesitate to contact us. We are here to support you throughout the submission and review process.
";
$report_tt .= "Thank you for choosing to submit your work to our journal. We look forward to working with you.
";
$report_tt .= "Best regards,
" . $journal_info['title'];
$maidata['email'] = trim($v['email']);
$maidata['title'] = $journal_info['title'];
$maidata['content'] = $report_tt;
$maidata['tmail'] = $journal_info['email'];
$maidata['tpassword'] = $journal_info['epassword'];
Queue::push('app\api\job\mail@fire', $maidata, "tmail");
}
}
}
$res_author = $this->article_author_obj->insertAll($authors);
//增加转投信息
$transr = true;
if ($data['istransfer'] == 'true') {
foreach ($data['checkedjours'] as $val) {
$trans_insert['article_id'] = $res;
$trans_insert['journal_id'] = $val;
$trans_insert['ctime'] = time();
$transr = $transr ? $this->article_transfer_obj->insert($trans_insert) : false;
}
}
//增加articlefile表的信息
$res_file1 = self::save_article_file($res, $user_res['user_id'], $user_res['account'], $data['coverLetter'], 'coverLetter');
$res_file2 = true;
if (isset($data['picturesAndTables'])) {
foreach ($data['picturesAndTables'] as $v) {
$res_file2 = $res_file2 ? self::save_article_file($res, $user_res['user_id'], $user_res['account'], $v, 'picturesAndTables') : false;
}
}
$res_file4 = self::save_article_file($res, $user_res['user_id'], $user_res['account'], $data['totalpage'], 'totalpage');
$res_file3 = self::save_article_file($res, $user_res['user_id'], $user_res['account'], $data['manuscirpt'], 'manuscirpt');
//发送邮件到编辑,提醒有待审文章
$editor_info = $this->user_obj->where('user_id', $journal_info['editor_id'])->find();
$tt = 'Dear editor,
';
$tt .= 'Please check the new manuscript in the submission system.';
sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
$user_rev_info = $this->user_reviewer_info_obj->where("reviewer_id", $user_res['user_id'])->find();
//发送邮件给作者,表示感谢
$tt_t = 'Dear Dr. ' . ($user_res['realname'] == '' ? $user_res['account'] : $user_res['realname']) . ',
';
$tt1 = 'Thank you for submitting your manuscript entitled "' . $data['title'] . '". Your submission has been assigned the following tracking number:' . $inset_data['accept_sn'] . '. We will be in touch again as soon as we have reached a decision. Please quote the tracking number in any communication. This e-mail simply acknowledges receipt of your submission. If the editors decide for editorial reasons that the paper is unsuitable for publication in ' . $journal_info['title'] . ', you will be informed as soon as possible.
';
if ($journal_info['journal_id'] == 9) { //life research 期刊发送收到文章邮件
$tt1 .= 'Life Research applies the CC BY-NC 4.0 license. Full details of the policy can be found at https://www.tmrjournals.com/notice.html?J_num=14&footer_id=123. Authors should read Guide to Authors carefully before submitting.
';
$tt1 .= 'You may check on the status of this manuscript in the Submission System. If you encounter any problems, please contact liferes@tmrjournals.com.
';
$tt1 .= 'Thank you for choosing to submit your manuscript to Life Research.
';
$tt1 .= 'Yours sincerely,
Haoran Zhang
';
$tt1 .= 'Manuscript Administration, Life Research
https://www.tmrjournals.com/lr/';
} else { //其他期刊发送邮件
$tt1 .= 'You may check on the status of this manuscript in the Submission System. If you encounter any problems, please contact ' . $journal_info['email'] . '.
';
$tt1 .= 'Thank you for choosing to submit your manuscript to ' . $journal_info['title'] . '.
';
$tt1 .= 'Sincerely,
Editorial Office
';
$tt1 .= 'Subscribe to this journal
';
$tt1 .= $journal_info['title'] . '
';
$tt1 .= 'Email: ' . $journal_info['email'] . '
';
$tt1 .= 'Website: ' . $journal_info['website'] . '
';
$tt1 .= '
If you have any questions, please contact us:
';
$tt1 .= 'Head of publication ethics
Dr. Dan Chen
TMR Publishing Group Limited Company, Auckland, New Zealand
Email: publication.ethics@tmrjournals.com';
}
sendEmail($user_res['email'], $journal_info['title'], $journal_info['title'], $tt_t . $tt1, $journal_info['email'], $journal_info['epassword']);
foreach ($author_email as $v) {
$cache_str = 'Dear Dr. ' . $v['name'] . ',
';
$maidata['email'] = $v['email'];
$maidata['title'] = $journal_info['title'];
$maidata['content'] = $cache_str . $tt1;
$maidata['tmail'] = $journal_info['email'];
$maidata['tpassword'] = $journal_info['epassword'];
Queue::push('app\api\job\mail@fire', $maidata, "tmail");
}
//增加用户操作log
$log_data['user_id'] = $user_res['user_id'];
$log_data['type'] = 0;
$log_data['content'] = $user_res['account'] . "(" . $user_res['realname'] . "),上传了一篇文章:" . $data['title'] . ",上传时间是:" . date('Y-m-d H:i:s', time());
$log_data['ctime'] = time();
$res_log = $this->user_log_obj->insert($log_data);
//增加usermsg
$res_msg = add_usermsg($journal_info['editor_id'], 'New manuscript', '/articleDetailEditor?id=' . $res);
//通讯作者转为审稿人
$this->addReviewerFromArticle($res, $journal_info['journal_id']);
//推荐审稿人
$recommend_res = true;
$reviewers = isset($data['reviewers']) ? $data['reviewers'] : [];
foreach ($reviewers as $v) {
$recommend_res = $this->addRecommentReviewer($v, $journal_info['journal_id'], $user_res['user_id'], $res);
}
if ($res && $res_author && $transr && $res_add_user && $res_file1 && $res_file2 && $res_file3 && $res_file4 && $res_log && $res_msg && $recommend_res) {
Db::commit();
$this->ai_scor($res);
return json(['code' => 0]);
} else {
Db::rollback();
return json(['code' => 1]);
}
}
/**添加作者
* @return void
*/
public function addAuthor()
{
$data = $this->request->post();
$rule = new Validate([
"article_id" => "require",
"firstname" => "require",
"lastname" => "require",
"email" => "require",
"country" => "require",
"isSuper" => "require",
"isReport" => "require",
'organ' => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$max = $this->article_author_obj->where("article_id", $data['article_id'])->where("state", 0)->max("sort");
$insert['article_id'] = $data['article_id'];
$insert['sort'] = $max + 1;
$insert['firstname'] = trim($data['firstname']);
$insert['lastname'] = trim($data['lastname']);
$insert['email'] = trim($data['email']);
$insert['country'] = trim($data['country']);
$insert['is_super'] = $data['isSuper'] == 'true' ? 1 : 0;
$insert['is_report'] = $data['isReport'] == 'true' ? 1 : 0;
$insert['author_title'] = isset($data['title']) ? trim($data["title"]) : "";
$insert['company'] = isset($data['company']) ? trim($data['company']) : "";
$insert['department'] = isset($data['department']) ? trim($data['department']) : "";
$insert['address'] = isset($data['address']) ? trim($data['address']) : "";
//新增修改orcid chengxiaoling 20251029 start
$insert['orcid'] = isset($data['orcid']) ? trim($data['orcid']) : "";
//新增修改orcid chengxiaoling 20251029 end
//处理作者绑定机构 chengxiaoling 251031 start
$aOrgrnId = empty($data['organ']) ? '' : $data['organ'];
if(!empty($aOrgrnId) && is_string($aOrgrnId)){
$aOrgrnId = explode(',', $aOrgrnId);
}
Db::startTrans();
$iId = $this->article_author_obj->insertGetId($insert);
if(empty($iId)){
return jsonError('Adding author failed');
}
if(!empty($aOrgrnId)){
//查询机构
$aWhere = ['organ_id' => ['in',$aOrgrnId],'state' => 0];
$aOrgan = Db::name('article_organ')->field('organ_id,article_id,organ_name')->where($aWhere)->select();
if(!empty($aOrgan)){
//获取最大sort值
$aMaxSort = Db::name('article_organ')->field('max(sort) as sort')->where(['article_id' => $data['article_id']])->find();
$iSort = empty($aMaxSort['sort']) ? 0 : $aMaxSort['sort'];
//处理数据
$aOrgrnIdData = $aCompanyName = [];
foreach ($aOrgan as $key => $value) {
if($value['article_id'] == $data['article_id']){
$aOrgrnIdData[] = $value['organ_id'];
$aCompanyName[] = $value['organ_name'];
}else{
$iSort ++;
$aAdd = ['article_id' => $data['article_id'],'organ_name' =>$value['organ_name'],'create_time' => time(),'sort' => $iSort];
$iOrganId = DB::name('article_organ')->insertGetId($aAdd);
if(empty($iOrganId)){
continue;
}
$aOrgrnIdData[] = $iOrganId;
$aCompanyName[] = $value['organ_name'];
}
}
}
if(!empty($aOrgrnIdData)){
foreach ($aOrgrnIdData as $key => $value) {
$aInsert[] = ['article_id' => $data['article_id'],'art_aut_id' => $iId,'organ_id' => $value,'create_time' => time()];
}
}
}
if(!empty($aInsert)){
$result = Db::name('article_author_organ')->insertAll($aInsert);
if($result === false){
return jsonError('Failed to add author institution');
}
}
if(!empty($aCompanyName) && !empty($iId)){
$aWhere = ['art_aut_id' => $iId];
$sCompany = implode('/', array_unique($aCompanyName));
$update_company_result = Db::name('article_author')->where($aWhere)->limit(1)->update(['company' => $sCompany]);
}
Db::commit();
//处理作者绑定机构 chengxiaoling 251031 end
return jsonSuccess([]);
}
public function editAuthor()
{
$data = $this->request->post();
$rule = new Validate([
"art_aut_id" => "require",
"article_id" => "require",
"firstname" => "require",
"lastname" => "require",
"email" => "require",
"country" => "require",
"isSuper" => "require",
"isReport" => "require",
"title" => "require",
'organ' => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$insert['article_id'] = $data['article_id'];
$insert['firstname'] = trim($data['firstname']);
$insert['lastname'] = trim($data['lastname']);
$insert['email'] = trim($data['email']);
$insert['country'] = trim($data['country']);
$insert['is_super'] = $data['isSuper'] == 'true' ? 1 : 0;
$insert['is_report'] = $data['isReport'] == 'true' ? 1 : 0;
$insert['author_title'] = trim($data["title"]);
$insert['company'] = isset($data['company']) ? trim($data['company']) : "";
$insert['department'] = isset($data['department']) ? trim($data['department']) : "";
$insert['address'] = isset($data['address']) ? trim($data['address']) : "";
//新增修改orcid chengxiaoling 20251029 start
$insert['orcid'] = isset($data['orcid']) ? trim($data['orcid']) : "";
//新增修改orcid chengxiaoling 20251029 end
//处理作者绑定机构 chengxiaoling 251031 start
$aOrgrnId = empty($data['organ']) ? '' : $data['organ'];
if(!empty($aOrgrnId) && is_string($aOrgrnId)){
$aOrgrnId = explode(',', $aOrgrnId);
//查询作者机构
$aWhere = ['art_aut_id' => $data['art_aut_id'],'state' => 0];
$aAuthorOrganId = Db::name('article_author_organ')->where($aWhere)->column('organ_id');
//新增
$aInsert = array_diff($aOrgrnId, $aAuthorOrganId);
//删除
$aDelete = array_diff($aAuthorOrganId, $aOrgrnId);
}
Db::startTrans();
if(!empty($aInsert)){
foreach ($aInsert as $key => $value) {
$aInsertData[] = ['article_id' => $data['article_id'],'art_aut_id' => $data['art_aut_id'],'organ_id' => $value,'create_time' => time()];
}
if(!empty($aInsertData)){
$result = Db::name('article_author_organ')->insertAll($aInsertData);
if($result === false){
return jsonError('Failed to add author institution');
}
}
}
if(!empty($aDelete)){
$aWhere = ['organ_id' => ['in',$aDelete],'state' => 0];
$aUpdate = ['state' => 1,'update_time' => time()];
$author_organ_result = Db::name('article_author_organ')->where($aWhere)->limit(count($aDelete))->update($aUpdate);
if($author_organ_result === false){
return json_encode(['status' => 3,'msg' => 'Failed to unbind the relationship between the institution and the author']);
}
}
//获取机构名称
$aWhere = ['art_aut_id' => $data['art_aut_id'],'state' => 0];
if(!empty($aDelete)){
$aWhere['organ_id'] =['not in',$aDelete];
}
$aOrganIdList = Db::name('article_author_organ')->where($aWhere)->column('organ_id');
$insert['company'] = '';
if(!empty($aOrganIdList)){
$aWhere = ['organ_id' => ['in',$aOrganIdList],'state' => 0];
$aOrganName = Db::name('article_organ')->where($aWhere)->column('organ_name');
if(!empty($aOrganName) && !empty($data['art_aut_id'])){
$sCompany = implode('/', array_unique($aOrganName));
$insert['company'] = $sCompany;
}
}
$update_company_result = $this->article_author_obj->where("art_aut_id", $data['art_aut_id'])->limit(1)->update($insert);
Db::commit();
//处理作者绑定机构 chengxiaoling 251031 end
return jsonSuccess([]);
}
/**
* @return void
*/
public function getAuthors()
{
$data = $this->request->post();
$rule = new Validate([
"article_id" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$authors = $this->article_author_obj->where("article_id", $data["article_id"])->where("state", 0)->order("sort")->select();
//查询作者机构 20251031 start
if(!empty($authors)){
//查询作者机构
$aAutId = array_column($authors, 'art_aut_id');
$aWhere = ['art_aut_id' => ['in',$aAutId],'state' => 0];
if($aAuthorOrganId = Db::name('article_author_organ')->field('art_aut_id,organ_id')->where($aWhere)->select()){
//查询机构名称
$aOragnId = array_unique(array_column($aAuthorOrganId, 'organ_id'));
$aWhere = ['article_id' => $data['article_id'],'state' => 0,'organ_id' => ['in',$aOragnId]];
$aOragn = Db::name('article_organ')->where($aWhere)->column('organ_id,organ_name');
}
if(!empty($aAuthorOrganId)){
$aAuthorOrgan = [];
foreach ($aAuthorOrganId as $key => $value) {
if(empty($aOragn[$value['organ_id']])){
continue;
}
$aAuthorOrgan[$value['art_aut_id']][] = ['organ_id' => $value['organ_id'],'organ_name' => empty($aOragn[$value['organ_id']]) ? '' : $aOragn[$value['organ_id']]];
}
}
foreach ($authors as $key => $value) {
$authors[$key]['organ_id'] = empty($aAuthorOrgan[$value['art_aut_id']]) ? [] : array_unique(array_column($aAuthorOrgan[$value['art_aut_id']], 'organ_id'));
$authors[$key]['organ_name'] = empty($aAuthorOrgan[$value['art_aut_id']]) ? [] : array_column($aAuthorOrgan[$value['art_aut_id']], 'organ_name');
}
}
//查询作者机构 20251031 end
$re['authors'] = $authors;
return jsonSuccess($re);
}
/**上调文章作者顺序
* @return void
*/
public function upAuthors()
{
$data = $this->request->post();
$rule = new Validate([
"art_aut_id" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$info = $this->article_author_obj->where("art_aut_id", $data['art_aut_id'])->find();
if ($info['sort'] < 2) {
return jsonError("Upward adjustment: Failed to obtain the location of the exchanged author");
}
$info_1 = $this->article_author_obj->where("article_id", $info['article_id'])->where("state", 0)->where("sort", $info['sort'] - 1)->find();
$this->article_author_obj->where("art_aut_id", $info['art_aut_id'])->setDec("sort");
$this->article_author_obj->where("art_aut_id", $info_1['art_aut_id'])->setInc("sort");
return jsonSuccess([]);
}
/**下调文章作者顺序
* @return \think\response\Json|void
*/
public function downAuthors()
{
$data = $this->request->post();
$rule = new Validate([
"art_aut_id" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$info = $this->article_author_obj->where("art_aut_id", $data['art_aut_id'])->find();
$info_1 = $this->article_author_obj->where("article_id", $info['article_id'])->where("state", 0)->where("sort", $info['sort'] + 1)->find();
if ($info_1 == null) {
return jsonError("Downward adjustment:Failed to obtain the location of the exchanged author");
}
$this->article_author_obj->where("art_aut_id", $info['art_aut_id'])->setInc("sort");
$this->article_author_obj->where("art_aut_id", $info_1['art_aut_id'])->setDec("sort");
return jsonSuccess([]);
}
/**
* @return void
*/
public function delAuthor()
{
$data = $this->request->post();
$rule = new Validate([
"art_aut_id" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$info = $this->article_author_obj->where("art_aut_id", $data['art_aut_id'])->find();
//大于此条的sort都减一
$this->article_author_obj->where("article_id", $info['article_id'])->where("sort", ">", $info['sort'])->setDec("sort");
$this->article_author_obj->where("art_aut_id", $data['art_aut_id'])->update(['state' => 1]);
return jsonSuccess([]);
}
/**
* 获取已暂存的文章列表
*/
public function getSaveArticles()
{
$data = $this->request->post();
$rule = new Validate([
'user_id' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$list = $this->article_obj
->field('t_article.*,t_journal.title journal_title')
->join('t_journal', 't_journal.journal_id = t_article.journal_id', 'left')
->where('t_article.user_id', $data['user_id'])
->where('t_article.state', -1)
->select();
$re['articles'] = $list;
return jsonSuccess($re);
}
public function getSaveArticleDetail()
{
$data = $this->request->post();
$rule = new Validate([
'article_id' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$base = $this->article_obj->where('article_id', $data['article_id'])->find();
// $major_info = $this->major_obj->where('major_id', $base['major_id'])->find();
$major = '';
// if ($major_info['major_level'] == 4) {
// $major2 = $this->major_obj->where('major_id', $major_info['pid'])->find();
// $major2['child'] = $major_info;
// $major = $this->major_obj->where('major_id', $major2['pid'])->find();
// $major['child'] = $major2;
// } elseif ($major_info['major_level'] == 3) {
// $major1 = $this->major_obj->where('major_id', $major_info['pid'])->find();
// $major1['child'] = $major_info;
// $major = $major1;
// } else {
// $major = $major_info;
// }
$majors = $this->major_to_article_obj->where("article_id", $data['article_id'])->where("state", 0)->select();
foreach ($majors as $k => $v) {
$majors[$k]["major"] = getMajorShu($v['major_id']);
}
$authors = $this->article_author_obj->where('article_id', $data['article_id'])->where('state', 0)->select();
$files = $this->article_file_obj->where('article_id', $data['article_id'])->where('state', 0)->select();
//推荐记录
$aWhere = ['urr_state' => 0,'article_id' => $data['article_id']];
$aUserRecommend = Db::name('user_reviewer_recommend')->where($aWhere)->column('reviewer_id,urr_id');
if(!empty($aUserRecommend)){
//获取基本信息
$aUserId = array_keys($aUserRecommend);
$aWhere = ['user_id' => ['in',$aUserId],'state' => 0];
$aUser = Db::name('user')->field('user_id,account,email,realname')->where($aWhere)->select();
if(!empty($aUser)){
$aWhere = ['reviewer_id' => ['in',$aUserId],'state' => 0];
$aReviewer = Db::name('user_reviewer_info')->field('reviewer_id,country,major,company,department')->where($aWhere)->select();
$aReviewer = array_column($aReviewer, null,'reviewer_id');
foreach ($aUser as $key => $value) {
$value['country'] = empty($aReviewer[$value['user_id']]['country']) ? '' : $aReviewer[$value['user_id']]['country'];
$value['major'] = empty($aReviewer[$value['user_id']]['major']) ? '' : $aReviewer[$value['user_id']]['major'];
$value['p_major'] = '';
if(!empty($value['major'])){
$value['p_major'] = empty($this->getMajorShuList($value['major'])) ? '' : trim($this->getMajorShuList($value['major']),',');
}
$value['urr_id'] = empty($aUserRecommend[$value['user_id']]) ? 0 : $aUserRecommend[$value['user_id']];
$value['company'] = empty($aReviewer[$value['user_id']]['company']) ? '' : $aReviewer[$value['user_id']]['company'];
$value['department'] = empty($aReviewer[$value['user_id']]['department']) ? '' : $aReviewer[$value['user_id']]['department'];
$aUser[$key] = $value;
}
}
}
$re['base'] = $base;
$re['authors'] = $authors;
$re['files'] = $files;
$re['major'] = $major;
$re['majors'] = $majors;
$re['reviewer'] = empty($aUser) ? [] : $aUser;
return jsonSuccess($re);
}
public function changeJournal()
{
$data = $this->request->post();
$rule = new Validate([
"article_id" => "require",
"journal_id" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$article_info = $this->article_obj->where("article_id", $data['article_id'])->find();
$journal_info = $this->journal_obj->where("journal_id", $data['journal_id'])->find();
if (!$article_info) {
return jsonError("The article has not been submitted yet");
}
$sn = getArticleSN($journal_info['abbr'], $article_info['type']);
$this->article_obj->where("article_id", $data['article_id'])->update(['journal_id' => $data['journal_id'], "accept_sn" => $sn]);
return jsonSuccess([]);
}
/**
* 添加文章第一部分
*/
public function addArticlePart1()
{
$data = $this->request->post();
$rule = new Validate([
'article_id' => 'require',
'user_id' => 'require',
'journal' => 'require',
'title' => 'require',
'type' => 'require',
// 'major' => 'require',
'abstrart' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
//判断简介字符串长度是否不低于200 chengxiaoling 20250327 start
if (!$this->checkMinChars($data['abstrart'], 200)) {
return jsonError("The abstract should not be less than 200 Chinese characters or English words!");
}
//判断简介字符串长度是否不低于200 chengxiaoling 20250327 end
//判断伦理
if(!empty($data['approval']) && $data['approval'] == 1 && empty($data['approval_file'])){
return jsonError("Ethics documents not uploaded");
}
if(isset($aArticle['approval']) && $aArticle['approval'] == 0 && empty($aArticle['approval_content'])){
return jsonError("Please explain the lack of ethical recognition");
}
$user_info = $this->user_obj->where('user_id', $data['user_id'])->find();
$journal_info = $this->journal_obj->where('journal_id', $data['journal'])->find();
if ($journal_info['state'] == 1) {
return jsonError("Submission failed");
}
$article_id = $data['article_id'];
//添加文章基础信息
if ($data['article_id'] == 0) {
$checkArticle = $this->article_obj->where("title", trim($data['title']))->select();
foreach ($checkArticle as $v) {
if ($v['state'] != 3) {
return json(['code' => 1, 'msg' => 'Warning: you are re-submitting the article!']);
}
}
$inset_data['user_id'] = $user_info['user_id'];
$inset_data['journal_id'] = $data['journal'];
$inset_data['editor_id'] = $journal_info['editor_id'];
$inset_data['title'] = trim($data['title']);
$inset_data['abstrart'] = trim($data['abstrart']);
$inset_data['keywords'] = isset($data['keyWords']) ? $data['keyWords'] : '';
$inset_data['fund'] = isset($data['fund']) ? trim($data['fund']) : '';
$sType = empty($data['type']) ? 'D' : $data['type'];
$inset_data['accept_sn'] = getArticleSN('Draft', $sType);
$inset_data['topics'] = isset($data["topics"]) ? json_encode($data['topics']) : "";
$inset_data['type'] = $data['type'];
// $inset_data['major_id'] = $data['major'];
//处理伦理
if (isset($data['approval']) && $data['approval'] == 1) {
$inset_data['approval'] = 1;
$inset_data['approval_file'] = isset($data["approval_file"]) ? $data["approval_file"] : '';
$inset_data['approval_content'] = '';
} else {
$inset_data["approval"] = 0;
$inset_data['approval_content'] = isset($data["approval_content"]) ? $data["approval_content"] : '';
$inset_data['approval_file'] = '';
}
$inset_data['ctime'] = time();
$inset_data['state'] = -1;
$article_id = $this->article_obj->insertGetId($inset_data);
} else {
// $checkArticle = $this->article_obj->where("article_id", "<>", $article_id)->where("title", trim($data['title']))->select();
// foreach ($checkArticle as $v) {
// if ($v['state'] != 3) {
// return json(['code' => 1, 'msg' => 'Warning: you are re-submitting the article!']);
// }
// }
//查询manuscirpt文件是否上传
$aWhere = ['article_id' => $data['article_id'],'state' => 0,'type_name' => 'manuscirpt'];
$aFile = Db::name('article_file')->where($aWhere)->order('ctime desc')->find();
if(empty($aFile)){
$iFirstStatus = 2;
$sFirstMsg = 'Step 1: The manuscirpt file has not been uploaded';
}
$up['user_id'] = $user_info['user_id'];
$up['journal_id'] = $data['journal'];
$up['editor_id'] = $journal_info['editor_id'];
$up['title'] = trim($data['title']);
$up['abstrart'] = trim($data['abstrart']);
$up['keywords'] = isset($data['keyWords']) ? $data['keyWords'] : '';
$up['topics'] = isset($data["topics"]) ? json_encode($data['topics']) : "";
$up['fund'] = isset($data['fund']) ? trim($data['fund']) : '';
$up['type'] = $data['type'];
// $up['major_id'] = $data['major'];
//处理伦理
if (isset($data['approval']) && $data['approval'] == 1) {
$up['approval'] = 1;
$up['approval_file'] = isset($data["approval_file"]) ? $data["approval_file"] : '';
$up['approval_content'] = '';
} else {
$up["approval"] = 0;
$up['approval_content'] = isset($data["approval_content"]) ? $data["approval_content"] : '';//trim($data['approval_content']);
$up['approval_file'] = '';
}
$this->article_obj->where('article_id', $article_id)->update($up);
}
//注释文章筛选领域添加修改为AI推荐领域,在第四步可以查看修改 chengxiaoling 20250722
// changeArticleMajor($article_id,$data['major']);
if(!empty($article_id)){//AI推荐领域队列执行
$oArticle = new \app\common\Article;
$aArticleField = $oArticle->getArticleField(['article_id' => $article_id]);
if(empty($aArticleField['data'])){
$sQueueId = \think\Queue::push('app\api\job\RecommendArticleField@fire',['article_id' => $article_id], 'RecommendArticleField');
}
}
//注释文章筛选领域添加修改为AI推荐领域,在第四步可以查看修改 chengxiaoling 20250722
return jsonSuccess(['article_id' => $article_id]);
}
public function mytest()
{
changeArticleMajor(5774, "97");
}
/**获取期刊话题
* @return void
*/
public function getJournalTopics()
{
$data = $this->request->post();
$rule = new Validate([
'journal_id' => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$journal_info = $this->journal_obj->where('journal_id', $data['journal_id'])->find();
$url = "http://journalapi.tmrjournals.com/public/index.php/master/Submision/getTopicsByIssn";
$pro['issn'] = $journal_info['issn'];
$res = object_to_array(json_decode(myPost($url, $pro)));
$topics = $res['data']['topics'];
$re['topics'] = $topics;
return jsonSuccess($re);
}
/**
* 保存文章作者
*/
public function saveArticleAuthor()
{
$data = $this->request->post();
$rule = new Validate([
'article_id' => 'require',
'authors' => 'require|array'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$article_info = $this->article_obj->where('article_id', $data['article_id'])->find();
$has_authors = $this->article_author_obj->where('article_id', $data['article_id'])->where('state', 0)->select();
Db::startTrans();
$insert_res = true;
foreach ($data['authors'] as $k => $v) {
if ($v['art_aut_id'] == 0) { //add
$i['article_id'] = $data['article_id'];
$i['firstname'] = trim($v['firstname']);
$i['lastname'] = trim($v['lastname']);
$i['orcid'] = isset($v['orcid']) ? $v['orcid'] : '';
$i['company'] = isset($v['company']) ? $v['company'] : '';
$i['department'] = isset($v['department']) ? $v['department'] : '';
$i['author_title'] = isset($v['title']) ? $v['title'] : '';
$i['country'] = $v['country'];
$i['email'] = trim($v['email']);
$i['address'] = isset($v['address']) ? $v['address'] : '';
$i['is_super'] = $v['isSuper'] == 'true' ? 1 : 0;
$i['is_report'] = $v['isReport'] == 'true' ? 1 : 0;
$add_res = $this->article_author_obj->insert($i);
if (!$add_res) {
$insert_res = false;
break;
}
} else { //edit
$u['article_id'] = $data['article_id'];
$u['firstname'] = trim($v['firstname']);
$u['lastname'] = trim($v['lastname']);
$u['orcid'] = isset($v['orcid']) ? $v['orcid'] : '';
$u['company'] = isset($v['company']) ? $v['company'] : '';
$u['department'] = isset($v['department']) ? $v['department'] : '';
$u['author_title'] = isset($v['title']) ? $v['title'] : '';
$u['country'] = $v['country'];
$u['email'] = trim($v['email']);
$u['address'] = isset($v['address']) ? $v['address'] : '';
$u['is_super'] = $v['isSuper'] == 'true' ? 1 : 0;
$u['is_report'] = $v['isReport'] == 'true' ? 1 : 0;
$this->article_author_obj->where('art_aut_id', $v['art_aut_id'])->update($u);
//去掉已存在的项
foreach ($has_authors as $key => $val) {
if ($val['art_aut_id'] == $v['art_aut_id']) {
unset($has_authors[$key]);
}
}
}
}
if ($insert_res) {
foreach ($has_authors as $v) {
$this->article_author_obj->where('art_aut_id', $v['art_aut_id'])->update(['state' => 1]);
}
}
if ($insert_res) {
Db::commit();
return jsonSuccess([]);
} else {
Db::rollback();
return jsonError("system error!");
}
}
/**
* 添加文章文件
*/
public function addArticlefile()
{
$data = $this->request->post();
$rule = new Validate([
'article_id' => 'require',
'type' => 'require',
'url' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$article_info = $this->article_obj->where('article_id', $data['article_id'])->find();
$user_info = $this->user_obj->where('user_id', $article_info['user_id'])->find();
$file_id = self::save_article_file($data['article_id'], $article_info['user_id'], $user_info['account'], $data['url'], $data['type']);
$re['file_id'] = $file_id;
return jsonSuccess($re);
}
public function delArticleFile()
{
$data = $this->request->post();
$rule = new Validate([
'file_id' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$this->article_file_obj->where('file_id', $data['file_id'])->update(['state' => 1]);
return jsonSuccess([]);
}
/**
* 删除
*/
public function delSaveArticle()
{
$data = $this->request->post();
$rule = new Validate([
'article_id' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$this->article_obj->where('article_id', $data['article_id'])->update(['state' => 3]);
return jsonSuccess([]);
}
/**
* 添加文章最终
*/
public function addArticlePart4(){
$data = $this->request->post();
$rule = new Validate([
'article_id' => 'require',
// 'istransfer' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
//验证文章领域
$sMajorData = empty($data['major']) ? '' : $data['major'];//文章领域
if(empty($sMajorData)){
return jsonError('Please select the field of the article');
}
//判断是否转投
// if (!isset($data['istransfer'])) {
// return jsonError('Please choose to transfer to a journal');
// }
// if(isset($data['istransfer']) && $data['istransfer'] == 'true' && empty($data['checkedjours'])){
// return jsonError('Please choose whether to transfer or not');
// }
$article_info = $this->article_obj->where('article_id', $data['article_id'])->find();
if(empty($article_info)){
return jsonError('The article does not exist.');
}
$journal_info = $this->journal_obj->where('journal_id', $article_info['journal_id'])->find();
if(empty($journal_info)){
return jsonError('The journal to which the article belongs does not exist');
}
$user_res = $this->user_obj->where('user_id', $article_info['user_id'])->find();
if(empty($user_res)){
return jsonError('Author information does not exist');
}
//验证是否在黑名单
$black = $this->user_black_obj->where('user_id', $user_res['user_id'])->where('black_state', 0)->find();
if ($black) {
return jsonError("Your account is currently blacklisted by TMR Publishing Group. Please contact the official email of the journal you wish to submit to for further clarification.");
}
//验证前三步骤是否完成
$aArticleState = $this->getArticleStateThree($article_info);
$iStatus = empty($aArticleState['status']) ? 0 : $aArticleState['status'];
$sMsg = empty($aArticleState['msg']) ? '' : $aArticleState['msg'];
if($iStatus != 1){
return jsonError($sMsg);
}
//稿件号
$sbbr = empty($journal_info['abbr']) ? '' : $journal_info['abbr'];
$sArticleType = empty($article_info['type']) ? '' : $article_info['type'];
$sArticleSn = '';
if(!empty($sbbr) && !empty($sArticleType)){
$sArticleSn = getArticleSN($sbbr, $sArticleType);
}
$author_email = [];
$authors = $this->article_author_obj->where('article_id', $data['article_id'])->where('state', 0)->select();
foreach ($authors as $k => $v) {
$cache['email'] = trim($v['email']);
$cache['name'] = trim($v['firstname']) . ' ' . trim($v['lastname']);
$author_email[] = $cache;
if ($v['is_report'] == "true") {
$re_user_check = $this->user_obj->where('account|email', trim($v['email']))->find();
if (!$re_user_check) {
$password = getRandPassword();
$inser_data['account'] = trim($v['email']);
$inser_data['password'] = md5($password);
$inser_data['email'] = trim($v['email']);
$inser_data['realname'] = trim($v['firstname']) . ' ' . trim($v['lastname']);
$inser_data['ctime'] = time();
$uid = $this->user_obj->insertGetId($inser_data);
$iuri['reviewer_id'] = $uid;
$iuri['country'] = $v['country'];
$iuri['technical'] = $v['author_title'];
$iuri['test_from'] = "addArticlePart4";
$this->user_reviewer_info_obj->insert($iuri);
//发送提示邮件给通讯作者
$report_tt = "Dear " . $inser_data['realname'] . ',
';
$report_tt .= "We are delighted to welcome you as a new author for our journal, " . $journal_info['title'] . ". We have received your submission and are excited to review it for potential publication.
";
$report_tt .= "As a next step, we have created an account for you on our journal's website. Your account is [Username: " . trim($v['email']) . " password:$password]";
$report_tt .= "and you can access your account by visiting " . $journal_info['website'] . " and logging in.
";
$report_tt .= "If you have any questions or need assistance with accessing your account, please don't hesitate to contact us. We are here to support you throughout the submission and review process.
";
$report_tt .= "Thank you for choosing to submit your work to our journal. We look forward to working with you.
";
$report_tt .= "Best regards,
Editorial Office" . '
' . $journal_info['title'];
$maidata['email'] = trim($v['email']);
$maidata['title'] = $journal_info['title'];
$maidata['content'] = $report_tt;
$maidata['tmail'] = $journal_info['email'];
$maidata['tpassword'] = $journal_info['epassword'];
if (trim($v['email']) !== $user_res['email']) {
Queue::push('app\api\job\mail@fire', $maidata, "tmail");
}
}
}
}
//增加转投信息
// $transr = true;
// if ($data['istransfer'] == 'true') {
// foreach ($data['checkedjours'] as $val) {
// $trans_insert['article_id'] = $data['article_id'];
// $trans_insert['journal_id'] = $val;
// $trans_insert['ctime'] = time();
// $transr = $transr ? $this->article_transfer_obj->insert($trans_insert) : false;
// }
// }
//发送邮件到编辑,提醒有待审文章
$editor_info = $this->user_obj->where('user_id', $journal_info['editor_id'])->find();
$tt = 'Dear editor,
';
$tt .= 'Please check the new manuscript in the submission system.' . $sArticleSn;
sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
$user_rev_info = $this->user_reviewer_info_obj->where("reviewer_id", $user_res['user_id'])->find();
//发送邮件给作者,表示感谢
$tt_t = 'Dear Dr. ' . ($user_res['realname'] == '' ? $user_res['account'] : $user_res['realname']) . ',
';
if ($article_info['journal_id'] == 1) {
$tt1 = 'Thank you for submitting your manuscript entitled "' . $article_info['title'] . '". Your submission has been assigned the following tracking number: ' . $sArticleSn . '. We will be in touch again as soon as we have reached a decision. You may check on the status of this manuscript in the Submission System. Please quote the tracking number in any communication.
';
$tt1 .= 'The following information was acknowledged during the submission process: Traditional Medicine Research is an open access journal that charges a publication fee of 600 USD for accepted manuscripts (click here for details).
';
$tt1 .= 'This e-mail simply acknowledges receipt of your submission. If the editors decide for editorial reasons that the paper is unsuitable for publication in Traditional Medicine Research, you will be informed as soon as possible.
';
$tt1 .= 'If you encounter any problems, please contact tmr@tmrjournals.com.
Thank you for choosing to submit your manuscript to Traditional Medicine Research.
';
$tt1 .= 'Sincerely,
Editorial Office
';
$tt1 .= $journal_info['title'] . '
';
$tt1 .= 'Email: ' . $journal_info['email'] . '
';
$tt1 .= 'Website: ' . $journal_info['website'] . '
';
$tt1 .= '
If you have any questions, please contact us:
';
$tt1 .= 'Head of publication ethics
Dr. Dan Chen
TMR Publishing Group Limited Company, Auckland, New Zealand
Email: publication.ethics@tmrjournals.com';
} else {
$tt1 = 'Thank you for submitting your manuscript entitled "' . $article_info['title'] . '". Your submission has been assigned the following tracking number:' . $sArticleSn . '. We will be in touch again as soon as we have reached a decision. Please quote the tracking number in any communication. This e-mail simply acknowledges receipt of your submission. If the editors decide for editorial reasons that the paper is unsuitable for publication in ' . $journal_info['title'] . ', you will be informed as soon as possible.
';
$tt1 .= 'You may check on the status of this manuscript in the Submission System. If you encounter any problems, please contact ' . $journal_info['email'] . '.
';
$tt1 .= 'Thank you for choosing to submit your manuscript to ' . $journal_info['title'] . '.
';
$tt1 .= 'Sincerely,
Editorial Office
';
$tt1 .= 'Subscribe to this journal
';
$tt1 .= $journal_info['title'] . '
';
$tt1 .= 'Email: ' . $journal_info['email'] . '
';
$tt1 .= 'Website: ' . $journal_info['website'] . '
';
$tt1 .= '
If you have any questions, please contact us:
';
$tt1 .= 'Head of publication ethics
Dr. Dan Chen
TMR Publishing Group Limited Company, Auckland, New Zealand
Email: publication.ethics@tmrjournals.com';
}
sendEmail($user_res['email'], $journal_info['title'], $journal_info['title'], $tt_t . $tt1, $journal_info['email'], $journal_info['epassword']);
foreach ($author_email as $v) {
$cache_str = 'Dear Dr. ' . $v['name'] . ',
';
$maidata['email'] = $v['email'];
$maidata['title'] = $journal_info['title'];
$maidata['content'] = $cache_str . $tt1;
$maidata['tmail'] = $journal_info['email'];
$maidata['tpassword'] = $journal_info['epassword'];
Queue::push('app\api\job\mail@fire', $maidata, "tmail");
}
//增加用户操作log
$log_data['user_id'] = $user_res['user_id'];
$log_data['type'] = 0;
$log_data['content'] = $user_res['account'] . "(" . $user_res['realname'] . "),上传了一篇文章:" . $article_info['title'] . ",上传时间是:" . date('Y-m-d H:i:s', time());
$log_data['ctime'] = time();
$res_log = $this->user_log_obj->insert($log_data);
//增加usermsg
$res_msg = add_usermsg($journal_info['editor_id'], 'New manuscript sn:'.$sArticleSn, '/articleDetailEditor?id=' . $data['article_id']);
//通讯作者转为审稿人
$this->addReviewerFromArticle($data['article_id'], $journal_info['journal_id']);
//推荐审稿人
$reviewers = isset($data['reviewers']) ? $data['reviewers'] : [];
foreach ($reviewers as $v) {
if(empty($v['email'])){
continue;
}
$this->addRecommentReviewer($v, $journal_info['journal_id'], $user_res['user_id'], $data['article_id']);
}
$update_l['state'] = 0;
$update_l['ctime'] = time();
if (isset($data['code']) && $data['code'] != '') {
$update_l['code'] = trim($data['code']);
}
//新增保存字段 chengxiaoling 20251031 start
// if (isset($data['istransfer']) && $data['istransfer'] == true) {
// $update_l['is_transfer'] = 1;
// }
// if (isset($data['istransfer']) && $data['istransfer'] == false) {
// $update_l['is_transfer'] = 0;
// }
if (isset($data['is_become_reviewer'])) {
$update_l['is_become_reviewer'] = $data['is_become_reviewer'];
}
if (isset($data['is_agree'])) {
$update_l['is_agree'] = $data['is_agree'];
}
if(!empty($sArticleSn)){
$update_l['accept_sn'] = $sArticleSn;
}
//新增保存字段 chengxiaoling 20251031 end
//更新文章用户最新操作状态 chengxiaoling start 20251113
$update_l['is_user_act'] = 1;
$update_l['user_update_time'] = time();
$update_l['received_time'] = time();
$iArticleId = empty($data['article_id']) ? 0 : $data['article_id'];
if(!empty($iArticleId)){
//用户操作日志
$oUserActLog = new \app\common\UserActLog;
$aUserLog = ['article_id' => $iArticleId,'type' => 5,'act_id' => $iArticleId,'user_id' => empty($user_res['user_id']) ? 0 : $user_res['user_id'],'content' => 'Author submits new manuscript'];
$aAddResult = $oUserActLog->addLog($aUserLog);
}
//更新文章用户最新操作状态 chengxiaoling end 20251113
$this->article_obj->where('article_id', $data['article_id'])->update($update_l);
$this->ai_scor($data['article_id']);
//AI初审队列 chengxiaoling 20250815 start
$iArticleId = empty($data['article_id']) ? 0 : $data['article_id'];//文章ID
if(!empty($iArticleId)){
$aQueueParam = ['article_id' => $iArticleId];
$sQueueId = \think\Queue::push('app\api\job\ArticleReview@fire', $aQueueParam, 'ArticleReview');
}
//AI初审队列 chengxiaoling 20250815 end
//判断是否有文章领域 进行更新操作 chengxiaoling 20250722 start
if(!empty($sMajorData) && !empty($iArticleId)){
$this->updateArticleField(['article_id' => $iArticleId,'article_field' => $sMajorData]);
}
//判断是否有文章领域 进行更新操作 chengxiaoling 20250722 end
return json(['code' => 0]);
}
public function ffff(){
$data = $this->request->post();
$this->ai_scor($data['article_id']);
}
/**
* 获取文章通讯作者信息
*/
public function getArticleReport()
{
$data = $this->request->post();
$rule = new Validate([
'article_id' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$reports = $this->article_author_obj->where('article_id', $data['article_id'])->where('is_report', 1)->select();
foreach ($reports as $k => $v) {
$ca = $this->user_obj->where('email', $v['email'])->find();
$reports[$k]['account'] = $ca;
}
$re['reports'] = $reports;
return jsonSuccess($re);
}
public function editHindexAndScor()
{
$data = $this->request->post();
$rule = new Validate([
'article_id' => 'require',
'email' => 'require',
'Hindex' => 'require',
'editor_id' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$editor_info = $this->user_obj->where('user_id', $data['editor_id'])->find();
$updata['google_index'] = $data['Hindex'];
$updata['google_time'] = time();
$updata['google_editor'] = $editor_info['realname'];
$this->user_obj->where('email', $data['email'])->update($updata);
$this->ai_scor($data['article_id']);
return jsonSuccess([]);
}
/**刷新评分
* @return void
*/
public function refuseScore()
{
$data = $this->request->post();
$rule = new Validate([
"article_id" => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$this->ai_scor($data['article_id']);
return jsonSuccess([]);
}
/**
* 人工智能打分
*/
public function ai_scor($article_id)
{
$article_info = $this->article_obj->where('article_id', $article_id)->find();
$files = $this->article_file_obj->where('article_id', $article_id)->where('type_name', 'manuscirpt')
->order('ctime desc')
->limit(1)
->select();
$authors = $this->article_author_obj->where('article_id', $article_id)->where('is_report', 1)->where('state', 0)->select();
$user_id = $article_info['user_id'];
$g_index = 0;
$google_time = 0;
foreach ($authors as $v) {
//获取H指数的值,wos为第一,scopus为第二,google为第三
$c_user = $this->user_obj->where('email', $v['email'])->find();
if ($c_user['wos_index'] > $c_user['scopus_index']) {//采用wos
if ($g_index < $c_user['wos_index']) {
$g_index = $c_user['wos_index'];
}
} else {
if ($c_user['scopus_index'] > 0) {//采用scopus
if ($g_index < $c_user['scopus_index']) {
$g_index = $c_user['scopus_index'];
}
} else {//采用google或者为空
if ($c_user['google_index'] > 0) {
if ($g_index < $c_user['google_index']) {
$g_index = $c_user['google_index'];
}
} else {//全部为空
if ($c_user['google_time'] > 0 || $c_user['wos_time'] > 0 || $c_user['scopus_time'] > 0) {//应对h指数为0的用户文章,先取是否填写过h指数为0的情况
$google_time++;
}
}
}
}
// if ($google_time < $c_user['google_time']) {//应对h指数为0的用户文章,先取是否填写过h指数为0的情况
// $google_time = $c_user['google_time'];
// }
// if ($c_user['google_index'] >= $g_index) {
// $user_id = $c_user['user_id'];
// $g_index = $c_user['google_index'];
// }
}
// $user_info = $this->user_obj->where('user_id', $user_id)->find();
$fen = 0;
//h指数分数
// $h_fen = 0;
if ($g_index >= 20) {
$h_fen = 4;
} elseif ($g_index >= 12) {
$h_fen = 3;
} elseif ($g_index >= 6) {
$h_fen = 2;
} elseif ($g_index >= 2) {
$h_fen = 1;
} else {
$h_fen = 0;
}
$fen += $h_fen;
//图表
$b_fen = 0;
$p_num = 0;
$url = $this->ts_base_url . "api/typeset/readPic";
$program['fileRoute'] = "https://submission.tmrjournals.com/public/" . $files[0]['file_url'];
$res = object_to_array(json_decode(myPost($url, $program)));
$wp = isset($res['data']['pic']) ? $res['data']['pic'] : 0;
$tp = isset($res['data']['table']) ? $res['data']['table'] : 0;
$pics = $this->article_file_obj->where('article_id', $article_id)->where('type_name', 'picturesAndTables')->select();
$np = 0;
foreach ($pics as $v) {
$ext = substr(strrchr($v['file_url'], '.'), 1);
if ($ext == 'zip') {
$cn = $this->readZip(ROOT_PATH . "public" . DS . $v['file_url']);
$np += $cn;
} else {
$np++;
}
}
$p_num = $wp > $np ? $wp : $np;
$all_num = $p_num + $tp;
if ($article_info['type'] == "A") {
if ($all_num >= 5) {
$b_fen = 2;
} elseif ($all_num >= 4) {
$b_fen = 1.5;
} elseif ($all_num >= 2) {
$b_fen = 1;
} elseif ($all_num >= 1) {
$b_fen = 0.5;
} else {
$b_fen = 0;
}
} elseif ($article_info['type'] == "B") {
if ($all_num >= 4) {
$b_fen = 2;
} elseif ($all_num >= 3) {
$b_fen = 1.5;
} elseif ($all_num >= 2) {
$b_fen = 1;
} elseif ($all_num >= 1) {
$b_fen = 0.5;
} else {
$b_fen = 0;
}
} else {
if ($all_num >= 2) {
$b_fen = 2;
} elseif ($all_num >= 1) {
$b_fen = 1;
} else {
$b_fen = 0;
}
}
// $all_num = $p_num + $tp;
// if ($all_num > 3) {
// $b_fen = 2;
// } elseif ($all_num >= 1) {
// $b_fen = 1;
// } else {
// $b_fen = 0;
// }
//当h指数为0 并且是编辑填写的
if ($h_fen == 0 && $google_time > 0) {
if ($article_info['type'] == "A") {
if ($all_num >= 6) {
$b_fen = 4;
} elseif ($all_num >= 5) {
$b_fen = 3;
} elseif ($all_num >= 4) {
$b_fen = 2.5;
} elseif ($all_num >= 3) {
$b_fen = 2;
} elseif ($all_num >= 2) {
$b_fen = 1;
} elseif ($all_num >= 1) {
$b_fen = 0.5;
} else {
$b_fen = 0;
}
} elseif ($article_info['type'] == "B") {
if ($all_num >= 5) {
$b_fen = 4;
} elseif ($all_num >= 4) {
$b_fen = 3;
} elseif ($all_num >= 3) {
$b_fen = 2;
} elseif ($all_num >= 2) {
$b_fen = 1;
} elseif ($all_num >= 1) {
$b_fen = 0.5;
} else {
$b_fen = 0;
}
} else {
if ($all_num >= 2) {
$b_fen = 4;
} elseif ($all_num >= 1) {
$b_fen = 2;
} else {
$b_fen = 0;
}
}
// if ($all_num >= 8) {
// $b_fen = 4;
// } elseif ($all_num == 7) {
// $b_fen = 3.5;
// } elseif ($all_num == 6) {
// $b_fen = 3;
// } elseif ($all_num == 5) {
// $b_fen = 2;
// } elseif ($all_num == 4) {
// $b_fen = 1.5;
// } elseif ($all_num >= 1) {
// $b_fen = 1;
// } else {
// $b_fen = 0;
// }
}
$fen += $b_fen;
//图表扣分环节
if ($article_info['journal_id'] == 1) {
$jan_fen = 0;
if ($article_info['type'] == "A") {
if ($all_num < 1) {
$jan_fen = 2;
} elseif ($all_num < 2) {
$jan_fen = 1;
} elseif ($all_num < 3) {
$jan_fen = 0.5;
}
} elseif ($article_info['type'] == "B") {
if ($all_num == 0) {
$jan_fen = 1;
}
}
$b_fen = $b_fen - $jan_fen;
$fen = $fen - $jan_fen;
} else {
$jan_fen1 = 0;
if ($article_info['type'] == "A") {
if ($all_num < 1) {
$jan_fen1 = 1;
}
if ($all_num < 2) {
$jan_fen1 = 0.5;
}
} elseif ($article_info['type'] == "B") {
if ($all_num == 0) {
$jan_fen1 = 0.5;
}
}
$b_fen = $b_fen - $jan_fen1;
$fen = $fen - $jan_fen1;
}
//国家
$c_fen = 0;
$author = $this->article_author_obj->where('article_id', $article_id)->where('is_report', 1)->find();
if ($author['country'] != "") {
$coun = $this->country_obj->where('en_name', $author['country'])->find();
if ($coun && $coun['is_hot'] == 1) {
$c_fen = 1;
$fen += 1;
} elseif ($coun && $coun['en_name'] != "China" && $coun['en_name'] != "India") {
$c_fen = 0.5;
$fen += 0.5;
} else {
$c_fen = 0;
$fen += 0;
}
}
//单位
$dw_fen = 0;
$dw_authors = $this->article_author_obj->where("article_id", $article_id)->where("state", 0)->select();
foreach ($dw_authors as $v) {
$ca_res = $this->company_top_obj->where('title', $v['company'])->find();
if ($ca_res) {
if ($ca_res['company_id'] <= 100 || ($ca_res['company_id'] > 201 && $ca_res['company_id'] <= 301)) {
$dw_fen = 1.5;
} else {
if ($dw_fen < 1.5) {
$dw_fen = 1;
}
}
}
}
$fen += $dw_fen;
// $report_author = $this->article_author_obj->where('article_id', $article_id)->where('state', $user_info['email'])->find();
//
// if ($report_author) {
// $ca_res = $this->company_top_obj->where('title', $report_author['company'])->find();
// if ($ca_res) {
// if ($ca_res['company_id'] <= 100 || ($ca_res['company_id'] > 201 && $ca_res['company_id'] <= 301)) {
// $dw_fen = 1.5;
// $fen += 1.5;
// } else {
// $dw_fen = 1;
// $fen += 1;
// }
// }
// }
//领域
$ly_fen = 0;
$m = $this->major_obj->where('major_id', $article_info['major_id'])->find();
if (!empty($m['is_hot']) && $m['is_hot'] == 1) {
$ly_fen = 1;
$fen += 1;
}
//基金
$jj_fen = 0;
if (strlen($article_info['fund']) > 10) {
$jj_fen = 0.5;
$fen += 0.5;
}
//对于以往文章的投递情况加分
$history_fen = $this->historyFen($article_id);
if($history_fen>0){
$fen += $history_fen;
}
// return $fen;
$updata['scoring'] = $fen;
$updata['h_fen'] = $h_fen;
$updata['b_fen'] = $b_fen;
$updata['c_fen'] = $c_fen;
$updata['dw_fen'] = $dw_fen;
$updata['ly_fen'] = $ly_fen;
$updata['jj_fen'] = $jj_fen;
$this->article_obj->where('article_id', $article_id)->update($updata);
return jsonSuccess([]);
}
public function hf_test(){
$data = $this->request->post();
$rule = new Validate([
"article_id"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
echo $this::historyFen($data['article_id']);
}
private function historyFen($article_id){
$es = $this->article_author_obj->where("article_id",$article_id)->where("is_report",1)->where("state",0)->column("email");
$authors = $this->article_author_obj
->field("t_article.*")
->join("t_article","t_article.article_id = t_article_author.article_id","left")
->whereIn("t_article_author.email",$es)
->where("t_article_author.is_report",1)
->where("t_article_author.article_id","<>",$article_id)
->where("t_article_author.state",0)
->where("t_article.ctime",">",strtotime("-3 years"))
->group("t_article_author.article_id")
->select();
if(count($authors)==0){
return 0;
}elseif (count($authors)==1){
if($authors[0]['ctime']0.8){
return 0.5;
}elseif ($fl>0.7){
return 0.4;
}elseif ($fl>0.6){
return 0.3;
}else{
return 0.2;
}
}
}
private function readZip($file)
{
$zip = new \ZipArchive();
if ($zip->open($file) === true) {
return $zip->numFiles;
} else {
return 0;
}
}
/**
* 添加推荐审稿人
*/
public function addRecommentReviewer($reivewe, $journal_id, $user_id, $article_id)
{
if(empty($reivewe['email'])){
return true;
}
$journal_info = $this->journal_obj->where('journal_id', $journal_id)->find();
//判断此用户是否存在
$reviewer_info = $this->user_obj->where('email', trim($reivewe['email']))->where('state', 0)->find();
if ($reviewer_info == null) { //添加用户
$insert_user['account'] = $reivewe['email'];
$insert_user['password'] = md5('123456qwe');
$insert_user['email'] = $reivewe['email'];
$insert_user['realname'] = $reivewe['realname'];
$insert_user['ctime'] = time();
$i_id = $this->user_obj->insertGetId($insert_user);
$reviewer_info = $this->user_obj->where('user_id', $i_id)->find();
}
//判断是否是此期刊审稿人
$rtj = $this->reviewer_to_journal_obj->where('journal_id', $journal_id)->where('reviewer_id', $reviewer_info['user_id'])->where('state', 0)->find();
$res2 = true;
$res3 = true;
if ($rtj == null) {
//判断是否具有审稿人身份,并具有审稿人资料
$uri = $this->user_reviewer_info_obj->where('reviewer_id', $reviewer_info['user_id'])->where('state', 0)->find();
if ($uri == null) { //添加审稿人信息
$insert_reviewer_info['reviewer_id'] = $reviewer_info['user_id'];
$insert_reviewer_info['major'] = empty($reivewe['major']) ? '' : $reivewe['major'];
// $insert_reviewer_info['cmajor'] = $reivewe['cmajor'];
$insert_reviewer_info['country'] = empty($reivewe['country']) ? '' : $reivewe['country'];
$insert_reviewer_info['company'] = empty($reivewe['company']) ? '' : $reivewe['company'];
$insert_reviewer_info['department'] = empty($reivewe['department']) ? '' : $reivewe['department'];
$insert_reviewer_info['test_from'] = "addRecommentReviewer";
$res2 = $this->user_reviewer_info_obj->insert($insert_reviewer_info);
}
$insert_rtj['reviewer_id'] = $reviewer_info['user_id'];
$insert_rtj['journal_id'] = $journal_info['journal_id'];
$insert_rtj['account'] = $reviewer_info['account'];
$insert_rtj['journal_title'] = $journal_info['title'];
$insert_rtj['ctime'] = time();
$res3 = $this->reviewer_to_journal_obj->insert($insert_rtj);
}
//添加推荐审稿人信息
$aWhere = ['urr_state' => 0,'article_id' => $article_id,'reviewer_id' => $reviewer_info['user_id']];
$aUserRecommend = Db::name('user_reviewer_recommend')->where($aWhere)->count();
$res_recommend = true;
if(empty($aUserRecommend)){
$insert_recommend['reviewer_id'] = $reviewer_info['user_id'];
$insert_recommend['article_id'] = $article_id;
$insert_recommend['recommend_user_id'] = $user_id;
$insert_recommend['urr_ctime'] = time();
$res_recommend = $this->user_reviewer_recommend_obj->insert($insert_recommend);
}
if ($res2 && $res3 && $res_recommend) {
return true;
} else {
return false;
}
}
/**
* @title 获取待审文章
* @description 获取待审文章
* @return articles:待审稿件#
* @author wangjinlei
* @url /api/Article/getReviewerArticles
* @method POST
*
*
*/
public function getReviewerArticles()
{
$list = $this->article_obj
->field('t_article.*,t_journal.title journalname')
->join('t_journal', 't_journal.journal_id = t_article.journal_id', 'LEFT')
->where('t_article.state', 2)->where("CHAR_LENGTH(t_article.title)=LENGTH(t_article.title)")->limit(3)->select();
$re['articles'] = $list;
return jsonSuccess($re);
}
/**
* @title 获取待审文章
* @description 获取待审文章
* @param name:issn type:string require:1 desc:issn
*
* @return articles:待审稿件#
* @author wangjinlei
* @url /api/Article/getReviewerArticlesForJournal
* @method POST
*
*/
public function getReviewerArticlesForJournal()
{
$data = $this->request->post();
$journal_info = $this->journal_obj->where('issn', $data['issn'])->find();
$list = $this->article_obj
->field('t_article.*,t_journal.title journalname')
->join('t_journal', 't_journal.journal_id = t_article.journal_id', 'LEFT')
->where('t_article.state', 2)->where('t_article.journal_id', $journal_info['journal_id'])
->where("(t_journal.journal_id = 21) or (length(t_article.title) = CHARACTER_LENGTH(t_article.title))")
->limit(3)->select();
$re['articles'] = $list;
return jsonSuccess($re);
}
// public function cfreviewer(){
// $list = $this->article_author_obj->where("is_report",1)->select();
// foreach ($list as $v){
// $ar = $this->article_obj->where("article_id",$v['article_id'])->find();
// if(!$ar){
// continue;
// }
// $this->addReviewerFromReportAuthor($v['art_aut_id'], $ar['journal_id']);
// }
// echo 'ok';
// }
private function addReviewerFromArticle($article_id, $journal_id)
{
$list = $this->article_author_obj->where('article_id', $article_id)->where('is_report', 1)->where('state', 0)->select();
foreach ($list as $v) {
$this->addReviewerFromReportAuthor($v['art_aut_id'], $journal_id);
}
}
/**
* 添加审稿人来自通讯作者
*/
private function addReviewerFromReportAuthor($art_aut_id, $journal_id)
{
$journal_info = $this->journal_obj->where('journal_id', $journal_id)->find();
//判断通讯作者信息是否合规
$author_info = $this->article_author_obj->where('art_aut_id', $art_aut_id)->find();
if (!preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $author_info['email'])) {
return;
}
$check = $this->reviewer_from_author_obj->where('art_aut_id', $art_aut_id)->where('journal_id', $journal_id)->find();
if ($check) {
return;
}
//判断目前的状态进行下一步流程
$user_info = $this->user_obj->where('email', $author_info['email'])->where('state', 0)->find();
if ($user_info == null) { //不存在用户
//添加用户,发送邮件
$user_insert['account'] = $author_info['email'];
$user_insert['password'] = md5("123456qwe");
$user_insert['email'] = $author_info['email'];
$user_insert['realname'] = $author_info['firstname'] . " " . $author_info['lastname'];
$user_insert['ctime'] = time();
$add_user_id = $this->user_obj->insertGetId($user_insert);
//发送邮件
$tt = 'Dear Dr. ' . $user_insert['realname'] . '
';
$tt .= 'Thank you for submitting your paper to ' . $journal_info['title'] . ' as the corresponding author.
';
$tt .= 'In order to provide a better online experience for authors, we have set up your account in our submission system.
';
$tt .= 'You could log in with your account in https://submission.tmrjournals.com/login
';
$tt .= 'Your username:' . $author_info['email'] . '
';
$tt .= 'Your password:123456qwe (you could change your password in the system by yourself later.)
';
$tt .= 'Thank you so much for your kindly support.
';
$tt .= 'Sincerely,
Editorial Office
' . $journal_info['title'] . '
';
$tt .= 'Email: ' . $journal_info['email'] . '
';
$tt .= 'Website:' . $journal_info['website'] . '';
sendEmail($author_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
//添加转换表数据
$art_insert['art_aut_id'] = $art_aut_id;
$art_insert['journal_id'] = $journal_id;
$art_insert['rfa_ctime'] = time();
$this->reviewer_from_author_obj->insert($art_insert);
return;
}
$reviewer_check = $this->reviewer_to_journal_obj->where('reviewer_id', $user_info['user_id'])->where('state', 0)->find();
$reviewer_this_check = $this->reviewer_to_journal_obj->where('reviewer_id', $user_info['user_id'])->where('journal_id', $journal_id)->where('state', 0)->find();
if ($reviewer_check == null) { //存在用户但不是审稿人
//添加转换表数据
$art_insert['art_aut_id'] = $art_aut_id;
$art_insert['journal_id'] = $journal_id;
$art_insert['rfa_ctime'] = time();
$this->reviewer_from_author_obj->insert($art_insert);
return;
} else {
if ($reviewer_this_check == null) {
//直接添加审稿人
$reviewer_insert['reviewer_id'] = $user_info['user_id'];
$reviewer_insert['journal_id'] = $journal_id;
$reviewer_insert['account'] = $author_info['email'];
$reviewer_insert['journal_title'] = $journal_info['title'];
$reviewer_insert['ctime'] = time();
$this->reviewer_to_journal_obj->insert($reviewer_insert);
return;
} else {
return;
}
}
}
/**
* 作者发送消息
*/
public function authorMessage()
{
$data = $this->request->post();
$insert['article_id'] = $data['articleId'];
$insert['content'] = $data['content'];
$insert['ftype'] = 1;
$insert['ctime'] = time();
$this->article_msg_obj->insert($insert);
$article_info = $this->article_obj->where("article_id",$data['articleId'])->find();
$journal_info = $this->journal_obj->where("journal_id",$article_info['journal_id'])->find();
$editor_info = $this->user_obj->where('user_id', $journal_info['editor_id'])->find();
$tt = 'Dear editor,
';
$tt .= 'The author sent a new message, please check. SN:'.$article_info['accept_sn'].'
';
$tt .= 'TMR Publishing Group';
sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
return json(['code' => 0]);
}
/**
* 获取期刊列表
*/
public function getJournal()
{
$username = $this->request->post('username');
$where = [];
if ($username) {
$uidres = $this->user_obj->where(['account' => $username])->column('user_id');
$where['editor_id'] = $uidres[0];
}
$where['state'] = 0;
$list = $this->journal_obj->where($where)->select();
// //获取期刊封面 chengxiaoling 20251027 start
// if(!empty($list)){
// $aParam = ['issn' => array_column($list, 'issn')];
// $sUrl = 'http://journalapi.tmrjournals.com/public/index.php/';
// $sUrl = $sUrl."api/Supplementary/getJournal";
// $aResult = object_to_array(json_decode(myPost1($sUrl,$aParam),true));
// $aResult = empty($aResult['data']) ? [] : array_column($aResult['data'], 'icon','issn');
// foreach ($list as $key => $value) {
// $list[$key]['journal_icon'] = empty($aResult[$value['issn']]) ? '' : $aResult[$value['issn']];
// }
// }
// //获取期刊封面 chengxiaoling 20251027 end
return json($list);
}
/**
* 获取期刊列表
*/
public function getJournalOutLx()
{
$editorid = $this->request->post('editor_id');
$list = $this->journal_obj->where('editor_id', $editorid)->where('journal_id', 'not in', '2,3,15')->select();
return json($list);
}
/**
* 获取文章历史上传file列表
*/
public function getFilelistByArticleID()
{
$article_id = $this->request->post('articleId');
$where['article_id'] = $article_id;
$res = $this->article_file_obj->where($where)->select();
$frag = [];
foreach ($res as $v) {
$frag[$v['type_name']][] = $v;
}
return json($frag);
}
/**
* 上传文章的文件
*/
public function up_file($type)
{
$file = request()->file($type);
if ($file) {
$info = $file->move(ROOT_PATH . 'public' . DS . $type);
if ($info) {
return json(['code' => 0, 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
} else {
return json(['code' => 1, 'msg' => $file->getError()]);
}
}
}
public function up_approval_file()
{
$file = request()->file('articleApproval');
if ($file) {
$info = $file->move(ROOT_PATH . 'public' . DS . 'articleApproval');
if ($info) {
return json(['code' => 0, 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
} else {
return json(['code' => 1, 'msg' => $file->getError()]);
}
}
}
/**
* @title 上传编辑修回意见文件
* @description 上传编辑修回意见文件
* @param name:name type:string require:1 default:articleProposal desc:文件域名称
*
* @return upurl:图片地址
* @author wangjinlei
* @url /api/Article/up_proposal_file
* @method POST
*
*/
public function up_proposal_file()
{
$file = request()->file('articleProposal');
if ($file) {
$info = $file->move(ROOT_PATH . 'public' . DS . 'articleProposal');
if ($info) {
return json(['code' => 0, 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
} else {
return json(['code' => 1, 'msg' => $file->getError()]);
}
}
}
/**
* 上传作者反馈审稿人文件
*/
public function up_response_file()
{
$file = request()->file('articleResponse');
if ($file) {
$info = $file->move(ROOT_PATH . 'public' . DS . 'articleResponse');
if ($info) {
return json(['code' => 0, 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
} else {
return json(['code' => 1, 'msg' => $file->getError()]);
}
}
}
/**
* 编辑获取连续出刊列表
*/
public function getContinuityJournals()
{
$data = $this->request->post();
$rule = new Validate([
'editor_id' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$res = $this->user_obj->where('user_id', $data['editor_id'])->find();
if (!$res) {
return jsonError('no this user!');
}
$journals = $this->journal_obj->where('editor_id', $res['user_id'])->where('journal_id', 'in', '2,3,15')->select();
$re['journals'] = $journals;
return jsonSuccess($re);
}
/**
* 获取文章审稿实例列表
*/
public function getReviewerList()
{
$data = $this->request->post();
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$where['t_article_reviewer.article_id'] = $data['articleId'];
if(isset($data['expire'])&&$data['expire']==1){
$where['t_article_reviewer.state'] = ["<>",4];
}
$res = $this->article_reviewer_obj
->field('t_article_reviewer.*,t_user.email,t_user.realname,t_user.account reviewer,t_user_reviewer_info.country country,t_user_reviewer_info.field,t_user_reviewer_info.company,t_user_reviewer_info.major')
->join('t_user', 't_article_reviewer.reviewer_id = t_user.user_id', 'LEFT')
->join('t_user_reviewer_info', 't_article_reviewer.reviewer_id = t_user_reviewer_info.reviewer_id', 'LEFT')
// ->join('t_reviewer_major', 't_reviewer_major.major_id = t_user_reviewer_info.major', 'LEFT')
->where($where)->limit($limit_start, $data['pageSize'])->select();
$count = $this->article_reviewer_obj->where($where)->count();
//注释查询审稿人领域 修改为异步操作 chengxiaoling 20250617 start
// foreach ($res as $k => $v) {
// $res[$k]['major_str'] = $this->getMajorStr($v['major']);
// }
//注释查询审稿人领域 修改为异步操作 chengxiaoling 20250617 start
if ($res) {
return json(['code' => 0, 'data' => $res, 'totle' => $count]);
} else {
return json(['code' => 1]);
}
}
/**
* 根据期刊别名获取期刊信息
*/
public function getJournalByAlias()
{
//接收参数
$data = $this->request->post();
$res = $this->journal_obj->where('alias', $data['alias'])->find();
return json($res);
}
public function getJournalByAbbr()
{
$data = $this->request->post();
$rule = new Validate([
"abbr" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$journal_info = $this->journal_obj->where("abbr", $data['abbr'])->find();
$re['detail'] = $journal_info;
return jsonSuccess($re);
}
/**
* 获取审核人详情
*/
public function getReviewerdetail()
{
$uid = $this->request->post('uid');
$res = $this->user_obj->field('t_user.*,t_user_reviewer_info.*,t_reviewer_major.title major_title')
->join('t_user_reviewer_info', 't_user.user_id = t_user_reviewer_info.reviewer_id', 'LEFT')
->join('t_reviewer_major', 't_reviewer_major.major_id = t_user_reviewer_info.major', 'LEFT')
->where('t_user.user_id', $uid)->find();
return json(['code' => 0, 'data' => $res]);
}
/**
* 获取文章审核员list
*/
public function getArticleReviewerList()
{
$data = $this->request->post();
$article_info = $this->article_obj->where('article_id', $data['articleId'])->find();
// $revids = $this->reviewer_to_journal_obj->where('journal_id', $article_info['journal_id'])->where('state',0)->column('reviewer_id');
$noids = $this->article_reviewer_obj->where('article_id', $data['articleId'])->column('reviewer_id');
$noids[] = $article_info['user_id'];
$res = $this->reviewer_to_journal_obj
->field('t_user.user_id,t_user.account')
->join('t_user', 't_user.user_id = t_reviewer_to_journal.reviewer_id', 'left')
->join('t_user_reviewer_info', 't_user.user_id = t_user_reviewer_info.reviewer_id', 'LEFT')
->where('t_reviewer_to_journal.journal_id', $article_info['journal_id'])
->where('t_user.user_id', 'not in', $noids)
->where('t_user.state', 0)
->select();
// if ($noids != null) {
// $where['t_user.user_id'] = [['in', $revids], ['not in', $noids]];
// } else {
// $where['t_user.user_id'] = ['in', $revids];
// }
// $where['t_user.state'] = 0;
// $res = $this->user_obj->field('t_user.*,t_user_reviewer_info.*')
// ->join('t_user_reviewer_info', 't_user.user_id = t_user_reviewer_info.reviewer_id', 'LEFT')
// ->where($where)
// ->select();
//
// echo $this->user_obj->getLastSql();
// die;
if ($res) {
return json(['code' => 0, 'data' => $res]);
} else {
return json(['code' => 1]);
}
}
/**
* 获取文章数通过期刊issn号
*/
public function getArticleForJournal()
{
$data = $this->request->post();
$journal_info = $this->journal_obj->where('issn', $data['issn'])->find();
$list = $this->article_obj
->where('journal_id', $journal_info['journal_id'])
->where('state', 'in', '0,1,2,4')
// ->where('ctime','>',$data['ctime'])
->select();
$re['articles'] = $list;
return jsonSuccess($re);
}
// 给审稿人发送邮件- 稿件的基本情况
public function sendEmailToReviewer($articleId, $state)
{
$resState = $state == 3 ? "Reject" : "Accept";
$allArticleReviewer = $this->article_reviewer_obj->field('t_user.email,t_user.realname,t_article_reviewer.reviewer_id,t_article_reviewer_question.recommend,t_article_reviewer_question.comments')
->join('t_article_reviewer_question', 't_article_reviewer_question.art_rev_id = t_article_reviewer.art_rev_id', 'LEFT')
->join('t_user', 't_user.user_id = t_article_reviewer.reviewer_id', 'LEFT')
->where('t_article_reviewer.article_id', $articleId)
->where('t_article_reviewer.state', 'in', [1, 2, 3])
->select();
// 根据文章ID查询journal_id
$journalInfo = $this->article_obj->field('t_journal.journal_id,t_journal.title,t_journal.email,t_journal.epassword')
->join('t_journal', 't_journal.journal_id = t_article.journal_id', 'LEFT')
->where('t_article.article_id', $articleId)
->find();
// 文章信息
$articleInfo = $this->article_obj->where('article_id', $articleId)->find();
$pushData = [
'title' => $journalInfo['title'], // 邮件标题
'journal_id' => $journalInfo['journal_id'], // 期刊ID
'sendEmail' => $journalInfo['email'], // 期刊邮箱
'sendPassword' => $journalInfo['epassword'], // 期刊密码
'from_name' => $journalInfo['title']
];
$difference = "Please check the final decision of the manuscript you reviewed.
Dear Reviewer,
";
$difference .= "The final decision of the manuscript " . '"' . $articleInfo['accept_sn'] . '"' . " is " . '"' . $resState . '"' . ".
";
$difference .= "We sincerely appreciate the time you spent reading and commenting on manuscripts, and we are very grateful for your willingness to serve in this role. Although final decisions are always editorial,the reviewers bring to our deliberations scientific insights, and passion.
";
$difference .= "We note that the final decision is contrary to your decision.
You deserve to know all peer review decisions and comments following as peer reviewer:
";
$recommend = [
1 => 'Accept with minor changes',
2 => 'Accept subject to revisions, as noted in comments',
3 => 'Reject in current form, but may be resubmitted',
4 => 'Reject, with no resubmission',
];
$all = "Please check the final decision of the manuscript you reviewed.
Dear Reviewer,
";
$all .= "The final decision of the manuscript " . '"' . $articleInfo['accept_sn'] . '"' . " is " . '"' . $resState . '"' . ".
";
$all .= "We sincerely appreciate the time you spent reading and commenting on manuscripts, and we are very grateful for your willingness to serve in this role. Although final decisions are always editorial,the reviewers bring to our deliberations scientific insights, and passion.
";
$all .= "Please let us know your feedback at publisher@tmrjournals.com.";
foreach ($allArticleReviewer as $k => $value) {
// 最终意见发给全部审稿人
$pushData['content'] = $all;
$pushData['user_id'] = $value['reviewer_id'];
$pushData['email'] = $value['email'];
$num = $value['recommend'];
if ($value['comments'] != '') {
$difference .= "
Reviewer " . ($k + 1) . ' : ' . $recommend[$num] . " ( " . preg_replace("/\t/", "", $value['comments']) . " )
";
} else {
$difference .= "
Reviewer " . ($k + 1) . ' : ' . $recommend[$num] . "
";
}
}
$difference .= "
Please let us know your feedback at publisher@tmrjournals.com.";
// 分歧稿件
foreach ($allArticleReviewer as $k => $value) {
$pushData['content'] = $difference;
$pushData['user_id'] = $value['reviewer_id'];
$pushData['email'] = $value['email'];
if ($state == 3 && ($value['recommend'] == 1 || $value['recommend'] == 2)) {
}
if ($state == 5 && ($value['recommend'] == 3 || $value['recommend'] == 4)) {
}
}
}
/**
* 留言板留言文章显示红点并发送邮件
* @param $article_id
* @param $user_id
*/
private function messageTips($article_id, $user_id,$iId = 0)
{
$article = $this->article_obj->field('t_article.user_id,t_article.editor_id,t_article.accept_sn,t_journal.journal_id,t_journal.title,t_journal.email,t_journal.epassword,t_journal.issn as journal_issn,t_journal.website as journal_website')
->join('t_journal', 't_journal.journal_id = t_article.journal_id', 'LEFT')
->where('t_article.article_id', $article_id)
->find();
// 判断提交留言人的身份
$res = $this->user_obj->where('user_id', $user_id)->find();
if ($res['type'] == 1) { // 作者 - 修改author_act,并发送给编辑发邮件
// $this->article_obj->where('article_id', $article_id)->update(['author_act' => 1]);
//更新文章用户最新操作状态 chengxiaoling start 20251113
$aUpdate = ['is_user_act' => 1,'user_update_time' => time(),'author_act' => 1];
$this->article_obj->where('article_id', $article_id)->limit(1)->update($aUpdate);
if(!empty($article_id) && !empty($iId)){
$oUserActLog = new \app\common\UserActLog;
$aUserLog = ['article_id' => $article_id,'type' => 6,'act_id' => $iId,'user_id' => $user_id,'content' => 'Author\'s new message submission'];
$aAddResult = $oUserActLog->addLog($aUserLog);
}
//更新文章用户最新操作状态 chengxiaoling end 20251113
$journal_info = $this->journal_obj->where("journal_id", $article['journal_id'])->find();
$editor = $this->user_obj->where('user_id', $journal_info['editor_id'])->find();
// 发邮件
$content = 'Dear editor,
please check the new feedback. article_sn:'.$article['accept_sn'];
sendEmail($editor['email'], $article['title'], $article['title'], $content, $article['email'], $article['epassword']);
$res_msg = add_usermsg($article['editor_id'], 'New manuscript feedback', '/articleDetailEditor?id=' . $article_id);
}
if ($res['type'] == 2) { //编辑 - 修改editor_act,并发送给作者发邮件
$this->article_obj->where('article_id', $article_id)->update(['editor_act' => 1]);
$author = $this->user_obj->where('user_id', $article['user_id'])->find();
// // 发邮件
// $content = 'Dear ' . $author['realname'] . ',
';
// $content .= 'Thank you for contacting our editor.
ID: ' . $article['accept_sn'] . '.
';
// $content .= ' Your manuscript: ' . $article['accept_sn'] . ' has received a new reply; please login https://submission.tmrjournals.com/login to check.
';
// $content .= 'Sincerely,
' . $article['title'];
// sendEmail($author['email'], $article['title'], $article['title'], $content, $article['email'], $article['epassword']);
//邮件内容修改 chengxiaoling 20251015 start
//邮箱
$email = empty($author['email']) ? '' : $author['email'];
if(!empty($email)){
//邮件模版
$aEmailConfig = [
'email_subject' => 'Please Check the Editorial Comments in the Submission System',
'email_content' => 'Dear {author_name},
We would like to inform you that our editors have left a message regarding your submission in the online submission system at https://submission.tmrjournals.com/login.
Please log in to your account to view the message and respond at your earliest convenience.
If you have any questions or encounter any issues accessing the submission system, please feel free to contact us.
Sincerely,
Editorial Office
{journal_title}
Subscribe to this journal
Email: {journal_email}
Website: {website}'
];
//作者姓名
$realname = empty($author['realname']) ? '' : $author['realname'];
$realname = empty($author['account']) ? $realname : $author['account'];
//期刊标题
$from_name = empty($article['title']) ? '' : $article['title'];
//发送邮件
$memail = empty($article['email']) ? '' : $article['email'];
$mpassword = empty($article['epassword']) ? '' : $article['epassword'];
//处理数据
$aSearch = [
'{journal_title}' => $from_name,//期刊名
'{journal_issn}' => empty($article['journal_issn']) ? '' : $article['journal_issn'],
'{journal_email}' => empty($article['email']) ? '' : $article['email'],
'{website}' => empty($article['journal_website']) ? '' : $article['journal_website'],
'{author_name}' => $realname
];
//邮件标题
$title = empty($aEmailConfig['email_subject']) ? '' : $aEmailConfig['email_subject'];
//邮件内容变量替换
$content = str_replace(array_keys($aSearch), array_values($aSearch), $aEmailConfig['email_content']);
$pre = \think\Env::get('emailtemplete.pre');
$net = \think\Env::get('emailtemplete.net');
$net1 = str_replace("{{email}}",trim($email),$net);
$content=$pre.$content.$net1;
//发送邮件
$result = sendEmail($email,$title,$from_name,$content,$memail,$mpassword);
}
//邮件内容修改 chengxiaoling 20251015 end
}
}
/**编辑消息一键全读
* @return void
*/
public function allEditorMsgReaded()
{
$data = $this->request->post();
$rule = new Validate([
'editor_id' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$this->user_msg_obj->where("user_id", $data['editor_id'])->update(["state" => 1]);
return jsonSuccess([]);
}
/**
* 验证字符长度
* @param $str 字符串
* @param $num 字符长度
* @return void
*/
private function checkMinChars($str = '', $num = 200)
{
// 过滤非汉字和英文的字符(保留汉字、大小写字母)
$filteredStr = preg_replace('/[^\x{4e00}-\x{9fa5}a-zA-Z0-9]/u', '', $str);
// 计算有效字符总数(汉字按1个字符计,英文和数字同理)
$total = mb_strlen($filteredStr, 'UTF-8');
return $total >= $num;
}
/**
* 审稿人审稿质量
* @param $article_id 文章ID
* @return void
*/
private function reviewQuality($article_id = '')
{
$article_id = empty($article_id) ? $this->request->post('article_id') : $article_id;
if (empty($article_id)) {
return json(['status' => 2, 'msg' => '请选择要查询的文章']);
}
//查询文章状态
$aWhere = [
'article_id' => $article_id,
'state' => ['in', [3, 5]]
];
$aArticle = Db::name('article')->field('article_id,state')->where($aWhere)->find();
if (empty($aArticle)) {
return json(['status' => 1, 'msg' => '暂无数据']);
}
//获取该文章审核人的信息
$aWhere = [
'article_id' => $aArticle['article_id'],
'state' => ['in', [1, 2, 3]]
];
$aReviewer = Db::name('article_reviewer')->where($aWhere)->column('reviewer_id,state');
if (empty($aReviewer)) {
return json(['status' => 1, 'msg' => '未查询到审核人信息']);
}
//查询审核人信息
$aUserId = array_keys($aReviewer);
$aUser = Db::name('user')->field('user_id,rs_num,right_times,error_times,major_times')->whereIn('user_id', $aUserId)->select();
if (empty($aUser)) {
return json(['status' => 1, 'msg' => '未查询到审核人信息']);
}
//处理数据并组装数据
$aCase = ['right_times' => '', 'right_rate' => '', 'error_times' => '', 'error_rate' => '', 'major_times' => '', 'major_rate' => ''];
$aToState = [2 => 3, 3 => 5];//文章3拒稿5录用 审稿人2拒稿3通过
foreach ($aUser as $key => $value) {
$iState = empty($aReviewer[$value['user_id']]) ? 0 : $aReviewer[$value['user_id']];
if (empty($iState)) {
continue;
}
if (empty($aToState[$iState])) {
if ($iState == 1) {
$iMajorTimes = $value['major_times'] + 1;
$iMajorRate = empty($value['rs_num']) ? 0 : round($iMajorTimes / $value['rs_num'], 2);
$aCase['major_times'] .= "WHEN {$value['user_id']} THEN ";
$aCase['major_times'] .= "'{$iMajorTimes}' ";
$aCase['major_rate'] .= "WHEN {$value['user_id']} THEN ";
$aCase['major_rate'] .= "'{$iMajorRate}' ";
$aId[] = $value['user_id'];
}
continue;
}
if ($aArticle['state'] == $aToState[$iState]) {
$iTimes = $value['right_times'] + 1;
$iRightRate = empty($value['rs_num']) ? 0 : round($iTimes / $value['rs_num'], 2);
$aCase['right_times'] .= "WHEN {$value['user_id']} THEN ";
$aCase['right_times'] .= "'{$iTimes}' ";
$aCase['right_rate'] .= "WHEN {$value['user_id']} THEN ";
$aCase['right_rate'] .= "'{$iRightRate}' ";
}
if ($aArticle['state'] != $aToState[$iState]) {
$iErrorTimes = $value['error_times'] + 1;
$iErrorRate = empty($value['rs_num']) ? 0 : round($iErrorTimes / $value['rs_num'], 2);
$aCase['error_times'] .= "WHEN {$value['user_id']} THEN ";
$aCase['error_times'] .= "'{$iErrorTimes}' ";
$aCase['error_rate'] .= "WHEN {$value['user_id']} THEN ";
$aCase['error_rate'] .= "'{$iErrorRate}' ";
}
$aId[] = $value['user_id'];
}
//更新数据库
foreach ($aCase as $key => $value) {
if (empty($value)) {
continue;
}
$aUpdate[$key] = Db::raw('CASE user_id ' . $value . 'END');
}
if (empty($aUpdate) || empty($aId)) {
return json(['status' => 1, 'msg' => '未查询到审核人信息']);
}
Db::name('user')->where('user_id', 'IN', $aId)->limit(count($aId))->update($aUpdate);
return json(['status' => 1, 'msg' => '执行成功']);
}
/**
* 获取文章所属领域
* @param reviewer_id 审核人ID
* @param
*/
public function getArticleField($aParam = [])
{
$aParam = empty($aParam) ? $this->request->post() : $aParam;
if (empty($aParam['article_id'])) {
return json_encode(['status' => 2, 'msg' => 'Please select a Article']);
}
//查询审稿人领域信息
$aParam['state'] = 0;
$aReviewerMajor = Db::name('major_to_article')->field('major_id')->where($aParam)->order('major_id asc')->select();
if (empty($aReviewerMajor)) {
return json_encode(['status' => 1, 'msg' => "The article field is empty", 'data' => []]);
}
//数据处理
foreach ($aReviewerMajor as $key => $value) {
$aReviewerMajor[$key]['major_title'] = getMajorStr($value['major_id']);
$aReviewerMajor[$key]['shu'] = getMajorShu($value['major_id']);
}
return json_encode(['status' => 1, 'msg' => "success", 'data' => $aReviewerMajor]);
}
/**
* 修改文章所属领域
* @param reviewer_id 审核人ID
* @param
*/
public function updateArticleField($aParam = [])
{
$aParam = empty($aParam) ? $this->request->post() : $aParam;
$iArticleId = empty($aParam['article_id']) ? 0 : $aParam['article_id'];
if (empty($iArticleId)) {
return json_encode(['status' => 2, 'msg' => 'Please select a article']);
}
$sField = empty($aParam['article_field']) ? '' : $aParam['article_field'];
if (empty($sField)) {
return json_encode(['status' => 2, 'msg' => "Please select the field to which the article belongs"]);
}
$aField = is_array($sField) ? $sField : explode(',', trim($sField, ','));
if (empty($aField)) {
return json_encode(['status' => 3, 'msg' => "Please select the user's field of expertise"]);
}
//查询审稿人领域信息
$aWhere = ['state' => 0, 'article_id' => $iArticleId];
$aArticleMajor = Db::name('major_to_article')->where($aWhere)->order('major_id asc')->column('major_id');
//新增
$aInsert = array_diff($aField, $aArticleMajor);
//删除
$aDelete = array_diff($aArticleMajor, $aField);
//数据处理
Db::startTrans();
if (!empty($aInsert)) {//新增
foreach ($aInsert as $key => $value) {
$aAdd[] = ['major_id' => $value, 'article_id' => $iArticleId, 'ctime' => time(), 'state' => 0];
}
$result = Db::name('major_to_article')->insertAll($aAdd);
}
if (!empty($aDelete)) {//修改状态为1
$aWhere = ['article_id' => $iArticleId, 'state' => 0, 'major_id' => ['in', $aDelete]];
$result = Db::name('major_to_article')->where($aWhere)->limit(count($aDelete))->update(['state' => 1, 'ctime' => time()]);
}
Db::commit();
return json_encode(['status' => 1, 'msg' => "The field to which the article belongs has been successfully updated"]);
}
/**
* 终审状态-通知作者
* @param reviewer_id 审核人ID
* @param
*/
private function sendEmailForAuthor($aParam = [])
{
//稿件信息
$aArticle = empty($aParam['article']) ? 0 : $aParam['article'];
//作者信息
$aUser = empty($aParam['user']) ? 0 : $aParam['user'];
//期刊信息
$aJournal = empty($aParam['journal']) ? 0 : $aParam['journal'];
if(empty($aArticle) || empty($aUser) || empty($aJournal)){
return ['status' => 2,'msg' => 'Missing information'];
}
//邮件内容
$aEmailConfig = [
'email_subject' => 'Manuscript Status Update – Final Decision - {accept_sn}',
'email_content' => '
Dear Dr. {realname},
I hope this message finds you well.
We are writing to inform you that your manuscript entitled “[{article_title}]” (Manuscript ID: [{accept_sn}]) has progressed to the final decision stage.
Thank you once again for choosing to submit your valuable manuscript to our journal.
Sincerely,
Editorial Office
{journal_title}
Email: {journal_email}
Website: {website}'
];
//数据准备-邮件内容替换
$aSearch = [
'{accept_sn}' => empty($aArticle['accept_sn']) ? '' : $aArticle['accept_sn'],//accept_sn
'{article_title}' => empty($aArticle['title']) ? '' : $aArticle['title'],//文章标题
'{abstrart}' => empty($aArticle['abstrart']) ? '' : $aArticle['abstrart'],//文章摘要
'{journal_title}' => empty($aJournal['title']) ? '' : $aJournal['title'],//期刊名
'{journal_issn}' => empty($aJournal['issn']) ? '' : $aJournal['issn'],
'{journal_email}' => empty($aJournal['email']) ? '' : $aJournal['email'],
'{website}' => empty($aJournal['website']) ? '' : $aJournal['website'],
];
//邮箱
$email = empty($aUser['email']) ? '' : $aUser['email'];//'tmr@tmrjournals.com';//
if(empty($email)){
return ['status' => 3,'msg' => 'The author\'s email is empty'];
}
//用户名
$realname = empty($aUser['account']) ? '' : $aUser['account'];
$realname = empty($aUser['realname']) ? $realname : $aUser['realname'];
$aSearch['{realname}'] = $realname;
//用户账号
$aSearch['{account}'] = empty($aUser['account']) ? '' : $aUser['account'];
//邮件标题
$title = str_replace(array_keys($aSearch), array_values($aSearch),$aEmailConfig['email_subject']);
//邮件内容变量替换
$content = str_replace(array_keys($aSearch), array_values($aSearch), $aEmailConfig['email_content']);
//带模版的邮件内容
$pre = \think\Env::get('emailtemplete.pre');
$net = \think\Env::get('emailtemplete.net');
$net1 = str_replace("{{email}}",trim($email),$net);
$content=$pre.$content.$net1;
//发送邮件邮箱配置
$memail = empty($aJournal['email']) ? '' : $aJournal['email'];
$mpassword = empty($aJournal['epassword']) ? '' : $aJournal['epassword'];
//期刊标题
$from_name = empty($aJournal['title']) ? '' : $aJournal['title'];
//发送邮件
$aResult = sendEmail($email,$title,$from_name,$content,$memail,$mpassword);
$iStatus = empty($aResult['status']) ? 1 : $aResult['status'];
$iIsSuccess = $iStatus == 1 ? 1 : 2;
$sMsg = empty($aResult['data']) ? $iIsSuccess : $aResult['data'];
//添加邮件发送日志
$iArticleId = empty($aArticle['article_id']) ? 0 : $aArticle['article_id'];
$iUserId = empty($aArticle['user_id']) ? 0 : $aArticle['user_id'];
$aEmailLog = ['article_id' => $iArticleId,'art_rev_id' => $iArticleId,'reviewer_id' => $iUserId,'type' => 7,'email' => $email,'content' => $content,'create_time' => time(),'is_success' => $iIsSuccess,'msg' => $sMsg];
$oReviewer = new \app\common\Reviewer;
$iId = $oReviewer->addLog($aEmailLog);
return ['status' => $iIsSuccess,'msg' => $sMsg];
}
/**
* 添加文章文件信息
* @param article_id
* @param
*/
public function addArticlePart3($aParam = []){
//获取参数
$aParam = empty($aParam) ? $this->request->post() : $aParam;
//必填值验证
$iArticleId = empty($aParam['article_id']) ? 0 : $aParam['article_id'];
if(empty($iArticleId)){
return json_encode(['status' => 2,'msg' => 'Please select an article']);
}
//用户ID
$iUserId = empty($aParam['user_id']) ? '' : $aParam['user_id'];
if(empty($iUserId)){
return json_encode(['status' => 2,'msg' => 'Please select author']);
}
//获取文章信息
$aArticle = $this->getArticleInfo($aParam);
$iStatus = empty($aArticle['status']) ? 0 : $aArticle['status'];
if($iStatus != 1){
return json_encode($aArticle);
}
$aArticle = empty($aArticle['data']) ? [] : $aArticle['data'];
//是否使用AI
$iIsUserAi = empty($aParam['is_use_ai']) ? 3 : $aParam['is_use_ai']; //是否使用AI1是2否
if($iIsUserAi == 3){
return json_encode(['status' => 5,'msg' => 'Please check whether to use AI technology']);
}
$sUseAiExplain = empty($aParam['use_ai_explain']) ? '' : $aParam['use_ai_explain'];
if($iIsUserAi == 1 && empty($sUseAiExplain)){
return json_encode(['status' => 6,'msg' => 'Please enter supplementary instructions']);
}
//是否上传图片版权声明1是2否
$iIsFigureCopyright = empty($aParam['is_figure_copyright']) ? 3 : $aParam['is_figure_copyright'];
if($iIsFigureCopyright == 3){
return json_encode(['status' => 7,'msg' => 'Please check whether to upload the figure copyright statement']);
}
$aWhere = ['article_id' => $iArticleId,'state' => 0,'type_name' => 'figurecopyright'];
$aFileId = Db::name('article_file')->where($aWhere)->column('file_id');
if($iIsFigureCopyright == 1){//是
if(empty($aFileId)){
return json_encode(['status' => 8,'msg' =>'Please upload the figure copyright declaration file']);
}
}
Db::startTrans();
if($iIsFigureCopyright == 2 && !empty($aFileId)){
$aWhere = ['article_id' => $iArticleId,'file_id' => ['in',$aFileId],'state' => 0,'type_name' => 'figurecopyright'];
$file_result = Db::name('article_file')->where($aWhere)->limit(count($aFileId))->update(['state' => 1]);
if($file_result === false){
return json_encode(['status' => 9,'msg' =>'figure copyright declaration File deletion failed']);
}
}
$aUpdate = ['is_use_ai' => $iIsUserAi,'use_ai_explain' => $sUseAiExplain,'is_figure_copyright' => $iIsFigureCopyright];
//更新文章内容
$aWhere = ['article_id' => $iArticleId,'state' => ['in',[-1,3]]];
$result = Db::name('article')->where($aWhere)->limit(1)->update($aUpdate);
if($result === false){
return json_encode(['status' => 10,'msg' =>'Failed to save article content']);
}
Db::commit();
return json_encode(['status' => 1,'msg' =>'The content of the article has been successfully saved']);
}
/**
* 按步骤获取文章的状态
*/
public function getArticleState(){
//获取参数
$aParam = empty($aParam) ? $this->request->post() : $aParam;
//获取文章ID
$iArticleId = empty($aParam['article_id']) ? 0 : $aParam['article_id'];
if(empty($iArticleId)){
return json_encode(['status' => 2,'msg' => 'Please select the article']);
}
//用户ID
$iUserId = empty($aParam['user_id']) ? '' : $aParam['user_id'];
if(empty($iUserId)){
return json_encode(['status' => 2,'msg' => 'Please select author']);
}
//获取文章信息
$aArticle = $this->getArticleInfo($aParam);
$iStatus = empty($aArticle['status']) ? 0 : $aArticle['status'];
if($iStatus != 1){
return json_encode($aArticle);
}
$aArticle = empty($aArticle['data']) ? [] : $aArticle['data'];
//定义返回内容
$aData = ['first' => 2,'second' => 2,'three' => 2,'four' => 2];
//第一步验证
$aFirst = ['title','type','abstrart','journal_id'];
$iFirstStatus = 1;
$sFirstMsg = $sSecondMsg = $sThreeMsg = $sFourMsg = '';
foreach ($aFirst as $key => $value) {
if(empty($aArticle[$value])){
$iFirstStatus = 2;
$sFirstMsg = 'Step 1: Required fields incomplete';
break;
}
}
//判断伦理
if(!empty($aArticle['approval']) && $aArticle['approval'] == 1 && empty($aArticle['approval_file'])){
$iFirstStatus = 2;
$sFirstMsg = 'Step 1: Ethics documents not uploaded';
}
if(isset($aArticle['approval']) && $aArticle['approval'] == 0 && empty($aArticle['approval_content'])){
$iFirstStatus = 2;
$sFirstMsg = 'Step 1: Please explain the lack of ethical recognition';
}
//查询manuscirpt文件是否上传
if($iFirstStatus == 1){
$aWhere = ['article_id' => $iArticleId,'state' => 0,'type_name' => 'manuscirpt'];
$aFile = Db::name('article_file')->where($aWhere)->order('ctime desc')->find();
if(empty($aFile)){
$iFirstStatus = 2;
$sFirstMsg = 'Step 1: The manuscirpt file has not been uploaded';
}
}
//第二步 查询作者
$iSecondStatus = 1;
$is_super = $is_report = 2;
$sSecondMsg = $sSecondReportMsg = '';
// if($iFirstStatus == 1){
$aWhere = ['article_id' => $iArticleId,'state' => 0];
$aAuthorData = DB::name('article_author')->where($aWhere)->select();
if(empty($aAuthorData)){
$iSecondStatus = 2;
}
if(!empty($aAuthorData)){
foreach ($aAuthorData as $key => $value) {
if(empty($value['email']) || empty($value['author_title']) || empty($value['company']) || empty($value['firstname']) || empty($value['lastname'])){
$iSecondStatus = 2;
$sSecondMsg = 'Step 2: The author\'s information is incomplete';
break;
}
if($is_report != 1){
if($value['is_report'] == 1){
if(empty($value['orcid'])){
$sSecondReportMsg = 'Step 2: Please fill in the ORCID of at least one corresponding author';
}
if(!empty($value['orcid'])){
$is_report = 1;
$sSecondReportMsg = '';
}
}
}
if($is_super != 1){
if($value['is_super'] == 1){
$is_super = 1;
}
}
}
}
// }
if($iSecondStatus == 2){
$sSecondMsg = empty($sSecondMsg) ? 'Step 2: The author\'s information is incomplete' : $sSecondMsg;
}
if($iSecondStatus == 1){
if($is_super == 2){
$sSecondMsg = 'Step 2: Please select the first author';
$iSecondStatus = 2;
}
if($is_report == 2){
$sSecondMsg = empty($sSecondReportMsg) ? 'Step 2: Please select the corresponding author' : $sSecondReportMsg;
$iSecondStatus = 2;
}
}
//第三步
$iThreeStatus = 1;
$sThreeMsg = '';
// if($iSecondStatus == 1){
if($aArticle['is_use_ai'] == 3){//验证是否使用AI
$sThreeMsg = 'Step 3: Please check whether to use AI technology';
$iThreeStatus = 2;
}
if($aArticle['is_use_ai'] == 1 && empty($aArticle['use_ai_explain'])){//验证是否填写AI说明
$sThreeMsg = 'Step 3: Please enter supplementary instructions';
$iThreeStatus = 2;
}
if($aArticle['is_figure_copyright'] == 3){//验证是否上传版权声明
$sThreeMsg = 'Step 3: Please check whether to upload the figure copyright statement';
$iThreeStatus = 2;
}
if($aArticle['is_figure_copyright'] == 1){//验证是否上传版权声明
$aWhere = ['article_id' => $iArticleId,'state' => 0,'type_name' => 'figurecopyright'];
$aFile = Db::name('article_file')->where($aWhere)->order('ctime desc')->find();
if(empty($aFile)){
$sThreeMsg = 'Step 3: Please upload the figure copyright declaration file';
$iThreeStatus = 2;
}
}
// }
//第四步
$iFourStatus = 1;
$sFourMsg = '';
// if($iThreeStatus == 1){
// if($aArticle['is_transfer'] == 3){//是否转投
// $sFourMsg = 'Step 4: Please choose whether to transfer or not';
// $iFourStatus = 2;
// }
// if($iFourStatus == 1 && $aArticle['is_transfer'] == 1){//查询转投期刊
// $aWhere = ['state' => 0, 'article_id' => $iArticleId];
// $iCount = Db::name('article_transfer')->where($aWhere)->count();
// if(empty($iCount)){
// $sFourMsg = 'Step 4: Please choose to transfer to a journal';
// $iFourStatus = 2;
// }
// }
//查询文章领域
if($iFourStatus == 1){
$aWhere = ['article_id' => $iArticleId,'state' => 0];
$aMajor = DB::name('major_to_article')->where($aWhere)->select();
if(empty($aMajor)){
$sFourMsg = 'Step 4: Please select the field of the article';
$iFourStatus = 2;
}
}
if($iFourStatus == 1){//查询是否推荐审稿人
$aWhere = ['urr_state' => 0,'article_id' => $iArticleId];
$aUserRecommend = Db::name('user_reviewer_recommend')->where($aWhere)->column('reviewer_id');
if(empty($aUserRecommend)){
$sFourMsg = 'Step 4: Please recommend reviewers';
$iFourStatus = 2;
}
if(!empty($aUserRecommend)){
//获取基本信息
$aWhere = ['user_id' => ['in',$aUserRecommend],'state' => 0];
$aUser = Db::name('user')->field('user_id,account,email,realname')->where($aWhere)->select();
if(empty($aUser)){
$sFourMsg = 'Step 4: Recommended reviewer does not exist';
$iFourStatus = 2;
}
if(!empty($aUser)){
$aWhere = ['reviewer_id' => ['in',$aUserRecommend],'state' => 0];
$aReviewer = Db::name('user_reviewer_info')->field('reviewer_id,country,major,company,department')->where($aWhere)->select();
$aReviewer = array_column($aReviewer, null,'reviewer_id');
if(empty($aReviewer)){
$sFourMsg = 'Step 4: Recommended reviewer\'s detailed information does not exist';
$iFourStatus = 2;
}
if(!empty($aReviewer)){
foreach ($aUser as $key => $value) {
if(empty($value['email']) || empty($value['realname'])){
$sFourMsg = 'The Reviewer\'s required information is incomplete';
$iFourStatus = 2;
break;
}
$value['major'] = empty($aReviewer[$value['user_id']]['major']) ? '' : $aReviewer[$value['user_id']]['major'];
if(empty($value['major'])){
$sFourMsg = 'The Reviewer\'s required information is incomplete';
$iFourStatus = 2;
break;
}
$value['company'] = empty($aReviewer[$value['user_id']]['company']) ? '' : $aReviewer[$value['user_id']]['company'];
if(empty($value['company'])){
$sFourMsg = 'The Reviewer\'s required information is incomplete';
$iFourStatus = 2;
break;
}
$value['department'] = empty($aReviewer[$value['user_id']]['department']) ? '' : $aReviewer[$value['user_id']]['department'];
if(empty($value['department'])){
$sFourMsg = 'The Reviewer\'s required information is incomplete';
$iFourStatus = 2;
break;
}
$value['country'] = empty($aReviewer[$value['user_id']]['country']) ? '' : $aReviewer[$value['user_id']]['country'];
$value['urr_id'] = empty($aUserRecommend[$value['user_id']]) ? 0 : $aUserRecommend[$value['user_id']];
$aUser[$key] = $value;
}
}
}
}
}
// }
//数据处理
$aData['first'] = $iFirstStatus;
$aData['second'] = $iSecondStatus;
$aData['three'] = $iThreeStatus;
$aData['four'] = $iFourStatus;
$aData['first_msg'] = $sFirstMsg;
$aData['second_msg'] = $sSecondMsg;
$aData['three_msg'] = $sThreeMsg;
$aData['four_msg'] = $sFourMsg;
//判断当前未完成的步骤
foreach ($aData as $key => $value) {
if($value == 2){
$current = $key;
break;
}
}
$aData['current_step'] = empty($current) ? '' : $current;
return json_encode(['status' => 1,'msg' => 'success','data' => $aData]);
}
/**
* 文章暂存
*/
public function addArticleStaging()
{
//获取参数
$aParam = empty($aParam) ? $this->request->post() : $aParam;
//用户ID
$iUserId = empty($aParam['user_id']) ? '' : $aParam['user_id'];
if(empty($iUserId)){
return json_encode(['status' => 2,'msg' => 'Please select author']);
}
//获取文章ID
$iArticleId = empty($aParam['article_id']) ? 0 : $aParam['article_id'];
$iJournalId = empty($aParam['journal']) ? 0 : $aParam['journal'];
if(!empty($iJournalId)){
$aParam['journal_id'] = $iJournalId;
}
if(empty($iArticleId)){
$sTitle = empty($aParam['title']) ? '' : $aParam['title'];
// if(empty($iJournalId)){
// return json_encode(['status' => 2,'msg' => 'Please select a journal']);
// }
$aArticleInsert = ['journal_id' => $iJournalId,'title' => $sTitle,'state' => -1,'user_id' => $iUserId];
$aArticleInsert['is_use_ai'] = 3;
$aArticleInsert['is_figure_copyright'] = 3;
// $aArticleInsert['is_transfer'] = 3;
$aArticleInsert['is_become_reviewer'] = 3;
$aArticleInsert['ctime'] = time();
$sType = empty($aParam['type']) ? 'D' : $aParam['type'];
$aArticleInsert['accept_sn'] = getArticleSN('Draft',$sType);
$iArticleId = Db::name('article')->insertGetId($aArticleInsert);
$aParam['article_id'] = $iArticleId;
}
if(empty($iArticleId)){
return json_encode(['status' => 2,'msg' => 'Please select a article']);
}
//获取文章信息
$aArticle = $this->getArticleInfo($aParam);
$iStatus = empty($aArticle['status']) ? 0 : $aArticle['status'];
if($iStatus != 1){
return json_encode($aArticle);
}
$aArticle = empty($aArticle['data']) ? [] : $aArticle['data'];
//定义更新数组
$aUpdate = [];
// //摘要
// $abstrart = empty($aParam['abstrart']) ? '' : $aParam['abstrart'];
// if(!empty($abstrart)){//判断简介字符串长度是否不低于200
// if(!$this->checkMinChars($abstrart, 200)){
// return json_encode(['status' => 3,'msg' => 'The abstract should not be less than 200 Chinese characters or English words!']);
// }
// $aUpdate['abstrart'] = $abstrart;
// }
//是否转投
// $istransfer = isset($aParam['istransfer']) ? $aParam['istransfer'] : '' ;
// if($istransfer == true){
// $aParam['is_transfer'] = 1;
// }
// if($istransfer == false){
// $aParam['is_transfer'] = 2;
// }
//是否成为审稿人
$becomeRev = isset($aParam['becomeRev']) ? $aParam['becomeRev'] : '';
if($becomeRev == true){
$aParam['is_become_reviewer'] = 1;
}
if($becomeRev == false){
$aParam['is_become_reviewer'] = 2;
}
$aField = ['is_use_ai','use_ai_explain','is_figure_copyright','is_become_reviewer','approval','approval_file','approval_content','code','is_become_reviewer','is_agree','title','abstrart','keywords','topics','fund','type','journal_id'];//,'title','abstrart','keywords','topics','fund','type','is_transfer',
$sMsg = '';
$iIsUpdate = 1;
foreach ($aField as $key => $value) {
$sValue = isset($aParam[$value]) ? $aParam[$value] : -2 ;
if($sValue == -2){
continue;
}
if($value == 'is_use_ai' && $sValue == 0){
$aUpdate['is_use_ai'] = 3;
continue;
}
if($value == 'is_figure_copyright' && $sValue == 0){
$aUpdate['is_figure_copyright'] = 3;
continue;
}
// if($value == 'is_use_ai'){
// if(!in_array($sValue, [1,2])){
// $sMsg = 'Please check whether to use AI technology';
// $iIsUpdate = 2;
// break;
// }
// // if($sValue == 1 && empty($aParam['use_ai_explain'])){
// // $sMsg = 'Please enter supplementary instructions';
// // $iIsUpdate = 3;
// // break;
// // }
// }
// if($value == 'is_figure_copyright'){
// if(!in_array($sValue, [1,2])){
// $sMsg = 'Please check whether to upload the figure copyright statement';
// break;
// }
// // if($sValue == 1){
// // $sMsg = 'Please enter supplementary instructions';
// // $iIsUpdate = 4;
// // break;
// // }
// }
// $iIsUpdate = 1;
$aUpdate[$value] = trim($aParam[$value]);
}
//获取期刊编辑
//期刊ID
if(!empty($iJournalId)){
//查询期刊信息
$aJournalWhere = ['journal_id' => $iJournalId,'state' => 0];
$aJournal = DB::name('journal')->field('editor_id')->where($aJournalWhere)->find();
$aUpdate['editor_id'] = empty($aJournal['editor_id']) ? 0 : $aJournal['editor_id'];
}
//数据处理
// if($iIsUpdate == 4){
// $aWhere = ['article_id' => $iArticleId,'state' => 0,'type_name' => 'figurecopyright'];
// $aFile = Db::name('article_file')->where($aWhere)->order('ctime desc')->find();
// if(empty($aFile)){
// $sSecondMsg = 'Step 3: Please upload the figure copyright declaration file';
// $iThreeStatus = 2;
// return json_encode(['status' => 4,'msg' => 'Please upload the figure copyright declaration file']);
// }
// }
if($iIsUpdate != 1){
return json_encode(['status' => 5,'msg' => $sMsg]);
}
//参数判空
$sMajorData = isset($aParam['major']) ? $aParam['major'] : '-1' ;//文章领域
// if(empty($sMajorData) && empty($aUpdate)){
// return json_encode(['status' => 6,'msg' => 'Update data to empty']);
// }
//文章领域处理
$aMajorInsert = $aMajorDelete = [];
if(!empty($sMajorData) && is_string($sMajorData) && $sMajorData != -1){
$aField = explode(',', $sMajorData);
$aWhere = ['state' => 0, 'article_id' => $iArticleId];
$aArticleMajor = Db::name('major_to_article')->where($aWhere)->order('major_id asc')->column('major_id');
//新增
$aInsert = array_diff($aField, $aArticleMajor);
//删除
$aMajorDelete = array_diff($aArticleMajor, $aField);
//数据处理
if (!empty($aInsert)) {//新增
foreach ($aInsert as $key => $value) {
$value = intval($value);
if(empty($value)){
continue;
}
$aMajorInsert[] = ['major_id' => $value, 'article_id' => $iArticleId, 'ctime' => time(), 'state' => 0];
}
}
}
if($sMajorData == ''){//为空删除
$aWhere = ['state' => 0, 'article_id' => $iArticleId];
$aMajorDelete = Db::name('major_to_article')->where($aWhere)->column('major_id');
}
//转投信息
// $aTransferJournalId = empty($aParam['checkedjours']) ? [] : $aParam['checkedjours'];
// if(!empty($aTransferJournalId) && is_string($aTransferJournalId)){
// $aTransferJournalId = explode(',', $aTransferJournalId);
// }
// $aJournalInsert = $aJournalDelete = [];
// if(!empty($aTransferJournalId)){
// //查询转投期刊ID
// $aWhere = ['state' => 0, 'article_id' => $iArticleId];
// $aTransferJournal = Db::name('article_transfer')->where($aWhere)->order('journal_id asc')->column('journal_id');
// //新增
// $aInsert = array_diff($aTransferJournalId, $aTransferJournal);
// //删除
// $aJournalDelete = array_diff($aTransferJournal, $aTransferJournalId);
// if (!empty($aInsert)) {//新增
// foreach ($aInsert as $key => $value) {
// $aJournalInsert[] = ['journal_id' => $value, 'article_id' => $iArticleId, 'ctime' => time(), 'state' => 0];
// }
// }
// }
//推荐审稿人
$aReviewer = isset($aParam['reviewers']) ? $aParam['reviewers'] : '-1';
// $json = '{
// "article_id": "5997",
// "user_id": "54",
// "major": "52,55,56",
// "checkedjours": [],
// "istransfer": false,
// "becomeRev": false,
// "reviewers": [
// {
// "realname": "77777",
// "email": "752204719@qq.com",
// "country": "Afghanistan",
// "company": "11111",
// "department": "33333333",
// "major_all": [
// 167,
// 171,
// 173
// ],
// "major": 173
// },
// {
// "realname": "8888",
// "email": "752204716@qq.com",
// "country": "Albania",
// "major_all": [
// 167,
// 171,
// 173
// ],
// "major": 173
// }
// ],
// "code": "777777777898"
// }';
// $aReviewer = json_decode($json,true);
// $aReviewer = $aReviewer['reviewers'];
if(!empty($aReviewer) && is_array($aReviewer)){
//根据用户邮箱查询是否注册
$aEmail = array_unique(array_column($aReviewer, 'email'));
$aWhere = ['email' => ['in',$aEmail],'state' => 0];
$aUserDataResult = Db::name('user')->field('user_id,account,email,realname')->where($aWhere)->select();
if(empty($aUserDataResult)){
$aUserDataResult = [];
}
$aUserData = empty($aUserDataResult) ? [] : array_column($aUserDataResult, null,'email');
//数据处理
$aUserInsert = $aUserRecommendDelete = [];
foreach ($aReviewer as $key => $value) {
$sEmail = empty($value['email']) ? '' : $value['email'];
if(empty($sEmail)){
continue;
}
if(!empty($aUserData[$sEmail])){
continue;
}
$aUserInsert = ['account' => $value['email'],'password' => md5('123456qwe'),'email' => $sEmail,'realname' => empty($value['realname']) ? '' : $value['realname'],'ctime' => time()];
$iId = Db::name('user')->insertGetId($aUserInsert);
if(empty($iId)){
continue;
}
$aUserInsert['user_id'] = $iId;
$aUserDataResult[] = $aUserInsert;
}
if(!empty($aUserDataResult)){
//查询期刊标题
$iJournalId = empty($aArticle['journal_id']) ? 0 : $aArticle['journal_id'];
$aWhere = ['journal_id' => $iJournalId,'state' => 0];
$aJournal = Db::name('journal')->field('title')->where($aWhere)->find();
//用户信息
$aUserDataResult = array_column($aUserDataResult, null,'user_id');
$aUserData = empty($aUserDataResult) ? [] : array_column($aUserDataResult, 'user_id','email');
//获取期刊审稿人
$aReviewerId = array_column($aUserDataResult, 'user_id');
$aWhere = ['reviewer_id' => ['in',$aReviewerId],'state' => 0];
$aReviewerToJournal = Db::name('reviewer_to_journal')->where($aWhere)->select();
$aReviewerToJournal = empty($aReviewerToJournal) ? [] : array_column($aReviewerToJournal, null,'reviewer_id');
//获取审稿人资料
$aReviewerInfo = Db::name('user_reviewer_info')->field('reviewer_info_id,reviewer_id')->where($aWhere)->select();
$aReviewerInfo = empty($aReviewerInfo) ? [] : array_column($aReviewerInfo, 'reviewer_info_id','reviewer_id');
//推荐记录
$aWhere = ['reviewer_id' => ['in',$aReviewerId],'urr_state' => 0,'article_id' => $iArticleId];
$aUserRecommend = Db::name('user_reviewer_recommend')->where($aWhere)->column('reviewer_id');
$aReviewerInfoAll = $aReviewerToJournalAll = $aInsertRecommend = [];
foreach ($aReviewer as $key => $value) {
$sEmail = empty($value['email']) ? '' : $value['email'];
if(empty($sEmail)){
continue;
}
$iReviewerUserId = empty($aUserData[$sEmail]) ? 0 : $aUserData[$sEmail];
if(empty($iReviewerUserId)){
continue;
}
//审稿人的详细信息
$insert_reviewer_info = ['reviewer_id' => $iReviewerUserId,'major' => empty($value['major']) ? '' : $value['major'], 'country' => empty($value['country']) ? '' : $value['country'],'test_from' => 'addRecommentReviewer','company' => empty($value['company']) ? '' : $value['company'],'department' => empty($value['department']) ? '' : $value['department']];
if(!empty($aReviewerInfo[$iReviewerUserId])){
$insert_reviewer_info['reviewer_info_id'] = $aReviewerInfo[$iReviewerUserId];
}
$aReviewerInfoAll[] = $insert_reviewer_info;
//期刊审稿人
$reviewer_to_journal = ['reviewer_id' => $iReviewerUserId,'journal_id' => $iJournalId, 'account' => empty($aUserDataResult[$iReviewerUserId]['account']) ? '' : $aUserDataResult[$iReviewerUserId]['account'],'journal_title' => empty($aJournal['title']) ? '' : $aJournal['title'],'ctime' => time()];
if(!empty($aReviewerToJournal[$iReviewerUserId])){
$reviewer_to_journal['rtj_id'] = $aReviewerToJournal[$iReviewerUserId]['rtj_id'];
}
$aReviewerToJournalAll[] = $reviewer_to_journal;
if(in_array($iReviewerUserId, $aUserRecommend)){
continue;
}
//添加推荐审稿人信息
$aInsertRecommend[] = ['reviewer_id' => $iReviewerUserId,'article_id' => $iArticleId,'recommend_user_id' => $iUserId,'urr_ctime' => time()];
}
//判读是否有删除
$aUserRecommendId = array_column($aUserDataResult, 'user_id');
//删除
$aWhere = ['urr_state' => 0,'article_id' => $iArticleId];
$aUserRecommend = Db::name('user_reviewer_recommend')->where($aWhere)->column('reviewer_id');
$aUserRecommendDelete = array_diff($aUserRecommend,$aUserRecommendId);
}
}
if($aReviewer == ''){
$aWhere = ['article_id' => $iArticleId];
$aUserRecommendDelete = Db::name('user_reviewer_recommend')->where($aWhere)->column('reviewer_id');
}
Db::startTrans();
if(!empty($aMajorInsert)){//新增领域
$add_result = Db::name('major_to_article')->insertAll($aMajorInsert);
}
if(!empty($aMajorDelete)){//删除领域
$aWhere = ['article_id' => $iArticleId, 'state' => 0, 'major_id' => ['in', $aMajorDelete]];
$delete_result = Db::name('major_to_article')->where($aWhere)->limit(count($aMajorDelete))->update(['state' => 1, 'ctime' => time()]);
}
// if(!empty($aJournalInsert)){//新增转投期刊
// $add_journal_result = Db::name('article_transfer')->insertAll($aJournalInsert);
// }
// if(!empty($aJournalDelete)){//删除转投期刊
// $aWhere = ['article_id' => $iArticleId, 'state' => 0, 'journal_id' => ['in', $aJournalDelete]];
// $delete_journal_result = Db::name('article_transfer')->where($aWhere)->limit(count($aJournalDelete))->delete();
// }
//更新数据
if(!empty($aUpdate)){//更新文章主表数据
//数据更新
$aWhere = ['article_id' => $iArticleId,'state' => ['in',[-1,3]]];
$result = Db::name('article')->where($aWhere)->limit(1)->update($aUpdate);
if($result === false){
return json_encode(['status' => 7,'msg' =>'Failed to save article content']);
}
}
//更新审稿人数据
if(!empty($aReviewerInfoAll)){
$oUserReviewerInfo = new \app\common\UserReviewerInfo();
$sReviewerInfoAll = $oUserReviewerInfo->saveAll($aReviewerInfoAll);
}
if(!empty($aReviewerToJournalAll)){
$oReviewerTojournal = new \app\common\ReviewerToJournal();
$sReviewerTojournal = $oReviewerTojournal->saveAll($aReviewerToJournalAll);
}
if(!empty($aInsertRecommend)){
$sInsertRecommend = Db::name('user_reviewer_recommend')->insertAll($aInsertRecommend);
}
if(!empty($aUserRecommendDelete)){
$aWhere = ['urr_state' => 0,'article_id' => $iArticleId,'reviewer_id' => ['in',$aUserRecommendDelete]];
$sDelete = Db::name('user_reviewer_recommend')->where($aWhere)->limit(count($aUserRecommendDelete))->update(['urr_state' => 1]);
}
Db::commit();
return json_encode(['status' => 1,'msg' =>'The content of the article has been successfully saved','data' => ['article_id' => $iArticleId]]);
}
/**
* 文章信息获取
*/
private function getArticleInfo($aParam = []){
//获取参数
$aParam = empty($aParam) ? [] : $aParam;
//获取文章ID
$iArticleId = empty($aParam['article_id']) ? 0 : $aParam['article_id'];
if(empty($iArticleId)){
return ['status' => 2,'msg' => 'Please select the article'];
}
//用户ID
$iUserId = empty($aParam['user_id']) ? '' : $aParam['user_id'];
if(empty($iUserId)){
return ['status' => 2,'msg' => 'Please select author'];
}
//查询文章
$aWhere = ['article_id' => $iArticleId];
$aArticle = Db::name('article')->field('article_id,title,type,abstrart,journal_id,state,user_id,is_use_ai,use_ai_explain,is_figure_copyright,is_transfer,approval,approval_content,approval_file')->where($aWhere)->find();
if(empty($aArticle)){
return ['status' => 7,'msg' => 'The article does not exist'];
}
if($aArticle['state'] != -1 && $aArticle['state'] != 3){
return ['status' => 8,'msg' => 'Article cannot be edited'];
}
if($aArticle['user_id'] != $iUserId){
return ['status' => 9,'msg' => 'The article does not belong to the current author'];
}
return ['status' => 1,'msg' => 'success','data' => $aArticle];
}
/**
* 添加图片版权声明文件
*/
public function addFigureCopyright($aParam = []){
//获取参数
$aParam = empty($aParam) ? $this->request->post() : $aParam;
//获取文章ID
$iArticleId = empty($aParam['article_id']) ? 0 : $aParam['article_id'];
if(empty($iArticleId)){
return json_encode(['status' => 2,'msg' => 'Please select the article']);
}
//用户ID
$iUserId = empty($aParam['user_id']) ? '' : $aParam['user_id'];
if(empty($iUserId)){
return json_encode(['status' => 2,'msg' => 'Please select author']);
}
//文件地址
$sUrl = empty($aParam['url']) ? '' : $aParam['url'];
if(empty($sUrl)){
return json_encode(['status' => 2,'msg' => 'Please choose to upload the file']);
}
//文件地址
$sTypeName = empty($aParam['type']) ? '' : $aParam['type'];
if(empty($sTypeName)){
return json_encode(['status' => 2,'msg' => 'Please select the type of file to upload']);
}
//文件地址
$aArticleUpdate = [];
if($sTypeName == 'figurecopyright'){
$is_figure_copyright = empty($aParam['is_figure_copyright']) ? 3 : $aParam['is_figure_copyright'];
if($is_figure_copyright != 1){
return json_encode(['status' => 2,'msg' => 'Please check whether to upload the figure copyright statement']);
}
$aArticleUpdate['is_figure_copyright'] = 1;
}
//获取文章信息
$aArticle = $this->getArticleInfo($aParam);
$iStatus = empty($aArticle['status']) ? 0 : $aArticle['status'];
if($iStatus != 1){
return json_encode($aArticle);
}
//验证文件是否上传
$aWhere = ['file_url' => $sUrl,'state' => 0];
$result = Db::name('article_file')->where($aWhere)->find();
if(!empty($result)){
return json_encode(['status' => 1,'msg' => 'Duplicate upload','data' => $result]);
}
//获取作者信息
$aWhere = ['user_id' => $iUserId,'state' => 0];
$aUser = Db::name('user')->field('account')->where($aWhere)->find();
Db::startTrans();
$aInsert['article_id'] = $iArticleId;
$aInsert['user_id'] = $iUserId;
$aInsert['username'] = empty($aUser['account']) ? '' : $aUser['account'];
$aInsert['file_url'] = $sUrl;
$aInsert['type_name'] = $sTypeName;
$aInsert['ctime'] = time();
$result = Db::name('article_file')->insertGetId($aInsert);
//更新文章内容
if(!empty($aArticleUpdate)){
$aWhere = ['article_id' => $iArticleId,'state' => ['in',[-1,3]]];
$update_result = Db::name('article')->where($aWhere)->limit(1)->update($aArticleUpdate);
}
Db::commit();
return json_encode(['status' => 1,'msg' => 'success','data' => ['file_id' => $result]]);
}
/**
* 获取领域树
*/
private function getMajorShuList($major)
{
$major_obj = Db::name('major');
if ($major == 0) {
return;
}
$res = $major_obj->where('major_id', $major)->find();
if ($res['pid'] == 0) {
return $res['major_id'];
}
$p = self::getMajorShuList($res['pid']);
return $p . ',' . $res['major_id'];
}
/**
* 按步骤获取文章的状态
*/
private function getArticleStateThree($aArticle = []){
if(empty($aArticle)){
return ['status' => 2,'msg' => 'The article does not exist'];
}
//第一步验证
$aFirst = ['title','type','abstrart','journal_id'];
$iFirstStatus = 1;
$sFirstMsg = $sSecondMsg = $sThreeMsg = $sFourMsg = '';
foreach ($aFirst as $key => $value) {
if(empty($aArticle[$value])){
$iFirstStatus = 2;
$sFirstMsg = 'Step 1: Required fields incomplete'.$value;
break;
}
}
if($iFirstStatus == 2){
return ['status' => 3,'msg' => $sFirstMsg];
}
//判断伦理
if(!empty($aArticle['approval']) && $aArticle['approval'] == 1 && empty($aArticle['approval_file'])){
$iFirstStatus = 2;
$sFirstMsg = 'Step 1: Ethics documents not uploaded';
return ['status' => 3,'msg' => $sFirstMsg];
}
if(isset($aArticle['approval']) && $aArticle['approval'] == 0 && empty($aArticle['approval_content'])){
$iFirstStatus = 2;
$sFirstMsg = 'Step 1: Please explain the lack of ethical recognition';
return ['status' => 3,'msg' => $sFirstMsg];
}
//查询manuscirpt文件是否上传
$iArticleId = empty($aArticle['article_id']) ? 0 : $aArticle['article_id'];
$aWhere = ['article_id' => $iArticleId,'state' => 0,'type_name' => 'manuscirpt'];
$aFile = Db::name('article_file')->where($aWhere)->order('ctime desc')->find();
if(empty($aFile)){
$iFirstStatus = 2;
$sFirstMsg = 'Step 1: The manuscirpt file has not been uploaded';
return ['status' => 3,'msg' => $sFirstMsg];
}
//第二步 查询作者
$iSecondStatus = 1;
$is_super = 2;
$is_report = 2;
$sSecondMsg = $sSecondReportMsg = '';
$aWhere = ['article_id' => $iArticleId,'state' => 0];
$aAuthorData = DB::name('article_author')->where($aWhere)->select();
if(empty($aAuthorData)){
$iSecondStatus = 2;
}
if(!empty($aAuthorData)){
foreach ($aAuthorData as $key => $value) {
if(empty($value['email']) || empty($value['author_title']) || empty($value['company']) || empty($value['firstname']) || empty($value['lastname'])){
$iSecondStatus = 2;
break;
}
if($is_report != 1){
if($value['is_report'] == 1){
if(empty($value['orcid'])){
$sSecondReportMsg = 'Step 2: Please fill in the ORCID of at least one corresponding author';
}
if(!empty($value['orcid'])){
$is_report = 1;
$sSecondReportMsg = '';
}
}
}
if($is_super != 1){
if($value['is_super'] == 1){
$is_super = 1;
}
}
}
}
if($iSecondStatus == 2){
$sSecondMsg = 'Step 2: The author\'s information is incomplete';
return ['status' => 3,'msg' => $sSecondMsg];
}
if($iSecondStatus == 1){
if($is_super == 2){
$sSecondMsg = 'Step 2: Please select the first author';
$iSecondStatus = 2;
return ['status' => 3,'msg' => $sSecondMsg];
}
if($is_report == 2){
$sSecondMsg = empty($sSecondReportMsg) ? 'Step 2: Please select the corresponding author' : $sSecondReportMsg;
$iSecondStatus = 2;
return ['status' => 3,'msg' => $sSecondMsg];
}
}
//第三步
$iThreeStatus = 1;
$sThreeMsg = '';
if($aArticle['is_use_ai'] == 3){//验证是否使用AI
$sThreeMsg = 'Step 3: Please check whether to use AI technology';
$iThreeStatus = 2;
return ['status' => 3,'msg' => $sThreeMsg];
}
if($aArticle['is_use_ai'] == 1 && empty($aArticle['use_ai_explain'])){//验证是否填写AI说明
$sThreeMsg = 'Step 3: Please enter supplementary instructions';
$iThreeStatus = 2;
return ['status' => 3,'msg' => $sThreeMsg];
}
if($aArticle['is_figure_copyright'] == 3){//验证是否上传版权声明
$sThreeMsg = 'Step 3: Please check whether to upload the figure copyright statement';
$iThreeStatus = 2;
return ['status' => 3,'msg' => $sThreeMsg];
}
if($aArticle['is_figure_copyright'] == 1){//验证是否上传版权声明
$aWhere = ['article_id' => $iArticleId,'state' => 0,'type_name' => 'figurecopyright'];
$aFile = Db::name('article_file')->where($aWhere)->order('ctime desc')->find();
if(empty($aFile)){
$sThreeMsg = 'Step 3: Please upload the figure copyright declaration file';
$iThreeStatus = 2;
return ['status' => 3,'msg' => $sThreeMsg];
}
}
return ['status' => 1,'msg' => 'success'];
}
}