ProjectController.php
7.4 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
<?php
namespace App\Http\Controllers\Aside\Project;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
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\City;
use App\Models\Inquiry\InquirySet;
use App\Models\Project\DeployBuild;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Payment;
use Illuminate\Http\Request;
/**
* 项目管理
* Class ProjectController
* @package App\Http\Controllers\Aside\Project
* @author zbj
* @date 2023/4/25
*/
class ProjectController extends BaseController
{
public function list(ProjectLogic $logic)
{
$map = [];
//搜索类型
if(!empty($this->param['type'])){
if($this->param['type'] == 3){//推广中
$map[] = ['type', '>=' ,$this->param['type']];
}else{
$map[] = ['type', $this->param['type']];
}
}
//搜索技术组
if(!empty($this->param['dep_id'])){
$map[] = ['id', 'in', DeployBuild::where('dept_id', $this->param['dep_id'])->pluck('project_id')->toArray()];
}
//搜索技术人员
if(!empty($this->param['manage_id'])){
$map[] = ['id', 'in', DeployBuild::where('leader_mid', $this->param['manage_id'])
->orwhere('manager_mid', $this->param['manage_id'])
->orwhere('designer_mid', $this->param['manage_id'])
->orwhere('tech_mid', $this->param['manage_id'])
->pluck('project_id')
->toArray()];
}
//按类型搜索
if(!empty($this->param['search']) && !empty($this->param['search_type'])){
if($this->param['search_type'] == 'domain'){
//搜索域名
$map[] = ['id', 'in', DeployOptimize::where('domain', 'like', "%{$this->param['search']}%")->pluck('project_id')->toArray()];
}else{
$map[] = [$this->param['search_type'], 'like', "%{$this->param['search']}%"];
}
}
$sort = ['id' => 'desc'];
$data = $logic->getList($map, $sort,['*'],$this->row);
return $this->success($data);
}
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);
}
public function save(ProjectRequest $request, ProjectLogic $logic)
{
$data = $logic->save($this->param);
return $this->success($data);
}
/**
* 询盘通知设置
* @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();
}
return $this->success($data);
}
$data = $logic->saveInquirySet($this->param);
return $this->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();
return $this->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);
return $this->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);
return $this->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']);
return $this->success($data);
}
/**
* 保存进程记录
* @author zbj
* @date 2023/6/25
*/
public function save_process_records(ProcessRecordsRequest $request, ProcessRecordsLogic $logic){
$this->param['operator_id'] = $this->manage['id'];
$data = $logic->save($this->param);
return $this->success($data);
}
/**
* 获取合同票据
* @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']);
return $this->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不能为空'
]);
$data = [
'project_id' => $this->param['id'],
'created_manage_id' => $this->manage['id'],
];
$logic->save($data);
return $this->success($data);
}
/**
* 上线审核
* @author zbj
* @date 2023/6/29
*/
public function online_check(Request $request, OnlineCheckLogic $logic){
$request->validate([
'id'=>'required',
'type'=>'required|in:optimist,qa',
'status'=>'required|in:1,2'
],[
'id.required' => 'ID不能为空',
'type.required' => '请选择审核类型',
'type.in' => '审核类型值无效',
'status.required' => '请选择审核状态',
'status.in' => '审核状态值无效',
]);
$this->param['manage_id'] = $this->manage['id'];
$logic->onlineCheck($this->param);
return $this->success();
}
}