InquiryInfoController.php
6.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
<?php
namespace App\Http\Controllers\Aside\Projects;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Projects\InquiryInfoLogic;
use App\Models\Projects\InquiryUser;
use Carbon\Carbon;
use PhpOffice\PhpSpreadsheet\IOFactory;
/**
* @remark :询盘中心
* @class :InquiryInfoController.php
* @author :lyh
* @time :2023/7/11 14:33
*/
class InquiryInfoController extends BaseController
{
/**
* @remark :获取询盘中心列表
* @name :lists
* @author :lyh
* @method :post
* @time :2023/7/11 15:23
*/
public function lists(InquiryInfoLogic $inquiryInfoLogic){
if(isset($this->param['url'])){
$this->map['url'] = ['like',','.$this->map['url'].','];
}
if(isset($this->param['email'])){
$this->map['email'] = ['like',','.$this->map['email'].','];
}
if(isset($this->param['title'])){
$this->map['title'] = ['like',','.$this->map['title'].','];
}
$lists = $inquiryInfoLogic->getInquiryLists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :参数验证
* @name :validationParam
* @author :lyh
* @method :post
* @time :2023/7/11 15:34
*/
public function validationParam(){
$this->request->validate([
'name'=>'required',//名称
'email'=>'required',//邮箱
'phone'=>'required',//电话号码
'ip'=>'required',//ip
'ip_area'=>'required',//ip地址
'forward_url'=>'required',//转发网址
'message'=>'required',//发送内容
'delay'=>'required',//延迟发送时间
'type'=>'required',//询盘1类型
],[
'name.required' => '名称不能为空',
'email.required' => '邮箱不能为空',
'phone.required' => '电话号码不能为空',
'ip.required' => 'ip不能为空',
'ip_area.required' => 'ip地址不能为空',
'forward_url.required' => '转发网址不能为空',
'message.required' => '发送内容不能为空',
'delay.required' => '延迟发送时间不能为空',
'type.required' => '类型不能为空',
]);
}
/**
* @remark :保存询盘信息
* @name :save
* @author :lyh
* @method :post
* @time :2023/7/11 15:33
*/
public function save(InquiryInfoLogic $inquiryInfoLogic){
//参数验证
$this->validationParam();
$inquiryInfoLogic->inquirySave();
$this->response('success');
}
/**
* @remark :转发详情
* @name :info
* @author :lyh
* @method :post
* @time :2023/7/12 17:19
*/
public function forwardInfo(InquiryInfoLogic $inquiryInfoLogic){
$this->request->validate([
'id'=>'required',//
],[
'id.required' => 'ID不能为空',
]);
$info = $inquiryInfoLogic->inquiryForwardInfo();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @param InquiryInfoLogic $inquiryInfoLogic
* @remark :删除
* @name :del
* @author :lyh
* @method :post
* @time :2023/7/12 14:10
*/
public function del(InquiryInfoLogic $inquiryInfoLogic){
$this->request->validate([
'id'=>'required',//
],[
'id.required' => '名称不能为空',
]);
$inquiryInfoLogic->inquiryInfoDel();
$this->response('success');
}
/**
* @remark :导入询盘记录
* @name :ImportInquirySave
* @author :lyh
* @method :post
* @time :2023/7/13 10:39
*/
public function importInquirySave(InquiryInfoLogic $inquiryInfoLogic){
if ($this->request->hasFile('file')) {
$path = $this->request->file('file')->getRealPath();
$spreadsheet = IOFactory::load($path);
$worksheet = $spreadsheet->getActiveSheet();
$rows = $worksheet->toArray();
foreach ($rows as $row) {
// 创建模型实例并设置属性
$inquiryInfoLogic->ImportInquiryInfoSave($row);
}
}
$this->response('success');
}
/**
* @remark :根据国家获取随机ip
* @name :getSearchIpInfo
* @author :lyh
* @method :post
* @time :2023/7/13 13:45
*/
public function getSearchIpInfo(InquiryInfoLogic $inquiryInfoLogic){
$this->request->validate([
'ip_area'=>'required',//
],[
'ip_area.required' => '国家不能为空',
]);
$info = $inquiryInfoLogic->getSearchIp();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :手动询盘转发
* @name :forwardInquiry
* @author :lyh
* @method :post
* @time :2023/7/14 10:43
*/
public function forwardInquiry(InquiryInfoLogic $inquiryInfoLogic){
$this->request->validate([
'id'=>'required',//
],[
'id.required' => 'id不能为空',
]);
$inquiryInfoLogic->forwardTime($this->param['id']);
$this->response('success');
}
/**
* @remark :修改状态
* @name :status
* @author :lyh
* @method :post
* @time :2023/7/14 15:20
*/
public function status(InquiryInfoLogic $inquiryInfoLogic){
$this->request->validate([
'id'=>'required',
'status'=>'required',
],[
'id.required' => 'id不能为空',
'status.required' => '状态不能为空',
]);
$inquiryInfoLogic->inquiryEdit();
$this->response('success');
}
/**
* @remark :获取最新30天数据
* @name :getNewThirtyCount
* @author :lyh
* @method :post
* @time :2023/7/14 15:55
*/
public function getCount(InquiryInfoLogic $inquiryInfoLogic){
$yesterday = Carbon::yesterday()->toDateString();
var_dump($yesterday);
die();
// 获取30天前的时间
// $thirtyDaysAgo = date("Y-m-d", strtotime("-30 days"));
// // 获取当前时间
// $currentDateTime = date("Y-m-d");
// $lists = $inquiryInfoLogic->getNewThirtyCount($thirtyDaysAgo,$currentDateTime);
// $this->response('success',Code::SUCCESS,$lists);
}
}