174 lines
5.9 KiB
PHP
174 lines
5.9 KiB
PHP
<?php
|
||
namespace app\api\controller;
|
||
|
||
use app\api\controller\Base;
|
||
use think\Db;
|
||
use think\Queue;
|
||
use think\Validate;
|
||
|
||
class Web extends Base
|
||
{
|
||
|
||
private $Base_url = "http://journalapi.tmrjournals.com/public/index.php/";
|
||
public function __construct(\think\Request $request = null)
|
||
{
|
||
parent::__construct($request);
|
||
}
|
||
|
||
public function getStages(){
|
||
$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 = $this->Base_url."master/Submision/getJournalStages";
|
||
$program['issn'] = $journal_info['issn'];
|
||
$res = object_to_array(json_decode(myPost($url,$program)));
|
||
$list = $res['data']['stages'];
|
||
$re['stages'] = $list;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**获取分期文章列表
|
||
* @return \think\response\Json|void
|
||
*/
|
||
public function getArticlesByStage(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
"journal_stage_id"=>"require"
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$url = $this->Base_url."master/Submision/getArticlesByStage";
|
||
$program['journal_stage_id'] = $data['journal_stage_id'];
|
||
$res = object_to_array(json_decode(myPost($url,$program)));
|
||
$list = $res['data']['articles'];
|
||
$re['articles'] = $list;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
public function getRefers(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
"w_article_id"=>"require",
|
||
"doi"=>"require"
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$production_info = $this->production_article_obj->where('w_article_id',$data['w_article_id'])->find();
|
||
if (!$production_info){//一次验证,如果w_article_id获取失败
|
||
$production_info = $this->production_article_obj->where('doi',$data['doi'])->where('state',0)->find();
|
||
}
|
||
|
||
if(!$production_info){//如果两次获取都失败
|
||
$refers = [];
|
||
return jsonSuccess(['refer'=>$refers]);
|
||
}
|
||
|
||
$list = $this->production_article_refer_obj->where('p_article_id',$production_info['p_article_id'])->where('state',0)->order('index')->select();
|
||
$re['refers'] = $list;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**获取文章流程通过doi
|
||
* @return void
|
||
*/
|
||
public function getStackByDoi(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
"doi"=>"require"
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$r = explode("/",$data['doi']);
|
||
$p_info = $this->production_article_obj->where('doi',$r[1])->where("state",2)->find();
|
||
if(!$p_info){
|
||
return jsonError("production error");
|
||
}
|
||
$article_info = $this->article_obj->where('article_id',$p_info['article_id'])->find();
|
||
//只显示2023年5。1之后的文章流程
|
||
// if($article_info['rtime']<1682870400){
|
||
// return jsonError("time error");
|
||
// }
|
||
|
||
|
||
$msgs = $this->article_msg_obj->where('article_id',$article_info['article_id'])->select();
|
||
$reviewers = $this->article_reviewer_obj
|
||
->field("t_article_reviewer.*,t_article_reviewer_question.ctime qtime,t_article_reviewer_question.rated,t_article_reviewer_question.is_anonymous")
|
||
->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',$p_info['article_id'])
|
||
->where('t_article_reviewer.state','in',[1,2,3])
|
||
->select();
|
||
foreach ($reviewers as $k => $v){
|
||
if($v['is_anonymous']==0){
|
||
$u_info = $this->user_obj->where('user_id',$v['reviewer_id'])->find();
|
||
$reviewers[$k]['reviewer_name'] = $u_info['realname'];
|
||
}else{
|
||
$reviewers[$k]['reviewer_name'] = "anonymous";
|
||
}
|
||
}
|
||
$begin['type'] = 0;
|
||
$begin['time'] = $article_info['ctime'];
|
||
$frag[] = $begin;
|
||
$reviewer_has = false;
|
||
foreach ($msgs as $v){
|
||
if($v['state_to']==2&&!$reviewer_has){
|
||
$reviewer_has = true;
|
||
$frag[] = [
|
||
"type"=>$v['state_to'],
|
||
"reviewers"=>$reviewers,
|
||
"time"=>$v['ctime']
|
||
];
|
||
continue;
|
||
}
|
||
$frag[] = [
|
||
"type"=>$v['state_to'],
|
||
"time"=>$v['ctime']
|
||
];
|
||
}
|
||
//如果没有审稿状态,添加
|
||
if(!$reviewer_has&&count($reviewers)>0){
|
||
$frag[] = [
|
||
"type"=>2,
|
||
"reviewers"=>$reviewers,
|
||
"time"=>$reviewers[0]['ctime']
|
||
];
|
||
}
|
||
|
||
//没有接收。添加
|
||
|
||
//如果没有proof,增加
|
||
if($p_info['proof_stime']>0){
|
||
$frag[] = [
|
||
"type"=>7,
|
||
"time"=>$p_info['proof_stime']
|
||
];
|
||
}
|
||
|
||
//没有online,添加
|
||
|
||
//冒泡排序法
|
||
for ($i = 0; $i < count($frag) -1; $i++) {//循环对比的轮数
|
||
for ($j = 0; $j < count($frag) - $i - 1; $j++) {//当前轮相邻元素循环对比
|
||
if ($frag[$j]["time"] > $frag[$j + 1]["time"]) {//如果前边的大于后边的
|
||
$tmp = $frag[$j];//交换数据
|
||
$frag[$j] = $frag[$j + 1];
|
||
$frag[$j + 1] = $tmp;
|
||
}
|
||
}
|
||
}
|
||
|
||
$re['msgs'] = $frag;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
}
|
||
?>
|