124 lines
3.9 KiB
PHP
124 lines
3.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("");
|
||
}
|
||
$article_info = $this->article_obj->where('article_id',$p_info['article_id'])->find();
|
||
$msgs = $this->article_msg_obj->where('article_id',$article_info['article_id'])->select();
|
||
$begin['type'] = 0;
|
||
$begin['time'] = $article_info['ctime'];
|
||
$frag[] = $begin;
|
||
foreach ($msgs as $v){
|
||
$frag[] = [
|
||
"type"=>$v['state_to'],
|
||
"time"=>$v['ctime']
|
||
];
|
||
// switch ($v['state_to']){
|
||
// case 1:
|
||
// $frag[] = [
|
||
// "type"=>1,
|
||
// "time"=>$v['ctime']
|
||
// ];
|
||
// break;
|
||
// case 2:
|
||
// $frag[] = [];
|
||
// break
|
||
// }
|
||
}
|
||
|
||
$re['msgs'] = $frag;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
}
|
||
?>
|