作者 lyh

gx

@@ -25,6 +25,15 @@ class InquiryInfoController extends BaseController @@ -25,6 +25,15 @@ class InquiryInfoController extends BaseController
25 * @time :2023/7/11 15:23 25 * @time :2023/7/11 15:23
26 */ 26 */
27 public function lists(InquiryInfoLogic $inquiryInfoLogic){ 27 public function lists(InquiryInfoLogic $inquiryInfoLogic){
  28 + if(isset($this->param['url'])){
  29 + $this->map['url'] = ['like',','.$this->map['url'].','];
  30 + }
  31 + if(isset($this->param['email'])){
  32 + $this->map['email'] = ['like',','.$this->map['email'].','];
  33 + }
  34 + if(isset($this->param['title'])){
  35 + $this->map['title'] = ['like',','.$this->map['title'].','];
  36 + }
28 $lists = $inquiryInfoLogic->getInquiryLists($this->map,$this->page,$this->row,$this->order); 37 $lists = $inquiryInfoLogic->getInquiryLists($this->map,$this->page,$this->row,$this->order);
29 $this->response('success',Code::SUCCESS,$lists); 38 $this->response('success',Code::SUCCESS,$lists);
30 } 39 }
@@ -7,6 +7,8 @@ use App\Models\InquiryIP; @@ -7,6 +7,8 @@ use App\Models\InquiryIP;
7 use App\Models\Projects\InquiryInfo; 7 use App\Models\Projects\InquiryInfo;
8 use App\Models\Projects\InquiryUser; 8 use App\Models\Projects\InquiryUser;
9 use Illuminate\Support\Facades\DB; 9 use Illuminate\Support\Facades\DB;
  10 +use Illuminate\Support\Facades\Artisan;
  11 +use Illuminate\Console\Scheduling\Schedule;
