This commit is contained in:
wangjinlei
2023-05-12 11:22:17 +08:00
parent 594e94661e
commit 30e1287ebb
6 changed files with 265 additions and 3 deletions

16
.env
View File

@@ -49,6 +49,20 @@ pre = '<!doctype html>
</td>
<td width="550" height="100" colspan="1" rowspan="1"
style="font-family: sans-serif; vertical-align: top;font-size: 14px;">
<a href="https://www.tmrjournals.com" target="_blank"
style="color: #333;font-size: 15px;margin: 0 0 0 40px;text-decoration: none;letter-spacing:-0.5px;text-shadow: 0 0 4px #fff;line-height: 95px">Home
page</a>
<b style="margin: 0 5px;color: #333;">|</b>
<a href="https://www.tmrjournals.com/rev_ver.html" target="_blank"
style="color: #333;font-size: 15px;text-decoration: none;letter-spacing:-0.5px;text-shadow: 0 0 4px #fff">Scientist
Community</a>
<b style="margin: 0 5px;color: #333;">|</b>
<a href="https://www.tmrjournals.com/tmrde/" target="_blank"
style="color: #333;font-size: 15px;text-decoration: none;letter-spacing:-0.5px;text-shadow: 0 0 4px #fff">Database</a>
<b style="margin: 0 5px;color: #333;">|</b>
<a href="https://submission.tmrjournals.com/" target="_blank"
style="color: #333;font-size: 15px;text-decoration: none;letter-spacing:-0.5px;text-shadow: 0 0 4px #fff">Submission
System</a>
</td>
</tr>
@@ -142,7 +156,7 @@ net = '</p>
<tbody>
<tr style="font-family:sans-serif; vertical-align: top;font-size: 12px;">
<td width="500" height="40" colspan="0" rowspan="0">
<a href="https://www.tmrjournals.com/afoor_text.html?&footer_id=75" target="_blank"
<a href="https://www.tmrjournals.com/afoor_con.html?&footer_id=6" target="_blank"
style="color: #333;margin: 2px 0 0 30px;line-height: 20px;display: block">
Privacy policy
</a>

View File

@@ -65,6 +65,7 @@ class Base extends Controller
protected $production_article_main_obj = '';
protected $apply_reviewer_obj = '';
protected $promotion_obj = '';
protected $promotion_email_obj = '';
public function __construct(\think\Request $request = null)
@@ -129,6 +130,7 @@ class Base extends Controller
$this->production_article_main_obj = Db::name('production_article_main');
$this->apply_reviewer_obj = Db::name("apply_reviewer");
$this->promotion_obj = Db::name("promotion");
$this->promotion_email_obj = Db::name("promotion_email");
}
@@ -263,6 +265,96 @@ class Base extends Controller
return $list;
}
/**获取标准化用户库的人
* @return void
*/
public function getLibraryList($lib,$type,$body,$pageIndex,$pageSize){
$frag = [];
if($lib=="user"){//正式库
$list = [];
if($type=='major'){
$list = $this->user_obj
->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.no_email',0)
->where('t_user.state',0)
->page($pageIndex,$pageSize)
->select();
}else{
$list = $this->user_obj
->join("t_user_reviewer_info","t_user_reviewer_info.reviewer_id = t_user.user_id",'left')
->where("t_user_reviewer_info.field","like","%".$body."%")
->where('t_user.no_email',0)
->where('t_user.state',0)
->page($pageIndex,$pageSize)
->select();
}
//规整化数据整理
foreach ($list as $v){
$ca['email'] = $v['email'];
$ca['name'] = $v['realname']==""?$v['account']:$v['realname'];
$ca['type'] = "user";
$ca['id'] = $v['user_id'];
$frag[] = $ca;
}
}elseif($lib == 'author'){//作者库
$list = [];
$exist = "select * from t_user_author where user_id = t_user.user_id";
if($type=='major'){
$list = $this->user_obj
->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.no_email',0)
->where('t_user.state',0)
->whereExists($exist)
->page($pageIndex,$pageSize)
->select();
}else{
$list = $this->user_obj
->join("t_user_reviewer_info","t_user_reviewer_info.reviewer_id = t_user.user_id",'left')
->where("t_user_reviewer_info.field","like","%".$body."%")
->where('t_user.no_email',0)
->where('t_user.state',0)
->whereExists($exist)
->page($pageIndex,$pageSize)
->select();
}
//规整化数据整理
foreach ($list as $v){
$ca['email'] = $v['email'];
$ca['name'] = $v['realname']==""?$v['account']:$v['realname'];
$ca['type'] = "user";
$ca['id'] = $v['user_id'];
$frag[] = $ca;
}
}else{//灰库
$list = [];
if($type=='major'){
$list = $this->user_ash_obj
->where('major',$body)
->where('no_email',0)
->where('state',0)
->page($pageIndex,$pageSize)
->select();
}else{
$list = $this->user_ash_obj
->where('major',$body)
->where('field',"like","%".$body."%")
->where('state',0)
->page($pageIndex,$pageSize)
->select();
}
//规整化数据整理
foreach ($list as $v){
$ca['email'] = $v['email'];
$ca['name'] = $v['name'];
$ca['type'] = "ash";
$ca['id'] = $v['ash_id'];
$frag[] = $ca;
}
}
return $frag;
}
}
?>

