作者 lyh

gx

@@ -5,7 +5,7 @@ namespace App\Console\Commands\DayCount; @@ -5,7 +5,7 @@ namespace App\Console\Commands\DayCount;
5 use App\Helper\Common; 5 use App\Helper\Common;
6 use App\Helper\FormGlobalsoApi; 6 use App\Helper\FormGlobalsoApi;
7 use App\Models\Domain\DomainInfo; 7 use App\Models\Domain\DomainInfo;
8 -use App\Models\Inquiry\InquiryOther; 8 +use App\Models\Inquiry\InquiryFormData;
9 use App\Models\Project\DeployBuild; 9 use App\Models\Project\DeployBuild;
10 use App\Models\Project\DeployOptimize; 10 use App\Models\Project\DeployOptimize;
11 use App\Models\Project\Project; 11 use App\Models\Project\Project;
@@ -102,7 +102,7 @@ class Count extends Command @@ -102,7 +102,7 @@ class Count extends Command
102 * @time :2023/6/14 15:40 102 * @time :2023/6/14 15:40
103 */ 103 */
104 public function pv_num($yesterday,$domain){ 104 public function pv_num($yesterday,$domain){
105 - $pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count(); 105 + $pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $yesterday)->count();
106 return $pv; 106 return $pv;
107 } 107 }
108 108
@@ -113,7 +113,7 @@ class Count extends Command @@ -113,7 +113,7 @@ class Count extends Command
113 * @time :2023/6/14 15:40 113 * @time :2023/6/14 15:40
114 */ 114 */
115 public function ip_num($yesterday,$domain){ 115 public function ip_num($yesterday,$domain){
116 - $ip = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count(); 116 + $ip = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $yesterday)->count();
117 return $ip; 117 return $ip;
118 } 118 }
119 119
@@ -146,8 +146,8 @@ class Count extends Command @@ -146,8 +146,8 @@ class Count extends Command
146 146
147 //加上其他询盘 147 //加上其他询盘
148 ProjectServer::useProject($project_id); 148 ProjectServer::useProject($project_id);
149 - $arr['inquiry_num'] = InquiryOther::count();  
150 - $countryData = InquiryOther::select("country",DB::raw('COUNT(*) as count'))->groupBy('country')->get()->toArray(); 149 + $arr['inquiry_num'] += InquiryFormData::getCount();
  150 + $countryData = InquiryFormData::getCountryCount();
