升级
This commit is contained in:
@@ -96,7 +96,6 @@ class Contribute extends Base
|
||||
if(!empty($aArticle)){
|
||||
return json_encode(['code' => 7, 'msg' => 'Warning: you are re-submitting the article!']);
|
||||
}
|
||||
|
||||
//数据入库
|
||||
$aData += $aParam;
|
||||
$result = $this->_addData($aData);
|
||||
@@ -121,34 +120,35 @@ class Contribute extends Base
|
||||
//插入基础表 t_article
|
||||
$aInsert = [];
|
||||
//标题
|
||||
if(empty($aArticle['title'])){
|
||||
// if(empty($aArticle['title'])){
|
||||
$sTitile = empty($aParam['title']) ? '' : $aParam['title'];
|
||||
if(!empty($sTitile)){
|
||||
$aInsert['title'] = $sTitile;
|
||||
$aInsert['title'] = is_string($sTitile) ? strip_tags($sTitile) : '';
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
//关键词
|
||||
if(empty($aArticle['keywords'])){
|
||||
// if(empty($aArticle['keywords'])){
|
||||
$sKeyWords = empty($aParam['keywords']) ? '' : $aParam['keywords'];
|
||||
if(!empty($sKeyWords)){
|
||||
$aInsert['keywords'] = is_array($sKeyWords) ? implode(',', $sKeyWords) : $sKeyWords;
|
||||
$aInsert['keywords'] = is_string($aInsert['keywords']) ? strip_tags($aInsert['keywords']) : '';
|
||||
}
|
||||
}
|
||||
// }
|
||||
//摘要
|
||||
if(empty($aArticle['abstrart'])){
|
||||
// if(empty($aArticle['abstrart'])){
|
||||
$sAbstrart = empty($aParam['abstrart']) ? '' : $aParam['abstrart'];
|
||||
if(!empty($sAbstrart)){
|
||||
$aInsert['abstrart'] = $sAbstrart;
|
||||
$aInsert['abstrart'] = is_string($sAbstrart) ? strip_tags($sAbstrart) : '';
|
||||
}
|
||||
}
|
||||
// }
|
||||
//基金
|
||||
if(empty($aArticle['fund'])){
|
||||
// if(empty($aArticle['fund'])){
|
||||
$sFund = empty($aParam['fund']) ? '' : $aParam['fund'];
|
||||
if(!empty($sAbstrart)){
|
||||
$aInsert['fund'] = $sFund;
|
||||
if(!empty($sFund)){
|
||||
$aInsert['fund'] = is_string($sFund) ? strip_tags($sFund) : '';
|
||||
}
|
||||
}
|
||||
// }
|
||||
//期刊ID
|
||||
$iJournalId = empty($aParam['journal_id']) ? 0 : $aParam['journal_id'];
|
||||
if(!empty($iJournalId)){
|
||||
@@ -182,19 +182,14 @@ class Contribute extends Base
|
||||
$aInsert['state'] = -1;
|
||||
$aInsert['is_use_ai'] = 3;
|
||||
$aInsert['is_figure_copyright'] = 3;
|
||||
$aInsert['is_transfer'] = 3;
|
||||
// $aInsert['is_transfer'] = 3;
|
||||
$aInsert['is_become_reviewer'] = 3;
|
||||
$sType = empty($aParam['type']) ? 'D' : $aParam['type'];
|
||||
$aInsert['accept_sn'] = getArticleSN('Draft',$sType);
|
||||
$iArticleId = Db::name('article')->insertGetId($aInsert);
|
||||
if(empty($iArticleId)){
|
||||
return json_encode(['status' => 3,'msg' => 'Article added successfully']);
|
||||
}
|
||||
//获取accept_sn并更新
|
||||
$sAcceptSn = $this->getArticleAcceptSn(['article_id' => $iArticleId]);
|
||||
if(!empty($sAcceptSn)){
|
||||
$aWhere = ['article_id' => $iArticleId];
|
||||
$aUpdate = ['accept_sn' => $sAcceptSn];
|
||||
$update_result = Db::name('article')->where($aWhere)->limit(1)->update($aUpdate);
|
||||
}
|
||||
}
|
||||
if(!empty($aArticle) && !empty($aInsert)){//更新
|
||||
$aWhere = ['article_id' => $iUpdateArticleId,'state' => ['in',[-1,3]]];
|
||||
@@ -237,6 +232,10 @@ class Contribute extends Base
|
||||
$iSort = $iMaxSort;
|
||||
$aSort[$key] = $iMaxSort;
|
||||
}
|
||||
$sName = is_string($sName) ? strip_tags($sName) : '';
|
||||
if(empty($sName)){
|
||||
continue;
|
||||
}
|
||||
$aCompanyInsert[] = ['article_id' => $iArticleId,'organ_name' =>$sName,'create_time' => time(),'sort' => $iSort];
|
||||
}
|
||||
}
|
||||
@@ -246,7 +245,8 @@ class Contribute extends Base
|
||||
return json_encode(['status' => 3,'msg' => 'Article institution insertion failed']);
|
||||
}
|
||||
$aWhere = ['article_id' => $iArticleId,'state' => 0];
|
||||
$aCompanyData = Db::name('article_organ')->where($aWhere)->column('sort,organ_id');
|
||||
$aCompanyData = Db::name('article_organ')->field('sort,organ_id,organ_name')->where($aWhere)->select();
|
||||
$aCompanyData = empty($aCompanyData) ? [] : array_column($aCompanyData, null,'sort');
|
||||
}
|
||||
//处理作者
|
||||
$aAuthorData = $aAuthorOrgn = [];
|
||||
@@ -262,18 +262,54 @@ class Contribute extends Base
|
||||
if(empty($iArticleId)){
|
||||
break;
|
||||
}
|
||||
//处理作者名字
|
||||
$aName = empty($value['name']) ? [] : explode(' ', $value['name']);
|
||||
if(empty($aName)){
|
||||
continue;
|
||||
}
|
||||
//名字拆分
|
||||
$sLastName = array_pop($aName);
|
||||
$value['firstname'] = empty($aName) ? '' : trim(implode(' ', $aName));
|
||||
$value['lastname'] = $sLastName;
|
||||
|
||||
//处理作者机构单位关联
|
||||
$aCountry = [];
|
||||
if(!empty($value['company_id'])){
|
||||
foreach ($value['company_id'] as $k => $v) {
|
||||
$iNewSort = empty($aSort[$v]) ? $v : $aSort[$v];
|
||||
$iOrgnId = empty($aCompanyData[$iNewSort]) ? 0 : $aCompanyData[$iNewSort];
|
||||
$iOrgnId = empty($aCompanyData[$iNewSort]['organ_id']) ? 0 : $aCompanyData[$iNewSort]['organ_id'];
|
||||
if(empty($iOrgnId)){
|
||||
continue;
|
||||
}
|
||||
$aAuthorOrgn[] = ['article_id' => $iArticleId,'organ_id' => $iOrgnId,'art_aut_id' => $value['name']];
|
||||
|
||||
//获取
|
||||
$sOrganName = empty($aCompanyData[$iNewSort]['organ_name']) ? 0 : $aCompanyData[$iNewSort]['organ_name'];
|
||||
if(!empty($sOrganName)){
|
||||
$sOrganName = str_replace([', ',','], ',', $sOrganName);
|
||||
$aOrganName = explode(',',$sOrganName);
|
||||
$aCountry[] = empty($aOrganName) ? '' : strtolower(end($aOrganName));
|
||||
}
|
||||
$aAuthorOrgn[] = ['article_id' => $iArticleId,'organ_id' => $iOrgnId,'art_aut_id' => $value['firstname']];
|
||||
}
|
||||
}
|
||||
$value['firstname'] = empty($value['name']) ? '' : trim($value['name']);
|
||||
|
||||
//处理城市
|
||||
$aCountry = empty($aCountry) ? [] : array_unique($aCountry);
|
||||
$value['country'] = '';
|
||||
if(count($aCountry) == 1){
|
||||
$value['country'] = empty($aCountry[0]) ? '' : ucfirst($aCountry[0]);
|
||||
}
|
||||
if(count($aCountry) > 1){
|
||||
// 1. 找到目标值的键名
|
||||
$key = array_search('china', $aCountry);
|
||||
// 2. 确认找到后删除(避免键名为 0 时被误判为 false)
|
||||
if ($key !== false) {
|
||||
unset($aCountry[$key]);
|
||||
}
|
||||
$aCountry = empty($aCountry) ? [] : array_values($aCountry);
|
||||
$value['country'] = empty($aCountry[0]) ? '' : ucfirst($aCountry[0]);
|
||||
}
|
||||
|
||||
//已添加
|
||||
if(!empty($value['firstname']) && in_array($value['firstname'], $aAuthorList)){
|
||||
continue;
|
||||
@@ -281,7 +317,7 @@ class Contribute extends Base
|
||||
$value['email'] = empty($aCorresponding[$value['name']]['email']) ? '' : $aCorresponding[$value['name']]['email'];
|
||||
$value['article_id'] = $iArticleId;
|
||||
unset($value['name'],$value['company_id']);
|
||||
$aAuthorData[$key] = $value;
|
||||
$aAuthorData[] = $value;
|
||||
}
|
||||
}
|
||||
if(!empty($aAuthorData)){
|
||||
@@ -318,9 +354,11 @@ class Contribute extends Base
|
||||
continue;
|
||||
}
|
||||
$value['art_aut_id'] = $iAuthorId;
|
||||
$value['create_time'] = time();
|
||||
$aAuthorOrgnInsert[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($aAuthorOrgnInsert)){
|
||||
$author_orgn_result = DB::name('article_author_organ')->insertAll($aAuthorOrgnInsert);
|
||||
if(empty($author_orgn_result)){
|
||||
@@ -342,18 +380,4 @@ class Contribute extends Base
|
||||
$aInsert['article_id'] = $iArticleId;
|
||||
return json_encode(['status' => 1,'msg' => 'Successfully added article','article' => $aInsert]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成文章sn号
|
||||
*/
|
||||
private function getArticleAcceptSn($aParam = [],$sFlag = 'Draft')
|
||||
{
|
||||
$iArticleId = empty($aParam['article_id']) ? 0 : $aParam['article_id'];
|
||||
if(empty($iArticleId)){
|
||||
return '';
|
||||
}
|
||||
$sDate = date('Y');
|
||||
$sType = $sDate;
|
||||
return $sFlag.$sType.str_pad($iArticleId,6,'0',STR_PAD_LEFT).rand(100,999);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user