This commit is contained in:
wangjinlei
2023-05-18 10:09:15 +08:00
parent 108dffb71c
commit d5a2822951
4 changed files with 221 additions and 45 deletions

View File

@@ -879,7 +879,8 @@ class Article extends Base
//初审分数不够,自动拒稿 //初审分数不够,自动拒稿
if ($article_info['state'] == 0 && $article_info['type'] != 'N' && $article_info['type'] != 'T') { if ($article_info['state'] == 0 && $article_info['type'] != 'N' && $article_info['type'] != 'T') {
if (($journal_info['journal_id'] == 1 && $article_info['scoring'] < 4) || (($journal_info['journal_id'] == 10 || $journal_info['journal_id'] == 23) && $article_info['scoring'] < 3) || ($journal_info['journal_id'] == 21 && $article_info['scoring'] < 0) || (($journal_info['journal_id'] == 16||$journal_info['journal_id'] == 6||$journal_info['journal_id'] == 12) && $article_info['scoring'] < 2) || ($journal_info['journal_id'] != 1 && $journal_info['journal_id'] != 6 && $journal_info['journal_id'] != 16 && $journal_info['journal_id'] != 12 && $journal_info['journal_id'] != 10 && $journal_info['journal_id'] != 21 && $journal_info['journal_id'] != 23 && $article_info['scoring'] < 1)) { // if (($journal_info['journal_id'] == 1 && $article_info['scoring'] < 4) || (($journal_info['journal_id'] == 10 || $journal_info['journal_id'] == 23) && $article_info['scoring'] < 3) || ($journal_info['journal_id'] == 21 && $article_info['scoring'] < 0) || (($journal_info['journal_id'] == 16||$journal_info['journal_id'] == 6||$journal_info['journal_id'] == 12) && $article_info['scoring'] < 2) || ($journal_info['journal_id'] != 1 && $journal_info['journal_id'] != 6 && $journal_info['journal_id'] != 16 && $journal_info['journal_id'] != 12 && $journal_info['journal_id'] != 10 && $journal_info['journal_id'] != 21 && $journal_info['journal_id'] != 23 && $article_info['scoring'] < 1)) {
if($article_info['scoring']<$journal_info['kfen']){
if (count($transfer_list) > 0) { if (count($transfer_list) > 0) {
//查询转投期刊信息 //查询转投期刊信息
$transfer_journal = $this->journal_obj->where('journal_id', $transfer_list[0]['journal_id'])->find(); $transfer_journal = $this->journal_obj->where('journal_id', $transfer_list[0]['journal_id'])->find();
@@ -1882,6 +1883,12 @@ class Article extends Base
$inset_data['state'] = -1; $inset_data['state'] = -1;
$article_id = $this->article_obj->insertGetId($inset_data); $article_id = $this->article_obj->insertGetId($inset_data);
} else { } else {
$checkArticle = $this->article_obj->where("article_id","<>",$article_id)->where("title", trim($data['title']))->select();
foreach ($checkArticle as $v) {
if ($v['state'] != 3) {
return json(['code' => 1, 'msg' => 'Warning: you are re-submitting the article!']);
}
}
$up['user_id'] = $user_info['user_id']; $up['user_id'] = $user_info['user_id'];
$up['journal_id'] = $data['journal']; $up['journal_id'] = $data['journal'];
$up['editor_id'] = $journal_info['editor_id']; $up['editor_id'] = $journal_info['editor_id'];
@@ -2308,6 +2315,12 @@ class Article extends Base
if ($coun && $coun['is_hot'] == 1) { if ($coun && $coun['is_hot'] == 1) {
$c_fen = 1; $c_fen = 1;
$fen += 1; $fen += 1;
}elseif($coun && $coun['en_name'] != "China" && $coun['en_name'] != "India"){
$c_fen = 0.5;
$fen += 0.5;
}else{
$c_fen = 0;
$fen += 0;
} }
} }
//单位 //单位
@@ -2902,6 +2915,8 @@ class Article extends Base
// 发邮件 // 发邮件
$content = 'Dear editor,<br>please check the new feedback.'; $content = 'Dear editor,<br>please check the new feedback.';
sendEmail($editor['email'], $article['title'], $article['title'], $content, $article['email'], $article['epassword']); sendEmail($editor['email'], $article['title'], $article['title'], $content, $article['email'], $article['epassword']);
$res_msg = add_usermsg($article['editor_id'], 'New manuscript feedback', '/articleDetailEditor?id=' . $article_id);
} }
if ($res['type'] == 2) { //编辑 - 修改editor_act,并发送给作者发邮件 if ($res['type'] == 2) { //编辑 - 修改editor_act,并发送给作者发邮件
$this->article_obj->where('article_id', $article_id)->update(['editor_act' => 1]); $this->article_obj->where('article_id', $article_id)->update(['editor_act' => 1]);
@@ -2914,4 +2929,19 @@ class Article extends Base
sendEmail($author['email'], $article['title'], $article['title'], $content, $article['email'], $article['epassword']); sendEmail($author['email'], $article['title'], $article['title'], $content, $article['email'], $article['epassword']);
} }
} }
/**编辑消息一键全读
* @return void
*/
public function allEditorMsgReaded(){
$data = $this->request->post();
$rule = new Validate([
'editor_id'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$this->user_msg_obj->where("user_id",$data['editor_id'])->update(["state"=>1]);
return jsonSuccess([]);
}
} }

