|
-
Privacy policy
diff --git a/application/api/controller/Base.php b/application/api/controller/Base.php
index 26289fc..0c15e3b 100644
--- a/application/api/controller/Base.php
+++ b/application/api/controller/Base.php
@@ -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;
+ }
}
?>
\ No newline at end of file
diff --git a/application/api/controller/Promotion.php b/application/api/controller/Promotion.php
index efeef51..fc807a3 100644
--- a/application/api/controller/Promotion.php
+++ b/application/api/controller/Promotion.php
@@ -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);
}
diff --git a/application/api/controller/Web.php b/application/api/controller/Web.php
new file mode 100644
index 0000000..56662a6
--- /dev/null
+++ b/application/api/controller/Web.php
@@ -0,0 +1,37 @@
+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);
+ }
+}
+?>
\ No newline at end of file
diff --git a/application/api/job/mail.php b/application/api/job/mail.php
index 94d18f2..39f96c2 100644
--- a/application/api/job/mail.php
+++ b/application/api/job/mail.php
@@ -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();
+ }
/**
* 发送邮件的逻辑
diff --git a/application/common.php b/application/common.php
index 1cbca50..30b75b7 100644
--- a/application/common.php
+++ b/application/common.php
@@ -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";
|