ProjectController.php
4.5 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
<?php
namespace App\Http\Controllers\Aside\Project;
use App\Helper\Arr;
use App\Http\Controllers\Aside\BaseController;
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\InquirySet;
use App\Models\Project\Payment;
use App\Rules\Ids;
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'])){
$map[] = ['type', $this->param['type']];
}
if(!empty($this->param['search'])){
$map[] = ['title|company', $this->param['search']];
}
$sort = ['id' => 'desc'];
$data = $logic->getList($map, $sort);
return $this->success($data);
}
public function info(Request $request, ProjectLogic $logic){
$request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$data = $logic->getInfo($this->param['id']);
return $this->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 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() : []);
}
}