151 foreach ($countryData as $v1){ 151 foreach ($countryData as $v1){
152 if(isset($countryArr[$v1['country']])){ 152 if(isset($countryArr[$v1['country']])){
153 $countryArr[$v1['country']] += $v1['count']; 153 $countryArr[$v1['country']] += $v1['count'];
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 namespace App\Console\Commands; 3 namespace App\Console\Commands;
4 4
5 use App\Helper\FormGlobalsoApi; 5 use App\Helper\FormGlobalsoApi;
6 -use App\Models\Inquiry\InquiryOther; 6 +use App\Models\Inquiry\InquiryFormData;
7 use App\Models\Project\Project; 7 use App\Models\Project\Project;
8 use App\Services\ProjectServer; 8 use App\Services\ProjectServer;
9 use Illuminate\Console\Command; 9 use Illuminate\Console\Command;
@@ -56,7 +56,7 @@ class LastInquiry extends Command @@ -56,7 +56,7 @@ class LastInquiry extends Command
56 $last_time = $res['data']['data'][0] ?? ''; 56 $last_time = $res['data']['data'][0] ?? '';
57 //其他询盘的最新时间 57 //其他询盘的最新时间
58 ProjectServer::useProject($item['id']); 58 ProjectServer::useProject($item['id']);
59 - $other_last_time = InquiryOther::orderBy('id', 'desc')->value('submit_time'); 59 + $other_last_time = InquiryFormData::orderBy('id', 'desc')->value('submit_at');
60 60
61 $last_inquiry_time = $last_time > $other_last_time ? $last_time : $other_last_time; 61 $last_inquiry_time = $last_time > $other_last_time ? $last_time : $other_last_time;
62 62
@@ -4,7 +4,7 @@ namespace App\Console\Commands\MonthlyCount; @@ -4,7 +4,7 @@ namespace App\Console\Commands\MonthlyCount;
4 4
5 use App\Helper\FormGlobalsoApi; 5 use App\Helper\FormGlobalsoApi;
6 use App\Models\Domain\DomainInfo; 6 use App\Models\Domain\DomainInfo;
7 -use App\Models\Inquiry\InquiryOther; 7 +use App\Models\Inquiry\InquiryFormData;
8 use App\Models\Project\Project; 8 use App\Models\Project\Project;
9 use App\Services\ProjectServer; 9 use App\Services\ProjectServer;
10 use Carbon\Carbon; 10 use Carbon\Carbon;
@@ -107,11 +107,9 @@ class InquiryMonthlyCount extends Command @@ -107,11 +107,9 @@ class InquiryMonthlyCount extends Command
107 } 107 }
108 //加上其他询盘 108 //加上其他询盘
109 ProjectServer::useProject($project_id); 109 ProjectServer::useProject($project_id);
110 - $arr['total'] += InquiryOther::count();  
111 - $arr['month_total'] += InquiryOther::whereBetween('submit_time',[$startTime, $endTime])->count();  
112 - $countryData = InquiryOther::whereBetween('submit_time',[$startTime, $endTime])  
113 - ->select("country",DB::raw('COUNT(*) as count'))  
114 - ->groupBy('country')->get()->toArray(); 110 + $arr['total'] += InquiryFormData::count();
  111 + $arr['month_total'] += InquiryFormData::getCount([$startTime, $endTime]);
  112 + $countryData = InquiryFormData::getCountryCount([$startTime, $endTime]);
115 foreach ($countryData as $v1){ 113 foreach ($countryData as $v1){
116 if(isset($countryArr[$v1['country']])){ 114 if(isset($countryArr[$v1['country']])){
117 $countryArr[$v1['country']] += $v1['count']; 115 $countryArr[$v1['country']] += $v1['count'];
@@ -2,30 +2,24 @@ @@ -2,30 +2,24 @@
2 2
3 namespace App\Console\Commands; 3 namespace App\Console\Commands;
4 4
5 -use App\Http\Logic\Aside\Project\DomainInfoLogic;  
6 -use App\Models\Com\UpdateNotify;  
7 -use App\Models\Devops\DevopsTask as DevopsTaskModel;  
8 -use App\Models\Devops\DevopsTaskLog; 5 +
  6 +
  7 +use App\Helper\FormGlobalsoApi;
9 use App\Models\Domain\DomainInfo; 8 use App\Models\Domain\DomainInfo;
10 -use App\Models\File\File;  
11 -use App\Models\File\Image;  
12 -use App\Models\Product\CategoryRelated;  
13 -use App\Models\Product\Product; 9 +use App\Models\HomeCount\Count;
  10 +use App\Models\Inquiry\InquiryFormData;
14 use App\Models\Project\Project; 11 use App\Models\Project\Project;
15 -use App\Models\RouteMap\RouteMap;  
16 -use App\Models\Template\BCustomTemplate;  
17 use App\Services\ProjectServer; 12 use App\Services\ProjectServer;
18 use Illuminate\Console\Command; 13 use Illuminate\Console\Command;
19 -use Illuminate\Database\QueryException; 14 +use Illuminate\Database\Eloquent\Model;
20 use Illuminate\Support\Facades\DB; 15 use Illuminate\Support\Facades\DB;
21 -use Illuminate\Support\Str; 16 +use mysql_xdevapi\Exception;
22 17
23 /** 18 /**
24 - * 测试  
25 - * Class Traffic 19 + * Class Test
26 * @package App\Console\Commands 20 * @package App\Console\Commands
27 * @author zbj 21 * @author zbj
28 - * @date 2023/5/18 22 + * @date 2023/4/25
29 */ 23 */
30 class Test extends Command 24 class Test extends Command
31 { 25 {
@@ -41,7 +35,7 @@ class Test extends Command @@ -41,7 +35,7 @@ class Test extends Command
41 * 35 *
42 * @var string 36 * @var string
43 */ 37 */
44 - protected $description = '测试'; 38 + protected $description = '';
45 39
46 /** 40 /**
47 * Create a new command instance. 41 * Create a new command instance.
@@ -58,52 +52,70 @@ class Test extends Command @@ -58,52 +52,70 @@ class Test extends Command
58 */ 52 */
59 public function handle() 53 public function handle()
60 { 54 {
61 - $domains = DB::table('gl_customer_visit')->groupBy('domain')->select('domain')->pluck('domain')->toArray();  
62 - foreach($domains as $domain){  
63 - if(!Str::contains($domain, 'globalso.site')){  
64 - $this->sync($domain); 55 + $projects = Project::all();
  56 + foreach ($projects as $project){
  57 + echo "project " . $project->id;
  58 + if(!ProjectServer::useProject($project->id)){
  59 + echo '未配置数据库' . PHP_EOL;
  60 + continue;
  61 + }
  62 + $test_domain = $project->deploy_build['test_domain'];
  63 + $domainInfo = new DomainInfo();
  64 + $info = $domainInfo->read(['id'=>$project->deploy_optimize['domain']]);
  65 + if($info !== false){
  66 + $test_domain = $info['domain'];
  67 + }
  68 +
  69 + try {
  70 + $list = Count::where('date', '2023-12-11')->where('project_id', $project->id)->get();
  71 + foreach ($list as $v){
  72 + $arr = $this->inquiry([],$test_domain, $v['id']);
  73 + $v->inquiry_num = $arr['inquiry_num'];
  74 + $v->country = $arr['country'];
  75 + $v->save();
  76 + echo $v['date'] . ':' . $v->pv_num .':'. $v->ip_num . PHP_EOL;
  77 + }
  78 + }catch (\Exception $e){
  79 + echo '保存失败' . $e->getMessage() . PHP_EOL;
65 } 80 }
66 } 81 }
  82 + echo "finish";
67 } 83 }
68 84
69 - public function sync($domain){  
70 - echo date('Y-m-d H:i:s') . "同步项目{$domain}" . PHP_EOL;  
71 - if(!Str::startsWith($domain,'www.')){  
72 - $domain = 'www.'.$domain;  
73 - }  
74 - $project_id = DomainInfo::where('domain', $domain)->value('project_id');  
75 - if(!$project_id){  
76 - echo date('Y-m-d H:i:s') . "项目{$domain}不存在" . PHP_EOL;  
77 - return true;  
78 - }  
79 - if(!ProjectServer::useProject($project_id)){  
80 - echo date('Y-m-d H:i:s') . "项目{$domain}数据库配置无效" . PHP_EOL;  
81 - return true; 85 + public function inquiry($arr,$domain,$project_id){
  86 + $inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
  87 + if($inquiry_list['status'] == 400){
  88 + $arr['inquiry_num'] = 0;
  89 + $countryArr = [];
  90 + }else{
  91 + $arr['inquiry_num'] = $inquiry_list['data']['total'];
  92 + //询盘国家统计
  93 + $countryData = $inquiry_list['data']['data'];
  94 + $countryArr = [];
  95 + foreach ($countryData as $v1){
  96 + if(isset($countryArr[$v1['country']])){
  97 + $countryArr[$v1['country']]++;
  98 + }else{
  99 + $countryArr[$v1['country']] = 1;
  100 + }
  101 + }
82 } 102 }
83 - $visit = 0;  
84 - $visit_item = 0;  
85 - $list = DB::table('gl_customer_visit')->whereIn('domain', [$domain, str_replace('www.','',$domain)])->get();  
86 - foreach ($list as $v){  
87 - $v = (array) $v;  
88 -  
89 - $items = DB::table('gl_customer_visit_item')->where('customer_visit_id', $v['id'])->get();  
90 -  
91 - unset($v['id']);  
92 - $id = DB::connection('custom_mysql')->table('gl_customer_visit')->insertGetId($v);  
93 -  
94 - $visit++;  
95 103
96 - $data = [];  
97 - foreach ($items as $item){  
98 - $item = (array) $item;  
99 - unset($item['id']);  
100 - $item['customer_visit_id'] = $id;  
101 - $data[] = $item;  
102 - $visit_item++; 104 + //加上其他询盘
  105 + $arr['inquiry_num'] += InquiryFormData::getCount();
  106 + $countryData = InquiryFormData::getCountryCount();
  107 + foreach ($countryData as $v1){
  108 + if(isset($countryArr[$v1['country']])){
  109 + $countryArr[$v1['country']] += $v1['count'];
  110 + }else{
  111 + $countryArr[$v1['country']] = $v1['count'];
103 } 112 }
104 - DB::connection('custom_mysql')->table('gl_customer_visit_item')->insert($data);  
105 } 113 }
106 - echo date('Y-m-d H:i:s') . "visit:{$visit};item:{$visit_item}" . PHP_EOL;exit;  
107 - }  
108 114
  115 +
  116 + arsort($countryArr);
  117 + $top20 = array_slice($countryArr, 0, 20, true);
  118 + $arr['country'] = json_encode($top20);
  119 + return $arr;
  120 + }
109 } 121 }
@@ -9,7 +9,6 @@ use App\Models\RouteMap\RouteMap; @@ -9,7 +9,6 @@ use App\Models\RouteMap\RouteMap;
9 use App\Services\CosService; 9 use App\Services\CosService;
10 use App\Services\ProjectServer; 10 use App\Services\ProjectServer;
11 use Illuminate\Console\Command; 11 use Illuminate\Console\Command;
12 -use Illuminate\Support\Facades\Cache;  
13 use Illuminate\Support\Facades\DB; 12 use Illuminate\Support\Facades\DB;
14 use Illuminate\Support\Facades\Redis; 13 use Illuminate\Support\Facades\Redis;
15 14
@@ -77,8 +76,8 @@ class HtmlCollect extends Command @@ -77,8 +76,8 @@ class HtmlCollect extends Command
77 $collect_info->status = CollectTask::STATUS_ING; 76 $collect_info->status = CollectTask::STATUS_ING;
78 $collect_info->save(); 77 $collect_info->save();
79 78
80 - //获取站点正式和测试域名  
81 - $old_info = $this->getOldDomain($project_id, $collect_info->domain); 79 + //获取站点原始域名信息
  80 + $old_info = getOldDomain($project_id, $collect_info->domain);
82 81
83 //采集html页面,下载资源到本地并替换 82 //采集html页面,下载资源到本地并替换
84 try { 83 try {
@@ -183,42 +182,6 @@ class HtmlCollect extends Command @@ -183,42 +182,6 @@ class HtmlCollect extends Command
183 return $task_id; 182 return $task_id;
184 } 183 }
185 184
186 - //获取站点老域名  
187 - protected function getOldDomain($project_id, $domain)  
188 - {  
189 - $key = 'project_collect_domain_' . $project_id;  
190 -  
191 - $data = Cache::get($key);  
192 -  
193 - if (!$data) {  
194 - $web_url_domain = $domain;  
195 - $home_url = $domain;  
196 -  
197 - $url_web_config = 'https://' . $domain . '/wp-content/cache/user_config.text';  
198 - $data_config = curl_c($url_web_config);  
199 - if ($data_config) {  
200 - $web_url_arr = parse_url($data_config['web_url_domain'] ?? '');  
201 - if (isset($web_url_arr['host'])) {  
202 - $web_url_domain = $web_url_arr['host'];  
203 - }  
204 -  
205 - $home_url_arr = parse_url($data_config['home_url'] ?? '');  
206 - if (isset($home_url_arr['host'])) {  
207 - $home_url = $home_url_arr['host'];  
208 - }  
209 - }  
210 -  
211 - $data = [  
212 - 'web_url_domain' => $web_url_domain,  
213 - 'home_url' => $home_url,  
214 - ];  
215 -  
216 - Cache::add($key, $data, 3600);//缓存1小时  
217 - }  
218 -  
219 - return $data;  
220 - }  
221 -  
222 //正则匹配html资源 185 //正则匹配html资源
223 protected function html_preg($html, $project_id, $domain, $web_url_domain, $home_url) 186 protected function html_preg($html, $project_id, $domain, $web_url_domain, $home_url)
224 { 187 {
@@ -9,7 +9,6 @@ use App\Models\RouteMap\RouteMap; @@ -9,7 +9,6 @@ use App\Models\RouteMap\RouteMap;
9 use App\Services\CosService; 9 use App\Services\CosService;
10 use App\Services\ProjectServer; 10 use App\Services\ProjectServer;
11 use Illuminate\Console\Command; 11 use Illuminate\Console\Command;
12 -use Illuminate\Support\Facades\Cache;  
13 use Illuminate\Support\Facades\DB; 12 use Illuminate\Support\Facades\DB;
14 use Illuminate\Support\Facades\Redis; 13 use Illuminate\Support\Facades\Redis;
15 14
@@ -78,7 +77,7 @@ class HtmlLanguageCollect extends Command @@ -78,7 +77,7 @@ class HtmlLanguageCollect extends Command
78 $collect_info->save(); 77 $collect_info->save();
79 78
80 //获取站点正式和测试域名 79 //获取站点正式和测试域名
81 - $old_info = $this->getOldDomain($project_id, $collect_info->domain); 80 + $old_info = getOldDomain($project_id, $collect_info->domain);
82 81
83 //采集html页面,下载资源到本地并替换 82 //采集html页面,下载资源到本地并替换
84 try { 83 try {
@@ -183,42 +182,6 @@ class HtmlLanguageCollect extends Command @@ -183,42 +182,6 @@ class HtmlLanguageCollect extends Command
183 return $task_id; 182 return $task_id;
184 } 183 }
185 184
186 - //获取站点老域名  
187 - protected function getOldDomain($project_id, $domain)  
188 - {  
189 - $key = 'project_collect_lan_domain_' . $project_id;  
190 -  
191 - $data = Cache::get($key);  
192 -  
193 - if (!$data) {  
194 - $web_url_domain = $domain;  
195 - $home_url = $domain;  
196 -  
197 - $url_web_config = 'https://' . $domain . '/wp-content/cache/user_config.text';  
198 - $data_config = curl_c($url_web_config);  
199 - if ($data_config) {  
200 - $web_url_arr = parse_url($data_config['web_url_domain'] ?? '');  
201 - if (isset($web_url_arr['host'])) {  
202 - $web_url_domain = $web_url_arr['host'];  
203 - }  
204 -  
205 - $home_url_arr = parse_url($data_config['home_url'] ?? '');  
206 - if (isset($home_url_arr['host'])) {  
207 - $home_url = $home_url_arr['host'];  
208 - }  
209 - }  
210 -  
211 - $data = [  
212 - 'web_url_domain' => $web_url_domain,  
213 - 'home_url' => $home_url,  
214 - ];  
215 -  
216 - Cache::add($key, $data, 3600);//缓存1小时  
217 - }  
218 -  
219 - return $data;  
220 - }  
221 -  
222 //正则匹配html资源 185 //正则匹配html资源
223 protected function html_preg($html, $project_id, $domain, $web_url_domain, $home_url) 186 protected function html_preg($html, $project_id, $domain, $web_url_domain, $home_url)
224 { 187 {
@@ -73,6 +73,7 @@ class ProjectUpdate extends Command @@ -73,6 +73,7 @@ class ProjectUpdate extends Command
73 $api_type = $task->api_type; 73 $api_type = $task->api_type;
74 $api_url_arr = explode('?', $task->api_url); 74 $api_url_arr = explode('?', $task->api_url);
75 $api_url = $api_url_arr[0]; 75 $api_url = $api_url_arr[0];
  76 + $domain_arr = parse_url($api_url);
76 77
77 $page_size = 20; 78 $page_size = 20;
78 79
@@ -81,26 +82,12 @@ class ProjectUpdate extends Command @@ -81,26 +82,12 @@ class ProjectUpdate extends Command
81 $task->status = UpdateLog::STATUS_ING;//同步中 82 $task->status = UpdateLog::STATUS_ING;//同步中
82 $task->save(); 83 $task->save();
83 84
84 - $domain_arr = parse_url($api_url);  
85 - //获取网站配置  
86 - $link_type = 0;  
87 - $web_url_domain = $domain_arr['host'];  
88 - $home_url = $domain_arr['host'];  
89 - $url_web_config = 'https://' . $domain_arr['host'] . '/wp-content/cache/user_config.text';  
90 - $data_config = curl_c($url_web_config);  
91 - if ($data_config) {  
92 - $link_type = $data_config['link_type'] ?? 0;  
93 -  
94 - $web_url_arr = parse_url($data_config['web_url_domain'] ?? '');  
95 - if (isset($web_url_arr['host'])) {  
96 - $web_url_domain = $web_url_arr['host'];  
97 - } 85 + //获取站点原始域名信息
  86 + $old_info = getOldDomain($project_id, $domain_arr['host']);
  87 + $link_type = $old_info['link_type'];
  88 + $web_url_domain = $old_info['web_url_domain'];
  89 + $home_url = $old_info['home_url'];
98 90
99 - $home_url_arr = parse_url($data_config['home_url'] ?? '');  
100 - if (isset($home_url_arr['host'])) {  
101 - $home_url = $home_url_arr['host'];  
102 - }  
103 - }  
104 //获取所有语种 91 //获取所有语种
105 $language_list = []; 92 $language_list = [];
106 $url_language = 'https://' . $domain_arr['host'] . '/wp-content/plugins/proofreading/json/user_language.json'; 93 $url_language = 'https://' . $domain_arr['host'] . '/wp-content/plugins/proofreading/json/user_language.json';
@@ -108,6 +95,7 @@ class ProjectUpdate extends Command @@ -108,6 +95,7 @@ class ProjectUpdate extends Command
108 if ($data_language) { 95 if ($data_language) {
109 $language_list = array_column($data_language, 'short'); 96 $language_list = array_column($data_language, 'short');
110 } 97 }
  98 +
111 //获取所有页面 99 //获取所有页面
112 $page_list = []; 100 $page_list = [];
113 $url_page = 'https://' . $domain_arr['host'] . '/wp-content/cache/pages_list.json'; 101 $url_page = 'https://' . $domain_arr['host'] . '/wp-content/cache/pages_list.json';
@@ -480,16 +468,19 @@ class ProjectUpdate extends Command @@ -480,16 +468,19 @@ class ProjectUpdate extends Command
480 //获取地址路由 468 //获取地址路由
481 protected function get_url_route($url) 469 protected function get_url_route($url)
482 { 470 {
483 - $arr = parse_url(urldecode($url)); 471 + if (strpos($url, '%ec') !== false) {
  472 + $url = str_replace('%ec', 'v6SpecialStr', $url);
  473 + $url = urldecode($url);
  474 + $url = str_replace('v6SpecialStr', '%ec', $url);
  475 + } else {
  476 + $url = urldecode($url);
  477 + }
  478 + $arr = parse_url($url);
484 if (empty($arr['path'])) { 479 if (empty($arr['path'])) {
485 return ''; 480 return '';
486 } 481 }
487 $path = $arr['path']; 482 $path = $arr['path'];
488 483
489 - if (strpos($path, '.') !== false) {  
490 - $path = substr($path, 0, strpos($path, '.'));  
491 - }  
492 -  
493 $path_arr = explode('/', $path); 484 $path_arr = explode('/', $path);
494 485
495 return end($path_arr) ? end($path_arr) : $path_arr[count($path_arr) - 2]; 486 return end($path_arr) ? end($path_arr) : $path_arr[count($path_arr) - 2];
@@ -623,8 +614,11 @@ class ProjectUpdate extends Command @@ -623,8 +614,11 @@ class ProjectUpdate extends Command
623 614
624 $url_complete = ($scheme ?: 'https') . '://' . ($host ?: $domain) . $path; 615 $url_complete = ($scheme ?: 'https') . '://' . ($host ?: $domain) . $path;
625 616
626 - if ((empty($host) || $host == $web_url_domain || $host == $home_url) && $path) {  
627 - 617 + if (
  618 + (empty($scheme) || $scheme == 'https' || $scheme == 'http')
  619 + && (empty($host) || (strpos($web_url_domain, $host) !== false) || (strpos($home_url, $host) !== false))
  620 + && $path
  621 + ) {
628 $source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first(); 622 $source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first();
629 if (!$source) { 623 if (!$source) {
630 $new_url = CosService::uploadRemote($project_id, 'image_product', $url_complete); 624 $new_url = CosService::uploadRemote($project_id, 'image_product', $url_complete);
@@ -68,6 +68,7 @@ class UpdateRoute extends Command @@ -68,6 +68,7 @@ class UpdateRoute extends Command
68 */ 68 */
69 public function getProductKeyword(){ 69 public function getProductKeyword(){
70 $keywordModel = new Keyword(); 70 $keywordModel = new Keyword();
  71 +<<<<<<< HEAD
71 $lists = $keywordModel->list(['route'=>'']); 72 $lists = $keywordModel->list(['route'=>'']);
72 if(!empty($lists)){ 73 if(!empty($lists)){
73 foreach ($lists as $v){ 74 foreach ($lists as $v){
@@ -75,9 +76,32 @@ class UpdateRoute extends Command @@ -75,9 +76,32 @@ class UpdateRoute extends Command
75 $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $this->user['project_id']); 76 $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $this->user['project_id']);
76 $this->curlDelRoute(['new_route'=>$route]); 77 $this->curlDelRoute(['new_route'=>$route]);
77 $this->model->edit(['route'=>$route],['id'=>$v['id']]); 78 $this->model->edit(['route'=>$route],['id'=>$v['id']]);
  79 +=======
  80 + $lists = $keywordModel->list(['route'=>null]);
  81 + if(!empty($lists)){
  82 + foreach ($lists as $v){
  83 + echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL;
  84 + $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], 75);
  85 + $this->curlDelRoute(['new_route'=>$route]);
  86 + $keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
  87 +>>>>>>> 8178402b9bc03df4ea9fefb41f4f06aaeb5f6cb5
78 echo date('Y-m-d H:i:s') . 'end :'.$route . PHP_EOL; 88 echo date('Y-m-d H:i:s') . 'end :'.$route . PHP_EOL;
79 } 89 }
80 } 90 }
81 } 91 }
82 92
  93 + /**
  94 + * @remark :删除路由通知C端
  95 + * @name :curlDelRoute
  96 + * @author :lyh
  97 + * @method :post
  98 + * @time :2023/11/30 14:43
  99 + */
  100 + public function curlDelRoute($data){
  101 + $data['project_id'] = 75;
  102 + $str = http_build_query($data);
  103 + $url = 'https://www.zrutong.com/api/delHtml/?'.$str;
  104 + curlGet($url);
  105 + return true;
  106 + }
83 } 107 }
@@ -9,6 +9,7 @@ use GuzzleHttp\Client; @@ -9,6 +9,7 @@ use GuzzleHttp\Client;
9 use GuzzleHttp\Exception\GuzzleException; 9 use GuzzleHttp\Exception\GuzzleException;
10 use Illuminate\Support\Carbon; 10 use Illuminate\Support\Carbon;
11 use App\Models\File\File; 11 use App\Models\File\File;
  12 +use Illuminate\Support\Facades\Cache;
12 use Illuminate\Support\Facades\Redis; 13 use Illuminate\Support\Facades\Redis;
13 14
14 define('HTTP_OPENAI_URL', 'http://openai.waimaoq.com/'); 15 define('HTTP_OPENAI_URL', 'http://openai.waimaoq.com/');
@@ -654,6 +655,7 @@ function redis_add($key,$val,$ttl=3600){ @@ -654,6 +655,7 @@ function redis_add($key,$val,$ttl=3600){
654 * 判断远程地址是否需要下载 655 * 判断远程地址是否需要下载
655 * @param $url 656 * @param $url
656 * @author Akun 657 * @author Akun
  658 + * @return bool
657 * @date 2023/12/08 14:17 659 * @date 2023/12/08 14:17
658 */ 660 */
659 function check_remote_url_down($url){ 661 function check_remote_url_down($url){
@@ -689,3 +691,50 @@ function check_remote_url_down($url){ @@ -689,3 +691,50 @@ function check_remote_url_down($url){
689 691
690 return true; 692 return true;
691 } 693 }
  694 +
  695 +/**
  696 + * 获取升级项目原始域名
  697 + * @param $project_id
  698 + * @param $domain
  699 + * @return array
  700 + * @author Akun
  701 + * @date 2023/12/12 10:52
  702 + */
  703 +function getOldDomain($project_id, $domain)
  704 +{
  705 + $key = 'project_collect_domain_' . $project_id;
  706 +
  707 + $data = Cache::get($key);
  708 +
  709 + if (!$data) {
  710 + $link_type = 0;
  711 + $web_url_domain = $domain;
  712 + $home_url = $domain;
  713 +
  714 + $url_web_config = 'https://' . $domain . '/wp-content/cache/user_config.text';
  715 + $data_config = curl_c($url_web_config);
  716 + if ($data_config) {
  717 + $link_type = $data_config['link_type'] ?? 0;
  718 +
  719 + $web_url_arr = parse_url($data_config['web_url_domain'] ?? '');
  720 + if (isset($web_url_arr['host'])) {
  721 + $web_url_domain = $web_url_arr['host'];
  722 + }
  723 +
  724 + $home_url_arr = parse_url($data_config['home_url'] ?? '');
  725 + if (isset($home_url_arr['host'])) {
  726 + $home_url = $home_url_arr['host'];
  727 + }
  728 + }
  729 +
  730 + $data = [
  731 + 'link_type' => $link_type,
  732 + 'web_url_domain' => $web_url_domain,
  733 + 'home_url' => $home_url,
  734 + ];
  735 +
  736 + Cache::add($key, $data, 3600);//缓存1小时
  737 + }
  738 +
  739 + return $data;
  740 +}
@@ -65,7 +65,7 @@ class ProjectLogic extends BaseLogic @@ -65,7 +65,7 @@ class ProjectLogic extends BaseLogic
65 public function getProjectInfo($id){ 65 public function getProjectInfo($id){
66 $info = $this->model->with('payment')->with('deploy_build')->with('deploy_optimize')->with('online_check') 66 $info = $this->model->with('payment')->with('deploy_build')->with('deploy_optimize')->with('online_check')
67 ->with('project_after')->where(['id'=>$id])->first()->toArray(); 67 ->with('project_after')->where(['id'=>$id])->first()->toArray();
68 - $info['online_check']['name'] = (new Manage())->getName(!empty($info['online_check']['created_manage_id']) ?? ''); 68 + $info['online_check']['name'] = (new Manage())->getName($info['online_check']['created_manage_id']);
69 $info['deploy_optimize']['minor_keywords'] = !empty($info['deploy_optimize']['minor_keywords']) ? json_decode($info['deploy_optimize']['minor_keywords']) : []; 69 $info['deploy_optimize']['minor_keywords'] = !empty($info['deploy_optimize']['minor_keywords']) ? json_decode($info['deploy_optimize']['minor_keywords']) : [];
70 $info['init_domain'] = $this->getInitDomain($info['serve_id'])['domain']; 70 $info['init_domain'] = $this->getInitDomain($info['serve_id'])['domain'];
71 if($info['extend_type'] != 0){ 71 if($info['extend_type'] != 0){
@@ -138,12 +138,17 @@ class CountLogic extends BaseLogic @@ -138,12 +138,17 @@ class CountLogic extends BaseLogic
138 $customerVisitModel = new Visit(); 138 $customerVisitModel = new Visit();
139 $data = $customerVisitModel->select('referrer_url', DB::raw('COUNT(*) as count')) 139 $data = $customerVisitModel->select('referrer_url', DB::raw('COUNT(*) as count'))
140 ->groupBy('referrer_url')->where(['domain'=>$this->user['domain']]) 140 ->groupBy('referrer_url')->where(['domain'=>$this->user['domain']])
141 - ->orderByDesc('count')->limit(8)->get()->toArray(); 141 + ->orderByDesc('count')->limit(9)->get()->toArray();
142 $total = $customerVisitModel->count(); 142 $total = $customerVisitModel->count();
143 if(!empty($data)){ 143 if(!empty($data)){
144 foreach ($data as $k=>$v){ 144 foreach ($data as $k=>$v){
  145 + if(empty($v['referrer_url'])){
  146 + unset($data[$k]);
  147 + continue;
  148 + }
145 $data[$k]['proportion'] = ($v['count']/$total) * 100; 149 $data[$k]['proportion'] = ($v['count']/$total) * 100;
146 } 150 }
  151 + $data = array_values($data);
147 } 152 }
148 return $this->success($data); 153 return $this->success($data);
149 } 154 }
@@ -6,7 +6,7 @@ use App\Helper\FormGlobalsoApi; @@ -6,7 +6,7 @@ use App\Helper\FormGlobalsoApi;
6 use App\Http\Logic\Bside\BaseLogic; 6 use App\Http\Logic\Bside\BaseLogic;
7 use App\Models\HomeCount\Count; 7 use App\Models\HomeCount\Count;
8 use App\Models\HomeCount\MonthCount; 8 use App\Models\HomeCount\MonthCount;
9 -use App\Models\Inquiry\InquiryOther; 9 +use App\Models\Inquiry\InquiryFormData;
10 use App\Models\Project\DeployOptimize; 10 use App\Models\Project\DeployOptimize;
11 use App\Services\ProjectServer; 11 use App\Services\ProjectServer;
12 use Carbon\Carbon; 12 use Carbon\Carbon;
@@ -86,11 +86,9 @@ class MonthCountLogic extends BaseLogic @@ -86,11 +86,9 @@ class MonthCountLogic extends BaseLogic
86 } 86 }
87 } 87 }
88 //加上其他询盘 88 //加上其他询盘
89 - $arr['total'] += InquiryOther::count();  
90 - $arr['month_total'] += InquiryOther::whereBetween('submit_time',[$startTime, $endTime])->count();  
91 - $countryData = InquiryOther::whereBetween('submit_time',[$startTime, $endTime])  
92 - ->select("country",DB::raw('COUNT(*) as count'))  
93 - ->groupBy('country')->get()->toArray(); 89 + $arr['total'] += InquiryFormData::getCount();
  90 + $arr['month_total'] += InquiryFormData::getCount([$startTime, $endTime]);
  91 + $countryData = InquiryFormData::getCountryCount([$startTime, $endTime]);
94 foreach ($countryData as $v1){ 92 foreach ($countryData as $v1){
95 if(isset($countryArr[$v1['country']])){ 93 if(isset($countryArr[$v1['country']])){
96 $countryArr[$v1['country']] += $v1['count']; 94 $countryArr[$v1['country']] += $v1['count'];
@@ -95,6 +95,11 @@ class InquiryLogic extends BaseLogic @@ -95,6 +95,11 @@ class InquiryLogic extends BaseLogic
95 ->select($fields)->orderBy('id', 'desc')->paginate($page_size, ['*'], 'page', $page); 95 ->select($fields)->orderBy('id', 'desc')->paginate($page_size, ['*'], 'page', $page);
96 $data = $lists->toArray(); 96 $data = $lists->toArray();
97 foreach ($data['list'] as &$v){ 97 foreach ($data['list'] as &$v){
  98 + foreach ($v['data'] as &$field){
  99 + if(is_array($field) && !empty($field['path'])){
  100 + $field['path'] = getImageUrl($field['path']);
  101 + }
  102 + }
98 $v = array_merge($v, $v['data']); 103 $v = array_merge($v, $v['data']);
99 } 104 }
100 return $this->success($data); 105 return $this->success($data);
@@ -4,6 +4,7 @@ namespace App\Models\Inquiry; @@ -4,6 +4,7 @@ namespace App\Models\Inquiry;
4 4
5 use App\Models\Base; 5 use App\Models\Base;
6 use Illuminate\Database\Eloquent\SoftDeletes; 6 use Illuminate\Database\Eloquent\SoftDeletes;
  7 +use Illuminate\Support\Facades\DB;
7 8
8 /** 9 /**
9 * Class InquiryFormData 10 * Class InquiryFormData
@@ -26,4 +27,32 @@ class InquiryFormData extends Base @@ -26,4 +27,32 @@ class InquiryFormData extends Base
26 { 27 {
27 return json_decode($value, true); 28 return json_decode($value, true);
28 } 29 }
  30 +
  31 + /**
  32 + * 非默认表单的数量统计
  33 + * @author zbj
  34 + * @date 2023/12/12
  35 + */
  36 + public static function getCount($submit_at = []){
  37 + return self::leftjoin('gl_inquiry_form', 'gl_inquiry_form.id', '=', 'gl_inquiry_form_data.form_id')
  38 + ->where('gl_inquiry_form.is_default', 0)
  39 + ->when($submit_at, function ($query, $submit_at) {
  40 + $query->whereBetween('submit_at',[$submit_at[0], $submit_at[1]]);
  41 + })
  42 + ->count();
  43 + }
  44 +
  45 + /**
  46 + * 非默认表单的国家统计
  47 + * @author zbj
  48 + * @date 2023/12/12
  49 + */
  50 + public static function getCountryCount($submit_at = []){
  51 + return self::leftjoin('gl_inquiry_form', 'gl_inquiry_form.id', '=', 'gl_inquiry_form_data.form_id')
  52 + ->where('gl_inquiry_form.is_default', 0)
  53 + ->when($submit_at, function ($query, $submit_at) {
  54 + $query->whereBetween('submit_at',[$submit_at[0], $submit_at[1]]);
  55 + })
  56 + ->select("country",DB::raw('COUNT(*) as count'))->groupBy('country')->get()->toArray();
  57 + }
29 } 58 }
@@ -38,9 +38,11 @@ class Manage extends Base @@ -38,9 +38,11 @@ class Manage extends Base
38 */ 38 */
39 public function getName($id){ 39 public function getName($id){
40 $name = ''; 40 $name = '';
41 - $info = $this->read(['id'=>$id],['id','name']);  
42 - if($info !== false){  
43 - $name = $info['name']; 41 + if(!empty($id)){
  42 + $info = $this->read(['id'=>$id],['id','name']);
  43 + if($info !== false){
  44 + $name = $info['name'];
  45 + }
44 } 46 }
45 return $name; 47 return $name;
46 } 48 }