2db47680
hexiaodong
chore: 初始提交 php 遗...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
<?php
namespace addons\antis\controller;
use addons\antis\model\Event;
use addons\antis\model\ExamineRecord;
use addons\antis\model\Message as MessageModel;
use addons\antis\model\Notice;
use addons\antis\model\ReceivablesPlan;
use addons\antis\model\Record;
/**
* 通知接口
*/
class Message extends StaffApi
{
protected $noNeedLogin = [];
protected $noNeedRight = [];
/**
* 获取通知列表
*/
public function getList()
{
$limit = input("limit/d", 10);
$where = ['to_staff_id' => $this->auth->id ,'relation_type'=>['neq',MessageModel::EXAMINE_TYPE]];
$records = MessageModel::where($where)->with(['fromStaff', 'examine'])->order('status asc,id desc')->paginate($limit);
$this->success('请求成功', $records);
}
/**
* 获取审批列表
*/
public function getExamineRecord()
{
$limit = input("limit/d", 10);
//合同审批,回款审批、业绩目标审批、办公审批 费用
$relation_type = input('type');
$status = input('status',0);
if($status == 1){
$status = array('in','2,3');
}
$ids = ExamineRecord::where(['relation_type' => $relation_type,
'status' => $status,
'check_staff_id' => $this->auth->id])->column('id');
$where = ['to_staff_id' => $this->auth->id, 'relation_id' => ['in', $ids], 'relation_type' => MessageModel::EXAMINE_TYPE];
$records = MessageModel::where($where)->with(['fromStaff', 'examine'])->order('status asc,id desc')->paginate($limit);
$this->success('请求成功', $records);
}
/**
* 获取审批通知详情
*/
public function getExamineInfo()
{
$data = [
ExamineRecord::CONTRACT_TYPE => ['count' => 0, 'msg' => '暂无消息'],
ExamineRecord::CONSUME_TYPE => ['count' => 0, 'msg' => '暂无消息'],
ExamineRecord::RECEIVABLES_TYPE => ['count' => 0, 'msg' => '暂无消息'],
ExamineRecord::APPROVAL_TYPE => ['count' => 0, 'msg' => '暂无消息'],
ExamineRecord::ACHIEVEMENT_TYPE => ['count' => 0, 'msg' => '暂无消息'],
ExamineRecord::CARD_TYPE => ['count' => 0, 'msg' => '暂无消息'],
ExamineRecord::LEAVE_TYPE => ['count' => 0, 'msg' => '暂无消息'],
];
foreach ($data as $type=>$v) {
$ids = ExamineRecord::where(['status' => 0, 'check_staff_id' => $this->auth->id,
'relation_type' => $type
])->column('id');
$count = MessageModel::where(['to_staff_id' => $this->auth->id,'relation_id' => ['in', $ids],
'relation_type' => MessageModel::EXAMINE_TYPE])
->count();
if ($count) {
$msg = MessageModel::where(['to_staff_id' => $this->auth->id, 'relation_id' => ['in', $ids],
'relation_type' => MessageModel::EXAMINE_TYPE])
->order('id desc')
->value('content');
$data[$type] = ['count' => $count, 'msg' => $msg];
}
}
$this->success('请求成功', $data);
}
/**
* 获取通知详情
*/
public function getInfo()
{
$leadsCount = MessageModel::where(['to_staff_id' => $this->auth->id,
'relation_type' => ['neq', MessageModel::EXAMINE_TYPE], 'status' => 0])->count();
if ($leadsCount > 0) {//其他提醒消息
$leadsDetail = MessageModel::where([
'relation_type' => ['neq', MessageModel::EXAMINE_TYPE],
'to_staff_id' => $this->auth->id,
'status' => 0
])->order('id desc')->find();
}
$noticeWhere['read_staff_ids'] = ['not like', "%,{$this->auth->id},%"];
$noticeCount = Notice::where($noticeWhere)->count();
if ($noticeCount > 0) {
$noticeDetail = Notice::where(['read_staff_ids' => ['not like', "%,{$this->auth->id},%"]])->order('id desc')->find();
}
$eventOne = Event::where([
'type' => 1,
'status' => ['in', [0, 1]],
'start_time' => ['lt', date('Y-m-d', strtotime('+1 day'))],
'staff_id|owner_staff_id' => $this->auth->id
])->count();
//合同审批
$contract = ExamineRecord::where([
'relation_type' => ExamineRecord::CONTRACT_TYPE,
'status' => 0,
'check_staff_id' => $this->auth->id
])->count();
//回款审批
$receivables = ExamineRecord::where([
'relation_type' => ExamineRecord::RECEIVABLES_TYPE,
'status' => 0,
'check_staff_id' => $this->auth->id
])->count();
//费用审批
$consume = ExamineRecord::where([
'relation_type' => ExamineRecord::CONSUME_TYPE,
'status' => 0,
'check_staff_id' => $this->auth->id
])->count();
//业绩目标审批
$achievement = ExamineRecord::where([
'relation_type' => ExamineRecord::ACHIEVEMENT_TYPE,
'status' => 0,
'check_staff_id' => $this->auth->id
])->count();
//办公审批
$approval = ExamineRecord::where([
'relation_type' => ExamineRecord::APPROVAL_TYPE,
'status' => 0,
'check_staff_id' => $this->auth->id
])->count();
//补卡审批
$card = ExamineRecord::where([
'relation_type' => ExamineRecord::CARD_TYPE,
'status' => 0,
'check_staff_id' => $this->auth->id
])->count();
//请假审批
$leave = ExamineRecord::where([
'relation_type' => ExamineRecord::LEAVE_TYPE,
'status' => 0,
'check_staff_id' => $this->auth->id
])->count();
$receivablesPlan = ReceivablesPlan::where([
'remind_date' => ['elt', date('Y-m-d')],
'status' => 0,
'owner_staff_id' => $this->auth->id
])->count();
$eventsCount = Event::where([
'start_time' => ['lt', date('Y-m-d', strtotime('+1 day'))],
'end_time' => ['lt', date('Y-m-d', strtotime('+1 day'))],
'status' => ['in', [0, 1]],
'staff_id' => $this->auth->id,
])->count();
$where['create_staff_id'] = $this->auth->id;
$where['next_time'] = array(array('egt',date('Y-m-d 00:00:00')),array('lt',date('Y-m-d 23:59:59')));
$where['follow_type'] = ['neq', '其它'];
$where['status'] = 0;
// 待跟进客户
$where1['relation_type'] = 1;
$customerlist = Record::where($where)->where($where1)->column('id');
$customerlist1 = 0;
if($customerlist){
$whereExit['id'] = array('in',$customerlist);
$whereExit['next_time'] = array('gt',date('Y-m-d 23:59:59'));
$customerlist1 = Record::where($whereExit)->count();
}
$customer = count($customerlist) - $customerlist1;
//待跟进合同
$where2['relation_type'] = 3;
$contractlist = Record::where($where)->where($where2)->column('id');
$contractlist1 = 0;
if($contractlist){
$whereExitC['id'] = array('in',$contractlist);
$whereExitC['next_time'] = array('gt',date('Y-m-d 23:59:59'));
$contractlist1 = Record::where($whereExitC)->count();
}
$contracts = count($contractlist)-$contractlist1;
//待跟进线索
$where3['relation_type'] = 4;
$leadlist = Record::where($where)->where($where3)->column('id');
$leadlist1 = 0;
if($leadlist){
$whereExitL['id'] = array('in',$leadlist);
$whereExitL['next_time'] = array('gt',date('Y-m-d 23:59:59'));
$leadlist1 = Record::where($whereExitL)->count();
}
$lead = count($leadlist)-$leadlist1;
//待跟进联系人
$where4['relation_type'] = 2;
$contactslist = Record::where($where)->where($where4)->column('id');
$contactslist1 = 0;
if($contactslist1){
$whereExitCs['id'] = array('in',$contactslist);
$whereExitCs['next_time'] = array('gt',date('Y-m-d 23:59:59'));
$contactslist1 = Record::where($whereExitCs)->count();
}
$contacts = count($contactslist)-$contactslist1;
//待跟进商机
$where5['relation_type'] = 5;
$businesslist = Record::where($where)->where($where5)->column('id');
$businesslist1 = 0;
if($businesslist1){
$whereExitB['id'] = array('in',$businesslist);
$whereExitB['next_time'] = array('gt',date('Y-m-d 23:59:59'));
$businesslist1 = Record::where($whereExitB)->count();
}
$business = count($businesslist)-$businesslist1;
//提醒消息
$data = [
'leads' => ['count' => $leadsCount, 'msg' => $leadsDetail['content'] ?? '暂无消息'],//提醒消息
'examine' => ['count' => $contract + $receivables+$consume+$achievement+$approval+$card+$leave,
'msg' => '审批消息提醒'],//提醒消息
'notice' => ['count' => $noticeCount, 'msg' => $noticeDetail['title'] ?? '暂无消息'],//系统公告
'agent' => [
'count' => $eventOne + $receivablesPlan+ $customer + $contracts + $lead + $contacts + $business,
'msg' => '您有新的待办事项需要处理!'
],//待办事项
'task' => [
'count' => $eventsCount,
'msg' => '即将超时的任务提醒!'
],//超时任务
'total' => $leadsCount + $noticeCount + $eventOne + $contract + $receivables + $receivablesPlan + $eventsCount+ $customer + $contracts + $lead + $contacts + $business+$consume+$achievement+$approval+$card+$leave,
'userinfo' => $this->auth->getUserinfo()
];
$this->success('请求成功', $data);
}
}
|