作者 张关杰

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into develop

... ... @@ -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);
}
... ... @@ -92,7 +101,7 @@ class InquiryInfoController extends BaseController
/**
* @param InquiryInfoLogic $inquiryInfoLogic
* @remark :执行逻辑删除
* @remark :删除
* @name :del
* @author :lyh
* @method :post
... ... @@ -103,7 +112,6 @@ class InquiryInfoController extends BaseController
'id'=>'required',//
],[
'id.required' => '名称不能为空',
]);
$inquiryInfoLogic->inquiryInfoDel();
$this->response('success');
... ...
... ... @@ -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,44 +38,11 @@ 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);
}
/**
* @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 :自定义添加特殊询盘信息
... ... @@ -84,8 +53,7 @@ class InquiryInfoLogic extends BaseLogic
*/
public function inquirySave(){
try {
$xp_id = $this->inquiryInfoSave();
$this->inquiryUserSave($xp_id);
$this->inquiryInfoSave();
}catch (\Exception $e){
$this->fail('error');
}
... ... @@ -109,36 +77,16 @@ class InquiryInfoLogic extends BaseLogic
'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);
return $this->model->add($param);
}
/**
* @remark :逻辑删除
* @name :inquiryInfoDel
... ... @@ -211,4 +159,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);
}
}
... ...