20201112
This commit is contained in:
@@ -29,6 +29,8 @@ class Article extends Controller {
|
||||
protected $country_obj = '';
|
||||
protected $subscribe_journal_obj = '';
|
||||
protected $subscribe_topic_obj = '';
|
||||
protected $base_topic_obj = '';
|
||||
protected $subscribe_base_topic_obj = '';
|
||||
|
||||
public function __construct(\think\Request $request = null) {
|
||||
parent::__construct($request);
|
||||
@@ -47,6 +49,8 @@ class Article extends Controller {
|
||||
$this->country_obj = Db::name('country');
|
||||
$this->subscribe_journal_obj = Db::name('subscribe_journal');
|
||||
$this->subscribe_topic_obj = Db::name('subscribe_topic');
|
||||
$this->base_topic_obj = Db::name('base_topic');
|
||||
$this->subscribe_base_topic_obj = Db::name('subscribe_base_topic');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -377,9 +381,7 @@ class Article extends Controller {
|
||||
* @articleInfo sort:权重
|
||||
* @articleInfo pub_date:发表日期
|
||||
*
|
||||
*
|
||||
* @return files:文件列表#
|
||||
*
|
||||
*/
|
||||
public function getArticleBase() {
|
||||
$data = $this->request->post();
|
||||
@@ -650,12 +652,47 @@ class Article extends Controller {
|
||||
$insert['topic_id'] = $data['topic_id'];
|
||||
$res = $this->article_to_topic_obj->insert($insert);
|
||||
$this->msg_subscript_topic($data['topic_id'], $data['article_id']);
|
||||
$this->msg_subscribe_base_topic($data['topic_id'], $data['article_id']);
|
||||
if ($res) {
|
||||
return json(['code' => 0, 'msg' => 'success']);
|
||||
} else {
|
||||
return json(['code' => 1, 'msg' => 'system error']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function msg_subscribe_base_topic($topic_id,$article_id){
|
||||
$article_info = $this->article_obj->where('article_id',$article_id)->find();
|
||||
$topic_info = $this->journal_topic_obj->where('journal_topic_id',$topic_id)->find();
|
||||
$base_topic_info = $this->base_topic_obj->where('title',$topic_info['title'])->find();
|
||||
$journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
|
||||
if($base_topic_info==null){
|
||||
return ;
|
||||
}
|
||||
$list = $this->subscribe_base_topic_obj->where('base_topic_id',$base_topic_info['base_topic_id'])->where('state',0)->select();
|
||||
|
||||
$title = 'These new articles included in TMRDE database are available online.';
|
||||
$tt = 'Dear Researcher,<br>';
|
||||
$tt .= 'It is our great honor to present you the articles included in TMRDE.The following new articles have just been included.<br>';
|
||||
$tt .= '<a href="https://www.tmrjournals.com/article.html?J_num='.$article_info['journal_id'].'&a_id='.$article_id.'">'.$article_info['title'].'</a><br>';
|
||||
foreach ($list as $v){
|
||||
$tt1='';
|
||||
$tt1 .= $tt;
|
||||
$tt1 .= '<a href="http://journalapi.tmrjournals.com/public/index.php/api/Journal/UnsubscribeBaseTopic/snum/' . $v['subscribe_base_topic_id'] . '">Unsubscribe</a><br><br>';
|
||||
$tt1 .= 'Email:'.$journal_info['email'].'<br>';
|
||||
$tt1 .= 'Website:'.$journal_info['website'].'<br><br>';
|
||||
$tt1 .= 'TMR Publishing Group Ltd.<br>';
|
||||
$tt1 .= '11 Cockle Bay Rd, Cockle Bay, Auckland, New Zealand<br>';
|
||||
$tt1 .= 'Tel: +64 02108293806.';
|
||||
$maidata['email'] = $v['email'];
|
||||
$maidata['title'] = $title;
|
||||
$maidata['content'] = $tt1;
|
||||
$maidata['tmail'] = 'publicrelations@tmrjournals.com';
|
||||
$maidata['tpassword'] = 'pRWU999999';
|
||||
Queue::push('app\api\job\mail@fire', $maidata, "mail");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function msg_subscript_topic($topic_id, $article_id) {
|
||||
$article_info = $this->article_obj->where('article_id', $article_id)->find();
|
||||
@@ -704,7 +741,7 @@ class Article extends Controller {
|
||||
$maidata['title'] = $journal_info['title'];
|
||||
$maidata['content'] = $cache;
|
||||
$maidata['tmail'] = 'publicrelations@tmrjournals.com';
|
||||
$maidata['tpassword'] = '999999Wu';
|
||||
$maidata['tpassword'] = 'pRWU999999';
|
||||
Queue::push('app\api\job\mail@fire', $maidata, "mail");
|
||||
}
|
||||
}
|
||||
@@ -740,22 +777,22 @@ class Article extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function mycc() {
|
||||
$list = $this->article_author_obj->where('article_author_id', '>', 5126)->select();
|
||||
foreach ($list as $v) {
|
||||
$ca = explode(' ', $v['author_name']);
|
||||
$caf = '';
|
||||
$cal = '';
|
||||
if (isset($ca[0])) {
|
||||
$caf = str_replace('-', '', $ca[0]);
|
||||
}
|
||||
if (isset($ca[1])) {
|
||||
$cal = $ca[1];
|
||||
}
|
||||
$this->article_author_obj->where('article_author_id', $v['article_author_id'])->update(['first_name' => $caf, 'last_name' => $cal]);
|
||||
}
|
||||
echo 'over';
|
||||
}
|
||||
// public function mycc() {
|
||||
// $list = $this->article_author_obj->where('article_author_id', '>', 5126)->select();
|
||||
// foreach ($list as $v) {
|
||||
// $ca = explode(' ', $v['author_name']);
|
||||
// $caf = '';
|
||||
// $cal = '';
|
||||
// if (isset($ca[0])) {
|
||||
// $caf = str_replace('-', '', $ca[0]);
|
||||
// }
|
||||
// if (isset($ca[1])) {
|
||||
// $cal = $ca[1];
|
||||
// }
|
||||
// $this->article_author_obj->where('article_author_id', $v['article_author_id'])->update(['first_name' => $caf, 'last_name' => $cal]);
|
||||
// }
|
||||
// echo 'over';
|
||||
// }
|
||||
|
||||
/**
|
||||
* @title 图片上传
|
||||
@@ -848,6 +885,29 @@ class Article extends Controller {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title imgCome文件上传
|
||||
* @description imgCome文件上传
|
||||
* @author wangjinlei
|
||||
* @url /master/Article/up_imgCome_file
|
||||
* @method POST
|
||||
*
|
||||
* @param name:name type:string require:1 default:imgCome desc:文件域名称
|
||||
*
|
||||
* @return upurl:图片地址
|
||||
*/
|
||||
public function up_imgCome_file(){
|
||||
$file = request()->file('imgCome');
|
||||
if ($file) {
|
||||
$info = $file->move(ROOT_PATH . 'public' . DS . 'imgCome');
|
||||
if ($info) {
|
||||
return json(['code' => 0, 'msg' => 'success', 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
|
||||
} else {
|
||||
return json(['code' => 1, 'msg' => $file->getError()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 文章文件上传
|
||||
@@ -1177,8 +1237,8 @@ http://www.crossref.org/schemas/crossref4.3.7.xsd">' . PHP_EOL . PHP_EOL;
|
||||
$xml .= '<body>' . PHP_EOL;
|
||||
$xml .= '<journal>' . PHP_EOL;
|
||||
$xml .= '<journal_metadata language="en">' . PHP_EOL;
|
||||
$xml .= '<full_title>' . $journal_info['title'] . '</full_title>' . PHP_EOL;
|
||||
$xml .= '<abbrev_title>' . $journal_info['jabbr'] . '</abbrev_title>' . PHP_EOL;
|
||||
$xml .= '<full_title>' . str_replace("&", "and", $journal_info['title']) . '</full_title>' . PHP_EOL;
|
||||
$xml .= '<abbrev_title>' . str_replace('&', 'and', $journal_info['jabbr']) . '</abbrev_title>' . PHP_EOL;
|
||||
$xml .= '<issn media_type="print">' . $journal_info['issn'] . '</issn>' . PHP_EOL;
|
||||
$xml .= '<coden>' . $journal_info['usx'] . '</coden>' . PHP_EOL;
|
||||
$xml .= '</journal_metadata>' . PHP_EOL;
|
||||
@@ -1193,7 +1253,7 @@ http://www.crossref.org/schemas/crossref4.3.7.xsd">' . PHP_EOL . PHP_EOL;
|
||||
$xml .= '</journal_issue>' . PHP_EOL;
|
||||
$xml .= '<journal_article publication_type="full_text">' . PHP_EOL;
|
||||
$xml .= '<titles>' . PHP_EOL;
|
||||
$xml .= '<title>' . $article_info['title'] . '</title>' . PHP_EOL;
|
||||
$xml .= '<title>' . str_replace("&", "and", $article_info['title']) . '</title>' . PHP_EOL;
|
||||
$xml .= '</titles>' . PHP_EOL;
|
||||
$xml .= '<contributors>' . PHP_EOL;
|
||||
$authors = $this->article_author_obj->where('article_id', $data['article_id'])->where('state', 0)->select();
|
||||
@@ -1347,8 +1407,8 @@ http://www.crossref.org/schemas/crossref4.3.7.xsd">' . PHP_EOL . PHP_EOL;
|
||||
*/
|
||||
public function agentDOI() {
|
||||
$data = $this->request->post();
|
||||
$data['doi'] = '10.12032/TMR20210301222';
|
||||
$data['article_id'] = 1333;
|
||||
// $data['doi'] = '10.12032/TMR20210301222';
|
||||
// $data['article_id'] = 1333;
|
||||
|
||||
|
||||
$xml = '';
|
||||
|
||||
@@ -31,6 +31,8 @@ class Journal extends Controller {
|
||||
protected $subscribe_topic_obj = '';
|
||||
protected $board_obj = '';
|
||||
protected $board_group_obj = '';
|
||||
protected $base_topic_obj = '';
|
||||
protected $subscribe_base_topic_obj = '';
|
||||
|
||||
public function __construct(\think\Request $request = null) {
|
||||
parent::__construct($request);
|
||||
@@ -52,6 +54,8 @@ class Journal extends Controller {
|
||||
$this->subscribe_topic_obj = Db::name('subscribe_topic');
|
||||
$this->board_obj = Db::name('board');
|
||||
$this->board_group_obj = Db::name('board_group');
|
||||
$this->base_topic_obj = Db::name('base_topic');
|
||||
$this->subscribe_base_topic_obj = Db::name('subscribe_base_topic');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,6 +175,9 @@ class Journal extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @title 修改期刊详情
|
||||
* @description 修改期刊详情
|
||||
@@ -449,6 +456,7 @@ class Journal extends Controller {
|
||||
* @param name:title type:string require:1 desc:标题
|
||||
* @param name:icon type:string require:1 desc:缩略图
|
||||
* @param name:intro type:string require:1 desc:介绍
|
||||
* @param name:come type:string require:1 desc:图片证书
|
||||
* @param name:position type:string require:1 desc:摆放位置
|
||||
* @param name:is_final type:int require:1 desc:是否终结点(0no1yes)
|
||||
* @param name:sort type:int require:1 default:0 desc:权重
|
||||
@@ -467,6 +475,7 @@ class Journal extends Controller {
|
||||
$insert['title'] = $data['title'];
|
||||
$insert['icon'] = $data['icon'];
|
||||
$insert['intro'] = $data['intro'];
|
||||
$insert['come'] = isset($data['come'])?$data['come']:'';
|
||||
if($data['parent_id']==0){
|
||||
$insert['position'] = $data['position'];
|
||||
}
|
||||
@@ -492,6 +501,7 @@ class Journal extends Controller {
|
||||
* @param name:title type:string require:1 desc:标题
|
||||
* @param name:icon type:string require:1 desc:缩略图
|
||||
* @param name:intro type:string require:1 desc:介绍
|
||||
* @param name:come type:string require:1 desc:图片证书
|
||||
* @param name:position type:string require:1 desc:摆放位置
|
||||
* @param name:is_final type:int require:1 desc:是否终结点(0no1yes)
|
||||
* @param name:sort type:int require:1 default:0 desc:权重
|
||||
@@ -502,15 +512,12 @@ class Journal extends Controller {
|
||||
$update['title'] = $data['title'];
|
||||
$update['icon'] = $data['icon'];
|
||||
$update['intro'] = $data['intro'];
|
||||
$update['come'] = $data['come'];
|
||||
$update['position'] = isset($data['position'])?$data['position']:'';
|
||||
$update['is_final'] = $data['is_final'];
|
||||
$update['sort'] = $data['sort'];
|
||||
$res = $this->journal_topic_obj->update($update);
|
||||
if($res){
|
||||
return json(['code'=>0,'msg'=>'success']);
|
||||
}else{
|
||||
return json(['code'=>1,'msg'=>'system error']);
|
||||
}
|
||||
return json(['code'=>0,'msg'=>'success']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -653,6 +660,7 @@ class Journal extends Controller {
|
||||
$insert['topic_id'] = $data['topic_id'];
|
||||
$res = $this->article_to_topic_obj->insert($insert);
|
||||
$this->msg_subscript_topic($data['topic_id'], $data['article_id']);
|
||||
$this->msg_subscribe_base_topic($data['topic_id'], $data['article_id']);
|
||||
if($res){
|
||||
return json(['code'=>0,'msg'=>'success']);
|
||||
}else{
|
||||
@@ -660,6 +668,45 @@ class Journal extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function mmm(){
|
||||
$this->msg_subscribe_base_topic(14, 5);
|
||||
}
|
||||
|
||||
|
||||
private function msg_subscribe_base_topic($topic_id,$article_id){
|
||||
$article_info = $this->article_obj->where('article_id',$article_id)->find();
|
||||
$topic_info = $this->journal_topic_obj->where('journal_topic_id',$topic_id)->find();
|
||||
$base_topic_info = $this->base_topic_obj->where('title',$topic_info['title'])->find();
|
||||
$journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
|
||||
if($base_topic_info==null){
|
||||
return ;
|
||||
}
|
||||
$list = $this->subscribe_base_topic_obj->where('base_topic_id',$base_topic_info['base_topic_id'])->where('state',0)->select();
|
||||
|
||||
$title = 'These new articles included in TMRDE database are available online.';
|
||||
$tt = 'Dear Researcher,<br>';
|
||||
$tt .= 'It is our great honor to present you the articles included in TMRDE.The following new articles have just been included.<br>';
|
||||
$tt .= '<a href="https://www.tmrjournals.com/article.html?J_num='.$article_info['journal_id'].'&a_id='.$article_id.'">'.$article_info['title'].'</a><br>';
|
||||
foreach ($list as $v){
|
||||
$tt1='';
|
||||
$tt1 .= $tt;
|
||||
$tt1 .= '<a href="http://journalapi.tmrjournals.com/public/index.php/api/Journal/UnsubscribeBaseTopic/snum/' . $v['subscribe_base_topic_id'] . '">Unsubscribe</a><br><br>';
|
||||
$tt1 .= 'Email:'.$journal_info['email'].'<br>';
|
||||
$tt1 .= 'Website:'.$journal_info['website'].'<br><br>';
|
||||
$tt1 .= 'TMR Publishing Group Ltd.<br>';
|
||||
$tt1 .= '11 Cockle Bay Rd, Cockle Bay, Auckland, New Zealand<br>';
|
||||
$tt1 .= 'Tel: +64 02108293806.';
|
||||
$maidata['email'] = $v['email'];
|
||||
$maidata['title'] = $title;
|
||||
$maidata['content'] = $tt1;
|
||||
$maidata['tmail'] = 'publicrelations@tmrjournals.com';
|
||||
$maidata['tpassword'] = 'pRWU999999';
|
||||
Queue::push('app\api\job\mail@fire', $maidata, "mail");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function msg_subscript_topic($topic_id,$article_id){
|
||||
$article_info = $this->article_obj->where('article_id',$article_id)->find();
|
||||
$stage_info = $this->journal_stage_obj->where('journal_stage_id', $article_info['journal_stage_id'])->find();
|
||||
@@ -707,7 +754,7 @@ class Journal extends Controller {
|
||||
$maidata['title'] = $journal_info['title'];
|
||||
$maidata['content'] = $cache;
|
||||
$maidata['tmail'] = 'publicrelations@tmrjournals.com';
|
||||
$maidata['tpassword'] = '999999Wu';
|
||||
$maidata['tpassword'] = 'pRWU999999';
|
||||
Queue::push('app\api\job\mail@fire', $maidata, "mail");
|
||||
}
|
||||
}
|
||||
@@ -1040,7 +1087,6 @@ class Journal extends Controller {
|
||||
$stage_info = $this->journal_stage_obj->where('journal_stage_id', $journal_stage_id)->find();
|
||||
$journal_info = $this->journal_obj->where('journal_id',$journal_id)->find();
|
||||
$list = $this->subscribe_journal_obj->where('journal_id',$journal_id)->where('state',0)->select();
|
||||
|
||||
//组成文章信息
|
||||
$tt1 = '<div style="background-color: #ededed;margin: 0;">
|
||||
<div class="con_content" style="font-family: Arial;
|
||||
@@ -1072,7 +1118,6 @@ class Journal extends Controller {
|
||||
$tt2 .= 'Tel: +64 02108293806.';
|
||||
$tt2 .= '</div>
|
||||
</div>';
|
||||
|
||||
foreach ($list as $v){
|
||||
$cache = $tt1.'<a href="http://journalapi.tmrjournals.com/public/index.php/api/Journal/UnsubscribeJournal/snum/'.$v['subscribe_journal_id'].'">Unsubscribe</a><br><br>'.$tt2;
|
||||
$maidata['email'] = $v['email'];
|
||||
@@ -1130,7 +1175,6 @@ class Journal extends Controller {
|
||||
* @method POST
|
||||
*
|
||||
* @param name:journal_notices_id type:int require:1 desc:期刊id
|
||||
*
|
||||
*/
|
||||
public function delNotices(){
|
||||
$data = $this->request->post();
|
||||
@@ -1149,7 +1193,6 @@ class Journal extends Controller {
|
||||
* @param name:title type:string require:1 desc:消息标题
|
||||
* @param name:content type:string require:1 desc:内容
|
||||
* @param name:ctime type:string require:1 desc:时间
|
||||
*
|
||||
*/
|
||||
public function changeNotices(){
|
||||
$data = $this->request->post();
|
||||
@@ -1347,6 +1390,134 @@ class Journal extends Controller {
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 获取期刊缩略图
|
||||
* @description 获取期刊缩略图
|
||||
* @author wangjinlei
|
||||
* @url /master/Journal/getJournalIcon
|
||||
* @method POST
|
||||
*
|
||||
* @param name:issn type:int require:1 desc:issn号
|
||||
*
|
||||
* @return icon:图片地址#
|
||||
*/
|
||||
public function getJournalIcon(){
|
||||
$data = $this->request->post();
|
||||
$journal_info = $this->journal_obj->where('issn',$data['issn'])->find();
|
||||
|
||||
$re['icon'] = $journal_info['licon'];
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 通用话题--获取通用话题列表
|
||||
* @description 通用话题--获取通用话题列表
|
||||
* @author wangjinlei
|
||||
* @url /master/Journal/getBaseTopicList
|
||||
* @method POST
|
||||
*
|
||||
* @return topics:通用话题#
|
||||
*/
|
||||
public function getBaseTopicList(){
|
||||
$father = $this->base_topic_obj->where('parent_id',0)->where('state',0)->order('sort desc')->select();
|
||||
foreach ($father as $k => $v){
|
||||
$cache = $this->base_topic_obj->where('parent_id',$v['base_topic_id'])->where('state',0)->order('sort desc')->select();
|
||||
$father[$k]['children'] = $cache;
|
||||
}
|
||||
$re['topics'] = $father;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 通用话题--增加通用话题
|
||||
* @description 通用话题--增加通用话题
|
||||
* @author wangjinlei
|
||||
* @url /master/Journal/addBaseTopic
|
||||
* @method POST
|
||||
*
|
||||
* @param name:title type:string require:1 desc:话题名称标题
|
||||
* @param name:parent_id type:int require:1 desc:父级话题id
|
||||
* @param name:sort type:int require:1 desc:权重值
|
||||
* @param name:icon type:string require:1 desc:图标
|
||||
*
|
||||
*/
|
||||
public function addBaseTopic(){
|
||||
$data = $this->request->post();
|
||||
$check = $this->base_topic_obj->where('title',$data['title'])->where('state',0)->find();
|
||||
if($check != null){
|
||||
return jsonError('此话题已存在,话题名不能重复!!');
|
||||
}
|
||||
|
||||
$insert['title'] = trim($data['title']);
|
||||
$insert['parent_id'] = $data['parent_id'];
|
||||
$insert['sort'] = $data['sort'];
|
||||
$insert['icon'] = $data['icon'];
|
||||
|
||||
$this->base_topic_obj->insert($insert);
|
||||
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 通用话题--编辑通用话题
|
||||
* @description 通用话题--编辑通用话题
|
||||
* @author wangjinlei
|
||||
* @url /master/Journal/editBaseTopic
|
||||
* @method POST
|
||||
*
|
||||
* @param name:base_topic_id type:int require:1 desc:通用话题id
|
||||
* @param name:title type:string require:1 desc:话题名称标题
|
||||
* @param name:sort type:int require:1 desc:权重值
|
||||
*/
|
||||
public function editBaseTopic(){
|
||||
$data = $this->request->post();
|
||||
$update['title'] = trim($data['title']);
|
||||
$update['sort'] = $data['sort'];
|
||||
if(isset($data['icon'])){
|
||||
$update['icon'] = $data['icon'];
|
||||
}
|
||||
$this->base_topic_obj->where('base_topic_id',$data['base_topic_id'])->update($update);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 通用话题--删除通用话题
|
||||
* @description 通用话题--删除通用话题
|
||||
* @author wangjinlei
|
||||
* @url /master/Journal/delBaseTopic
|
||||
* @method POST
|
||||
*
|
||||
* @param name:base_topic_id type:int require:1 desc:通用话题id
|
||||
*/
|
||||
public function delBaseTopic(){
|
||||
$data = $this->request->post();
|
||||
$this->base_topic_obj->where('base_topic_id',$data['base_topic_id'])->update(['state'=>1]);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 通用话题--图片上传
|
||||
* @description 通用话题--图片上传
|
||||
* @author wangjinlei
|
||||
* @url /master/Journal/baseTopic_up_file
|
||||
* @method POST
|
||||
*
|
||||
* @param name:name type:string require:1 default:baseTopic desc:文件域名称
|
||||
*
|
||||
* @return upurl:图片地址
|
||||
*/
|
||||
public function baseTopic_up_file() {
|
||||
$file = request()->file('baseTopic');
|
||||
if ($file) {
|
||||
$info = $file->move(ROOT_PATH . 'public' . DS . 'baseTopic');
|
||||
if ($info) {
|
||||
return json(['code'=>0 , 'msg'=>'success', 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
|
||||
} else {
|
||||
return json(['code' => 1, 'msg' => $file->getError()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 增加期刊paper文章
|
||||
* @description 增加期刊paper文章
|
||||
@@ -1406,6 +1577,7 @@ class Journal extends Controller {
|
||||
$data = $this->request->post();
|
||||
$update['title'] = $data['title'];
|
||||
$update['content'] = $data['content'];
|
||||
$update['sort']=$data['sort'];
|
||||
$this->journal_paper_art_obj->where('journal_paper_art_id',$data['journal_paper_art_id'])->update($update);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
@@ -395,12 +395,14 @@ class Mysystem extends Controller {
|
||||
*
|
||||
* @param name:title type:string require:1 desc:消息标题
|
||||
* @param name:content type:string require:1 desc:内容
|
||||
* @param name:icon type:string require:1 desc:图标
|
||||
* @param name:ctime type:string require:1 desc:时间
|
||||
*/
|
||||
public function addNotices(){
|
||||
$data = $this->request->post();
|
||||
$insert['title'] = $data['title'];
|
||||
$insert['content'] = $data['content'];
|
||||
$insert['icon'] = $data['icon'];
|
||||
$insert['ctime'] = $data['ctime']==''?time():strtotime($data['ctime']);
|
||||
$this->sys_not_obj->insert($insert);
|
||||
return jsonSuccess([]);
|
||||
@@ -430,11 +432,13 @@ class Mysystem extends Controller {
|
||||
*
|
||||
* @param name:system_notices_id type:int require:1 desc:消息标题
|
||||
* @param name:title type:string require:1 desc:消息标题
|
||||
* @param name:icon type:string require:1 desc:图标
|
||||
* @param name:content type:string require:1 desc:内容
|
||||
*/
|
||||
public function editNotices(){
|
||||
$data = $this->request->post();
|
||||
$update['title'] = $data['title'];
|
||||
$update['icon'] = $data['icon'];
|
||||
$update['content'] = $data['content'];
|
||||
$this->sys_not_obj->where('system_notices_id',$data['system_notices_id'])->update($update);
|
||||
return jsonSuccess([]);
|
||||
|
||||
502
application/master/controller/Propa.php
Normal file
502
application/master/controller/Propa.php
Normal file
@@ -0,0 +1,502 @@
|
||||
<?php
|
||||
|
||||
namespace app\master\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
use think\Queue;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
|
||||
/**
|
||||
* @title 推广邮件功能
|
||||
* @description 推广邮件功能
|
||||
*/
|
||||
class Propa extends Controller {
|
||||
|
||||
//put your code here
|
||||
protected $admin_obj = '';
|
||||
protected $journal_obj = '';
|
||||
protected $article_obj = '';
|
||||
protected $article_author_obj = '';
|
||||
protected $journal_topic_obj = '';
|
||||
protected $journal_stage_obj = '';
|
||||
protected $journal_notices_obj = '';
|
||||
protected $journal_abs_obj = '';
|
||||
protected $journal_special_obj = '';
|
||||
protected $journal_special_editor_obj = '';
|
||||
protected $journal_special_to_editor_obj = '';
|
||||
protected $journal_special_alert_obj = '';
|
||||
protected $article_to_topic_obj = '';
|
||||
protected $sys_scient_obj = '';
|
||||
protected $sys_book_obj = '';
|
||||
protected $propa_email_model_obj = '';
|
||||
protected $propa_email_obj = '';
|
||||
protected $propa_email_type_obj = '';
|
||||
protected $propa_email_log_obj = '';
|
||||
|
||||
public function __construct(\think\Request $request = null) {
|
||||
parent::__construct($request);
|
||||
$this->admin_obj = Db::name('admin');
|
||||
$this->journal_obj = Db::name('journal');
|
||||
$this->article_obj = Db::name('article');
|
||||
$this->article_author_obj = Db::name('article_author');
|
||||
$this->journal_topic_obj = Db::name('journal_topic');
|
||||
$this->journal_stage_obj = Db::name('journal_stage');
|
||||
$this->journal_notices_obj = Db::name('journal_notices');
|
||||
$this->journal_abs_obj = Db::name('journal_abstracting');
|
||||
$this->journal_special_obj = Db::name('journal_special');
|
||||
$this->journal_special_editor_obj = Db::name('journal_special_editor');
|
||||
$this->journal_special_to_editor_obj = Db::name('journal_special_to_editor');
|
||||
$this->journal_special_alert_obj = Db::name('journal_special_alert');
|
||||
$this->article_to_topic_obj = Db::name('article_to_topic');
|
||||
$this->sys_scient_obj = Db::name('system_scient');
|
||||
$this->sys_book_obj = Db::name('system_books');
|
||||
$this->propa_email_model_obj = Db::name('propa_email_model');
|
||||
$this->propa_email_obj = Db::name('propa_email');
|
||||
$this->propa_email_type_obj = Db::name('propa_email_type');
|
||||
$this->propa_email_log_obj = Db::name('propa_email_log');
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 获取编辑名下期刊列表
|
||||
* @description 获取编辑名下期刊列表
|
||||
* @author wangjinlei
|
||||
* @url /master/Propa/getEditorJournals
|
||||
* @method POST
|
||||
*
|
||||
* @param name:editor_id type:int require:1 desc:编辑id
|
||||
*
|
||||
* @return journals:期刊列表#
|
||||
*/
|
||||
public function getEditorJournals(){
|
||||
$data = $this->request->post();
|
||||
$journals = $this->journal_obj->where('editor_id',$data['editor_id'])->where('state',0)->select();
|
||||
|
||||
$re['journals'] = $journals;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 获取期刊详情
|
||||
* @description 获取期刊详情
|
||||
* @author wangjinlei
|
||||
* @url /master/Propa/getJournalDetail
|
||||
* @method POST
|
||||
*
|
||||
* @param name:journal_id type:int require:1 desc:期刊id
|
||||
*
|
||||
* @return journal:期刊信息#
|
||||
*/
|
||||
public function getJournalDetail(){
|
||||
$data = $this->request->post();
|
||||
$info = $this->journal_obj->where('journal_id',$data['journal_id'])->where('state',0)->find();
|
||||
$re['journal'] = $info;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @title 添加推广邮箱(单个邮箱)
|
||||
* @description 添加推广邮箱(单个邮箱)
|
||||
* @author wangjinlei
|
||||
* @url /master/Propa/addPropaEmail
|
||||
* @method POST
|
||||
*
|
||||
* @param name:journal_id type:int require:1 desc:期刊id
|
||||
* @param name:pet_id type:int require:1 desc:分类id
|
||||
* @param name:email type:string require:1 desc:邮箱地址
|
||||
*
|
||||
*/
|
||||
public function addPropaEmail(){
|
||||
$data = $this->request->post();
|
||||
$count = $this->propa_email_obj->where('journal_id',$data['journal_id'])->where('pet_id',$data['pet_id'])->where('state',0)->count();
|
||||
if($count>=200){
|
||||
return jsonError("超过最大上限数量,最大上限200");
|
||||
}
|
||||
$check = $this->propa_email_obj
|
||||
->where('email',trim($data['email']))
|
||||
->where('pet_id',$data['pet_id'])
|
||||
->where('journal_id',$data['journal_id'])
|
||||
->where('state',0)
|
||||
->find();
|
||||
if($check!=null){
|
||||
return jsonError('has add');
|
||||
}
|
||||
$insert['journal_id'] = $data['journal_id'];
|
||||
$insert['pet_id'] = $data['pet_id'];
|
||||
$insert['email'] = trim($data['email']);
|
||||
$this->propa_email_obj->insert($insert);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 添加推广邮箱(txt)
|
||||
* @description 添加推广邮箱(txt)
|
||||
* @author wangjinlei
|
||||
* @url /master/Propa/addPropaEmailByTxt
|
||||
* @method POST
|
||||
*
|
||||
* @param name:fileDir type:string require:1 desc:上传文件的返回地址
|
||||
* @param name:journal_id type:int require:1 desc:期刊id
|
||||
* @param name:pet_id type:int require:1 desc:分类id
|
||||
*
|
||||
*/
|
||||
public function addPropaEmailByTxt(){
|
||||
$data = $this->request->post();
|
||||
// $data['journal_id'] = 1;
|
||||
// $data['fileDir'] = '20210915/9754ea4775f85a167140d0e33610b4e5.txt';
|
||||
|
||||
$txt = ROOT_PATH.'public'.DS.'txtfile'.DS.$data['fileDir'];
|
||||
$handle = fopen($txt, "r");//读取二进制文件时,需要将第二个参数设置成'rb'
|
||||
//通过filesize获得文件大小,将整个文件一下子读到一个字符串中
|
||||
$contents = fread($handle, filesize ($txt));
|
||||
fclose($handle);
|
||||
$emails = $this->extract_emails_from($contents);
|
||||
$count = $this->propa_email_obj->where('journal_id',$data['journal_id'])->where('pet_id',$data['pet_id'])->where('state',0)->count();
|
||||
if(($count+count($emails))>=200){
|
||||
return jsonError('超过最大上限数量,最大上限为200');
|
||||
}
|
||||
foreach ($emails as $v){
|
||||
$cache_check = $this->propa_email_obj->where('email',$v)->where('pet_id',$data['pet_id'])->where('state',0)->find();
|
||||
if($cache_check!=null){
|
||||
continue;
|
||||
}
|
||||
$cache_insert['journal_id'] = $data['journal_id'];
|
||||
$cache_insert['pet_id'] = $data['pet_id'];
|
||||
$cache_insert['email'] = $v;
|
||||
$this->propa_email_obj->insert($cache_insert);
|
||||
}
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 删除推广邮箱
|
||||
* @description 删除推广邮箱
|
||||
* @author wangjinlei
|
||||
* @url /master/Propa/delPropaEmail
|
||||
* @method POST
|
||||
*
|
||||
* @param name:propa_email_id type:int require:1 desc:推广邮箱id
|
||||
*
|
||||
*/
|
||||
public function delPropaEmail(){
|
||||
$data = $this->request->post();
|
||||
$this->propa_email_obj->where('propa_email_id',$data['propa_email_id'])->update(['state'=>1]);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 获取推广邮箱列表(分页)
|
||||
* @description 获取推广邮箱列表(分页)
|
||||
* @author wangjinlei
|
||||
* @url /master/Propa/getPropaEmails
|
||||
* @method POST
|
||||
*
|
||||
* @param name:journal_id type:int require:1 desc:期刊id
|
||||
* @param name:pet_id type:int require:1 desc:分类id
|
||||
* @param name:pageIndex type:int require:1 desc:当前页码数
|
||||
* @param name:pageSize type:int require:1 desc:单页数据条数
|
||||
*
|
||||
* @return emails:邮箱列表#
|
||||
* @return count:总数
|
||||
*/
|
||||
public function getPropaEmails(){
|
||||
$data = $this->request->post();
|
||||
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
|
||||
$list = $this->propa_email_obj
|
||||
->where('journal_id',$data['journal_id'])
|
||||
->where('pet_id',$data['pet_id'])
|
||||
->where('state',0)
|
||||
->limit($limit_start,$data['pageSize'])
|
||||
->select();
|
||||
$count = $this->propa_email_obj->where('journal_id',$data['journal_id'])->where('pet_id',$data['pet_id'])->where('state',0)->count();
|
||||
|
||||
$re['emails'] = $list;
|
||||
$re['count'] = $count;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 获取推广邮箱当天已发送数量
|
||||
* @description 获取推广邮箱当天已发送数量
|
||||
* @author wangjinlei
|
||||
* @url /master/Propa/getPropaEmailLog
|
||||
* @method POST
|
||||
*
|
||||
* @param name:journal_id type:int require:1 desc:期刊id
|
||||
*
|
||||
* @return count:总数
|
||||
*/
|
||||
public function getPropaEmailLog(){
|
||||
$data = $this->request->post();
|
||||
$log = $this->propa_email_log_obj->where('journal_id',$data['journal_id'])->where('date', date('Ymd'))->find();
|
||||
|
||||
$re['count'] = $log['num'];
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 获取推广邮箱分类
|
||||
* @description 获取推广邮箱分类
|
||||
* @author wangjinlei
|
||||
* @url /master/Propa/getPropaType
|
||||
* @method POST
|
||||
*
|
||||
* @param name:journal_id type:int require:1 desc:期刊id
|
||||
*
|
||||
* @return types:分类列表#
|
||||
*/
|
||||
public function getPropaType(){
|
||||
$data = $this->request->post();
|
||||
$types = $this->propa_email_type_obj->where('journal_id',$data['journal_id'])->where('state',0)->select();
|
||||
if($types==null){//当一个分类没有时新建一个默认分类
|
||||
$insert['journal_id'] = $data['journal_id'];
|
||||
$insert['title'] = 'default';
|
||||
$this->propa_email_type_obj->insert($insert);
|
||||
$types = $this->propa_email_type_obj->where('journal_id',$data['journal_id'])->where('state',0)->select();
|
||||
}
|
||||
|
||||
$re['types'] = $types;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 添加邮件模板
|
||||
* @description 添加邮件模板
|
||||
* @author wangjinlei
|
||||
* @url /master/Propa/addPropaEmailModel
|
||||
* @method POST
|
||||
*
|
||||
* @param name:journal_id type:int require:1 desc:期刊id
|
||||
* @param name:title type:string require:1 desc:标题
|
||||
* @param name:content type:string require:1 desc:内容
|
||||
*/
|
||||
public function addPropaEmailModel(){
|
||||
$data = $this->request->post();
|
||||
$insert['journal_id'] = $data['journal_id'];
|
||||
$insert['title'] = trim($data['title']);
|
||||
$insert['content'] = $data['content'];
|
||||
$this->propa_email_model_obj->insert($insert);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 添加推广邮件类型
|
||||
* @description 添加推广邮件类型
|
||||
* @author wangjinlei
|
||||
* @url /master/Propa/addPropaEmailType
|
||||
* @method POST
|
||||
*
|
||||
* @param name:journal_id type:int require:1 desc:期刊id
|
||||
* @param name:title_content type:string require:1 desc:分类名称
|
||||
*/
|
||||
public function addPropaEmailType(){
|
||||
$data = $this->request->post();
|
||||
$insert['journal_id'] = $data['journal_id'];
|
||||
$insert['title'] = trim($data['title_content']);
|
||||
$this->propa_email_type_obj->insert($insert);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 删除邮件模板
|
||||
* @description 删除邮件模板
|
||||
* @author wangjinlei
|
||||
* @url /master/Propa/delPropaEmailModel
|
||||
* @method POST
|
||||
*
|
||||
* @param name:pem_id type:int require:1 desc:邮件模板id
|
||||
*/
|
||||
public function delPropaEmailModel(){
|
||||
$data = $this->request->post();
|
||||
$this->propa_email_model_obj->where('pem_id',$data['pem_id'])->update(['state'=>1]);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 编辑邮件模板
|
||||
* @description 编辑邮件模板
|
||||
* @author wangjinlei
|
||||
* @url /master/Propa/editPropaEmailModel
|
||||
* @method POST
|
||||
*
|
||||
* @param name:pem_id type:int require:1 desc:邮件模板id
|
||||
* @param name:title type:string require:1 desc:标题
|
||||
* @param name:content type:string require:1 desc:内容
|
||||
*/
|
||||
public function editPropaEmailModel(){
|
||||
$data = $this->request->post();
|
||||
$update['title'] = trim($data['title']);
|
||||
$update['content'] = $data['content'];
|
||||
$this->propa_email_model_obj->where('pem_id',$data['pem_id'])->update($update);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 获取邮件模板列表
|
||||
* @description 获取邮件模板列表
|
||||
* @author wangjinlei
|
||||
* @url /master/Propa/getPropaEmailModel
|
||||
* @method POST
|
||||
*
|
||||
* @param name:journal_id type:int require:1 desc:期刊id
|
||||
*
|
||||
* @return models:模板列表#
|
||||
*/
|
||||
public function getPropaEmailModel(){
|
||||
$data = $this->request->post();
|
||||
$models = $this->propa_email_model_obj->where('journal_id',$data['journal_id'])->where('state',0)->select();
|
||||
$re['models'] = $models;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 获取单个邮件模板
|
||||
* @description 获取单个邮件模板
|
||||
* @author wangjinlei
|
||||
* @url /master/Propa/getOneEmailModel
|
||||
* @method POST
|
||||
*
|
||||
* @param name:pem_id type:int require:1 desc:邮件模板id
|
||||
*
|
||||
* @return models:模板信息#
|
||||
*/
|
||||
public function getOneEmailModel(){
|
||||
$data = $this->request->post();
|
||||
$model = $this->propa_email_model_obj->where('pem_id',$data['pem_id'])->find();
|
||||
$re['model'] = $model;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 发送邮件
|
||||
* @description 发送邮件
|
||||
* @author wangjinlei
|
||||
* @url /master/Propa/sendEmail
|
||||
* @method POST
|
||||
*
|
||||
* @param name:content type:string require:1 desc:内容
|
||||
* @param name:pet_id type:int require:1 desc:分类id
|
||||
* @param name:journal_id type:int require:1 desc:期刊id
|
||||
*/
|
||||
public function sendEmail(){
|
||||
$data = $this->request->post();
|
||||
$journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find();
|
||||
$emails = $this->propa_email_obj->where('journal_id',$data['journal_id'])->where('pet_id',$data['pet_id'])->where('state',0)->select();
|
||||
$time = date('Ymd');
|
||||
$log = $this->propa_email_log_obj->where('journal_id',$data['journal_id'])->where('date',$time)->find();
|
||||
$num = 0;
|
||||
if($log==null){
|
||||
$in['journal_id'] = $data['journal_id'];
|
||||
$in['date'] = $time;
|
||||
$this->propa_email_log_obj->insert($in);
|
||||
}else{
|
||||
$num = $log['num'];
|
||||
}
|
||||
|
||||
foreach ($emails as $k => $v){
|
||||
if($num>=200){
|
||||
continue;
|
||||
}
|
||||
$maidata['email'] = $v['email'];
|
||||
$maidata['title'] = $journal_info['title'];
|
||||
$maidata['content'] = $data['content'];
|
||||
Queue::push('app\api\job\mail@propa', $maidata, "mail");
|
||||
$num++;
|
||||
}
|
||||
$this->propa_email_log_obj->where('journal_id',$data['journal_id'])->where('date',$time)->update(['num'=>$num]);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
private function aliemail(){
|
||||
vendor('aliemail.email');
|
||||
$mailto='751475802@qq.com';
|
||||
$mailsubject="测试邮件";
|
||||
$mailbody='这里是邮件内容';
|
||||
$smtpserver = "smtpdm-ap-southeast-1.aliyun.com";
|
||||
$smtpserverport = 80;
|
||||
$smtpusermail = "propa@hellotmr.top";
|
||||
// 发件人的账号,填写控制台配置的发信地址,比如xxx@xxx.com
|
||||
$smtpuser = "propa@hellotmr.top";
|
||||
// 访问SMTP服务时需要提供的密码(在控制台选择发信地址进行设置)
|
||||
$smtppass = "Wu751019Pnx";
|
||||
$mailsubject = "=?UTF-8?B?" . base64_encode($mailsubject) . "?=";
|
||||
$mailtype = "HTML";
|
||||
//可选,设置回信地址
|
||||
$smtpreplyto = "13662001490@126.com";
|
||||
$smtp = new \smtp($smtpserver, $smtpserverport, true, $smtpuser, $smtppass);
|
||||
$smtp->debug = false;
|
||||
$cc ="";
|
||||
$bcc = "";
|
||||
$additional_headers = "";
|
||||
//设置发件人名称,名称用户可以自定义填写。
|
||||
$sender = "wangjinlei test";
|
||||
$res = $smtp->sendmail($mailto,$smtpusermail, $mailsubject, $mailbody, $mailtype, $cc, $bcc, $additional_headers, $sender, $smtpreplyto);
|
||||
|
||||
echo '<pre>';
|
||||
var_dump($res);
|
||||
echo '</pre>';
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @title txt文件上传
|
||||
* @description txt文件上传
|
||||
* @author wangjinlei
|
||||
* @url /master/Propa/up_file
|
||||
* @method POST
|
||||
*
|
||||
* @param name:name type:string require:1 default:txtfile desc:文件域名称
|
||||
*
|
||||
* @return upurl:图片地址
|
||||
*/
|
||||
public function up_file(){
|
||||
$file = request()->file('txtfile');
|
||||
if ($file) {
|
||||
$info = $file->move(ROOT_PATH . 'public' . DS . 'txtfile');
|
||||
if ($info) {
|
||||
return json(['code' => 0, 'msg' => 'success', 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
|
||||
} else {
|
||||
return json(['code' => 1, 'msg' => $file->getError()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 获取txt文件包含邮箱地址
|
||||
* @description 获取txt文件包含邮箱地址
|
||||
* @author wangjinlei
|
||||
* @url /master/Propa/readTxt
|
||||
* @method POST
|
||||
*
|
||||
* @param name:txtdir type:string require:1 desc:txt文件上传后返回地址
|
||||
*
|
||||
* @return emails:邮箱列表#
|
||||
*/
|
||||
public function readTxt(){
|
||||
$data = $this->request->post();
|
||||
$txt = ROOT_PATH.'public'.DS.'txtfile'.DS.$data['txtdir'];
|
||||
$handle = fopen($txt, "r");//读取二进制文件时,需要将第二个参数设置成'rb'
|
||||
//通过filesize获得文件大小,将整个文件一下子读到一个字符串中
|
||||
$contents = fread($handle, filesize ($txt));
|
||||
fclose($handle);
|
||||
$emails = $this->extract_emails_from($contents);
|
||||
$re['emails'] = $emails;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
private function extract_emails_from($string) {
|
||||
preg_match_all("/[\._a-zA-Z0-9-]+(@|#)[\._a-zA-Z0-9-]+/i", $string, $matches);
|
||||
$emails = $matches[0];
|
||||
//去掉邮件最后的.
|
||||
foreach ($emails as $k => $email){
|
||||
if(substr($email,strlen($email)-1,1)=='.'){
|
||||
$emails[$k] = substr($email,0, strlen($email)-1);
|
||||
}
|
||||
}
|
||||
return $emails;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user