作者 lyh

gx

... ... @@ -25,6 +25,15 @@ class InquiryInfoController extends BaseController
* @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);
}
... ...
... ... @@ -7,6 +7,8 @@ use App\Models\InquiryIP;
use App\Models\Projects\InquiryInfo;
use App\Models\Projects\InquiryUser;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Console\Scheduling\Schedule;
/**
* @remark :询盘中心
... ... @@ -36,20 +38,8 @@ class InquiryInfoLogic extends BaseLogic
* @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']);
}
if(isset($map['url'])){
$query = $query->where('gl_inquiry_info.url',$map['url']);
}
$lists = $query->paginate($row, $this->selectParam(), 'page', $page);
public function getInquiryLists($map,$page,$row,$order = 'id',$filed = ['*']){
$lists = $this->model->lists($map,$page,$row,$order,$filed);
return $this->success($lists);
}
... ... @@ -82,11 +72,10 @@ class InquiryInfoLogic extends BaseLogic
* @method :post
* @time :2023/7/12 9:22
*/
public function inquirySave($status = 3){
public function inquirySave(){
try {
$xp_id = $this->inquiryInfoSave($status);
$this->inquiryUserSave($xp_id);
//TODO::转发询盘
//手动添加询盘
$this->inquiryInfoSave();
}catch (\Exception $e){
$this->fail('error');
}
... ... @@ -100,7 +89,7 @@ class InquiryInfoLogic extends BaseLogic
* @method :post
* @time :2023/7/12 11:12
*/
public function inquiryInfoSave($status = 3){
public function inquiryInfoSave($status = 0){
//组装数据
$param = [
'name'=>$this->param['name'],
... ... @@ -111,36 +100,16 @@ class InquiryInfoLogic extends BaseLogic
'message'=>$this->param['message'],
'type'=>$this->param['type'],
'status'=>$status,
'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);
return $this->model->add($param);
}
/**
* @remark :逻辑删除
* @name :inquiryInfoDel
... ... @@ -197,7 +166,7 @@ class InquiryInfoLogic extends BaseLogic
'forward_url'=>$row[7],
'delay'=>$row[8],
];
$this->inquirySave(0);
$this->inquirySave();
return $this->success();
}
... ... @@ -213,4 +182,61 @@ class InquiryInfoLogic extends BaseLogic
$info = $inquiryIpModel->where($this->param)->inRandomOrder()->first();
return $this->success($info);
}
/**
* @remark :根据时间转发
* @name :forwardTime
* @author :lyh
* @method :post
* @time :2023/7/13 17:39
*/
public function forwardTime($param){
if($param['delay'] == 0){
$arr_url = explode(',',$param['forward_url']);
foreach ($arr_url as $v){
$param['url'] = $v;
$this->inquiryForward($param);
}
}else{
// 获取执行时间
$scheduledTime = date('Y-m-d H:i:s',time() + $this->param['delay'] * 60 * 60);
$schedule = new Schedule;
// 定义定时任务
$schedule->call(function () use ($param) {
// 任务执行的代码
$arr_url = explode(',',$param['forward_url']);
foreach ($arr_url as $v){
$param['url'] = $v;
$this->inquiryForward($param);
}
})->cron($scheduledTime);
// 获取任务调度的命令行参数
$parameters = $schedule->dueEvents($schedule->events());
// 执行命令行任务
Artisan::call($parameters);
}
return true;
}
/**
* @remark :询盘转发
* @name :inquiryForward
* @author :lyh
* @method :post
* @time :2023/7/13 14:39
*/
public function inquiryForward($post_data){
$url = 'https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f';
$post_data_new = [];
$post_data_new['refer'] = $post_data['url'];
$post_data_new['name'] = $post_data['name'];
$post_data_new['email'] = $post_data['email'];
$post_data_new['phone'] = $post_data['phone'];
$post_data_new['ip'] = $post_data['ip'];
$post_data_new['message'] = $post_data['message'];
$post_data_new['submit_time'] = date('Y-m-d H:i:s',time()+20);
$token = md5($post_data_new['refer'].$post_data_new['name'].$post_data_new['ip'].date("Y-m-d",time()));
$post_data_new['token'] = $token;
return http_post($url,$post_data_new);
}
}
... ...