作者 赵彬吉

update

  1 +<?php
  2 +
  3 +namespace App\Console\Commands;
  4 +
  5 +use App\Helper\Arr;
  6 +use App\Helper\FormGlobalsoApi;
  7 +use App\Http\Logic\Bside\InquiryLogic;
  8 +use App\Models\Product\Category;
  9 +use App\Models\Product\Product;
  10 +use App\Models\Project\OnlineCheck;
  11 +use App\Models\Project\Project;
  12 +use App\Models\RankData\RankData as GoogleRankModel;
  13 +use App\Models\RouteMap\RouteMap;
  14 +use GuzzleHttp\Client;
  15 +use GuzzleHttp\Promise\Utils;
  16 +use Illuminate\Console\Command;
  17 +use Illuminate\Database\Eloquent\Model;
  18 +use Illuminate\Support\Facades\DB;
  19 +use Illuminate\Support\Str;
  20 +
  21 +/**
  22 + * 最近一次询盘
  23 + * Class InquiryList
  24 + * @package App\Console\Commands
  25 + * @author zbj
  26 + * @date 2023/9/11
  27 + */
  28 +class LastInquiry extends Command
  29 +{
  30 + /**
  31 + * The name and signature of the console command.
  32 + *
  33 + * @var string
  34 + */
  35 + protected $signature = 'last_inquiry';
  36 +
  37 + /**
  38 + * The console command description.
  39 + *
  40 + * @var string
  41 + */
  42 + protected $description = '询盘列表';
  43 +
  44 + /**
  45 + * Create a new command instance.
  46 + *
  47 + * @return void
  48 + */
  49 + public function __construct()
  50 + {
  51 + parent::__construct();
  52 + }
  53 +
  54 + /**
  55 + * @return bool
  56 + */
  57 + public function handle()
  58 + {
  59 + $list = Project::with('deploy_optimize')->whereIn('type', [2,3,4])->get();
  60 + foreach ($list as $item){
  61 + if(empty($item['deploy_optimize']['domain'])){
  62 + continue;
  63 + }
  64 + $api = new FormGlobalsoApi();
  65 + $res = $api->getInquiryList($item['deploy_optimize']['domain']);
  66 + if($res && $res['status'] == 200){
  67 + if(empty($res['data']['data'][0])){
  68 + continue;
  69 + }
  70 + $item->last_inquiry_time = $res['data']['data'][0]['submit_time'];
  71 + $item->save();
  72 + }
  73 + }
  74 + }
  75 +}
@@ -144,11 +144,13 @@ class RankData extends BaseCommands @@ -144,11 +144,13 @@ class RankData extends BaseCommands
144 } 144 }
145 145
146 //关键词达标天数 146 //关键词达标天数
  147 + $model->is_compliance = 0;
