OnlineCheckLogic.php
2.9 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
<?php
namespace App\Http\Logic\Aside\Project;
use App\Helper\Common;
use App\Http\Logic\Aside\BaseLogic;
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('项目未提交审核');
}
//查看当前用户是否有权限审核
if($this->param['type'] == 'optimist'){
if($info['optimist_mid'] != $this->manager['id']){
$this->fail('你无权限提交审核');
}
}else{
//查看当前优化师是否审核
if($info['optimist_status'] != 1){
$this->fail('请先优化师审核');
}
if($info['qa_mid'] != $this->manager['id']){
$this->fail('你无权限提交审核');
}
if(isset($this->param['project_type']) && !empty($this->param['project_type'])){
$projectModel = new Project();
$projectModel->edit(['type'=>$this->param['project_type']],['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){
$this->fail('已提交,请勿重复提交');
}else{
//组装数据
$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')
];
$rs = $this->model->add($data);
if($rs === false){
$this->fail('error');
}
//提交审核修改状态为审核中
$projectModel->edit(['status'=>$projectModel::STATUS_ONE],['id'=>$this->param['id']]);
}
return $this->success();
}
}