作者 赵彬吉

update

<?php
namespace App\Console\Commands;
use App\Helper\Arr;
use App\Helper\FormGlobalsoApi;
use App\Http\Logic\Bside\InquiryLogic;
use App\Models\Product\Category;
use App\Models\Product\Product;
use App\Models\Project\OnlineCheck;
use App\Models\Project\Project;
use App\Models\RankData\RankData as GoogleRankModel;
use App\Models\RouteMap\RouteMap;
use GuzzleHttp\Client;
use GuzzleHttp\Promise\Utils;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
/**
* 最近一次询盘
* Class InquiryList
* @package App\Console\Commands
* @author zbj
* @date 2023/9/11
*/
class LastInquiry extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'last_inquiry';
/**
* The console command description.
*
* @var string
*/
protected $description = '询盘列表';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* @return bool
*/
public function handle()
{
$list = Project::with('deploy_optimize')->whereIn('type', [2,3,4])->get();
foreach ($list as $item){
if(empty($item['deploy_optimize']['domain'])){
continue;
}
$api = new FormGlobalsoApi();
$res = $api->getInquiryList($item['deploy_optimize']['domain']);
if($res && $res['status'] == 200){
if(empty($res['data']['data'][0])){
continue;
}
$item->last_inquiry_time = $res['data']['data'][0]['submit_time'];
$item->save();
}
}
}
}
... ...
... ... @@ -144,11 +144,13 @@ class RankData extends BaseCommands
}
//关键词达标天数
$model->is_compliance = 0;
if($model->updated_date != date('Y-m-d')){
//保证关键词数
$keyword_num = DeployBuild::where('project_id', $project_id)->value('keyword_num');
if($first_page_num >= $keyword_num){
$model->compliance_day = $model->compliance_day + 1;
$model->is_compliance = 1;
}
}
... ...
... ... @@ -16,7 +16,7 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
$schedule->command('remain_day')->dailyAt('00:30')->withoutOverlapping(1); // 项目剩余服务时长
$schedule->command('remain_day')->dailyAt('03:00')->withoutOverlapping(1); // 项目剩余服务时长
$schedule->command('rank_data')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每天凌晨执行一次
$schedule->command('rank_data_speed')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-测速数据,每周一凌晨执行一次
$schedule->command('rank_data_external_links')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次
... ... @@ -34,6 +34,7 @@ class Kernel extends ConsoleKernel
$schedule->command('inquiry_delay')->everyMinute()->withoutOverlapping(1);//TODO::上线放开,转发询盘,每分钟执行一次
$schedule->command('inquiry_count')->dailyAt('01:00')->withoutOverlapping(1); // 询盘统计数据,每天凌晨执行一次
$schedule->command('domain_info')->dailyAt('01:00')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次
$schedule->command('last_inquiry')->dailyAt('04:00')->withoutOverlapping(1);// 最近一次询盘信息
}
/**
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Http\Controllers\Aside\Project;
use App\Enums\Common\Code;
use App\Helper\QuanqiusouApi;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Manage\ManageLogic;
use App\Http\Logic\Aside\Project\OnlineCheckLogic;
... ... @@ -15,6 +16,7 @@ use App\Models\Channel\Channel;
use App\Models\Com\City;
use App\Models\Devops\ServerConfig;
use App\Models\Domain\DomainInfo;
use App\Models\HomeCount\Count;
use App\Models\Inquiry\InquirySet;
use App\Models\Manage\BelongingGroup;
use App\Models\Manage\Manage;
... ... @@ -25,6 +27,7 @@ use App\Models\Project\Payment;
use App\Models\Project\Project;
use App\Models\RankData\RankData;
use App\Models\Task\Task;
use App\Models\Visit\Visit;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
... ... @@ -571,17 +574,44 @@ class ProjectController extends BaseController
public function getProjectByChannel(){
$source_id = $this->param['channel_id']; //原系统渠道id
$size = $this->param['page_size'] ?? 20;
$type = $this->param['type'];
$type = $this->param['type'] ?? '';
$company = $this->param['company'] ?? '';
$channel = Channel::where('source_id', $source_id)->first();
if(!$channel){
$this->response('渠道不存在',Code::SYSTEM_ERROR);
}
$list = Project::where('channel->channel_id', $channel->id)->where(function ($query) use ($type){
if($type){
$data = Project::with(['deploy_build', 'deploy_optimize', 'online_check'])->where('channel->channel_id', $channel->id)->where(function ($query) use ($type, $company){
if ($type) {
$query->where('type', $type);
}
})->orderBy('id', 'desc')->paginate($size);
$this->response('success',Code::SUCCESS, $list);
if ($company) {
$query->where('company', 'like', '%' . $company . '%');
}
})->orderBy('id', 'desc')->paginate($size)->toArray();
foreach ($data['list'] as $item){
$item['type_text'] = Project::typeMap()[$item['type']] ?? '';
$item['plan_text'] = Project::planMap()[$item['deploy_build']['plan']] ?? '';
$item['start_date'] = $item['deploy_optimize']['start_date'] ?? '';
$item['domain'] = $item['deploy_optimize']['domain'] ?? '';
$item['test_domain'] = $item['deploy_build']['test_domain'] ?? '';
$item['online_time'] = $item['online_check']['qa_check_time'] ?? '';
if ($item['type'] == 3) {
$item['is_compliance'] = RankData::where('project_id', $item['id'])->where('lang', '')->value('is_compliance') ?: 0;
} else {
$item['is_compliance'] = 1;
}
$yesterday_count = Count::where('project_id', $item['id'])->where('date', date('Y-m-d', strtotime('-1 day')))->first();
$today_count = Count::where('project_id', $item['id'])->where('date', date('Y-m-d'))->first();
$item['yesterday_ip_count'] = $yesterday_count['ip_num'] ?? 0;
$item['to_ip_count'] = $today_count['ip_num'] ?? 0;
$item['inquiry_num'] = $today_count['inquiry_num'] ?? 0;
unset($item['deploy_build']);
unset($item['deploy_optimize']);
unset($item['online_check']);
}
$this->response('success',Code::SUCCESS, $data);
}
}
... ...
... ... @@ -36,5 +36,12 @@ class Visit extends Base
return self::deviceMap()[$this->device_port] ?? '';
}
/**
* @author zbj
* @date 2023/9/11
*/
public function yesterdayIpCount(){
return self::deviceMap()[$this->device_port] ?? '';
}
}
... ...