...
|
...
|
@@ -5,6 +5,7 @@ namespace Controller\fob_ai; |
|
|
|
|
|
|
|
|
use Controller\Base;
|
|
|
use Lib\Verify;
|
|
|
use Model\folderSql;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -20,6 +21,14 @@ class MailList extends Base { |
|
|
|
|
|
/**
|
|
|
* 邮件列表
|
|
|
* 接收参数
|
|
|
* page 分页
|
|
|
* limit 每页数量
|
|
|
* mail_id 指定邮件id
|
|
|
* attachment 是否附件
|
|
|
* emails 邮箱
|
|
|
* folder 文件夹
|
|
|
* from_not_in 不在这些发件箱的邮件
|
|
|
* @throws \Lib\Err
|
|
|
* @author:dc
|
|
|
* @time 2024/7/18 11:40
|
...
|
...
|
@@ -42,28 +51,33 @@ class MailList extends Base { |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 附件
|
|
|
$attachment = app()->request('attachment',0,'bool_Val');
|
|
|
|
|
|
$deleted = 0;
|
|
|
|
|
|
$where = ['email_id'=>$this->getEmails('id')];
|
|
|
|
|
|
// 目录
|
|
|
$folder = app()->request('folder','收件箱');
|
|
|
// 只允许查询这里文件夹
|
|
|
if(in_array($folder,['收件箱','发件箱','垃圾箱','星标邮件','预热收件箱','预热发件箱']))
|
|
|
if(!in_array($folder,['收件箱','发件箱','垃圾箱','星标邮件','预热收件箱','预热发件箱'])){
|
|
|
app()->e('folder_not_fount');
|
|
|
}
|
|
|
$extSql = ''; // 扩展sql
|
|
|
// $origin_folder = $folder;
|
|
|
if($folder=='星标邮件'){
|
|
|
$folder = '收件箱';
|
|
|
$where['flagged'] = 1; // 星标
|
|
|
}elseif ($folder=='预热收件箱'){
|
|
|
$folder = '收件箱';
|
|
|
$extSql = "s";
|
|
|
}elseif ($folder=='预热发件箱'){
|
|
|
$folder = '发件箱';
|
|
|
$extSql = "f";
|
|
|
}
|
|
|
// 查询 文件夹
|
|
|
$folderList = db()->all(folderSql::all($where['email_id']));
|
|
|
$folder_id = [];
|
|
|
// 文件夹id
|
|
|
if($folderList){
|
|
|
foreach ($folderList as $item){
|
|
|
if(
|
|
|
// 数组文件夹
|
|
|
(is_array($folder) && in_array($item['folder'],$folder))
|
|
|
|| $item['folder'] == $folder
|
|
|
){
|
|
|
if(folderAlias($item['folder']) == $folder){
|
|
|
$folder_id[] = $item['id'];
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -77,77 +91,12 @@ class MailList extends Base { |
|
|
if($ids) $where['id'] = $ids;
|
|
|
|
|
|
if(paramHas('attachment')){
|
|
|
$where['is_file'] = $attachment ? 1 : 0; //附件
|
|
|
// 附件
|
|
|
$where['is_file'] = app()->request('attachment',0,'bool_Val') ? 1 : 0; //附件
|
|
|
}
|
|
|
|
|
|
|
|
|
// 软删
|
|
|
$where['deleted'] = $deleted;
|
|
|
// 已读/未读
|
|
|
if(paramHas('seen')){
|
|
|
if(in_array($seen,[0,1])){
|
|
|
$where['seen'] = $seen;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$where['_'] = [];
|
|
|
// 搜索关键字
|
|
|
$keyword = app()->request('keyword','',['htmlspecialchars','addslashes']);
|
|
|
if($keyword){
|
|
|
$where['_'][] = '`subject` like "%'.$keyword.'%"';
|
|
|
}
|
|
|
|
|
|
// 那个发的
|
|
|
$address = app()->request('address');
|
|
|
if($address){
|
|
|
if(is_array($address)){
|
|
|
// 发贱人
|
|
|
if(Verify::sEmail($address['from']??'')){
|
|
|
$where['from'] = $address['from'];
|
|
|
}
|
|
|
// 收件人
|
|
|
if(Verify::sEmail($address['to']??'')){
|
|
|
$where['_'][] = '`to_name` like "%'.$address.'%"';
|
|
|
}
|
|
|
|
|
|
}else if(Verify::sEmail($address)){
|
|
|
// 收件人/发件人
|
|
|
$where['_'][] = '(`from` = "'.$address.'" or `to_name` like "%'.$address.'%")';
|
|
|
}
|
|
|
}
|
|
|
// from 搜索收件人
|
|
|
if(app()->requestHas('from')){
|
|
|
// 如果是发件箱
|
|
|
if($folder == '发件箱'){
|
|
|
$where['to'] = app()->request('from');
|
|
|
if(!$where['to']){
|
|
|
// 不让查询数据
|
|
|
$where['id'] = 0;
|
|
|
}
|
|
|
}else{
|
|
|
$where['from'] = app()->request('from');
|
|
|
if(!$where['from']){
|
|
|
// 不让查询数据
|
|
|
$where['id'] = 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
// 回复
|
|
|
if (paramHas('answered')){
|
|
|
$where['answered'] = app()->request('answered',0,'bool_Val')?1:0;
|
|
|
}
|
|
|
|
|
|
// 这个主要是来筛选 是否是自己发送的
|
|
|
$fromto = app()->request('formorto');
|
|
|
if($fromto=='from'){
|
|
|
$where['from'] = $this->getEmails('email');
|
|
|
}elseif ($fromto=='to'){
|
|
|
$where['from.notin'] = $this->getEmails('email');
|
|
|
}
|
|
|
$where['deleted'] = 0;
|
|
|
|
|
|
/**
|
|
|
* 不查询哪些发件人的邮件
|
...
|
...
|
@@ -175,18 +124,20 @@ class MailList extends Base { |
|
|
}
|
|
|
|
|
|
|
|
|
$filed = '`id`,`uid`,`subject`,`from`,`from_name`,`flagged`,`seen`,`udate`,`folder_id`,`is_file`,`description`,`email_id`,`to_name`';
|
|
|
|
|
|
if($extSql){
|
|
|
$sql = "select %s from `lists` join left `fob_hot_mail` on `lists`.`id` = `fob_hot_mail`.`lists_id` where `fob_hot_mail`.`folder` = '{$extSql}' and ".dbWhere($where);
|
|
|
}else{
|
|
|
$sql = "select %s from `lists` where ".dbWhere($where);
|
|
|
}
|
|
|
|
|
|
$lists = db()->all(
|
|
|
listsSql::lists(
|
|
|
dbWhere($where),
|
|
|
$page,
|
|
|
$limit
|
|
|
)
|
|
|
);
|
|
|
// 查询列表数据
|
|
|
$lists = db()->all(sprintf($sql,$filed)." order by `udate` desc limit {$limit} offset ".(($page-1)*$limit));
|
|
|
|
|
|
// map
|
|
|
$lists = array_map(function ($v){
|
|
|
$v['uuid'] = get_email_uuid($v['subject'],$v['udate'],$v['from'],$v['to'],$v['size']);
|
|
|
$v['uuid'] = md5($v['email_id'].'-'.$v['folder_id'].'-'.$v['uid']);
|
|
|
if(!empty($v['description'])){
|
|
|
$v['description'] = @html_entity_decode($v['description'], ENT_COMPAT, 'UTF-8');
|
|
|
}
|
...
|
...
|
@@ -205,9 +156,7 @@ class MailList extends Base { |
|
|
},$lists);
|
|
|
|
|
|
// 总数
|
|
|
$total = db()->count(
|
|
|
listsSql::listCount(dbWhere($where))
|
|
|
);
|
|
|
$total = db()->count(sprintf($sql,"count(*)"));
|
|
|
|
|
|
app()->_json(listsPage($lists,$total,$page,$limit));
|
|
|
|
...
|
...
|
|