|
@@ -5,6 +5,7 @@ namespace Controller\fob_ai; |
|
@@ -5,6 +5,7 @@ namespace Controller\fob_ai; |
5
|
|
5
|
|
6
|
|
6
|
|
7
|
use Controller\Base;
|
7
|
use Controller\Base;
|
|
|
8
|
+use Lib\Verify;
|
8
|
use Model\folderSql;
|
9
|
use Model\folderSql;
|
9
|
|
10
|
|
10
|
/**
|
11
|
/**
|
|
@@ -20,6 +21,14 @@ class MailList extends Base { |
|
@@ -20,6 +21,14 @@ class MailList extends Base { |
20
|
|
21
|
|
21
|
/**
|
22
|
/**
|
22
|
* 邮件列表
|
23
|
* 邮件列表
|
|
|
24
|
+ * 接收参数
|
|
|
25
|
+ * page 分页
|
|
|
26
|
+ * limit 每页数量
|
|
|
27
|
+ * mail_id 指定邮件id
|
|
|
28
|
+ * attachment 是否附件
|
|
|
29
|
+ * emails 邮箱
|
|
|
30
|
+ * folder 文件夹
|
|
|
31
|
+ * from_not_in 不在这些发件箱的邮件
|
23
|
* @throws \Lib\Err
|
32
|
* @throws \Lib\Err
|
24
|
* @author:dc
|
33
|
* @author:dc
|
25
|
* @time 2024/7/18 11:40
|
34
|
* @time 2024/7/18 11:40
|
|
@@ -42,28 +51,33 @@ class MailList extends Base { |
|
@@ -42,28 +51,33 @@ class MailList extends Base { |
42
|
}
|
51
|
}
|
43
|
}
|
52
|
}
|
44
|
|
53
|
|
45
|
- // 附件
|
|
|
46
|
- $attachment = app()->request('attachment',0,'bool_Val');
|
|
|
47
|
-
|
|
|
48
|
- $deleted = 0;
|
|
|
49
|
-
|
|
|
50
|
$where = ['email_id'=>$this->getEmails('id')];
|
54
|
$where = ['email_id'=>$this->getEmails('id')];
|
51
|
|
55
|
|
52
|
// 目录
|
56
|
// 目录
|
53
|
$folder = app()->request('folder','收件箱');
|
57
|
$folder = app()->request('folder','收件箱');
|
54
|
// 只允许查询这里文件夹
|
58
|
// 只允许查询这里文件夹
|
55
|
- if(in_array($folder,['收件箱','发件箱','垃圾箱','星标邮件','预热收件箱','预热发件箱']))
|
59
|
+ if(!in_array($folder,['收件箱','发件箱','垃圾箱','星标邮件','预热收件箱','预热发件箱'])){
|
|
|
60
|
+ app()->e('folder_not_fount');
|
|
|
61
|
+ }
|
|
|
62
|
+ $extSql = ''; // 扩展sql
|
|
|
63
|
+// $origin_folder = $folder;
|
|
|
64
|
+ if($folder=='星标邮件'){
|
|
|
65
|
+ $folder = '收件箱';
|
|
|
66
|
+ $where['flagged'] = 1; // 星标
|
|
|
67
|
+ }elseif ($folder=='预热收件箱'){
|
|
|
68
|
+ $folder = '收件箱';
|
|
|
69
|
+ $extSql = "s";
|
|
|
70
|
+ }elseif ($folder=='预热发件箱'){
|
|
|
71
|
+ $folder = '发件箱';
|
|
|
72
|
+ $extSql = "f";
|
|
|
73
|
+ }
|
56
|
// 查询 文件夹
|
74
|
// 查询 文件夹
|
57
|
$folderList = db()->all(folderSql::all($where['email_id']));
|
75
|
$folderList = db()->all(folderSql::all($where['email_id']));
|
58
|
$folder_id = [];
|
76
|
$folder_id = [];
|
59
|
// 文件夹id
|
77
|
// 文件夹id
|
60
|
if($folderList){
|
78
|
if($folderList){
|
61
|
foreach ($folderList as $item){
|
79
|
foreach ($folderList as $item){
|
62
|
- if(
|
|
|
63
|
- // 数组文件夹
|
|
|
64
|
- (is_array($folder) && in_array($item['folder'],$folder))
|
|
|
65
|
- || $item['folder'] == $folder
|
|
|
66
|
- ){
|
80
|
+ if(folderAlias($item['folder']) == $folder){
|
67
|
$folder_id[] = $item['id'];
|
81
|
$folder_id[] = $item['id'];
|
68
|
}
|
82
|
}
|
69
|
}
|
83
|
}
|
|
@@ -77,77 +91,12 @@ class MailList extends Base { |
|
@@ -77,77 +91,12 @@ class MailList extends Base { |
77
|
if($ids) $where['id'] = $ids;
|
91
|
if($ids) $where['id'] = $ids;
|
78
|
|
92
|
|
79
|
if(paramHas('attachment')){
|
93
|
if(paramHas('attachment')){
|
80
|
- $where['is_file'] = $attachment ? 1 : 0; //附件
|
94
|
+ // 附件
|
|
|
95
|
+ $where['is_file'] = app()->request('attachment',0,'bool_Val') ? 1 : 0; //附件
|
81
|
}
|
96
|
}
|
82
|
|
97
|
|
83
|
-
|
|
|
84
|
// 软删
|
98
|
// 软删
|
85
|
- $where['deleted'] = $deleted;
|
|
|
86
|
- // 已读/未读
|
|
|
87
|
- if(paramHas('seen')){
|
|
|
88
|
- if(in_array($seen,[0,1])){
|
|
|
89
|
- $where['seen'] = $seen;
|
|
|
90
|
- }
|
|
|
91
|
- }
|
|
|
92
|
-
|
|
|
93
|
- $where['_'] = [];
|
|
|
94
|
- // 搜索关键字
|
|
|
95
|
- $keyword = app()->request('keyword','',['htmlspecialchars','addslashes']);
|
|
|
96
|
- if($keyword){
|
|
|
97
|
- $where['_'][] = '`subject` like "%'.$keyword.'%"';
|
|
|
98
|
- }
|
|
|
99
|
-
|
|
|
100
|
- // 那个发的
|
|
|
101
|
- $address = app()->request('address');
|
|
|
102
|
- if($address){
|
|
|
103
|
- if(is_array($address)){
|
|
|
104
|
- // 发贱人
|
|
|
105
|
- if(Verify::sEmail($address['from']??'')){
|
|
|
106
|
- $where['from'] = $address['from'];
|
|
|
107
|
- }
|
|
|
108
|
- // 收件人
|
|
|
109
|
- if(Verify::sEmail($address['to']??'')){
|
|
|
110
|
- $where['_'][] = '`to_name` like "%'.$address.'%"';
|
|
|
111
|
- }
|
|
|
112
|
-
|
|
|
113
|
- }else if(Verify::sEmail($address)){
|
|
|
114
|
- // 收件人/发件人
|
|
|
115
|
- $where['_'][] = '(`from` = "'.$address.'" or `to_name` like "%'.$address.'%")';
|
|
|
116
|
- }
|
|
|
117
|
- }
|
|
|
118
|
- // from 搜索收件人
|
|
|
119
|
- if(app()->requestHas('from')){
|
|
|
120
|
- // 如果是发件箱
|
|
|
121
|
- if($folder == '发件箱'){
|
|
|
122
|
- $where['to'] = app()->request('from');
|
|
|
123
|
- if(!$where['to']){
|
|
|
124
|
- // 不让查询数据
|
|
|
125
|
- $where['id'] = 0;
|
|
|
126
|
- }
|
|
|
127
|
- }else{
|
|
|
128
|
- $where['from'] = app()->request('from');
|
|
|
129
|
- if(!$where['from']){
|
|
|
130
|
- // 不让查询数据
|
|
|
131
|
- $where['id'] = 0;
|
|
|
132
|
- }
|
|
|
133
|
- }
|
|
|
134
|
-
|
|
|
135
|
-
|
|
|
136
|
- }
|
|
|
137
|
-
|
|
|
138
|
-
|
|
|
139
|
- // 回复
|
|
|
140
|
- if (paramHas('answered')){
|
|
|
141
|
- $where['answered'] = app()->request('answered',0,'bool_Val')?1:0;
|
|
|
142
|
- }
|
|
|
143
|
-
|
|
|
144
|
- // 这个主要是来筛选 是否是自己发送的
|
|
|
145
|
- $fromto = app()->request('formorto');
|
|
|
146
|
- if($fromto=='from'){
|
|
|
147
|
- $where['from'] = $this->getEmails('email');
|
|
|
148
|
- }elseif ($fromto=='to'){
|
|
|
149
|
- $where['from.notin'] = $this->getEmails('email');
|
|
|
150
|
- }
|
99
|
+ $where['deleted'] = 0;
|
151
|
|
100
|
|
152
|
/**
|
101
|
/**
|
153
|
* 不查询哪些发件人的邮件
|
102
|
* 不查询哪些发件人的邮件
|
|
@@ -175,18 +124,20 @@ class MailList extends Base { |
|
@@ -175,18 +124,20 @@ class MailList extends Base { |
175
|
}
|
124
|
}
|
176
|
|
125
|
|
177
|
|
126
|
|
|
|
127
|
+ $filed = '`id`,`uid`,`subject`,`from`,`from_name`,`flagged`,`seen`,`udate`,`folder_id`,`is_file`,`description`,`email_id`,`to_name`';
|
|
|
128
|
+
|
|
|
129
|
+ if($extSql){
|
|
|
130
|
+ $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);
|
|
|
131
|
+ }else{
|
|
|
132
|
+ $sql = "select %s from `lists` where ".dbWhere($where);
|
|
|
133
|
+ }
|
178
|
|
134
|
|
179
|
- $lists = db()->all(
|
|
|
180
|
- listsSql::lists(
|
|
|
181
|
- dbWhere($where),
|
|
|
182
|
- $page,
|
|
|
183
|
- $limit
|
|
|
184
|
- )
|
|
|
185
|
- );
|
135
|
+ // 查询列表数据
|
|
|
136
|
+ $lists = db()->all(sprintf($sql,$filed)." order by `udate` desc limit {$limit} offset ".(($page-1)*$limit));
|
186
|
|
137
|
|
187
|
// map
|
138
|
// map
|
188
|
$lists = array_map(function ($v){
|
139
|
$lists = array_map(function ($v){
|
189
|
- $v['uuid'] = get_email_uuid($v['subject'],$v['udate'],$v['from'],$v['to'],$v['size']);
|
140
|
+ $v['uuid'] = md5($v['email_id'].'-'.$v['folder_id'].'-'.$v['uid']);
|
190
|
if(!empty($v['description'])){
|
141
|
if(!empty($v['description'])){
|
191
|
$v['description'] = @html_entity_decode($v['description'], ENT_COMPAT, 'UTF-8');
|
142
|
$v['description'] = @html_entity_decode($v['description'], ENT_COMPAT, 'UTF-8');
|
192
|
}
|
143
|
}
|
|
@@ -205,9 +156,7 @@ class MailList extends Base { |
|
@@ -205,9 +156,7 @@ class MailList extends Base { |
205
|
},$lists);
|
156
|
},$lists);
|
206
|
|
157
|
|
207
|
// 总数
|
158
|
// 总数
|
208
|
- $total = db()->count(
|
|
|
209
|
- listsSql::listCount(dbWhere($where))
|
|
|
210
|
- );
|
159
|
+ $total = db()->count(sprintf($sql,"count(*)"));
|
211
|
|
160
|
|
212
|
app()->_json(listsPage($lists,$total,$page,$limit));
|
161
|
app()->_json(listsPage($lists,$total,$page,$limit));
|
213
|
|
162
|
|