OnlineCheckLogic.php
2.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
<?php
namespace App\Http\Logic\Aside\Project;
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();
}
public function onlineCheck($param){
$info = $this->model->where('project_id', $param['id'])->first();
if(!$info){
$this->fail('项目未提交审核');
}
//查看当前用户是否有权限审核
if($param['type'] == 'optimist'){
if($info['optimist_mid'] != $this->manager['id']){
$this->fail('你无权限提交审核');
}
}else{
if($info['qa_mid'] != $this->manager['id']){
$this->fail('你无权限提交审核');
}
}
$data = [
'project_id' => $param['id'],
$param['type'] . '_mid' => $param['manage_id'],
$param['type'] . '_check_time' => date('Y-m-d H:i:s'),
$param['type'] . '_status' => $param['status'],
'remark' => $param['remark'] ??'',
];
$data['id'] = $info['id'];
return $this->save($data);
}
/**
* @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']]);
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 = new Project();
$projectModel->edit(['status'=>$projectModel::STATUS_ONE],['id'=>$this->param['id']]);
}
return $this->success();
}
}