10 12
11 /** 13 /**
12 * @remark :询盘中心 14 * @remark :询盘中心
@@ -36,20 +38,8 @@ class InquiryInfoLogic extends BaseLogic @@ -36,20 +38,8 @@ class InquiryInfoLogic extends BaseLogic
36 * @method :post 38 * @method :post
37 * @time :2023/7/11 15:25 39 * @time :2023/7/11 15:25
38 */ 40 */
39 - public function getInquiryLists($map,$page,$row,$order = 'id'){  
40 - $query = $this->model->leftJoin('gl_inquiry_user', 'gl_inquiry_info.id', '=', 'gl_inquiry_user.xp_id')  
41 - ->orderBy('gl_inquiry_info.'.$order,'desc');  
42 - //搜索条件处理  
43 - if(isset($map['domain'])){  
44 - $query = $query->where('gl_inquiry_info.domain','like','%'.$map['domain'].'%');  
45 - }  
46 - if(isset($map['type'])){  
47 - $query = $query->where('gl_inquiry_info.type',$map['type']);  
48 - }  
49 - if(isset($map['url'])){  
50 - $query = $query->where('gl_inquiry_info.url',$map['url']);  
51 - }  
52 - $lists = $query->paginate($row, $this->selectParam(), 'page', $page); 41 + public function getInquiryLists($map,$page,$row,$order = 'id',$filed = ['*']){
  42 + $lists = $this->model->lists($map,$page,$row,$order,$filed);
53 return $this->success($lists); 43 return $this->success($lists);
54 } 44 }
55 45
@@ -82,11 +72,10 @@ class InquiryInfoLogic extends BaseLogic @@ -82,11 +72,10 @@ class InquiryInfoLogic extends BaseLogic
82 * @method :post 72 * @method :post
83 * @time :2023/7/12 9:22 73 * @time :2023/7/12 9:22
84 */ 74 */
85 - public function inquirySave($status = 3){ 75 + public function inquirySave(){
86 try { 76 try {
87 - $xp_id = $this->inquiryInfoSave($status);  
88 - $this->inquiryUserSave($xp_id);  
89 - //TODO::转发询盘 77 + //手动添加询盘
  78 + $this->inquiryInfoSave();
90 }catch (\Exception $e){ 79 }catch (\Exception $e){
91 $this->fail('error'); 80 $this->fail('error');
92 } 81 }
@@ -100,7 +89,7 @@ class InquiryInfoLogic extends BaseLogic @@ -100,7 +89,7 @@ class InquiryInfoLogic extends BaseLogic
100 * @method :post 89 * @method :post
101 * @time :2023/7/12 11:12 90 * @time :2023/7/12 11:12
102 */ 91 */
103 - public function inquiryInfoSave($status = 3){ 92 + public function inquiryInfoSave($status = 0){
104 //组装数据 93 //组装数据
105 $param = [ 94 $param = [
106 'name'=>$this->param['name'], 95 'name'=>$this->param['name'],
@@ -111,36 +100,16 @@ class InquiryInfoLogic extends BaseLogic @@ -111,36 +100,16 @@ class InquiryInfoLogic extends BaseLogic
111 'message'=>$this->param['message'], 100 'message'=>$this->param['message'],
112 'type'=>$this->param['type'], 101 'type'=>$this->param['type'],
113 'status'=>$status, 102 'status'=>$status,
114 - 'created_at'=>date('Y-m-d H:i:s'),  
115 - 'updated_at'=>date('Y-m-d H:i:s'),  
116 - ];  
117 - return $this->model->insertGetId($param);  
118 - }  
119 -  
120 - /**  
121 - * @remark :保存询盘用户转发记录  
122 - * @name :inquiryInfoSave  
123 - * @author :lyh  
124 - * @method :post  
125 - * @time :2023/7/12 11:12  
126 - */  
127 - public function inquiryUserSave($xp_id){  
128 - //组装数据  
129 - $param = [  
130 'user_id'=>$this->manager['id'], 103 'user_id'=>$this->manager['id'],
131 'user_name'=>$this->manager['name'], 104 'user_name'=>$this->manager['name'],
132 - 'xp_id'=>$xp_id,  
133 'forward_url'=>$this->param['forward_url'], 105 'forward_url'=>$this->param['forward_url'],
134 'delay'=>$this->param['delay'], 106 'delay'=>$this->param['delay'],
135 - 'ip'=>$this->param['ip'],  
136 - 'phone'=>$this->param['phone'],  
137 - 'message'=>$this->param['message'],  
138 - 'send_time'=>date('Y-m-d H:i:s', time()+ $this->param['delay'] * 60 * 60)  
139 ]; 107 ];
140 - $inquiryUserModel = new InquiryUser();  
141 - return $inquiryUserModel->add($param); 108 + return $this->model->add($param);
142 } 109 }
143 110
  111 +
  112 +
144 /** 113 /**
145 * @remark :逻辑删除 114 * @remark :逻辑删除
146 * @name :inquiryInfoDel 115 * @name :inquiryInfoDel
@@ -197,7 +166,7 @@ class InquiryInfoLogic extends BaseLogic @@ -197,7 +166,7 @@ class InquiryInfoLogic extends BaseLogic
197 'forward_url'=>$row[7], 166 'forward_url'=>$row[7],
198 'delay'=>$row[8], 167 'delay'=>$row[8],
199 ]; 168 ];
200 - $this->inquirySave(0); 169 + $this->inquirySave();
201 return $this->success(); 170 return $this->success();
202 } 171 }
203 172
@@ -213,4 +182,61 @@ class InquiryInfoLogic extends BaseLogic @@ -213,4 +182,61 @@ class InquiryInfoLogic extends BaseLogic
213 $info = $inquiryIpModel->where($this->param)->inRandomOrder()->first(); 182 $info = $inquiryIpModel->where($this->param)->inRandomOrder()->first();
214 return $this->success($info); 183 return $this->success($info);
215 } 184 }
  185 +
  186 + /**
  187 + * @remark :根据时间转发
  188 + * @name :forwardTime
  189 + * @author :lyh
  190 + * @method :post
  191 + * @time :2023/7/13 17:39
  192 + */
  193 + public function forwardTime($param){
  194 + if($param['delay'] == 0){
  195 + $arr_url = explode(',',$param['forward_url']);
  196 + foreach ($arr_url as $v){
  197 + $param['url'] = $v;
  198 + $this->inquiryForward($param);
  199 + }
  200 + }else{
  201 + // 获取执行时间
  202 + $scheduledTime = date('Y-m-d H:i:s',time() + $this->param['delay'] * 60 * 60);
  203 + $schedule = new Schedule;
  204 + // 定义定时任务
  205 + $schedule->call(function () use ($param) {
  206 + // 任务执行的代码
  207 + $arr_url = explode(',',$param['forward_url']);
  208 + foreach ($arr_url as $v){
  209 + $param['url'] = $v;
  210 + $this->inquiryForward($param);
  211 + }
  212 + })->cron($scheduledTime);
  213 + // 获取任务调度的命令行参数
  214 + $parameters = $schedule->dueEvents($schedule->events());
  215 + // 执行命令行任务
  216 + Artisan::call($parameters);
  217 + }
  218 + return true;
  219 + }
  220 +
  221 + /**
  222 + * @remark :询盘转发
  223 + * @name :inquiryForward
  224 + * @author :lyh
  225 + * @method :post
  226 + * @time :2023/7/13 14:39
  227 + */
  228 + public function inquiryForward($post_data){
  229 + $url = 'https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f';
  230 + $post_data_new = [];
  231 + $post_data_new['refer'] = $post_data['url'];
  232 + $post_data_new['name'] = $post_data['name'];
  233 + $post_data_new['email'] = $post_data['email'];
  234 + $post_data_new['phone'] = $post_data['phone'];
  235 + $post_data_new['ip'] = $post_data['ip'];
  236 + $post_data_new['message'] = $post_data['message'];
  237 + $post_data_new['submit_time'] = date('Y-m-d H:i:s',time()+20);
  238 + $token = md5($post_data_new['refer'].$post_data_new['name'].$post_data_new['ip'].date("Y-m-d",time()));
  239 + $post_data_new['token'] = $token;
  240 + return http_post($url,$post_data_new);
  241 + }
216 } 242 }