147 if($model->updated_date != date('Y-m-d')){ 148 if($model->updated_date != date('Y-m-d')){
148 //保证关键词数 149 //保证关键词数
149 $keyword_num = DeployBuild::where('project_id', $project_id)->value('keyword_num'); 150 $keyword_num = DeployBuild::where('project_id', $project_id)->value('keyword_num');
150 if($first_page_num >= $keyword_num){ 151 if($first_page_num >= $keyword_num){
151 $model->compliance_day = $model->compliance_day + 1; 152 $model->compliance_day = $model->compliance_day + 1;
  153 + $model->is_compliance = 1;
152 } 154 }
153 } 155 }
154 156
@@ -16,7 +16,7 @@ class Kernel extends ConsoleKernel @@ -16,7 +16,7 @@ class Kernel extends ConsoleKernel
16 protected function schedule(Schedule $schedule) 16 protected function schedule(Schedule $schedule)
17 { 17 {
18 // $schedule->command('inspire')->hourly(); 18 // $schedule->command('inspire')->hourly();
19 - $schedule->command('remain_day')->dailyAt('00:30')->withoutOverlapping(1); // 项目剩余服务时长 19 + $schedule->command('remain_day')->dailyAt('03:00')->withoutOverlapping(1); // 项目剩余服务时长
20 $schedule->command('rank_data')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每天凌晨执行一次 20 $schedule->command('rank_data')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每天凌晨执行一次
21 $schedule->command('rank_data_speed')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-测速数据,每周一凌晨执行一次 21 $schedule->command('rank_data_speed')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-测速数据,每周一凌晨执行一次
22 $schedule->command('rank_data_external_links')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次 22 $schedule->command('rank_data_external_links')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次
@@ -34,6 +34,7 @@ class Kernel extends ConsoleKernel @@ -34,6 +34,7 @@ class Kernel extends ConsoleKernel
34 $schedule->command('inquiry_delay')->everyMinute()->withoutOverlapping(1);//TODO::上线放开,转发询盘,每分钟执行一次 34 $schedule->command('inquiry_delay')->everyMinute()->withoutOverlapping(1);//TODO::上线放开,转发询盘,每分钟执行一次
35 $schedule->command('inquiry_count')->dailyAt('01:00')->withoutOverlapping(1); // 询盘统计数据,每天凌晨执行一次 35 $schedule->command('inquiry_count')->dailyAt('01:00')->withoutOverlapping(1); // 询盘统计数据,每天凌晨执行一次
36 $schedule->command('domain_info')->dailyAt('01:00')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次 36 $schedule->command('domain_info')->dailyAt('01:00')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次
  37 + $schedule->command('last_inquiry')->dailyAt('04:00')->withoutOverlapping(1);// 最近一次询盘信息
37 } 38 }
38 39
39 /** 40 /**
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 namespace App\Http\Controllers\Aside\Project; 3 namespace App\Http\Controllers\Aside\Project;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
  6 +use App\Helper\QuanqiusouApi;
6 use App\Http\Controllers\Aside\BaseController; 7 use App\Http\Controllers\Aside\BaseController;
7 use App\Http\Logic\Aside\Manage\ManageLogic; 8 use App\Http\Logic\Aside\Manage\ManageLogic;
8 use App\Http\Logic\Aside\Project\OnlineCheckLogic; 9 use App\Http\Logic\Aside\Project\OnlineCheckLogic;
@@ -15,6 +16,7 @@ use App\Models\Channel\Channel; @@ -15,6 +16,7 @@ use App\Models\Channel\Channel;
15 use App\Models\Com\City; 16 use App\Models\Com\City;
16 use App\Models\Devops\ServerConfig; 17 use App\Models\Devops\ServerConfig;
17 use App\Models\Domain\DomainInfo; 18 use App\Models\Domain\DomainInfo;
  19 +use App\Models\HomeCount\Count;
18 use App\Models\Inquiry\InquirySet; 20 use App\Models\Inquiry\InquirySet;
19 use App\Models\Manage\BelongingGroup; 21 use App\Models\Manage\BelongingGroup;
20 use App\Models\Manage\Manage; 22 use App\Models\Manage\Manage;
@@ -25,6 +27,7 @@ use App\Models\Project\Payment; @@ -25,6 +27,7 @@ use App\Models\Project\Payment;
25 use App\Models\Project\Project; 27 use App\Models\Project\Project;
26 use App\Models\RankData\RankData; 28 use App\Models\RankData\RankData;
27 use App\Models\Task\Task; 29 use App\Models\Task\Task;
  30 +use App\Models\Visit\Visit;
28 use Illuminate\Http\Request; 31 use Illuminate\Http\Request;
29 use Illuminate\Support\Facades\DB; 32 use Illuminate\Support\Facades\DB;
30 33
@@ -571,17 +574,44 @@ class ProjectController extends BaseController @@ -571,17 +574,44 @@ class ProjectController extends BaseController
571 public function getProjectByChannel(){ 574 public function getProjectByChannel(){
572 $source_id = $this->param['channel_id']; //原系统渠道id 575 $source_id = $this->param['channel_id']; //原系统渠道id
573 $size = $this->param['page_size'] ?? 20; 576 $size = $this->param['page_size'] ?? 20;
574 - $type = $this->param['type']; 577 + $type = $this->param['type'] ?? '';
  578 + $company = $this->param['company'] ?? '';
575 $channel = Channel::where('source_id', $source_id)->first(); 579 $channel = Channel::where('source_id', $source_id)->first();
576 if(!$channel){ 580 if(!$channel){
577 $this->response('渠道不存在',Code::SYSTEM_ERROR); 581 $this->response('渠道不存在',Code::SYSTEM_ERROR);
578 } 582 }
579 583
580 - $list = Project::where('channel->channel_id', $channel->id)->where(function ($query) use ($type){  
581 - if($type){ 584 + $data = Project::with(['deploy_build', 'deploy_optimize', 'online_check'])->where('channel->channel_id', $channel->id)->where(function ($query) use ($type, $company){
  585 + if ($type) {
582 $query->where('type', $type); 586 $query->where('type', $type);
583 } 587 }
584 - })->orderBy('id', 'desc')->paginate($size);  
585 - $this->response('success',Code::SUCCESS, $list); 588 + if ($company) {
  589 + $query->where('company', 'like', '%' . $company . '%');
  590 + }
  591 + })->orderBy('id', 'desc')->paginate($size)->toArray();
  592 + foreach ($data['list'] as $item){
  593 + $item['type_text'] = Project::typeMap()[$item['type']] ?? '';
  594 + $item['plan_text'] = Project::planMap()[$item['deploy_build']['plan']] ?? '';
  595 + $item['start_date'] = $item['deploy_optimize']['start_date'] ?? '';
  596 + $item['domain'] = $item['deploy_optimize']['domain'] ?? '';
  597 + $item['test_domain'] = $item['deploy_build']['test_domain'] ?? '';
  598 + $item['online_time'] = $item['online_check']['qa_check_time'] ?? '';
  599 + if ($item['type'] == 3) {
  600 + $item['is_compliance'] = RankData::where('project_id', $item['id'])->where('lang', '')->value('is_compliance') ?: 0;
  601 + } else {
  602 + $item['is_compliance'] = 1;
  603 + }
  604 + $yesterday_count = Count::where('project_id', $item['id'])->where('date', date('Y-m-d', strtotime('-1 day')))->first();
  605 + $today_count = Count::where('project_id', $item['id'])->where('date', date('Y-m-d'))->first();
  606 + $item['yesterday_ip_count'] = $yesterday_count['ip_num'] ?? 0;
  607 + $item['to_ip_count'] = $today_count['ip_num'] ?? 0;
  608 + $item['inquiry_num'] = $today_count['inquiry_num'] ?? 0;
  609 +
  610 + unset($item['deploy_build']);
  611 + unset($item['deploy_optimize']);
  612 + unset($item['online_check']);
  613 + }
  614 +
  615 + $this->response('success',Code::SUCCESS, $data);
586 } 616 }
587 } 617 }
@@ -36,5 +36,12 @@ class Visit extends Base @@ -36,5 +36,12 @@ class Visit extends Base
36 return self::deviceMap()[$this->device_port] ?? ''; 36 return self::deviceMap()[$this->device_port] ?? '';
37 } 37 }
38 38
  39 + /**
  40 + * @author zbj
  41 + * @date 2023/9/11
  42 + */
  43 + public function yesterdayIpCount(){
  44 + return self::deviceMap()[$this->device_port] ?? '';
  45 + }
39 46
40 } 47 }