From 29c6b4c627fb9cdb800a61038ff0766c3fb130fd Mon Sep 17 00:00:00 2001 From: wangjinlei <751475802@qq.com> Date: Tue, 23 Aug 2022 15:20:37 +0800 Subject: [PATCH] 1 --- .env | 73 +++++++++++++++++++++++--- application/api/controller/Article.php | 17 ++++++ application/api/controller/Email.php | 52 ++++++++++++++++++ application/api/controller/Journal.php | 34 ++++++++++++ application/api/job/mail.php | 23 +++----- application/common.php | 32 ++++++++--- 6 files changed, 200 insertions(+), 31 deletions(-) diff --git a/.env b/.env index 5d75257..7240bbf 100644 --- a/.env +++ b/.env @@ -40,23 +40,27 @@ pre = ' -

TMR +

+ TMR Publishing Group

Home Page + 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 | Scientist Community + style="color: #333;font-size: 15px;text-decoration: none;letter-spacing:-0.5px;text-shadow: 0 0 4px #fff">Scientist + Community | Database | Submission System + style="color: #333;font-size: 15px;text-decoration: none;letter-spacing:-0.5px;text-shadow: 0 0 4px #fff">Submission + System @@ -120,13 +124,14 @@ net = '

-

Copyright © TMR Publishing Group Limited.
- E-Mail: publisher@tmrjournals.com | https://www.tmrjournals.com
- Telephone: +64 02108293806

+

+ E-mail: publisher@tmrjournals.com | https://www.tmrjournals.com
+ Telephone: +64 02108293806 +

+ style="width: 90px;margin:10px 30px 6px 0"> @@ -135,6 +140,58 @@ net = '

+ + + + + + + + + + + + + +
+ + + + + + + +
+ + Privacy policy + + +

+ 2/77 Prince regent drive
+ Half moon bay, Auckland 2012
+ New Zealand
+

+
+
+ + + + + + + +
+

+ This email was sent to tmr@tmrjournals.com and is specific to the recipient. + If you have received this email in error please delete it and notify the sender immediately. +

+

+ Copyright © TMR Publishing Group Limited. +

