AI对接
This commit is contained in:
@@ -191,6 +191,8 @@ class Reviewer
|
|||||||
//获取审稿人信息
|
//获取审稿人信息
|
||||||
// 获取时间点
|
// 获取时间点
|
||||||
$iSixMonth = strtotime(date('Y-m-d 00:00:00',strtotime('-6 months')));
|
$iSixMonth = strtotime(date('Y-m-d 00:00:00',strtotime('-6 months')));
|
||||||
|
// 计算10天之前的时间戳
|
||||||
|
$iTeenDaysLater = strtotime('-10 days');
|
||||||
|
|
||||||
// 先查询符合专业条件的审稿人ID
|
// 先查询符合专业条件的审稿人ID
|
||||||
$aWhere = ['state' => 0, 'major_id' => ['in', $aMajorId]];
|
$aWhere = ['state' => 0, 'major_id' => ['in', $aMajorId]];
|
||||||
@@ -213,8 +215,11 @@ class Reviewer
|
|||||||
if(!empty($aParam['field'])){//根据领域搜索
|
if(!empty($aParam['field'])){//根据领域搜索
|
||||||
$aWhere['field'] = ['like',"%" . $aParam["field"] . "%"];
|
$aWhere['field'] = ['like',"%" . $aParam["field"] . "%"];
|
||||||
}
|
}
|
||||||
$sCompanyQuery = Db::name('user_reviewer_info')->field('reviewer_id,technical,country,introduction,company,field')->where($aWhere)->buildSql();
|
$sCompanyQuery = Db::name('user_reviewer_info')->field('reviewer_id,technical,country,introduction,company,field,last_invite_time')
|
||||||
|
->where($aWhere)->where(function($query) use ($iTeenDaysLater) {
|
||||||
|
$query->where('last_invite_time', '<', $iTeenDaysLater)
|
||||||
|
->whereOr('last_invite_time', '=', 0);
|
||||||
|
})->buildSql();
|
||||||
// 主查询条件
|
// 主查询条件
|
||||||
$iSize = empty($aParam['size']) ? $this->iReviewerNum : $aParam['size'];//每页显示条数
|
$iSize = empty($aParam['size']) ? $this->iReviewerNum : $aParam['size'];//每页显示条数
|
||||||
$iPage = empty($aParam['page']) ? 1 : $aParam['page'];// 当前页码
|
$iPage = empty($aParam['page']) ? 1 : $aParam['page'];// 当前页码
|
||||||
@@ -258,7 +263,7 @@ class Reviewer
|
|||||||
->field($sSelect)
|
->field($sSelect)
|
||||||
->fieldRaw("
|
->fieldRaw("
|
||||||
CASE
|
CASE
|
||||||
WHEN t_reviewer_to_journal.is_yboard = 1 AND t_reviewer_to_journal.ctime < {$iSixMonth} THEN 1
|
WHEN t_reviewer_to_journal.is_yboard = 1 AND t_reviewer_to_journal.ctime < {$iSixMonth} THEN 1
|
||||||
ELSE 2
|
ELSE 2
|
||||||
END AS new_level
|
END AS new_level
|
||||||
")
|
")
|
||||||
@@ -385,20 +390,31 @@ class Reviewer
|
|||||||
|
|
||||||
//数据处理
|
//数据处理
|
||||||
$aInsert = [];
|
$aInsert = [];
|
||||||
|
$iNowTime = time();
|
||||||
foreach ($aReviewerId as $value) {
|
foreach ($aReviewerId as $value) {
|
||||||
if(in_array($value, $aReviewer)){
|
if(in_array($value, $aReviewer)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$aInsert[] = ['reviewer_id' => $value,'article_id' => $iArticleId,'editor_act' => 1,'ctime' => time(),'state' => 5,'invited_time' => time()];
|
$aInsert[] = ['reviewer_id' => $value,'article_id' => $iArticleId,'editor_act' => 1,'ctime' => time(),'state' => 5,'invited_time' => $iNowTime];
|
||||||
}
|
}
|
||||||
if(empty($aInsert)){
|
if(empty($aInsert)){
|
||||||
return json_encode(['status' => 3,'msg' => 'Reviewers have been invited to review, please do not repeat the process']);
|
return json_encode(['status' => 3,'msg' => 'Reviewers have been invited to review, please do not repeat the process']);
|
||||||
}
|
}
|
||||||
//插入审稿人数据
|
//插入审稿人数据
|
||||||
|
Db::startTrans();
|
||||||
$result = Db::name('article_reviewer')->insertAll($aInsert);
|
$result = Db::name('article_reviewer')->insertAll($aInsert);
|
||||||
if($result === false){
|
if($result === false){
|
||||||
return json_encode(['status' => 4,'msg' => 'Reviewer data insertion failed:'.json_encode($aInsert)]);
|
return json_encode(['status' => 4,'msg' => 'Reviewer data insertion failed:'.json_encode($aInsert)]);
|
||||||
}
|
}
|
||||||
|
//更新审稿人最后一次审稿时间
|
||||||
|
$aReviewerId = array_column($aInsert, 'reviewer_id');
|
||||||
|
$aUpdate = ['last_invite_time'=>$iNowTime];
|
||||||
|
$aWhere = ['reviewer_id' => ['in',$aReviewerId]];
|
||||||
|
$updateResult = Db::name('user_reviewer_info')->where($aWhere)->limit(count($aReviewerId))->update($aUpdate);
|
||||||
|
if($updateResult === false){
|
||||||
|
return json_encode(['status' => 5,'msg' => 'Invitation time update failed:'.json_encode($aReviewerId)]);
|
||||||
|
}
|
||||||
|
Db::commit();
|
||||||
return json_encode(['status' => 1,'msg' => 'Reviewer data insertion successful, execute email queue']);
|
return json_encode(['status' => 1,'msg' => 'Reviewer data insertion successful, execute email queue']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user