1
This commit is contained in:
@@ -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 获取文章详情(作者,编辑)
|
||||
|
||||
@@ -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()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user