作者 lyh

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

@@ -179,9 +179,9 @@ class RelayInquiry extends Command @@ -179,9 +179,9 @@ class RelayInquiry extends Command
179 foreach ($inquiry as $key=>$val) { 179 foreach ($inquiry as $key=>$val) {
180 $this->output('询盘ID:' . $val->id); 180 $this->output('询盘ID:' . $val->id);
181 //询盘时间超过2小时 就不处理了 181 //询盘时间超过2小时 就不处理了
182 - if(time() - strtotime($val->inquiry_date) > 7200){ 182 + if(time() - strtotime($val->inquiry_date) > 259200){
183 $val->status = ReInquiryForm::STATUS_FORGO; 183 $val->status = ReInquiryForm::STATUS_FORGO;
184 - $val->remark = '超时2小时未处理!'; 184 + $val->remark = '超时72小时未处理!';
185 $val->save(); 185 $val->save();
186 continue; 186 continue;
187 } 187 }
@@ -355,7 +355,8 @@ class RelayInquiry extends Command @@ -355,7 +355,8 @@ class RelayInquiry extends Command
355 // 推送消息 消息内容小于10个字符, 使用内置询盘内容 355 // 推送消息 消息内容小于10个字符, 使用内置询盘内容
356 $message = $form->message; 356 $message = $form->message;
357 $message_id = 0; 357 $message_id = 0;
358 - if (strlen($message) < 10) { 358 + // 通过字符数量区分, 改成完全获取内置询盘内容
  359 + if (true) {
359 $use_ids = ReInquiryDetail::where(['re_website' => $domain])->where('status', '<>', ReInquiryDetail::STATUS_FAIL)->pluck('text_id')->toArray(); 360 $use_ids = ReInquiryDetail::where(['re_website' => $domain])->where('status', '<>', ReInquiryDetail::STATUS_FAIL)->pluck('text_id')->toArray();
360 $text = ReInquiryText::whereNotIn('id', $use_ids)->where('status', ReInquiryText::STATUS_USABLE)->inRandomOrder()->first(); 361 $text = ReInquiryText::whereNotIn('id', $use_ids)->where('status', ReInquiryText::STATUS_USABLE)->inRandomOrder()->first();
361 $message = $text->content; 362 $message = $text->content;
@@ -2,15 +2,10 @@ @@ -2,15 +2,10 @@
2 2
3 namespace App\Console\Commands\RankData; 3 namespace App\Console\Commands\RankData;
4 4
5 -  
6 use App\Helper\QuanqiusouApi; 5 use App\Helper\QuanqiusouApi;
7 -use App\Http\Logic\Bside\RankData\RankDataLogic;  
8 -use App\Models\Domain\DomainInfo; 6 +use App\Models\RankData\RankDataLog as RankDataLogModel;
9 use App\Models\Project\DeployOptimize; 7 use App\Models\Project\DeployOptimize;
10 use App\Models\Project\Project; 8 use App\Models\Project\Project;
11 -use App\Models\RankData\RankData as GoogleRankModel;  
12 -use App\Utils\LogUtils;  
13 -use Illuminate\Database\Eloquent\Model;  
14 use Illuminate\Support\Facades\Cache; 9 use Illuminate\Support\Facades\Cache;
15 use Illuminate\Support\Facades\Log; 10 use Illuminate\Support\Facades\Log;
16 11
@@ -35,7 +30,7 @@ class RankData extends BaseCommands @@ -35,7 +30,7 @@ class RankData extends BaseCommands
35 * 30 *
36 * @var string 31 * @var string
37 */ 32 */
38 - protected $description = '谷歌排名数据'; 33 + protected $description = '分发任务';
39 34
40 /** 35 /**
41 * @author zbj 36 * @author zbj
@@ -45,67 +40,31 @@ class RankData extends BaseCommands @@ -45,67 +40,31 @@ class RankData extends BaseCommands
45 { 40 {
46 try { 41 try {
47 Log::channel('rank_data')->info('开始-排名数据'); 42 Log::channel('rank_data')->info('开始-排名数据');
  43 +
48 //所有项目 今日是否达标 重置 44 //所有项目 今日是否达标 重置
49 //有失败会重跑任务,导致达标又被重置 加缓存一天只重置一次 45 //有失败会重跑任务,导致达标又被重置 加缓存一天只重置一次
50 if (!Cache::get('clear_remain_today_' . date('Y-m-d'))) { 46 if (!Cache::get('clear_remain_today_' . date('Y-m-d'))) {
51 Project::where('is_remain_today', 1)->update(['is_remain_today' => 0]); 47 Project::where('is_remain_today', 1)->update(['is_remain_today' => 0]);
52 Cache::set('clear_remain_today_' . date('Y-m-d'), 1, 24 * 3600); 48 Cache::set('clear_remain_today_' . date('Y-m-d'), 1, 24 * 3600);
53 } 49 }
54 - $error = 0;  
55 - $api = new QuanqiusouApi();  
56 //有排名api编号的项目 50 //有排名api编号的项目
57 $list = DeployOptimize::where('api_no', '>', 0)->select('api_no', 'project_id')->orderBy('project_id', 'asc')->get(); 51 $list = DeployOptimize::where('api_no', '>', 0)->select('api_no', 'project_id')->orderBy('project_id', 'asc')->get();
58 Log::channel('rank_data')->info('开始-排名数据-' . count($list)); 52 Log::channel('rank_data')->info('开始-排名数据-' . count($list));
59 - //当日所有站点谷歌收录数据  
60 - $site_res = $api->getSiteRes();  
61 - if (!$site_res) {  
62 - Log::channel('rank_data')->error('谷歌收录数据获取失败'); 53 + foreach ($list as $item){
  54 + RankDataLogModel::addTask($item['project_id'], $item['api_no']);
63 } 55 }
64 - foreach ($list as $item) {  
65 - Log::channel('rank_data')->info('项目开始:ID' . $item['project_id'] .' - '. $item['api_no']) . '';  
66 - try {  
67 - (new RankDataLogic())->syncRankData($item['api_no'], $site_res);  
68 - } catch (\Exception $e) {  
69 - Log::channel('rank_data')->error('RankData:失败 ' . $item['api_no'] . $e->getMessage());  
70 - $error++;  
71 - continue; 56 + //小语种
  57 + $api = new QuanqiusouApi();
  58 + $lang_list = $api->getLangList();
  59 + foreach ($list as $item){
  60 + $langs = $lang_list[$item['api_no']] ?? [];
  61 + foreach ($langs as $lang){
  62 + RankDataLogModel::addTask($item['project_id'], $item['api_no'], $lang);
72 } 63 }
73 } 64 }
74 - return !$error;  
75 } catch (\Exception|\Throwable $e) { 65 } catch (\Exception|\Throwable $e) {
76 Log::channel('rank_data')->error('排名数据任务失败 ' . $e->getMessage()); 66 Log::channel('rank_data')->error('排名数据任务失败 ' . $e->getMessage());
77 - throw new \Exception($e->getMessage());  
78 } 67 }
79 - }  
80 -  
81 - /**  
82 - * 同步项目api_no  
83 - * @author zbj  
84 - * @date 2023/10/16  
85 - */  
86 - public function SyncApiNo(){  
87 - $deploy_optimizes = DeployOptimize::leftJoin('gl_project', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')  
88 - ->whereIn('gl_project.type', [Project::TYPE_TWO,Project::TYPE_THREE])->where('gl_project_deploy_optimize.api_no', 0)  
89 - ->where('gl_project_deploy_optimize.domain', '>', 0)  
90 - ->get();  
91 - if(!$deploy_optimizes){  
92 return true; 68 return true;
93 } 69 }
94 - $api = new QuanqiusouApi();  
95 - $ai_nos = $api->getWebApiNo();  
96 - if($ai_nos){  
97 - foreach ($deploy_optimizes as $deploy_optimize){  
98 - $domain = DomainInfo::where('id', $deploy_optimize['domain'])->value('domain');  
99 - if(!$domain){  
100 - continue;  
101 - }  
102 - $api_no = array_search($domain, $ai_nos);  
103 - if($api_no){  
104 - $deploy_optimize->api_no = $api_no;  
105 - $deploy_optimize->save();  
106 - }  
107 - }  
108 - }  
109 - }  
110 -  
111 } 70 }
  1 +<?php
  2 +
  3 +namespace App\Console\Commands\RankData;
  4 +
  5 +
  6 +use App\Helper\Arr;
  7 +use App\Helper\QuanqiusouApi;
  8 +use App\Http\Logic\Bside\BaseLogic;
  9 +use App\Http\Logic\Bside\RankData\RankDataLogic;
  10 +use App\Models\RankData\RankDataLog as RankDataLogModel;
  11 +use App\Models\Project\DeployOptimize;
  12 +use App\Models\Project\Project;
  13 +use Illuminate\Support\Facades\Cache;
  14 +use Illuminate\Support\Facades\Log;
  15 +use Illuminate\Support\Facades\Redis;
  16 +
  17 +/**
  18 + * Class GoogleRank
  19 + * @package App\Console\Commands
  20 + * @author zbj
  21 + * @date 2023/5/6
  22 + */
  23 +class RankDataLog extends BaseCommands
  24 +{
  25 + /**
  26 + * The name and signature of the console command.
  27 + *
  28 + * @var string
  29 + */
  30 + protected $signature = 'rank_data_log';
  31 +
  32 + /**
  33 + * The console command description.
  34 + * The console command description.
  35 + *
  36 + * @var string
  37 + */
  38 + protected $description = '谷歌排名数据';
  39 +
  40 + /**
  41 + * @author zbj
  42 + * @date 2023/5/6
  43 + */
  44 + public function do()
  45 + {
  46 + while (true) {
  47 + $log_id = Redis::rpop('rank_data_task');
  48 + echo $log_id . PHP_EOL;
  49 + if (!$log_id) {
  50 + sleep(10);
  51 + continue;
  52 + }
  53 +
  54 + $log = RankDataLogModel::where('id', $log_id)->where('status', 0)->first();
  55 + if(!$log){
  56 + continue;
  57 + }
  58 + try {
  59 + $this->output('项目开始:ID'.$log->project_id . ',APINO' . $log->api_no);
  60 + $project = Project::find($log->project_id);
  61 + if (!$project) {
  62 + $this->output('关联的项目不存在:ID'.$log->project_id . ',APINO' . $log->api_no);
  63 + $log->status = 9;
  64 + $log->save();
  65 + continue;
  66 + }
  67 + //接口获取数据
  68 + $api = new QuanqiusouApi();
  69 + $res = $api->getGoogleRank($log->project_id, $log->api_no, $log->lang);
  70 + if (!$res) {
  71 + $this->output('接口数据获取失败:ID'.$log->project_id . ',APINO' . $log->api_no);
  72 + $log->status = 9;
  73 + $log->save();
  74 + continue;
  75 + }
  76 + $log->data = Arr::s2a($res);
  77 + //保存数据
  78 + $this->output('保存排名数据:ID'.$log->project_id . ',APINO' . $log->api_no);
  79 + $is_compliance = (new RankDataLogic())->save_rank($log->project_id, $res, null, $log->lang);
  80 + $log->is_compliance = $is_compliance;
  81 + $log->status = 1;
  82 + $log->save();
  83 +
  84 + } catch (\Exception $e) {
  85 + $this->output('处理失败:ID'.$log->project_id . ',APINO' . $log->api_no . ':' . $e->getMessage());
  86 + }
  87 + }
  88 + }
  89 +
  90 + public function output($message)
  91 + {
  92 + $date = date('Y-m-d H:i:s');
  93 + $output = $date . ', ' . $message . PHP_EOL;
  94 + echo $output;
  95 + Log::channel('rank_data')->info($output);
  96 + return true;
  97 + }
  98 +}
@@ -37,6 +37,10 @@ class WorkchatMessageSend extends Command @@ -37,6 +37,10 @@ class WorkchatMessageSend extends Command
37 foreach ($tasks as $task) { 37 foreach ($tasks as $task) {
38 $this->output('开始推送消息' . $task->id); 38 $this->output('开始推送消息' . $task->id);
39 try { 39 try {
  40 + //超过两小时 不推送了
  41 + if(time() - $task->send_time > 7200){
  42 + throw new \Exception('超时两小时未推送');
  43 + }
40 ProjectAssociationServices::getInstance()->sendMessage($task->friend_id, $task->content, $task->content_type); 44 ProjectAssociationServices::getInstance()->sendMessage($task->friend_id, $task->content, $task->content_type);
41 $this->output('推送消息' . $task->id . '成功'); 45 $this->output('推送消息' . $task->id . '成功');
42 $task->status = MessagePush::STATUS_SUCCESS; 46 $task->status = MessagePush::STATUS_SUCCESS;
@@ -397,29 +397,56 @@ class ProjectUpdate extends Command @@ -397,29 +397,56 @@ class ProjectUpdate extends Command
397 $ve = ''; 397 $ve = '';
398 } 398 }
399 $extend = $extend_model->read(['title' => $ke]); 399 $extend = $extend_model->read(['title' => $ke]);
400 - if (!$extend) {  
401 - $extend_key = $this->get_extend_key($extend_model);  
402 - $extend_model->add([  
403 - 'project_id' => $project_id,  
404 - 'title' => $ke,  
405 - 'type' => 1,  
406 - 'key' => $extend_key  
407 - ]); 400 +
  401 + if ($extend) {
  402 + if ($extend['type'] == 3) {
  403 + //图片
  404 + $gallery = [];
  405 + if (is_array($ve)) {
  406 + foreach ($ve as $ve_img) {
  407 + $gallery[] = ['title' => '', 'description' => '', 'url' => $this->source_download($ve_img, $project_id, $domain_arr['host'], $web_url_domain, $home_url, 1)];
  408 + }
408 } else { 409 } else {
409 - $extend_key = $extend['key']; 410 + $gallery[] = ['title' => '', 'description' => '', 'url' => $this->source_download($ve, $project_id, $domain_arr['host'], $web_url_domain, $home_url, 1)];
  411 + }
  412 + $value = Arr::a2s($gallery);
  413 + } elseif ($extend['type'] == 4) {
  414 + //文件
  415 + $file = [];
  416 + if (is_array($ve)) {
  417 + $file_title = $ve['title'] ?? '';
  418 + $file_url = $ve['url'] ?? '';
  419 + if ($file_url) {
  420 + $file[] = [
  421 + 'name' => $file_title,
  422 + 'url' => $this->source_download($file_url, $project_id, $domain_arr['host'], $web_url_domain, $home_url, 1)
  423 + ];
  424 + }
  425 + } elseif ($ve) {
  426 + $ve_array = explode('/', $ve);
  427 + $file[] = [
  428 + 'name' => end($ve_array),
  429 + 'url' => $this->source_download($ve, $project_id, $domain_arr['host'], $web_url_domain, $home_url, 1)
  430 + ];
  431 + }
  432 + $value = Arr::a2s($file);
  433 + } else {
  434 + //文本
  435 + $value = $ve;
410 } 436 }
411 437
412 - $extend_info = $extend_info_model->read(['key' => $extend_key, 'product_id' => $id]); 438 + $extend_info = $extend_info_model->read(['key' => $extend['key'], 'product_id' => $id]);
413 if (!$extend_info) { 439 if (!$extend_info) {
414 $extend_info_model->add([ 440 $extend_info_model->add([
415 - 'key' => $extend_key, 441 + 'key' => $extend['key'],
  442 + 'type' => $extend['type'],
416 'project_id' => $project_id, 443 'project_id' => $project_id,
417 'product_id' => $id, 444 'product_id' => $id,
418 - 'values' => $ve,  
419 - 'type' => 1 445 + 'values' => $value,
420 ]); 446 ]);
421 } else { 447 } else {
422 - $extend_info_model->edit(['values' => $ve], ['key' => $extend_key, 'product_id' => $id]); 448 + $extend_info_model->edit(['type' => $extend['type'], 'values' => $value], ['key' => $extend['key'], 'product_id' => $id]);
  449 + }
423 } 450 }
424 } 451 }
425 } 452 }
@@ -712,6 +739,9 @@ class ProjectUpdate extends Command @@ -712,6 +739,9 @@ class ProjectUpdate extends Command
712 if ($six_read) { 739 if ($six_read) {
713 if ($item['extend'] ?? []) { 740 if ($item['extend'] ?? []) {
714 foreach ($item['extend'] as $ke => $ve) { 741 foreach ($item['extend'] as $ke => $ve) {
  742 + if ($ve == '--') {
  743 + $ve = '';
  744 + }
715 $extend = $extend_model->read(['title' => $ke]); 745 $extend = $extend_model->read(['title' => $ke]);
716 if ($extend) { 746 if ($extend) {
717 if ($extend['type'] == 3) { 747 if ($extend['type'] == 3) {
@@ -727,21 +757,24 @@ class ProjectUpdate extends Command @@ -727,21 +757,24 @@ class ProjectUpdate extends Command
727 $value = Arr::a2s($gallery); 757 $value = Arr::a2s($gallery);
728 } elseif ($extend['type'] == 4) { 758 } elseif ($extend['type'] == 4) {
729 //文件 759 //文件
  760 + $file = [];
730 if (is_array($ve)) { 761 if (is_array($ve)) {
731 - if (isset($ve['title']) || isset($ve['url'])) {  
732 - $file = [  
733 - [  
734 - 'name' => isset($ve['title']) ? $ve['title'] : '',  
735 - 'url' => isset($ve['url']) ? $this->source_download($ve['url'], $project_id, $domain_arr['host'], $web_url_domain, $home_url, 1) : ''  
736 - ] 762 + $file_title = $ve['title'] ?? '';
  763 + $file_url = $ve['url'] ?? '';
  764 + if ($file_url) {
  765 + $file[] = [
  766 + 'name' => $file_title,
  767 + 'url' => $this->source_download($file_url, $project_id, $domain_arr['host'], $web_url_domain, $home_url, 1)
737 ]; 768 ];
738 - } else {  
739 - $file = [];  
740 } 769 }
741 - $value = Arr::a2s($file);  
742 - } else {  
743 - $value = Arr::a2s([$this->source_download($ve, $project_id, $domain_arr['host'], $web_url_domain, $home_url, 1)]); 770 + } elseif ($ve) {
  771 + $ve_array = explode('/', $ve);
  772 + $file[] = [
  773 + 'name' => end($ve_array),
  774 + 'url' => $this->source_download($ve, $project_id, $domain_arr['host'], $web_url_domain, $home_url, 1)
  775 + ];
744 } 776 }
  777 + $value = Arr::a2s($file);
745 } else { 778 } else {
746 //文本 779 //文本
747 $value = $ve; 780 $value = $ve;
@@ -1064,8 +1097,8 @@ class ProjectUpdate extends Command @@ -1064,8 +1097,8 @@ class ProjectUpdate extends Command
1064 ]); 1097 ]);
1065 1098
1066 //同步到177 1099 //同步到177
1067 - $error_file = ErrorFile::where('path',$new_url)->first();  
1068 - if(!$error_file){ 1100 + $error_file = ErrorFile::where('path', $new_url)->first();
  1101 + if (!$error_file) {
1069 $error_file = new ErrorFile(); 1102 $error_file = new ErrorFile();
1070 $error_file->path = $new_url; 1103 $error_file->path = $new_url;
1071 $error_file->status = 0; 1104 $error_file->status = 0;
@@ -20,14 +20,14 @@ class Kernel extends ConsoleKernel @@ -20,14 +20,14 @@ class Kernel extends ConsoleKernel
20 $schedule->command('template_label')->dailyAt('01:00')->withoutOverlapping(1);//最新模块 20 $schedule->command('template_label')->dailyAt('01:00')->withoutOverlapping(1);//最新模块
21 $schedule->command('popular_template_label')->dailyAt('01:30')->withoutOverlapping(1);//热门模块 21 $schedule->command('popular_template_label')->dailyAt('01:30')->withoutOverlapping(1);//热门模块
22 // $schedule->command('inspire')->hourly(); 22 // $schedule->command('inspire')->hourly();
23 - $schedule->command('remain_day')->dailyAt('09:30')->withoutOverlapping(1); // 项目剩余服务时长 23 +// $schedule->command('remain_day')->dailyAt('09:30')->withoutOverlapping(1); // 项目剩余服务时长
24 $schedule->command('rank_data_task')->everyMinute()->withoutOverlapping(1); // 排名数据更新任务 24 $schedule->command('rank_data_task')->everyMinute()->withoutOverlapping(1); // 排名数据更新任务
25 $schedule->command('service_count')->dailyAt('01:00')->withoutOverlapping(1); //服务器使用情况,每天凌晨1点执行一次 25 $schedule->command('service_count')->dailyAt('01:00')->withoutOverlapping(1); //服务器使用情况,每天凌晨1点执行一次
26 - $schedule->command('web_traffic_special')->everyMinute()->withoutOverlapping(1); // 特殊引流  
27 - $schedule->command('web_traffic_russia_special')->everyMinute()->withoutOverlapping(1); // 特殊引流 26 +// $schedule->command('web_traffic_special')->everyMinute()->withoutOverlapping(1); // 特殊引流
  27 +// $schedule->command('web_traffic_russia_special')->everyMinute()->withoutOverlapping(1); // 特殊引流
28 $schedule->command('sync_channel')->dailyAt('06:00')->withoutOverlapping(1); // 渠道信息,每天执行一次 28 $schedule->command('sync_channel')->dailyAt('06:00')->withoutOverlapping(1); // 渠道信息,每天执行一次
29 $schedule->command('forward_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计转发询盘记录 29 $schedule->command('forward_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计转发询盘记录
30 - $schedule->command('inquiry_delay')->everyMinute()->withoutOverlapping(1);//TODO::上线放开,转发询盘,每分钟执行一次 30 +// $schedule->command('inquiry_delay')->everyMinute()->withoutOverlapping(1);//TODO::上线放开,转发询盘,每分钟执行一次
31 $schedule->command('inquiry_count')->dailyAt('01:00')->withoutOverlapping(1); // 询盘统计数据,每天凌晨执行一次 31 $schedule->command('inquiry_count')->dailyAt('01:00')->withoutOverlapping(1); // 询盘统计数据,每天凌晨执行一次
32 // $schedule->command('domain_info')->dailyAt('01:20')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次 32 // $schedule->command('domain_info')->dailyAt('01:20')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次
33 $schedule->command('share_user')->dailyAt('01:20')->withoutOverlapping(1);// 每天凌晨1点执行一次 33 $schedule->command('share_user')->dailyAt('01:20')->withoutOverlapping(1);// 每天凌晨1点执行一次
@@ -107,7 +107,6 @@ class QuanqiusouApi @@ -107,7 +107,6 @@ class QuanqiusouApi
107 if($res){ 107 if($res){
108 $res = Arr::s2a($res); 108 $res = Arr::s2a($res);
109 Cache::put($key, $res, 2 * 3600); 109 Cache::put($key, $res, 2 * 3600);
110 - RankDataLog::addLog($project_id, $api_no, $lang, $endDay, $res);  
111 } 110 }
112 } catch (\Exception | GuzzleException $e) { 111 } catch (\Exception | GuzzleException $e) {
113 errorLog('获取谷歌排名数据失败', [$api_no], $e); 112 errorLog('获取谷歌排名数据失败', [$api_no], $e);
@@ -34,14 +34,23 @@ class AdsController extends BaseController @@ -34,14 +34,23 @@ class AdsController extends BaseController
34 */ 34 */
35 public function fbAdsList(Request $request) 35 public function fbAdsList(Request $request)
36 { 36 {
37 - $ads_id = trim($request->input('ads_id')); 37 + $title = trim($request->input('title'));
38 $industry = trim($request->input('industry')); 38 $industry = trim($request->input('industry'));
39 - $result = ReInquiryTask::where(['status' => ReInquiryTask::STATUS_OPEN])  
40 - ->when($ads_id, function ($query, $ads_id) { 39 + $ad_id = trim($request->input('ad_id'));
  40 + $status = $request->input('status', '');
  41 + $result = ReInquiryTask::when($ad_id, function ($query, $ads_id) {
41 return $query->where('ad_id', 'like', '%' . $ads_id . '%'); 42 return $query->where('ad_id', 'like', '%' . $ads_id . '%');
42 }) 43 })
  44 + ->when($title, function ($query, $title) {
  45 + return $query->where('title', 'like', '%' . $title . '%');
  46 + })
43 ->when($industry, function ($query, $industry) { 47 ->when($industry, function ($query, $industry) {
44 - return $query->where('industry', $industry); 48 + return $query->where('industry', 'like', '%' . $industry . '%');
  49 + })
  50 + ->where(function ($query)use($status) {
  51 + if(is_numeric($status)){
  52 + return $query->where('status', $status);
  53 + }
45 }) 54 })
46 ->orderBy('id', 'desc') 55 ->orderBy('id', 'desc')
47 ->paginate(); 56 ->paginate();
@@ -390,6 +390,7 @@ class RankDataLogic extends BaseLogic @@ -390,6 +390,7 @@ class RankDataLogic extends BaseLogic
390 public function syncRankData($api_no, $site_res, $force=false){ 390 public function syncRankData($api_no, $site_res, $force=false){
391 $project_ids = DeployOptimize::where('api_no', $api_no)->pluck('project_id'); 391 $project_ids = DeployOptimize::where('api_no', $api_no)->pluck('project_id');
392 foreach ($project_ids as $project_id) { 392 foreach ($project_ids as $project_id) {
  393 + Log::channel('rank_data')->info('开始查项目:' . $project_id);
393 $project = Project::find($project_id); 394 $project = Project::find($project_id);
394 if (!$project) { 395 if (!$project) {
395 throw new \Exception($api_no . '关联的项目不存在'); 396 throw new \Exception($api_no . '关联的项目不存在');
@@ -397,12 +398,14 @@ class RankDataLogic extends BaseLogic @@ -397,12 +398,14 @@ class RankDataLogic extends BaseLogic
397 $api = new QuanqiusouApi(); 398 $api = new QuanqiusouApi();
398 $model = RankData::where('project_id', $project_id)->where('lang', '')->first(); 399 $model = RankData::where('project_id', $project_id)->where('lang', '')->first();
399 if (!$model || $model->updated_date != date('Y-m-d') || $force) { 400 if (!$model || $model->updated_date != date('Y-m-d') || $force) {
  401 + Log::channel('rank_data')->info('开始接口数据:' . $project_id);
400 $res = $api->getGoogleRank($project_id, $api_no, '', 7, $force); 402 $res = $api->getGoogleRank($project_id, $api_no, '', 7, $force);
401 if (!$res) { 403 if (!$res) {
402 throw new \Exception("接口数据获取失败,api_no:{$api_no}"); 404 throw new \Exception("接口数据获取失败,api_no:{$api_no}");
403 } 405 }
404 //收录数 406 //收录数
405 $indexed_pages_num = $site_res[$api_no] ?? 0; 407 $indexed_pages_num = $site_res[$api_no] ?? 0;
  408 + Log::channel('rank_data')->info('开始保存:' . $project_id);
406 $this->save_rank($project_id, $res, $indexed_pages_num); 409 $this->save_rank($project_id, $res, $indexed_pages_num);
407 } 410 }
408 //有小语种的 411 //有小语种的
@@ -444,13 +447,13 @@ class RankDataLogic extends BaseLogic @@ -444,13 +447,13 @@ class RankDataLogic extends BaseLogic
444 447
445 /** 448 /**
446 * @param $project_id 449 * @param $project_id
447 - * @param int $indexed_pages_num 450 + * @param $indexed_pages_num
448 * @param $data 451 * @param $data
449 * @param string $lang 452 * @param string $lang
450 * @author zbj 453 * @author zbj
451 * @date 2023/5/8 454 * @date 2023/5/8
452 */ 455 */
453 - public function save_rank($project_id, $data, int $indexed_pages_num = 0, string $lang = ''){ 456 + public function save_rank($project_id, $data, $indexed_pages_num = null, string $lang = ''){
454 $without_project_ids = []; //不用处理排名的项目 457 $without_project_ids = []; //不用处理排名的项目
455 $without_extension_project_ids = [658]; //是否达标只统计主词的 458 $without_extension_project_ids = [658]; //是否达标只统计主词的
456 $extension_project_ids = [354]; //扩展词也到达标的 459 $extension_project_ids = [354]; //扩展词也到达标的
@@ -545,11 +548,15 @@ class RankDataLogic extends BaseLogic @@ -545,11 +548,15 @@ class RankDataLogic extends BaseLogic
545 $model->first_three_pages_num = $first_three_pages_num; 548 $model->first_three_pages_num = $first_three_pages_num;
546 $model->first_five_pages_num = $first_five_pages_num; 549 $model->first_five_pages_num = $first_five_pages_num;
547 $model->first_ten_pages_num = $first_ten_pages_num; 550 $model->first_ten_pages_num = $first_ten_pages_num;
  551 + if($indexed_pages_num !== null){
548 $model->indexed_pages_num = $indexed_pages_num; 552 $model->indexed_pages_num = $indexed_pages_num;
  553 + }
549 $model->lang = $lang; 554 $model->lang = $lang;
550 $model->data = $data; 555 $model->data = $data;
551 $model->updated_date = date('Y-m-d'); 556 $model->updated_date = date('Y-m-d');
552 $model->save(); 557 $model->save();
  558 +
  559 + return $model->is_compliance;
553 } 560 }
554 561
555 /** 562 /**
@@ -51,7 +51,7 @@ class InquiryFormData extends Base @@ -51,7 +51,7 @@ class InquiryFormData extends Base
51 //5分钟内是否有重复数据 51 //5分钟内是否有重复数据
52 $is_exist = self::where('sign', $sign)->where('created_at', '>', date('Y-m-d H:i:s', strtotime('-5 minute')))->first(); 52 $is_exist = self::where('sign', $sign)->where('created_at', '>', date('Y-m-d H:i:s', strtotime('-5 minute')))->first();
53 if($is_exist){ 53 if($is_exist){
54 - return true; 54 + return 0;
55 } 55 }
56 56
57 $model = new self(); 57 $model = new self();
@@ -5,6 +5,7 @@ namespace App\Models\RankData; @@ -5,6 +5,7 @@ namespace App\Models\RankData;
5 5
6 use App\Helper\Arr; 6 use App\Helper\Arr;
7 use App\Models\Base; 7 use App\Models\Base;
  8 +use Illuminate\Support\Facades\Redis;
8 9
9 /** 10 /**
10 * Class GoogleRank 11 * Class GoogleRank
@@ -27,22 +28,29 @@ class RankDataLog extends Base @@ -27,22 +28,29 @@ class RankDataLog extends Base
27 return Arr::s2a($value); 28 return Arr::s2a($value);
28 } 29 }
29 30
30 - public static function addLog($project_id, $api_no, $lang, $date, $res){  
31 - $data= [];  
32 - foreach ($res as $key=>$item){  
33 - $data[$key] = $item[$date];  
34 - } 31 + public static function addTask($project_id, $api_no, $lang =''){
  32 + $date = date('Y-m-d');
35 $model = self::where('project_id', $project_id)->where('date', $date)->where('lang', $lang)->first(); 33 $model = self::where('project_id', $project_id)->where('date', $date)->where('lang', $lang)->first();
36 - if(!$model){  
37 - $model = new self(); 34 + if($model){
  35 + //已达标的
  36 + if($model->is_compliance){
  37 + return true;
38 } 38 }
  39 + //有未执行的
  40 + if(!$model->status){
  41 + return true;
  42 + }
  43 + }else{
  44 + $model = new self();
39 $model->project_id = $project_id; 45 $model->project_id = $project_id;
40 $model->api_no = $api_no; 46 $model->api_no = $api_no;
41 $model->lang = $lang; 47 $model->lang = $lang;
42 $model->date = $date; 48 $model->date = $date;
43 - $model->data = $data; 49 + }
  50 + $model->status = 0;
44 $model->save(); 51 $model->save();
45 52
  53 + Redis::lpush('rank_data_task', $model->id);
46 return true; 54 return true;
47 } 55 }
48 56
@@ -63,10 +63,10 @@ class MessagePush extends Base @@ -63,10 +63,10 @@ class MessagePush extends Base
63 $model->type = self::TYPE_INQUIRY; 63 $model->type = self::TYPE_INQUIRY;
64 $model->ref_ids = $id; 64 $model->ref_ids = $id;
65 $model->content = '[' . date('H:i', strtotime($submit_at)) . '] 您的全球搜网站收到来自【' . $country . $name . '】的询盘信息,请登录后台或APP进行查看!'; 65 $model->content = '[' . date('H:i', strtotime($submit_at)) . '] 您的全球搜网站收到来自【' . $country . $name . '】的询盘信息,请登录后台或APP进行查看!';
  66 + $model->send_time = $submit_at;
66 }else{ 67 }else{
67 //定时发送时间 68 //定时发送时间
68 - $send_time = $hour >= 9 ? date('Y-m-d 09:00:00', strtotime('+1 day')) : date('Y-m-d 09:00:00');  
69 - 69 + $send_time = $hour >= 9 ? date('Y-m-d 09:00:00', strtotime($submit_at . '+1 day')) : date('Y-m-d 09:00:00', strtotime($submit_at));
70 $model = self::where('project_id', $project_id)->where('type', self::TYPE_INQUIRY)->where('send_time', $send_time)->first(); 70 $model = self::where('project_id', $project_id)->where('type', self::TYPE_INQUIRY)->where('send_time', $send_time)->first();
71 if(!$model){ 71 if(!$model){
72 $model = new self(); 72 $model = new self();
@@ -159,13 +159,14 @@ class SyncSubmitTaskService @@ -159,13 +159,14 @@ class SyncSubmitTaskService
159 Visit::isInquiry($data['ip']); 159 Visit::isInquiry($data['ip']);
160 160
161 //推送企微消息 161 //推送企微消息
  162 + if($id){
162 try { 163 try {
163 $name = empty($data['data']['name']) ? '' : ' ' . $data['data']['name']; 164 $name = empty($data['data']['name']) ? '' : ' ' . $data['data']['name'];
164 MessagePush::addInquiryMessage($id, $data['project_id'], $data['country'], $name, $data['submit_at']); 165 MessagePush::addInquiryMessage($id, $data['project_id'], $data['country'], $name, $data['submit_at']);
165 }catch (\Exception $e){ 166 }catch (\Exception $e){
166 LogUtils::error('询盘消息'.$id.'写入企微消息队列失败' . $e->getMessage()); 167 LogUtils::error('询盘消息'.$id.'写入企微消息队列失败' . $e->getMessage());
167 } 168 }
168 - 169 + }
169 170
170 return true; 171 return true;
171 } 172 }
@@ -189,6 +190,7 @@ class SyncSubmitTaskService @@ -189,6 +190,7 @@ class SyncSubmitTaskService
189 $referrer_url = $url_arr['scheme'] . '://' . $url_arr['host'] . '/'; 190 $referrer_url = $url_arr['scheme'] . '://' . $url_arr['host'] . '/';
190 } 191 }
191 } 192 }
  193 +
192 $visit_data['referrer_url'] = $this->handle_referer($referrer_url); 194 $visit_data['referrer_url'] = $this->handle_referer($referrer_url);
193 $visit_data['device_port'] = $data['data']['device_port']??''; 195 $visit_data['device_port'] = $data['data']['device_port']??'';
194 $visit_data['url'] = $data['data']['url']??''; 196 $visit_data['url'] = $data['data']['url']??'';
@@ -201,7 +203,7 @@ class SyncSubmitTaskService @@ -201,7 +203,7 @@ class SyncSubmitTaskService
201 if(!empty($data['is_cf'])){ 203 if(!empty($data['is_cf'])){
202 $visit_data['is_inquiry'] = 1; 204 $visit_data['is_inquiry'] = 1;
203 } 205 }
204 - Visit::saveData($visit_data, $date); 206 + Visit::saveData($visit_data, $visit_data['updated_date']);
205 207
206 return true; 208 return true;
207 } 209 }