+
+
diff --git a/application/api/controller/Article.php b/application/api/controller/Article.php index a9d6d0a..e69237a 100644 --- a/application/api/controller/Article.php +++ b/application/api/controller/Article.php @@ -215,6 +215,23 @@ class Article extends Controller { return json(['total' => $count, 'data' => $res]); } + + /** + * 获取文章的用户详情 + */ + public function getArticleUserDetail(){ + $data = $this->request->post(); + $rule = new Validate([ + 'article_id'=>'require' + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + $article_info = $this->article_obj->where('article_id',$data['article_id'])->find(); + $user_info = $this->user_obj->where('user_id',$article_info['user_id'])->find(); + $re['userDetail'] = $user_info; + return jsonSuccess($re); + } /** * @title 获取文章详情(作者,编辑) diff --git a/application/api/controller/Email.php b/application/api/controller/Email.php index f25ca2b..5f46687 100644 --- a/application/api/controller/Email.php +++ b/application/api/controller/Email.php @@ -136,5 +136,57 @@ class Email extends Controller{ return jsonSuccess($re); } + /** + * 发送模板邮件 + */ + public function pushEmailOnTemplate(){ + $data = $this->request->post(); + $rule = new Validate([ + 'email'=>'require', + 'content'=>'require', + 'article_id'=>'require' + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + $article_info = $this->article_obj->where('article_id',$data['article_id'])->find(); + $journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find(); + + + $maidata['email'] = $data['email']; + $maidata['title'] = $journal_info['title']; + $maidata['content'] = $data['content']; + $maidata['tmail'] = $journal_info['email']; + $maidata['tpassword'] = $journal_info['epassword']; + $maidata['article_id'] = $data['article_id']; + $maidata['attachmentFile'] = (isset($data['attachment'])&&$data['attachment']!='')?ROOT_PATH . 'public' . DS . $data['attachment']:''; + + Queue::push('app\api\job\mail@tgpu', $maidata, "tmail"); + + return jsonSuccess([]); + + } + + public function tttt(){ + $str = "home".DS."ds".DS."12312321.jpg"; + echo substr($str,strrpos($str,DS)+1); + } + + + /** + * 上传文章的文件 + */ + public function up_enclosure_file() { + $file = request()->file("enclosure"); + if ($file) { + $info = $file->move(ROOT_PATH . 'public' . DS . 'enclosure'); + if ($info) { + return json(['code' => 0, 'upurl' => str_replace("\\", "/", $info->getSaveName())]); + } else { + return json(['code' => 1, 'msg' => $file->getError()]); + } + } + } + } \ No newline at end of file diff --git a/application/api/controller/Journal.php b/application/api/controller/Journal.php index f013e12..0f5ee11 100644 --- a/application/api/controller/Journal.php +++ b/application/api/controller/Journal.php @@ -128,5 +128,39 @@ class Journal extends Controller { return jsonSuccess($re); } + /** + * 获取期刊详情 + */ + public function getJournalDetail(){ + $data = $this->request->post(); + $rule = new Validate([ + 'journal_id'=>'require' + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + $info = $this->journal_obj->where('journal_id',$data['journal_id'])->find(); + $re['journal'] = $info; + return jsonSuccess($re); + } + + /** + * 获取期刊详情通过文章id + */ + public function getJournalDetailByArticleId(){ + $data = $this->request->post(); + $rule = new Validate([ + 'article_id'=>'require' + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + $article_info = $this->article_obj->where('article_id',$data['article_id'])->find(); + $info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find(); + $re['journal'] = $info; + return jsonSuccess($re); + + } + } diff --git a/application/api/job/mail.php b/application/api/job/mail.php index f69f2fc..94d18f2 100644 --- a/application/api/job/mail.php +++ b/application/api/job/mail.php @@ -9,23 +9,14 @@ class mail { //put your code here public function fire(Job $job, $data) { - $res = $this->send($data); + $this->send($data); + $job->delete(); + } + + + public function tgpu(Job $job, $data){ + my_tg_pushmail($data); $job->delete(); -// if($res){ -// file_put_contents('/usr/local/email.txt', 'log_time:'.date('Y-m-d H:i:s').' success:to '.$data['email'].PHP_EOL, FILE_APPEND); -// $job->delete(); -// }else{ -// if($job->attempts()>3){ -// file_put_contents('/usr/local/email.txt', 'log_time:'.date('Y-m-d H:i:s').' error:to '.$data['email'].PHP_EOL, FILE_APPEND); - // 第1种处理方式:重新发布任务,该任务延迟10秒后再执行 - //$job->release(10); - // 第2种处理方式:原任务的基础上1分钟执行一次并增加尝试次数 - //$job->failed(); - // 第3种处理方式:删除任务 -// $job->delete(); -// } -// } - } /** diff --git a/application/common.php b/application/common.php index 2eccc7f..c1a3937 100644 --- a/application/common.php +++ b/application/common.php @@ -76,16 +76,16 @@ function sendEmail($email = '', $title = '', $from_name = '', $content = '', $me $mail->msgHTML($pre.$content.$net); //Replace the plain text body with one created manually $mail->AltBody = ''; - if (is_array($attachmentFile)) { - for ($i = 0; $i < count($attachmentFile); $i++) { - $mail->addAttachment($attachmentFile[$i], 'thanks.jpg' . $i); //这里可以是多维数组,然后循环附件的文件和名称 - } - } else { + // if (is_array($attachmentFile)) { + // for ($i = 0; $i < count($attachmentFile); $i++) { + // $mail->addAttachment($attachmentFile[$i], 'thanks' . $i.'.jpg'); //这里可以是多维数组,然后循环附件的文件和名称 + // } + // } else { if ($attachmentFile != '') { //Attach an image file - $mail->addAttachment($attachmentFile, 'thanks.jpg'); + $mail->addAttachment($attachmentFile, substr($attachmentFile,strrpos($attachmentFile,DS)+1)); } - } + // } //send the message, check for errors if (!$mail->send()) { $status = 0; @@ -261,6 +261,24 @@ function my_doiToFrag($data){ } +function my_tg_pushmail($data){ + $res = sendEmail($data['email'],$data['title'],$data['title'],$data['content'],$data['tmail'],$data['tpassword'],$data['attachmentFile']); + if(isset($res['status'])){ + $log_obj = Db::name('email_log'); + $insert['article_id'] = $data['article_id']; + $insert['email'] = $data['email']; + $insert['content'] = $data['content']; + $insert['is_success'] = $res['status']; + $insert['attachment'] = $data['attachmentFile']; + $insert['ctime'] = time(); + $log_obj->insert($insert); + $log_obj->close(); + } + + +} + + /** * 增加usermsg */