ProjectController.php
14.3 KB
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
<?php
namespace App\Http\Controllers\Aside\Project;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Manage\ManageLogic;
use App\Http\Logic\Aside\Project\OnlineCheckLogic;
use App\Http\Logic\Aside\Project\ProcessRecordsLogic;
use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Http\Requests\Aside\Project\ProcessRecordsRequest;
use App\Http\Requests\Aside\Project\ProjectRequest;
use App\Models\ASide\APublicModel;
use App\Models\Channel\Channel;
use App\Models\Com\City;
use App\Models\Devops\ServerConfig;
use App\Models\Domain\DomainInfo;
use App\Models\Inquiry\InquirySet;
use App\Models\Manage\BelongingGroup;
use App\Models\Manage\Manage;
use App\Models\Manage\ManageHr;
use App\Models\Project\DeployBuild;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Payment;
use App\Models\Project\Project;
use App\Models\RankData\RankData;
use App\Models\Task\Task;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
/**
* 项目管理
* Class ProjectController
* @package App\Http\Controllers\Aside\Project
* @author zbj
* @date 2023/4/25
*/
class ProjectController extends BaseController
{
/**
* @remark :项目列表
* @name :lists
* @author :lyh
* @method :post
* @time :2023/8/30 10:11
*/
public function lists(Project $project){
$map = [];
//搜索参数处理
$map = $this->searchParam($map,$this->map);
//类型
if(isset($this->map['type'])){
$map['type'] = $this->searchType($this->map['type']);
$map['extend_type'] = 0;//排除未续费项目
}
$filed = ['id', 'title', 'mysql_id' ,'channel','cooperate_date' ,'type', 'created_at'];
$lists = $project->formatQuery($map)->select($filed)->with('payment')->with('deploy_build')
->with('deploy_optimize')->with('online_check')->paginate($this->row, ['*'], 'page', $this->page);
if(!empty($lists)){
$lists = $lists->toArray();
foreach ($lists['list'] as $k=>$item){
$item = $this->handleParam($item);
$lists['list'][$k] = $item;
}
}
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :返回参数过滤
* @name :returnParamItem
* @author :lyh
* @method :post
* @time :2023/8/30 11:07
*/
public function handleParam(&$item){
$manageModel = new Manage();
if($item['mysql_id'] != 0 && $item['type'] != 0){
$data = APublicModel::getNumByProjectId($item['id']);
}
$item = [
'id' => $item['id'],
'title' => $item['title'],
'channel' => Channel::getChannelText($item['channel']['user_id'] ?? 0),
'key' => $item['deploy_build']['keyword_num'] ?? 0,
'day' => $item['deploy_build']['service_duration'] ?? 0,
'amount' => $item['payment']['amount'] ?? 0,
'build_leader' => $manageModel->getName($item['deploy_build']['leader_mid']), //组长
'build_manager' => $manageModel->getName($item['deploy_build']['manager_mid']), //项目经理
'build_designer' => $manageModel->getName($item['deploy_build']['designer_mid']), //设计师
'build_tech' => $manageModel->getName($item['deploy_build']['tech_mid']), //技术助理
'optimize_manager' => $manageModel->getName($item['deploy_optimize']['manager_mid']), //优化服务经理
'optimize_optimist' => $manageModel->getName($item['deploy_optimize']['optimist_mid']), //优化师
'optimize_assist' => $manageModel->getName($item['deploy_optimize']['assist_mid']), //优化助理
'optimize_tech' => $manageModel->getName($item['deploy_optimize']['tech_mid']), //售后技术
'type' => $item['type'],
'test_domain' => $item['deploy_build']['test_domain'] ?? 0,
'plan' =>Project::planMap()[$item['deploy_build']['plan']],
'domain' => $item['deploy_optimize']['domain'] ?? 0,
'created_at' => date('Y年m月d日', strtotime($item['created_at'])),
'product_num' => $data['product'] ?? 0,
'keyword_num' => $item['deploy_build']['keyword_num'] ?? 0,
'article_num' => ($data['blog'] ?? 0) + ($data['news'] ?? 0),
'task_finish_num' => Task::getNumByProjectId($item['id'], Task::STATUS_DOWN),
'task_pending_num' => Task::getNumByProjectId($item['id'], [Task::STATUS_DONGING, Task::STATUS_WAIT]),
'optimist_status'=>$item['online_check']['optimist_status'] ?? 0,
'qa_status'=>$item['online_check']['qa_status'] ?? 0,
'service_day'=>$item['deploy_build']['service_duration'] - $this->compliance_day($item['id']),
];
return $item;
}
/**
* @param $yesterday
* @name :(服务达标天数)compliance_day
* @author :lyh
* @method :post
* @time :2023/6/14 15:48
*/
public function compliance_day($project_id){
//服务达标天数
$rankDataModel = new RankData();
$rank_info = $rankDataModel->where(['project_id'=>$project_id,'lang'=>''])->select(['compliance_day'])->first();
if(empty($rank_info)){
$compliance_day = 0;
}else{
$compliance_day = $rank_info->compliance_day;
}
return $compliance_day;
}
/**
* @remark :type类型
* @name :searchType
* @author :lyh
* @method :post
* @time :2023/8/30 10:14
*/
public function searchType($type){
//初始项目
if($type == Project::TYPE_ZERO){
$type = Project::TYPE_ZERO;
}
//建站中
if($type == Project::TYPE_ONE){
$type = Project::TYPE_ONE;
}
//建站完成
if($type == Project::TYPE_TWO){
$type = ['in',[Project::TYPE_TWO,Project::TYPE_THREE]];
}
if($this->param['type'] == Project::TYPE_THREE){
$type = ['in',[Project::TYPE_FOUR,Project::TYPE_SIX]];
}
return $type;
}
/**
* @remark :搜索参数处理
* @name :searchParam
* @author :lyh
* @method :post
* @time :2023/8/30 10:30
*/
public function searchParam(&$map,$param){
//搜索技术组
if(!empty($param['dep_id'])){
$map['id'] = ['in', DeployBuild::where('dept_id', $param['dep_id'])->pluck('project_id')->toArray()];
}
//搜索技术人员
if(!empty($param['manage_id'])){
$map['id'] = ['in', DeployBuild::where('leader_mid', $param['manage_id'])
->orwhere('manager_mid', $param['manage_id'])->orwhere('designer_mid', $param['manage_id'])
->orwhere('tech_mid', $param['manage_id'])->pluck('project_id')->toArray()];
}
//按类型搜索
if(!empty($param['search']) && !empty($param['search_type'])){
if($this->param['search_type'] == 'domain'){
//搜索域名
$map['id'] = ['id', 'in', DeployOptimize::where('domain', 'like', "%{$this->param['search']}%")->pluck('project_id')->toArray()];
}else{
$map[$param['search_type']] = ['like', "%{$param['search']}%"];
}
}
return $map;
}
/**
* @remark :获取数据详情
* @name :info
* @author :lyh
* @method :post
* @time :2023/8/17 16:42
*/
public function info(Request $request, ProjectLogic $logic){
$request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$data = $logic->getProjectInfo($this->param['id']);
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2023/8/17 16:42
*/
public function save(ProjectRequest $request, ProjectLogic $logic)
{
$request->validated();
$logic->projectSave();
$this->response('success');
}
/**
* 询盘通知设置
* @param ProjectRequest $request
* @param ProjectLogic $logic
* @return \Illuminate\Http\JsonResponse
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @author zbj
* @date 2023/5/17
*/
public function inquiry_set(Request $request, ProjectLogic $logic){
$request->validate([
'project_id'=>'required'
],[
'project_id.required' => '项目ID不能为空'
]);
if($request->isMethod('get')){
$data = InquirySet::where('project_id', $request->project_id)->first();
if(!$data){
$data = ['emails' => '', 'phones' => ''];
}else{
$data = $data->toArray();
}
$this->response('success',Code::SUCCESS,$data);
}
$data = $logic->saveInquirySet($this->param);
$this->response('success',Code::SUCCESS,$data);
}
/**
* 数据源
* @param ProjectLogic $logic
* @return \Illuminate\Http\JsonResponse
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @author zbj
* @date 2023/6/20
*/
public function data_source(ProjectLogic $logic){
$data = $logic->dataSource();
$this->response('success',Code::SUCCESS,$data);
}
/**
* 省市数据源
* @param ProjectLogic $logic
* @return \Illuminate\Http\JsonResponse
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @author zbj
* @date 2023/6/27
*/
public function city_source(){
$data = City::source($this->param['id'] ?? 0);
$this->response('success',Code::SUCCESS,$data);
}
/**
* 渠道数据源
* @param ProjectLogic $logic
* @return \Illuminate\Http\JsonResponse
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @author zbj
* @date 2023/6/27
*/
public function channel_source(ProjectLogic $logic){
$data = $logic->channelSource($this->param);
$this->response('success',Code::SUCCESS,$data);
}
/**
* 进程记录
* @author zbj
* @date 2023/6/25
*/
public function get_process_records(Request $request, ProcessRecordsLogic $logic){
$request->validate([
'project_id'=>'required'
],[
'project_id.required' => '项目ID不能为空'
]);
$data = $logic->getInfo($this->param['project_id']);
$this->response('success',Code::SUCCESS,$data);
}
/**
* 保存进程记录
* @author zbj
* @date 2023/6/25
*/
public function save_process_records(ProcessRecordsRequest $request, ProcessRecordsLogic $logic){
$request->validated();
$logic->recordSave();
$this->response('success');
}
/**
* 获取合同票据
* @author zbj
* @date 2023/6/27
*/
public function get_contract_bill(Request $request){
$request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$payment = Payment::where('project_id', $this->param['id'])->select(['contract', 'bill'])->first();
$data = $payment->makeVisible(['contract', 'bill']);
$this->response('success',Code::SUCCESS,$data ? $data->toArray() : []);
}
/**
* 提交审核
* @author zbj
* @date 2023/6/29
*/
public function submit_check(Request $request, OnlineCheckLogic $logic){
$request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$logic->saveOnlineCheck();
$this->response('success');
}
/**
* @remark :上线审核
* @name :online_check
* @author :lyh
* @method :post
* @time :2023/8/30 19:01
*/
public function online_check(Request $request, OnlineCheckLogic $logic){
$request->validate([
'id'=>'required',
'type'=>'required|in:optimist,qa',
'status'=>'required|in:0,1'
],[
'id.required' => 'ID不能为空',
'type.required' => '请选择审核类型',
'type.in' => '审核类型值无效',
'status.required' => '请选择审核状态',
'status.in' => '审核状态值无效',
]);
$logic->onlineCheck($this->param);
$this->response('success');
}
/**
* @remark :获取组
* @name :getBelongingGroup
* @author :lyh
* @method :post
* @time :2023/8/4 16:27
*/
public function getBelongingGroup(){
$this->request->validate([
'type'=>'required',
],[
'type.required' => '请选择审核类型'
]);
$belongGroupModel = new BelongingGroup();
$lists = $belongGroupModel->list($this->map);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :根据用户组获取成员
* @name :getManager
* @author :lyh
* @method :post
* @time :2023/8/8 10:29
*/
public function getManagerList(){
$hrManagerModel = new ManageHr();
$this->map['status'] = $hrManagerModel::STATUS_ONE;
$lists = $hrManagerModel->list($this->map,'id',['id','manage_id','name','entry_position','is_leader']);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :获取项目服务器与数据库列表
* @name :getServiceConfig
* @author :lyh
* @method :post
* @time :2023/8/14 10:23
*/
public function getServiceConfig(){
$serviceConfigModel = new ServerConfig();
$list = $serviceConfigModel->list($this->param);
$this->response('success',Code::SUCCESS,$list);
}
/**
* @remark :获取域名列表
* @name :getDomain
* @author :lyh
* @method :post
* @time :2023/8/14 10:29
*/
public function getDomain(){
$domainModel = new DomainInfo();
$list = $domainModel->list(['status'=>0,'project_id'=>['or',$this->param['project_id']]]);
$this->response('success',Code::SUCCESS,$list);
}
}