InquiryInfoLogic.php
3.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
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
<?php
namespace App\Http\Logic\Aside\Projects;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Projects\InquiryInfo;
use App\Models\Projects\InquiryUser;
use mysql_xdevapi\Exception;
/**
* @remark :询盘中心
* @class :InquiryInfoLogic.php
* @author :lyh
* @time :2023/7/11 15:20
*/
class InquiryInfoLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new InquiryInfo();
//TODO::测试数据
$this->manager = [
'id'=>1,
'name'=>'cs'
];
}
/**
* @remark :获取列表
* @name :getInquiryLists
* @author :lyh
* @method :post
* @time :2023/7/11 15:25
*/
public function getInquiryLists($map,$page,$row,$order = 'id'){
$query = $this->model->leftJoin('gl_inquiry_user', 'gl_inquiry_info.id', '=', 'gl_inquiry_user.xp_id')
->orderBy('gl_inquiry_info.'.$order,'desc');
//搜索条件处理
if(isset($map['domain'])){
$query = $query->where('gl_inquiry_info.domain','like','%'.$map['domain'].'%');
}
if(isset($map['type'])){
$query = $query->where('gl_inquiry_info.type',$map['type']);
}
$lists = $query->paginate($row, $this->selectParam(), 'page', $page);
return $this->success($lists);
}
/**
* @remark :查询字段
* @name :selectParam
* @author :lyh
* @method :post
* @time :2023/7/11 16:57
*/
public function selectParam(){
$select = [
'gl_inquiry_info.*',
'gl_inquiry_user.user_id',
'gl_inquiry_user.user_name',
'gl_inquiry_user.message',
'gl_inquiry_user.ip',
'gl_inquiry_user.forward_url',
'gl_inquiry_user.status AS user_status',
'gl_inquiry_user.delay',
'gl_inquiry_user.send_time'
];
return $select;
}
/**
* @remark :自定义添加特殊询盘信息
* @name :inquirySave
* @author :lyh
* @method :post
* @time :2023/7/12 9:22
*/
public function inquirySave(){
// try {
$xp_id = $this->inquiryInfoSave();
$this->inquiryUserSave($xp_id);
// }catch (Exception $e){
// $this->fail('error');
// }
return $this->success();
}
/**
* @remark :保存询盘记录表
* @name :inquiryInfoSave
* @author :lyh
* @method :post
* @time :2023/7/12 11:12
*/
public function inquiryInfoSave(){
//组装数据
$param = [
'name'=>$this->param['name'],
'email'=>$this->param['email'],
'phone'=>$this->param['phone'],
'ip'=>$this->param['ip'],
'ip_area'=>$this->param['ip_area'],
'message'=>$this->param['message'],
'type'=>$this->param['type'],
'created_at'=>date('Y-m-d H:i:s'),
'updated_at'=>date('Y-m-d H:i:s'),
];
return $this->model->insertGetId($param);
}
/**
* @remark :保存询盘用户转发记录
* @name :inquiryInfoSave
* @author :lyh
* @method :post
* @time :2023/7/12 11:12
*/
public function inquiryUserSave($xp_id){
//组装数据
$param = [
'user_id'=>$this->manager['id'],
'user_name'=>$this->manager['name'],
'xp_id'=>$xp_id,
'forward_url'=>$this->param['forward_url'],
'delay'=>$this->param['delay'],
'ip'=>$this->param['ip'],
'phone'=>$this->param['phone'],
'message'=>$this->param['message'],
'send_time'=>date('Y-m-d H:i:s', time()+ $this->param['delay'] * 60 * 60)
];
$inquiryUserModel = new InquiryUser();
return $inquiryUserModel->add($param);
}
}