View File

@@ -98,11 +98,125 @@ class Promotion extends Base
}
/**获取官网文章列表
* @return void
*/
public function getWebArticles(){
$data = $this->request->post();
$rule = new Validate([
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
}
/**获取邮件模版列表
* @return void
*/
public function getEmailModel(){
$list = $this->promotion_email_obj->where('state',0)->select();
$re['list'] = $list;
return jsonSuccess($re);
}
/**添加推广任务主体
* @return void
*/
public function addPromotion(){
$data = $this->request->post();
$rule = new Validate([
'user_id'=>"require",
'journal_id'=>"require",
"library"=>"require",
"category"=>"require",
"pagesize"=>"require",
"email_title"=>"require",
"template"=>"require",
"has_hb"=>"require",
"frequency"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$insert['user_id'] = $data['user_id'];
$insert['journal_id'] = $data['journal_id'];
$insert['library'] = $data['library'];
$insert['category'] = $data['category'];
if($data['category']=="major"){
$insert['major'] = $data['major'];
}else{
$insert['keyword'] = trim($data['keyword']);
}
$insert['pagesize'] = $data['pagesize'];
$insert['email_title'] = $data['email_title'];
$insert['template']=$data['template'];
$insert['has_hb'] = $data['has_hb'];
$insert['frequency'] = $data['frequency'];
$insert['ctime'] = time();
$this->promotion_obj->insert($insert);
return jsonSuccess([]);
}
/**执行推广任务主方法
* @return void
*/
public function autoPushPromotion(){
$data = $this->request->post();
$rule = new Validate([
"pro_id"=>'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();
if(!$pro_info||$pro_info['is_end']==1){
return jsonError('ended');
}
$push_arr = json_decode($pro_info['pushed']);
$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']);
// $l['email'] = "751475802@qq.com";
// $l['name'] = "wangjinlei";
// $l['type'] = "ash";
// $l['id'] = 35;
// $list[] = $l;
//组合模版
$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);
//发送邮件
foreach ($list as $v){
$template = str_replace("{{user_name}}",$v['name'],$template);
$template = str_replace("{{unsubscribe}}","http://journalapi.tmrjournals.com/public/index.php/api/Promotion/NoEmail?lib=".$v['type']."&id=".$v['id'],$template);
$ali['email'] = $v['email'];
$ali['title'] = $pro_info['email_title'];
$ali['content'] = $template;
$ali['has_hb'] = $pro_info['has_hb'];
// aliemail($v['email'],$pro_info['email_title'],$template,$pro_info['has_hb']);
Queue::push('app\api\job\mail@promotion',$ali,'mail');
}
//更改各种状态
//如果后续没有待发数据,要关闭此推广项目
$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){
$this->promotion_obj->where('pro_id',$data['pro_id'])->update(['is_end'=>1]);
}
//发送过的数据加一页
$push_arr[] = $pageIndex;
$this->promotion_obj->where('pro_id',$data['pro_id'])->update(["pushed"=>json_encode($push_arr)]);
$re['msg'] = "push email :".count($list);
return jsonSuccess($re);
}

View File

@@ -0,0 +1,37 @@
<?php
namespace app\api\controller;
use app\api\controller\Base;
use think\Db;
use think\Queue;
use think\Validate;
class Web extends Base
{
private $Base_url = "http://journalapi.tmrjounals.com/public/index.php/";
public function __construct(\think\Request $request = null)
{
parent::__construct($request);
}
public function getStages(){
$data = $this->request->post();
$rule = new Validate([
"journal_id" => 'equire'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find();
//发送请求到官网
$url = $this->Base_url."api/Submision/getJournalStages";
$program['issn'] = $journal_info['issn'];
$res = object_to_array(json_decode(myPost($url,$program)));
$list = $res['data']['stages'];
$re['stages'] = $list;
return jsonSuccess($re);
}
}
?>

View File

@@ -18,6 +18,11 @@ class mail {
my_tg_pushmail($data);
$job->delete();
}
public function promotion(Job $job,$data){
aliemail($data['email'],$data['title'],$data['content'],$data['has_hb']);
$job->delete();
}
/**
* 发送邮件的逻辑

View File

@@ -586,7 +586,7 @@ function getReviewerCvs($reviewer_id){
return $cvs;
}
function aliemail($email,$title,$content){
function aliemail($email,$title,$content,$has_hb=1){
// file_put_contents('/usr/a.txt', $email,FILE_APPEND);
vendor('aliemail.email');
$mailto=$email;
@@ -595,7 +595,7 @@ function aliemail($email,$title,$content){
$pre = Env::get('emailtemplete.pre');
$net = Env::get('emailtemplete.net');
$net1 = str_replace("{{email}}",$email,$net);
$mailbody=$pre.$content.$net1;
$mailbody=$has_hb==1?$pre.$content.$net1:$content;
$smtpserver = "smtpdm-ap-southeast-1.aliyun.com";
$smtpserverport = 80;
$smtpusermail = "propa@hellotmr.top";