1
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace app\api\job;
|
namespace app\api\job;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
use think\Log;
|
use think\Log;
|
||||||
use think\queue\Job;
|
use think\queue\Job;
|
||||||
@@ -13,37 +14,71 @@ class domail {
|
|||||||
// $job->delete();
|
// $job->delete();
|
||||||
|
|
||||||
// 发送邮件
|
// 发送邮件
|
||||||
$isJobDone = $this->doTask($data);
|
try{
|
||||||
// 删除
|
$this->send($data);
|
||||||
$job->delete();
|
$job->delete();
|
||||||
|
// $isJobDone = $this->doTask($data);
|
||||||
|
}catch(Exception $e){
|
||||||
|
$this->addErrMsg($data);
|
||||||
|
$job->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
// $job->delete();
|
||||||
//入库
|
//入库
|
||||||
$this->insertData($data,$isJobDone);
|
// $this->insertData($data,$isJobDone);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 发送邮件
|
||||||
|
// * @param $data
|
||||||
|
// * @return array
|
||||||
|
// */
|
||||||
|
// public function doTask($data){
|
||||||
|
// if(isset($data['attachment_url']) && !empty($data['attachment_url']) ){
|
||||||
|
// $res = sendEmail($data['email'],$data['title'],$data['from_name'],$data['content'],$data['sendEmail'],$data['sendPassword'],$data['attachment_url']);
|
||||||
|
// }else{
|
||||||
|
// $res = sendEmail($data['email'],$data['title'],$data['from_name'],$data['content'],$data['sendEmail'],$data['sendPassword']);
|
||||||
|
// }
|
||||||
|
// return $res;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * email记录入库
|
||||||
|
// * @param $data
|
||||||
|
// * @param $isJobDone
|
||||||
|
// */
|
||||||
|
// public function insertData($data,$isJobDone)
|
||||||
|
// {
|
||||||
|
// $insert = [
|
||||||
|
// 'title' => $data['title'],
|
||||||
|
// 'content' => $data['content'],
|
||||||
|
// 'recive_id' => $data['user_id'],
|
||||||
|
// 'recive_email' => $data['email'],
|
||||||
|
// 'journal_id' => $data['journal_id'],
|
||||||
|
// 'journal_email' => $data['sendEmail'],
|
||||||
|
// 'journal_password' => $data['sendPassword'],
|
||||||
|
// 'create_time' => time()
|
||||||
|
// ];
|
||||||
|
// if (isset($data['attachment_url']) && !empty($data['attachment_url'])) {
|
||||||
|
// $insert['is_attachment'] = 1;
|
||||||
|
// $insert['attachment_url'] = $data['attachment_url'];
|
||||||
|
// }
|
||||||
|
// if($isJobDone['status']==0){
|
||||||
|
// $insert['is_success'] = 0;
|
||||||
|
// $insert['fail_reason'] = $isJobDone['data'];
|
||||||
|
// }
|
||||||
|
// Db::name('email')->insert($insert);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送邮件
|
* 添加邮件错误记录
|
||||||
* @param $data
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function doTask($data){
|
private function addErrMsg($data){
|
||||||
if(isset($data['attachment_url']) && !empty($data['attachment_url']) ){
|
|
||||||
$res = sendEmail($data['email'],$data['title'],$data['from_name'],$data['content'],$data['sendEmail'],$data['sendPassword'],$data['attachment_url']);
|
|
||||||
}else{
|
|
||||||
$res = sendEmail($data['email'],$data['title'],$data['from_name'],$data['content'],$data['sendEmail'],$data['sendPassword']);
|
|
||||||
}
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* email记录入库
|
|
||||||
* @param $data
|
|
||||||
* @param $isJobDone
|
|
||||||
*/
|
|
||||||
public function insertData($data,$isJobDone)
|
|
||||||
{
|
|
||||||
$insert = [
|
$insert = [
|
||||||
'title' => $data['title'],
|
'title' => $data['title'],
|
||||||
'content' => $data['content'],
|
'content' => $data['content'],
|
||||||
@@ -58,15 +93,11 @@ class domail {
|
|||||||
$insert['is_attachment'] = 1;
|
$insert['is_attachment'] = 1;
|
||||||
$insert['attachment_url'] = $data['attachment_url'];
|
$insert['attachment_url'] = $data['attachment_url'];
|
||||||
}
|
}
|
||||||
if($isJobDone['status']==0){
|
|
||||||
$insert['is_success'] = 0;
|
$insert['is_success'] = 0;
|
||||||
$insert['fail_reason'] = $isJobDone['data'];
|
$insert['fail_reason'] = "system error at push email queue!";
|
||||||
}
|
|
||||||
Db::name('email')->insert($insert);
|
Db::name('email')->insert($insert);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送邮件的逻辑
|
* 发送邮件的逻辑
|
||||||
* @param type $data
|
* @param type $data
|
||||||
|
|||||||
Reference in New Issue
Block a user