Blame view

application/admin/controller/antis/customer/Need.php 8.83 KB
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
  <?php

  

  namespace app\admin\controller\antis\customer;

  

  use addons\antis\model\ReceivablesPlan;

  use app\admin\controller\antis\Base;

  use addons\antis\model\Staff;

  use think\Db;

  use think\Exception;

  use addons\antis\model\Event;

  use addons\antis\model\ExamineRecord;

  

  use addons\antis\model\Record;

  

  /**

   * 待办管理

   * 操作文档:https://doc.fastadmin.net/antis

   * 软件介绍:https://www.fastadmin.net/store/antis.html

   * 售后微信:qingdong_crm

   */

  class Need extends Base

  {

      protected $relationSearch = true;

  

      protected $model = null;

  

  

      public function _initialize()

      {

          parent::_initialize();

  

      }

      /**

       * 待办列表

       */

      public function index(){

          $where['create_staff_id'] = $this->_staff->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('relation_id');

          $customerlist1 = 0;

          if($customerlist){

              $whereExit['relation_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;

          if($customer <=0){

              $customer =0;

          }

          //待跟进合同

          $where2['relation_type'] = 3;

          $contractlist = Record::where($where)->where($where2)->column('relation_id');

          $contractlist1 = 0;

          if($contractlist){

              $whereExitC['relation_id'] = array('in',$contractlist);

              $whereExitC['next_time'] = array('gt',date('Y-m-d 23:59:59'));

              $contractlist1 = Record::where($whereExitC)->count();

          }

          $contract = count($contractlist)-$contractlist1;

          if($contract <=0){

              $contract =0;

          }

          //待跟进线索

          $where3['relation_type'] = 4;

          $leadlist = Record::where($where)->where($where3)->column('relation_id');

          $leadlist1 = 0;

          if($leadlist){

              $whereExitL['relation_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;

          if($lead <=0){

              $lead =0;

          }

          //费用审核

          $consume = ExamineRecord::where([

              'relation_type'  => ExamineRecord::CONSUME_TYPE,

              'status'         => 0,

              'check_staff_id' => $this->_staff->id

          ])->count();

          //待处理日程

          $eventOne = Event::where([

              'type'       => 1,

              'status'     => ['in', [0, 1]],

              'staff_id'   => $this->_staff->id,

          ])->count();

          //待审核合同

          $examine = ExamineRecord::where([

              'relation_type'  => ExamineRecord::CONTRACT_TYPE,

              'status'         => 0,

              'check_staff_id' => $this->_staff->id

          ])->count();

          //待审核回款

          $receivables = ExamineRecord::where([

              'relation_type'  => ExamineRecord::RECEIVABLES_TYPE,

              'status'         => 0,

              'check_staff_id' => $this->_staff->id,

          ])->count();

          //待审批办公

          $approval = ExamineRecord::where([

              'relation_type'  => ExamineRecord::APPROVAL_TYPE,

              'status'         => 0,

              'check_staff_id' => $this->_staff->id,

          ])->count();

          //超时任务

          $eventtask = Event::where([

              'type'       => 1,

              'status'     => ['in', [0, 1]],

              'start_time' => ['lt', date('Y-m-d', strtotime('+1 day'))],

              'staff_id'   => $this->_staff->id,

          ])->count();

          //业绩审核

          $achievement = ExamineRecord::where([

              'relation_type'  => ExamineRecord::ACHIEVEMENT_TYPE,

              'status'         => 0,

              'check_staff_id' => $this->_staff->id

          ])->count();

          $info = array(

              'customer'=>$customer,

              'contract'=>$contract,

              'lead'=>$lead,

              'consume'=>$consume,

              'eventOne'=>$eventOne,

              'examine'=>$examine,

              'receivables'=>$receivables,

              'approval'=>$approval,

              'eventtask'=>$eventtask,

              'achievement'=>$achievement,

          );

          $this->view->assign('row',$info);

          return $this->view->fetch();

      }

      /**

       * 获取通知数量

       */

      public function get_need_number(){

           $where['create_staff_id'] = $this->_staff->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('relation_id');

          $customerlist1 = 0;

          if($customerlist){

              $whereExit['relation_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;

          if($customer <=0){

              $customer =0;

          }

          //待跟进合同

          $where2['relation_type'] = 3;

          $contractlist = Record::where($where)->where($where2)->column('relation_id');

          $contractlist1 = 0;

          if($contractlist){

              $whereExitC['relation_id'] = array('in',$contractlist);

              $whereExitC['next_time'] = array('gt',date('Y-m-d 23:59:59'));

              $contractlist1 = Record::where($whereExitC)->count();

          }

          $contract = count($contractlist)-$contractlist1;

          if($contract <=0){

              $contract =0;

          }

          //待跟进线索

          $where3['relation_type'] = 4;

          $leadlist = Record::where($where)->where($where3)->column('relation_id');

          $leadlist1 = 0;

          if($leadlist){

              $whereExitL['relation_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;

          if($lead <=0){

              $lead =0;

          }

          //费用审核

          $consume = ExamineRecord::where([

              'relation_type'  => ExamineRecord::CONSUME_TYPE,

              'status'         => 0,

              'check_staff_id' => $this->_staff->id

          ])->count();

  

          //待处理日程

          $eventOne = Event::where([

              'type'       => 1,

              'status'     => ['in', [0, 1]],

              'staff_id'   => ['in',$this->_staff->id],

          ])->count();

          //待审核合同

          $examine = ExamineRecord::where([

              'relation_type'  => ExamineRecord::CONTRACT_TYPE,

              'status'         => 0,

              'check_staff_id' => $this->_staff->id

          ])->count();

          //待审核回款

          $receivables = ExamineRecord::where([

              'relation_type'  => ExamineRecord::RECEIVABLES_TYPE,

              'status'         => 0,

              'check_staff_id' => $this->_staff->id

          ])->count();

          //待审批办公

          $approval = ExamineRecord::where([

              'relation_type'  => ExamineRecord::APPROVAL_TYPE,

              'status'         => 0,

              'check_staff_id' =>  $this->_staff->id

          ])->count();

          //超时任务

          $eventtask = Event::where([

              'type'       => 1,

              'status'     => ['in', [0, 1]],

              'start_time' => ['lt', date('Y-m-d', strtotime('+1 day'))],

              'staff_id'   =>  $this->_staff->id

          ])->count();

          //业绩审核

          $achievement = ExamineRecord::where([

              'relation_type'  => ExamineRecord::ACHIEVEMENT_TYPE,

              'status'         => 0,

              'check_staff_id' => $this->_staff->id

          ])->count();

          $info = array(

              'customer'=>$customer,

              'contract'=>$contract,

              'lead'=>$lead,

              'consume'=>$consume,

              'eventOne'=>$eventOne,

              'examine'=>$examine,

              'receivables'=>$receivables,

              'approval'=>$approval,

              'eventtask'=>$eventtask,

              'achievement'=>$achievement,

          );

          $number=array_sum(array_values($info));

          $info['number']=$number;

          $this->success('请求成功','',$info);

      }

  }