作者 张关杰

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

<?php
namespace App\Console\Commands;
use App\Models\Projects\InquiryInfo;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
/**
* @remark :
* @class :InquiryDelay.php
* @author :lyh
* @time :2023/7/14 10:16
*/
class InquiryDelay extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'inquiry_delay';
/**
* The console command description.
*
* @var string
*/
protected $description = '延时询盘转发';
/**
* @remark :延时询盘转发
* @name :handle
* @author :lyh
* @method :post
* @time :2023/7/14 10:17
*/
public function handle()
{
$inquiryInfoModel = new InquiryInfo();
$param = $inquiryInfoModel->formatQuery(['status'=>0,'delay'=>['!=',0]])->orderBy('send_time','asc')->first();
if($param !== false){
$time = date('Y-m-d H:i:s');
if($time >= $param['send_time']){
$data = [];
//TODO::处理转发的url
$arr_url = explode(',',$param['forward_url']);
foreach ($arr_url as $v){
$data['url'] = $v;
$this->inquiryForward($data);
Log::info('询盘转发记录'.json_encode($data),'debug------------------info');
}
}
}
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);
}
}
... ...
... ... @@ -30,6 +30,7 @@ class Kernel extends ConsoleKernel
$schedule->command('sync_channel')->dailyAt('06:00')->withoutOverlapping(1); // 渠道信息,每周执行一次
$schedule->command('sync_project')->everyMinute()->withoutOverlapping(1); //同步项目
$schedule->command('month_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计记录
$schedule->command('inquiry_delay')->everyMinute()->withoutOverlapping(1);//每分钟执行一次
// // 更新域名|证书结束时间,每天凌晨1点执行一次
// $schedule->command('domain_time')->dailyAt('01:00')->withoutOverlapping(1);
// // B站 - 网站数据统计
... ...
... ... @@ -150,9 +150,25 @@ class InquiryInfoController extends BaseController
'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');
}
}
... ...
... ... @@ -7,8 +7,6 @@ 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 :询盘中心
... ... @@ -52,43 +50,20 @@ class InquiryInfoLogic extends BaseLogic
* @time :2023/7/12 9:22
*/
public function inquirySave(){
try {
$this->inquiryInfoSave();
}catch (\Exception $e){
$xp_id = $this->model->insertGetId($this->param);
if(!$xp_id){
$this->fail('error');
}
return $this->success();
//延时时间为0时,询盘转发
if($this->param['delay'] == 0){
$this->forwardTime($xp_id);
}
/**
* @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'],
'user_id'=>$this->manager['id'],
'user_name'=>$this->manager['name'],
'forward_url'=>$this->param['forward_url'],
'delay'=>$this->param['delay'],
];
return $this->model->add($param);
return $this->success();
}
/**
* @remark :逻辑删除
* @remark :删除
* @name :inquiryInfoDel
* @author :lyh
* @method :post
... ... @@ -116,8 +91,7 @@ class InquiryInfoLogic extends BaseLogic
* @time :2023/7/12 17:43
*/
public function inquiryForwardInfo(){
$inquiryUserModel = new InquiryUser();
$info = $inquiryUserModel->read(['xp_id'=>$this->param['id']]);
$info = $this->model->read(['id'=>$this->param['id']]);
if($info === false){
$this->fail('error');
}
... ... @@ -167,32 +141,27 @@ class InquiryInfoLogic extends BaseLogic
* @method :post
* @time :2023/7/13 17:39
*/
public function forwardTime($param){
public function forwardTime($xp_id){
//获取数据详情
$param = $this->model->read(['id'=>$xp_id]);
if($param['delay'] == 0){
$data = $param;
$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);
$data['url'] = $v;
$this->inquiryForward($data);
}
//更新数据库,修改状态为已转发
$this->param['status'] = 3;
$this->param['user_id'] = $this->manager['id'];
$this->param['user_name'] = $this->manager['name'];
$this->param['send_time'] = date('Y-m-d H:i:s',time() + $param['delay'] * 60 * 60) ;
$rs = $this->model->edit($this->param,['id'=>$xp_id]);
if($rs === false){
$this->fail('error');
}
})->cron($scheduledTime);
// 获取任务调度的命令行参数
$parameters = $schedule->dueEvents($schedule->events());
// 执行命令行任务
Artisan::call($parameters);
}
return true;
return $this->success();
}
/**
... ...
... ... @@ -267,6 +267,7 @@ Route::group([], function () {
Route::prefix('inquiry')->group(function () {
Route::any('/', [Aside\Projects\InquiryInfoController::class, 'lists'])->name('admin.inquiry_lists');
Route::any('/save', [Aside\Projects\InquiryInfoController::class, 'save'])->name('admin.inquiry_save');
Route::any('/forwardInquiry', [Aside\Projects\InquiryInfoController::class, 'forwardInquiry'])->name('admin.inquiry_forwardInquiry');
Route::any('/forwardInfo', [Aside\Projects\InquiryInfoController::class, 'forwardInfo'])->name('admin.inquiry_forwardInfo');
Route::any('/importInquirySave', [Aside\Projects\InquiryInfoController::class, 'importInquirySave'])->name('admin.inquiry_importInquirySave');
Route::any('/getSearchIpInfo', [Aside\Projects\InquiryInfoController::class, 'getSearchIpInfo'])->name('admin.inquiry_getSearchIpInfo');
... ...