diff --git a/application/api/controller/Contribute.php b/application/api/controller/Contribute.php index 6f2aedb..e911669 100644 --- a/application/api/controller/Contribute.php +++ b/application/api/controller/Contribute.php @@ -256,8 +256,9 @@ class Contribute extends Base $aCorresponding = empty($aParam['corresponding']) ? [] : array_column($aParam['corresponding'], null,'name'); //查询文章作者 $aWhere = ['article_id' => $iArticleId,'state' => 0]; - $aAuthorList = Db::name('article_author')->field('art_aut_id,firstname')->where($aWhere)->select(); + $aAuthorList = Db::name('article_author')->field('art_aut_id,firstname,sort')->where($aWhere)->select(); $aAuthorNameList = empty($aAuthorList) ? [] : array_column($aAuthorList, 'firstname'); + $iMaxSort = empty($aAuthorList) ? 0 : max(array_column($aAuthorList, 'sort')); foreach ($aAuthor as $key => $value) { if(empty($iArticleId)){ break; @@ -317,9 +318,12 @@ 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']); + $iMaxSort++; + $value['sort'] = $iMaxSort; $aAuthorData[] = $value; } } + if(!empty($aAuthorData)){ $author_result = DB::name('article_author')->insertAll($aAuthorData); if(empty($author_result)){