OnlineCheckLogic.php
4.2 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
<?php
namespace App\Http\Logic\Aside\Project;
use App\Helper\Common;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Project\DeployOptimize;
use App\Models\Project\OnlineCheck;
use App\Models\Project\Project;
class OnlineCheckLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new OnlineCheck();
}
/**
* @remark :用户审核
* @name :onlineCheck
* @author :lyh
* @method :post
* @time :2023/9/22 11:01
*/
public function onlineCheck(){
$info = $this->model->read(['project_id'=>$this->param['id']]);
if($info === false){
$this->fail('项目未提交审核');
}
//获取项目优化人员
$optimizeModel = new DeployOptimize();
$optimizeInfo = $optimizeModel->read(['project_id'=>$this->param['id']]);
if(!empty($this->manager['special'])){
foreach ($this->manager['special'] as $value){
if($value['name'] == 'examine'){
$info['qa_mid'] = $this->manager['id'];
$optimizeInfo['optimist_mid'] = $this->manager['id'];
$optimizeInfo['assist_mid'] = $this->manager['id'];
}
}
}
//查看当前用户是否有权限审核
if($this->param['type'] == 'optimist'){
if(($optimizeInfo['optimist_mid'] != $this->manager['id']) && ($optimizeInfo['assist_mid'] != $this->manager['id'])){
$this->fail('你无权限提交审核');
}
}else{
//查看当前优化师是否审核
if($info['optimist_status'] != 1){
$this->fail('请先优化师审核');
}
if(($info['qa_mid'] != 0) && ($info['qa_mid'] != $this->manager['id'])){
$this->fail('你无权限提交审核');
}
$projectModel = new Project();
$projectInfo = $projectModel->read(['id'=>$this->param['id']]);
if(!empty($projectInfo['uptime'])){
$param['uptime'] = date('Y-m-d H:i:s');
}
if(isset($this->param['project_type']) && !empty($this->param['project_type'])){
$param['type'] = $this->param['project_type'];
}
if(isset($param)){
$projectModel->edit($param,['id'=>$this->param['id']]);
}
}
$data = [
$this->param['type'] . '_mid' => $this->manager['id'],
$this->param['type'] . '_check_time' => date('Y-m-d H:i:s'),
$this->param['type'] . '_status' => $this->param['status'],
'remark' => $param['remark'] ??'',
];
return $this->model->edit($data,['id'=>$info['id']]);
}
/**
* @remark :提交审核
* @name :submitCheck
* @author :lyh
* @method :post
* @time :2023/7/31 11:06
*/
public function saveOnlineCheck(){
$info = $this->model->read(['project_id'=>$this->param['id']]);
$projectModel = new Project();
if($info !== false){
$projectInfo = $projectModel->read(['id'=>$this->param['id']],['id','status']);
if($projectInfo['status'] != $projectModel::STATUS_ONE){
$projectModel->edit(['status'=>$projectModel::STATUS_ONE],['id'=>$projectInfo['id']]);
}
}else{
if(($this->param['optimist_mid'] == 0) || ($this->param['qa_mid'] == 0)){
$this->fail('请先选择优化师和品控,在提交审核');
}
//组装数据
$data = [
'project_id' => $this->param['id'],
'created_manage_id' => $this->manager['id'],
'optimist_mid' => $this->param['optimist_mid'],
'qa_mid' => $this->param['qa_mid'],
'created_at'=>date('Y-m-d H:i:s')
];
try {
$projectModel->edit(['status'=>$projectModel::STATUS_ONE],['id'=>$this->param['id']]);
$this->model->add($data);
}catch (\Exception $e){
$this->fail('提交失败,请联系开发人员');
}
}
return $this->success();
}
}