View File

@@ -275,7 +275,7 @@ class Base extends Controller
if($type=='major'){ if($type=='major'){
$list = $this->user_obj $list = $this->user_obj
->join("t_user_reviewer_info","t_user_reviewer_info.reviewer_id = t_user.user_id",'left') ->join("t_user_reviewer_info","t_user_reviewer_info.reviewer_id = t_user.user_id",'left')
->where("t_user_reviewer_info.major",$body) ->where("t_user_reviewer_info.major",'in',$this->majorids($body))
->where('t_user.no_email',0) ->where('t_user.no_email',0)
->where('t_user.state',0) ->where('t_user.state',0)
->page($pageIndex,$pageSize) ->page($pageIndex,$pageSize)
@@ -303,7 +303,7 @@ class Base extends Controller
if($type=='major'){ if($type=='major'){
$list = $this->user_obj $list = $this->user_obj
->join("t_user_reviewer_info","t_user_reviewer_info.reviewer_id = t_user.user_id",'left') ->join("t_user_reviewer_info","t_user_reviewer_info.reviewer_id = t_user.user_id",'left')
->where("t_user_reviewer_info.major",$body) ->where("t_user_reviewer_info.major",'in',$this->majorids($body))
->where('t_user.no_email',0) ->where('t_user.no_email',0)
->where('t_user.state',0) ->where('t_user.state',0)
->whereExists($exist) ->whereExists($exist)
@@ -331,7 +331,7 @@ class Base extends Controller
$list = []; $list = [];
if($type=='major'){ if($type=='major'){
$list = $this->user_ash_obj $list = $this->user_ash_obj
->where('major',$body) ->where('major','in',$this->majorids($body))
->where('no_email',0) ->where('no_email',0)
->where('state',0) ->where('state',0)
->page($pageIndex,$pageSize) ->page($pageIndex,$pageSize)

View File

@@ -27,8 +27,17 @@ class Promotion extends Base
return jsonError($rule->getError()); return jsonError($rule->getError());
} }
$list = $this->promotion_obj->where('user_id',$data['user_id'])->select(); $list = $this->promotion_obj->where('user_id',$data['user_id'])->select();
foreach ($list as $k => $v){
$list[$k]['journal'] = $this->journal_obj->where('journal_id',$v['journal_id'])->find();
if($v['category']=="major"){
$list[$k]['major_str'] = $this->getMajorStr($v['major']);
}else{
$list[$k]['major_str'] = '';
}
$list[$k]['user_count'] = $this->getLibUserCount($v['library'],$v['category'],$v['category']=="major"?$v['major']:$v['keyword']);
}
$re['list'] = $list; $re['list'] = $list;
return jsonSuccess($list); return jsonSuccess($re);
} }
/**获取用户库列表 /**获取用户库列表
@@ -56,63 +65,64 @@ class Promotion extends Base
if(!$rule->check($data)){ if(!$rule->check($data)){
return jsonError($rule->getError()); return jsonError($rule->getError());
} }
$count = $this->getLibUserCount($data['lib'],$data['category'],$data['body']);
$re['count'] = $count;
return jsonSuccess($re);
}
private function getLibUserCount($lib,$category,$body){
$count = 0; $count = 0;
if($data['lib']=="user"){//用户库选择为正式库 if($lib=="user"){//用户库选择为正式库
$where['t_user.state'] = 0; $where['t_user.state'] = 0;
$where['t_user.no_email'] = 0; $where['t_user.no_email'] = 0;
if($data['category']=="major"){ if($category=="major"){
$where['t_user_reviewer_info.major'] = ['in',$this->majorids($data['body'])]; $where['t_user_reviewer_info.major'] = ['in',$this->majorids($body)];
}else{ }else{
$where["t_user_reviewer_info.field"] = ["like","%".$data['body']."%"]; $where["t_user_reviewer_info.field"] = ["like","%".$body."%"];
} }
$count=$this->user_obj->join("t_user_reviewer_info","t_user.user_id = t_user_reviewer_info.reviewer_id","left")->where($where)->count(); $count=$this->user_obj->join("t_user_reviewer_info","t_user.user_id = t_user_reviewer_info.reviewer_id","left")->where($where)->count();
}elseif($data['lib']=="author"){//用户库选择为作者库 }elseif($lib=="author"){//用户库选择为作者库
$where['t_user.state'] = 0; $where['t_user.state'] = 0;
$where['t_user.no_email'] = 0; $where['t_user.no_email'] = 0;
if($data['category']=="major"){ if($category=="major"){
$where['t_user_reviewer_info.major'] = ['in',$this->majorids($data['body'])]; $where['t_user_reviewer_info.major'] = ['in',$this->majorids($body)];
}else{ }else{
$where["t_user_reviewer_info.field"] = ["like","%".$data['body']."%"]; $where["t_user_reviewer_info.field"] = ["like","%".$body."%"];
} }
$exist = "select * from t_user_author where user_id = t_user.user_id"; $exist = "select * from t_user_author where user_id = t_user.user_id";
$count=$this->user_obj->join("t_user_reviewer_info","t_user.user_id = t_user_reviewer_info.reviewer_id","left")->where($where)->whereExists($exist)->count(); $count=$this->user_obj->join("t_user_reviewer_info","t_user.user_id = t_user_reviewer_info.reviewer_id","left")->where($where)->whereExists($exist)->count();
}else{//灰库 }else{//灰库
$where["t_user_ash.state"] = 0 ; $where["t_user_ash.state"] = 0 ;
$where['t_user_ash.no_email'] = 0; $where['t_user_ash.no_email'] = 0;
if($data['category']=="major"){ if($category=="major"){
$where['t_user_ash.major'] = ['in',$this->majorids($data['body'])]; $where['t_user_ash.major'] = ['in',$this->majorids($body)];
}else { }else {
$where['t_use_ash.field'] = ['like',"%".$data['body']."%"]; $where['t_user_ash.field'] = ['like',"%".$body."%"];
} }
$count=$this->user_ash_obj->where($where)->count(); $count=$this->user_ash_obj->where($where)->count();
} }
$re['count'] = $count; return $count;
return jsonSuccess($re);
} }
/**退订推广邮件 /**退订推广邮件
* @return void * @return void
*/ */
public function NoEmail(){ public function NoEmail(){
$data = $this->request->get();
}
/**获取官网文章列表
* @return void
*/
public function getWebArticles(){
$data = $this->request->post();
$rule = new Validate([ $rule = new Validate([
'lib'=>"require",
"id"=>"require"
]); ]);
if(!$rule->check($data)){ if(!$rule->check($data)){
return jsonError($rule->getError()); return jsonError($rule->getError());
} }
if($data['lib']=="ash"){
$this->user_ash_obj->where('ash_id',$data['id'])->update(['no_email'=>1]);
}else{
$this->user_obj->where('user_id',$data['id'])->update(['no_email'=>1]);
}
echo "Unsubscribed successfully";
} }
/**获取邮件模版列表 /**获取邮件模版列表
* @return void * @return void
@@ -156,23 +166,154 @@ class Promotion extends Base
$insert['template']=$data['template']; $insert['template']=$data['template'];
$insert['has_hb'] = $data['has_hb']; $insert['has_hb'] = $data['has_hb'];
$insert['frequency'] = $data['frequency']; $insert['frequency'] = $data['frequency'];
$insert['is_end'] = 1;
$insert['ctime'] = time(); $insert['ctime'] = time();
$this->promotion_obj->insert($insert); $this->promotion_obj->insert($insert);
return jsonSuccess([]); return jsonSuccess([]);
} }
/**执行推广任务主方法 /**开启任务
* @return void * @return void
*/ */
public function autoPushPromotion(){ public function startPromotion(){
$data = $this->request->post(); $data = $this->request->post();
$rule = new Validate([ $rule = new Validate([
"pro_id"=>'require' "pro_id"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$this->promotion_obj->where('pro_id',$data['pro_id'])->update(['is_end'=>0]);
return jsonSuccess([]);
}
/**关闭任务
* @return void
*/
public function stopPromotion(){
$data = $this->request->post();
$rule = new Validate([
"pro_id"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$this->promotion_obj->where('pro_id',$data['pro_id'])->update(['is_end'=>1]);
return jsonSuccess([]);
}
/**获取推广任务详情
* @return void
*/
public function getPromotionDetail(){
$data = $this->request->post();
$rule = new Validate([
"pro_id"=>"require"
]); ]);
if(!$rule->check($data)){ if(!$rule->check($data)){
return jsonError($rule->getError()); return jsonError($rule->getError());
} }
$pro_info = $this->promotion_obj->where('pro_id',$data['pro_id'])->find(); $pro_info = $this->promotion_obj->where('pro_id',$data['pro_id'])->find();
$re['promotion'] = $pro_info;
return jsonSuccess($re);
}
/**自动执行day推广
* @return void
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function doPromotionDay(){
$list = $this->promotion_obj->where('frequency',"day")->where('state',0)->where('is_end',0)->select();
foreach ($list as $v){
$this->autoPushPromotion($v['pro_id']);
}
}
/**自动执行week推广
* @return void
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function doPromotionWeek(){
$list = $this->promotion_obj->where('frequency',"week")->where('state',0)->where('is_end',0)->select();
foreach ($list as $v){
$this->autoPushPromotion($v['pro_id']);
}
}
/**删除推广任务
* @return \think\response\Json
* @throws Exception
* @throws \think\exception\PDOException
*/
public function delPromotion(){
$data = $this->request->post();
$rule = new Validate([
"pro_id"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$this->promotion_obj->where('pro_id',$data['pro_id'])->update(['state'=>1]);
return jsonSuccess([]);
}
/**自动执行month推广
* @return void
*/
public function doPromotionMonth(){
$list = $this->promotion_obj->where('frequency',"month")->where('state',0)->where('is_end',0)->select();
foreach ($list as $v){
$this->autoPushPromotion($v['pro_id']);
}
}
/**发送测试邮件
* @return void
*/
public function pushTestEmail(){
$data = $this->request->post();
$rule = new Validate([
'pro_id'=>"require",
'email'=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$pro_info = $this->promotion_obj->where('pro_id',$data['pro_id'])->find();
$journal_info = $this->journal_obj->where("journal_id",$pro_info['journal_id'])->find();
$email_title = $pro_info['email_title'];
$email_title = str_replace("{{journal_title}}",$journal_info['title'],$email_title);
$template = $pro_info['template'];
$template = str_replace("{{journal_title}}",$journal_info['title'],$template);
$template = str_replace("{{journal_abbr}}",$journal_info['abbr'],$template);
$template = str_replace("{{journal_email}}",$journal_info['email'],$template);
$template = str_replace("{{journal_jabbr}}",$journal_info['jabbr'],$template);
$template = str_replace("{{journal_issn}}",$journal_info['issn'],$template);
$template = str_replace("{{journal_website}}",$journal_info['website'],$template);
$template = str_replace("{{user_name}}","emailTestName",$template);
$template = str_replace("{{unsubscribe}}","http://journalapi.tmrjournals.com/public/index.php/api/Promotion/NoEmail?lib=ash&id=35",$template);
aliemail($data['email'],$email_title,$template,$pro_info['has_hb']);
return jsonSuccess([]);
}
public function mytest(){
$this->autoPushPromotion(1);
}
/**执行推广任务主方法
* @return void
*/
private function autoPushPromotion($pro_id){
$pro_info = $this->promotion_obj->where('pro_id',$pro_id)->find();
$journal_info = $this->journal_obj->where('journal_id',$pro_info['journal_id'])->find(); $journal_info = $this->journal_obj->where('journal_id',$pro_info['journal_id'])->find();
if(!$pro_info||$pro_info['is_end']==1){ if(!$pro_info||$pro_info['is_end']==1){
return jsonError('ended'); return jsonError('ended');
@@ -180,12 +321,17 @@ class Promotion extends Base
$push_arr = json_decode($pro_info['pushed']); $push_arr = json_decode($pro_info['pushed']);
$pageIndex = $pro_info['pushed']==""?1:end($push_arr)+1; $pageIndex = $pro_info['pushed']==""?1:end($push_arr)+1;
//选择人员 //选择人员
$list = $this->getLibraryList($pro_info['library'],$pro_info['category'],$pro_info['category']=="major"?$pro_info['major']:$pro_info['keyword'],$pageIndex,$pro_info['pagesize']); // $list = $this->getLibraryList($pro_info['library'],$pro_info['category'],$pro_info['category']=="major"?$pro_info['major']:$pro_info['keyword'],$pageIndex,$pro_info['pagesize']);
// $l['email'] = "751475802@qq.com"; $l['email'] = "751475802@qq.com";
// $l['name'] = "wangjinlei"; $l['name'] = "wangjinlei";
// $l['type'] = "ash"; $l['type'] = "ash";
// $l['id'] = 35; $l['id'] = 35;
// $list[] = $l; $l1['email'] = "2714044218@qq.com";
$l1['name'] = "liuna";
$l1['type'] = "ash";
$l1['id'] = 36;
$list[] = $l;
$list[] = $l1;
//组合模版 //组合模版
$template = $pro_info['template']; $template = $pro_info['template'];
$template = str_replace("{{journal_title}}",$journal_info['title'],$template); $template = str_replace("{{journal_title}}",$journal_info['title'],$template);
@@ -193,6 +339,7 @@ class Promotion extends Base
$template = str_replace("{{journal_email}}",$journal_info['email'],$template); $template = str_replace("{{journal_email}}",$journal_info['email'],$template);
$template = str_replace("{{journal_jabbr}}",$journal_info['jabbr'],$template); $template = str_replace("{{journal_jabbr}}",$journal_info['jabbr'],$template);
$template = str_replace("{{journal_issn}}",$journal_info['issn'],$template); $template = str_replace("{{journal_issn}}",$journal_info['issn'],$template);
$template = str_replace("{{journal_website}}",$journal_info['website'],$template);
//发送邮件 //发送邮件
foreach ($list as $v){ foreach ($list as $v){
$template = str_replace("{{user_name}}",$v['name'],$template); $template = str_replace("{{user_name}}",$v['name'],$template);
@@ -209,14 +356,14 @@ class Promotion extends Base
//如果后续没有待发数据,要关闭此推广项目 //如果后续没有待发数据,要关闭此推广项目
$check_next = $this->getLibraryList($pro_info['library'],$pro_info['category'],$pro_info['category']=="major"?$pro_info['major']:$pro_info['keyword'],$pageIndex+1,$pro_info['pagesize']); $check_next = $this->getLibraryList($pro_info['library'],$pro_info['category'],$pro_info['category']=="major"?$pro_info['major']:$pro_info['keyword'],$pageIndex+1,$pro_info['pagesize']);
if(count($check_next)==0){ if(count($check_next)==0){
$this->promotion_obj->where('pro_id',$data['pro_id'])->update(['is_end'=>1]); $this->promotion_obj->where('pro_id',$pro_id)->update(['is_end'=>1]);
} }
//发送过的数据加一页 //发送过的数据加一页
$push_arr[] = $pageIndex; $push_arr[] = $pageIndex;
$this->promotion_obj->where('pro_id',$data['pro_id'])->update(["pushed"=>json_encode($push_arr)]); $this->promotion_obj->where('pro_id',$pro_id)->update(["pushed"=>json_encode($push_arr)]);
$re['msg'] = "push email :".count($list);
return jsonSuccess($re); return "push email :".count($list);
} }

View File

@@ -587,7 +587,6 @@ function getReviewerCvs($reviewer_id){
} }
function aliemail($email,$title,$content,$has_hb=1){ function aliemail($email,$title,$content,$has_hb=1){
// file_put_contents('/usr/a.txt', $email,FILE_APPEND);
vendor('aliemail.email'); vendor('aliemail.email');
$mailto=$email; $mailto=$email;
$mailsubject=$title; $mailsubject=$title;