定时任务调用接口
This commit is contained in:
70
application/crontab/controller/Cite.php
Normal file
70
application/crontab/controller/Cite.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace app\crontab\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
use think\Queue;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* @title 文章引用接口
|
||||
* @description 期刊相关操作
|
||||
* @group 期刊相关
|
||||
*/
|
||||
class Cite extends Controller
|
||||
{
|
||||
|
||||
public function __construct(\think\Request $request = null)
|
||||
{
|
||||
parent::__construct($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询文章是否被引用 并发送邮件给通讯作者
|
||||
* @param date 查询日期
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function getList(){
|
||||
|
||||
//获取参数
|
||||
$aParam = $this->request->post();
|
||||
|
||||
//开始时间
|
||||
$sDate = empty($aParam['date']) ? date('Y-m-d') : $aParam['date'];//date('Y-m-d');
|
||||
$sStartDate = strtotime(date($sDate.' 00:00:00', strtotime('-1 day')));
|
||||
//结束时间
|
||||
$sEndDate = strtotime(date($sDate.'23:59:59', strtotime('-1 day')));
|
||||
|
||||
//获取前一天被引用的文章记录
|
||||
$aWhere = ['state' => 1,'ctime' => ['between',[$sStartDate,$sEndDate]]];
|
||||
$aArticleCite = Db::name('article_cite')->field('article_id,journal_id,journal_name,article_name,factor,date,ctime,state,article_cite_id')->where($aWhere)->select();
|
||||
if(empty($aArticleCite)){
|
||||
return json_encode(['status' => 1,'msg' => 'Article citation record is empty','data' => []]);
|
||||
}
|
||||
|
||||
|
||||
//处理数据-获取通讯作者信息
|
||||
$aArticleId = array_column($aArticleCite, 'article_id');
|
||||
$aWhere = ['article_id' => ['in',$aArticleId],'is_report' => 1];
|
||||
$aArticleAuthor = Db::name('article_author')->field('article_id,author_name,email')->where($aWhere)->select();
|
||||
if(empty($aArticleAuthor)){
|
||||
return json_encode(['status' => 1,'msg' => 'No corresponding author information found for the article','data' => []]);
|
||||
}
|
||||
|
||||
//处理数据-获取文章信息
|
||||
$aArticleId = array_unique(array_column($aArticleCite, 'article_id'));
|
||||
$aWhere = ['article_id' => ['in',$aArticleId]];
|
||||
$aArticle = Db::name('article')->where($aWhere)->column('article_id,title');
|
||||
|
||||
//处理数据-获取期刊信息
|
||||
$aJournalId = array_unique(array_column($aArticleCite, 'journal_id'));
|
||||
$aWhere = ['journal_id' => ['in',$aJournalId]];
|
||||
$aJournal = Db::name('journal')->where($aWhere)->column('journal_id,title as journal_title,usx,email,sx,editorinchief,email,epassword,issn');
|
||||
|
||||
|
||||
$aData = ['article_cite' => $aArticleCite,'article_author' => $aArticleAuthor,'article' => $aArticle,'journal' => $aJournal];
|
||||
return json_encode(['status' => 1,'msg' => 'Successfully obtained data','data' => $aData]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user