作者 赵彬吉
@@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
10 namespace App\Console\Commands\LyhTest; 10 namespace App\Console\Commands\LyhTest;
11 11
12 use App\Models\Project\AiBlogTask; 12 use App\Models\Project\AiBlogTask;
  13 +use App\Models\Project\Project;
13 use Illuminate\Console\Command; 14 use Illuminate\Console\Command;
14 use Illuminate\Support\Facades\Artisan; 15 use Illuminate\Support\Facades\Artisan;
15 use Illuminate\Support\Facades\DB; 16 use Illuminate\Support\Facades\DB;
@@ -31,12 +32,8 @@ class lyhDemo extends Command @@ -31,12 +32,8 @@ class lyhDemo extends Command
31 protected $description = '更新路由'; 32 protected $description = '更新路由';
32 33
33 public function handle(){ 34 public function handle(){
34 - $aiBlogTaskModel = new AiBlogTask();  
35 - $lists = $aiBlogTaskModel->distinct()->pluck('project_id')->toArray();  
36 - foreach ($lists as $v){  
37 - echo '执行的项目id:'.$v;  
38 - Artisan::call('save_ai_blog_list', ['project_id' => $v]);  
39 - }  
40 - return true; 35 + $projectModel = new Project();
  36 + $lists = $projectModel->list(['from_order_id'=>null]);
  37 + return true;
41 } 38 }
42 } 39 }
@@ -269,6 +269,16 @@ class SyncProject extends Command @@ -269,6 +269,16 @@ class SyncProject extends Command
269 } 269 }
270 270
271 /** 271 /**
  272 + * @remark :生成唯一的13位数字
  273 + * @name :stringTo13DigitNumber
  274 + * @author :lyh
  275 + * @method :post
  276 + * @time :2025/3/27 15:09
  277 + */
  278 + public function generateUniqueString($input) {
  279 + return substr(md5($input), 0, 13);
  280 + }
  281 + /**
272 * @remark :设置post_id 282 * @remark :设置post_id
273 * @name :setPostId 283 * @name :setPostId
274 * @author :lyh 284 * @author :lyh
@@ -299,6 +309,9 @@ class SyncProject extends Command @@ -299,6 +309,9 @@ class SyncProject extends Command
299 $param['channel'] = Arr::a2s(["user_id"=>"", "zone_id"=>"", "channel_id"=>""]); 309 $param['channel'] = Arr::a2s(["user_id"=>"", "zone_id"=>"", "channel_id"=>""]);
300 } 310 }
301 $projectModel = new Project(); 311 $projectModel = new Project();
  312 + if(empty($param['from_order_id'])){
  313 + $param['from_order_id'] = $this->generateUniqueString($param['notice_order_id']);
  314 + }
302 $info = $projectModel->read(['from_order_id'=>$param['from_order_id'],'delete_status'=>0]); 315 $info = $projectModel->read(['from_order_id'=>$param['from_order_id'],'delete_status'=>0]);
303 if($info !== false){ 316 if($info !== false){
304 unset($param['type']); //更新的 不更新状态了 317 unset($param['type']); //更新的 不更新状态了
@@ -973,5 +973,261 @@ class Country @@ -973,5 +973,261 @@ class Country
973 ] 973 ]
974 }'; 974 }';
975 975
  976 + /**
  977 + * @remark :国家码与国家名称的映射
  978 + * @name :getCountryNameByAlpha3
  979 + * @author :lyh
  980 + * @method :post
  981 + * @time :2025/3/27 10:38
  982 + */
  983 +public function getCountryNameByAlpha3($alpha3) {
  984 + // ISO 3166-1 alpha-3 国家码与国家名称的映射
  985 + $countries = [
  986 + 'AFG' => 'Afghanistan',
  987 + 'ALB' => 'Albania',
  988 + 'DZA' => 'Algeria',
  989 + 'AND' => 'Andorra',
  990 + 'AGO' => 'Angola',
  991 + 'ATG' => 'Antigua and Barbuda',
  992 + 'ARG' => 'Argentina',
  993 + 'ARM' => 'Armenia',
  994 + 'AUS' => 'Australia',
  995 + 'AUT' => 'Austria',
  996 + 'AZE' => 'Azerbaijan',
  997 + 'BHS' => 'Bahamas',
  998 + 'BHR' => 'Bahrain',
  999 + 'BGD' => 'Bangladesh',
  1000 + 'BRB' => 'Barbados',
  1001 + 'BLR' => 'Belarus',
  1002 + 'BEL' => 'Belgium',
  1003 + 'BLZ' => 'Belize',
  1004 + 'BEN' => 'Benin',
  1005 + 'BTN' => 'Bhutan',
  1006 + 'BOL' => 'Bolivia',
  1007 + 'BES' => 'Bonaire, Sint Eustatius and Saba',
  1008 + 'BIH' => 'Bosnia and Herzegovina',
  1009 + 'BWA' => 'Botswana',
  1010 + 'BVT' => 'Bouvet Island',
  1011 + 'BRA' => 'Brazil',
  1012 + 'IOT' => 'British Indian Ocean Territory',
  1013 + 'BRN' => 'Brunei Darussalam',
  1014 + 'BGR' => 'Bulgaria',
  1015 + 'BFA' => 'Burkina Faso',
  1016 + 'BDI' => 'Burundi',
  1017 + 'CPV' => 'Cabo Verde',
  1018 + 'KHM' => 'Cambodia',
  1019 + 'CMR' => 'Cameroon',
  1020 + 'CAN' => 'Canada',
  1021 + 'CYM' => 'Cayman Islands',
  1022 + 'CAF' => 'Central African Republic',
  1023 + 'TCD' => 'Chad',
  1024 + 'CHL' => 'Chile',
  1025 + 'CHN' => 'China',
  1026 + 'CXR' => 'Christmas Island',
  1027 + 'CCK' => 'Cocos (Keeling) Islands',
  1028 + 'COL' => 'Colombia',
  1029 + 'COM' => 'Comoros',
  1030 + 'COD' => 'Congo (Democratic Republic of the)',
  1031 + 'COG' => 'Congo',
  1032 + 'COK' => 'Cook Islands',
  1033 + 'CRI' => 'Costa Rica',
  1034 + 'CIV' => 'Côte d\'Ivoire',
  1035 + 'HRV' => 'Croatia',
  1036 + 'CUB' => 'Cuba',
  1037 + 'CUW' => 'Curaçao',
  1038 + 'CYP' => 'Cyprus',
  1039 + 'CZE' => 'Czech Republic',
  1040 + 'DNK' => 'Denmark',
  1041 + 'DJI' => 'Djibouti',
  1042 + 'DMA' => 'Dominica',
  1043 + 'DOM' => 'Dominican Republic',
  1044 + 'ECU' => 'Ecuador',
  1045 + 'EGY' => 'Egypt',
  1046 + 'SLV' => 'El Salvador',
  1047 + 'GNQ' => 'Equatorial Guinea',
  1048 + 'ERI' => 'Eritrea',
  1049 + 'EST' => 'Estonia',
  1050 + 'SWZ' => 'Eswatini',
  1051 + 'ETH' => 'Ethiopia',
  1052 + 'FLK' => 'Falkland Islands (Malvinas)',
  1053 + 'FRO' => 'Faroe Islands',
  1054 + 'FJI' => 'Fiji',
  1055 + 'FIN' => 'Finland',
  1056 + 'FRA' => 'France',
  1057 + 'GUF' => 'French Guiana',
  1058 + 'PYF' => 'French Polynesia',
  1059 + 'ATF' => 'French Southern Territories',
  1060 + 'GAB' => 'Gabon',
  1061 + 'GMB' => 'Gambia',
  1062 + 'GEO' => 'Georgia',
  1063 + 'DEU' => 'Germany',
  1064 + 'GHA' => 'Ghana',
  1065 + 'GIB' => 'Gibraltar',
  1066 + 'GRC' => 'Greece',
  1067 + 'GRL' => 'Greenland',
  1068 + 'GRD' => 'Grenada',
  1069 + 'GLP' => 'Guadeloupe',
  1070 + 'GUM' => 'Guam',
  1071 + 'GTM' => 'Guatemala',
  1072 + 'GGY' => 'Guernsey',
  1073 + 'GIN' => 'Guinea',
  1074 + 'GNB' => 'Guinea-Bissau',
  1075 + 'GUY' => 'Guyana',
  1076 + 'HTI' => 'Haiti',
  1077 + 'HMD' => 'Heard Island and McDonald Islands',
  1078 + 'VAT' => 'Holy See',
  1079 + 'HND' => 'Honduras',
  1080 + 'HKG' => 'Hong Kong',
  1081 + 'HUN' => 'Hungary',
  1082 + 'ISL' => 'Iceland',
  1083 + 'IND' => 'India',
  1084 + 'IDN' => 'Indonesia',
  1085 + 'IRN' => 'Iran (Islamic Republic of)',
  1086 + 'IRQ' => 'Iraq',
  1087 + 'IRL' => 'Ireland',
  1088 + 'IMN' => 'Isle of Man',
  1089 + 'ISR' => 'Israel',
  1090 + 'ITA' => 'Italy',
  1091 + 'JAM' => 'Jamaica',
  1092 + 'JPN' => 'Japan',
  1093 + 'JEY' => 'Jersey',
  1094 + 'JOR' => 'Jordan',
  1095 + 'KAZ' => 'Kazakhstan',
  1096 + 'KEN' => 'Kenya',
  1097 + 'KIR' => 'Kiribati',
  1098 + 'KOR' => 'Korea (Republic of)',
  1099 + 'KWT' => 'Kuwait',
  1100 + 'KGZ' => 'Kyrgyzstan',
  1101 + 'LAO' => 'Lao People\'s Democratic Republic',
  1102 + 'LVA' => 'Latvia',
  1103 + 'LBN' => 'Lebanon',
  1104 + 'LSO' => 'Lesotho',
  1105 + 'LBR' => 'Liberia',
  1106 + 'LBY' => 'Libya',
  1107 + 'LIE' => 'Liechtenstein',
  1108 + 'LTU' => 'Lithuania',
  1109 + 'LUX' => 'Luxembourg',
  1110 + 'MAC' => 'Macao',
  1111 + 'MDG' => 'Madagascar',
  1112 + 'MWI' => 'Malawi',
  1113 + 'MYS' => 'Malaysia',
  1114 + 'MDV' => 'Maldives',
  1115 + 'MLI' => 'Mali',
  1116 + 'MLT' => 'Malta',
  1117 + 'MHL' => 'Marshall Islands',
  1118 + 'MTQ' => 'Martinique',
  1119 + 'MRT' => 'Mauritania',
  1120 + 'MUS' => 'Mauritius',
  1121 + 'MYT' => 'Mayotte',
  1122 + 'MEX' => 'Mexico',
  1123 + 'FSM' => 'Micronesia (Federated States of)',
  1124 + 'MDA' => 'Moldova (Republic of)',
  1125 + 'MCO' => 'Monaco',
  1126 + 'MNG' => 'Mongolia',
  1127 + 'MNE' => 'Montenegro',
  1128 + 'MSR' => 'Montserrat',
  1129 + 'MAR' => 'Morocco',
  1130 + 'MOZ' => 'Mozambique',
  1131 + 'MMR' => 'Myanmar',
  1132 + 'NAM' => 'Namibia',
  1133 + 'NRU' => 'Nauru',
  1134 + 'NPL' => 'Nepal',
  1135 + 'NLD' => 'Netherlands',
  1136 + 'NCL' => 'New Caledonia',
  1137 + 'NZL' => 'New Zealand',
  1138 + 'NIC' => 'Nicaragua',
  1139 + 'NER' => 'Niger',
  1140 + 'NGA' => 'Nigeria',
  1141 + 'NIU' => 'Niue',
  1142 + 'NFK' => 'Norfolk Island',
  1143 + 'MNP' => 'Northern Mariana Islands',
  1144 + 'NOR' => 'Norway',
  1145 + 'OMN' => 'Oman',
  1146 + 'PAK' => 'Pakistan',
  1147 + 'PLW' => 'Palau',
  1148 + 'PSE' => 'Palestine, State of',
  1149 + 'PAN' => 'Panama',
  1150 + 'PNG' => 'Papua New Guinea',
  1151 + 'PRY' => 'Paraguay',
  1152 + 'PER' => 'Peru',
  1153 + 'PHL' => 'Philippines',
  1154 + 'PCN' => 'Pitcairn',
  1155 + 'POL' => 'Poland',
  1156 + 'PRT' => 'Portugal',
  1157 + 'PRI' => 'Puerto Rico',
  1158 + 'QAT' => 'Qatar',
  1159 + 'REU' => 'Réunion',
  1160 + 'ROU' => 'Romania',
  1161 + 'RUS' => 'Russian Federation',
  1162 + 'RWA' => 'Rwanda',
  1163 + 'BLM' => 'Saint Barthélemy',
  1164 + 'SHN' => 'Saint Helena, Ascension and Tristan da Cunha',
  1165 + 'KNA' => 'Saint Kitts and Nevis',
  1166 + 'LCA' => 'Saint Lucia',
  1167 + 'MAF' => 'Saint Martin (French part)',
  1168 + 'SPM' => 'Saint Pierre and Miquelon',
  1169 + 'VCT' => 'Saint Vincent and the Grenadines',
  1170 + 'WSM' => 'Samoa',
  1171 + 'SMR' => 'San Marino',
  1172 + 'STP' => 'Sao Tome and Principe',
  1173 + 'SAU' => 'Saudi Arabia',
  1174 + 'SEN' => 'Senegal',
  1175 + 'SRB' => 'Serbia',
  1176 + 'SYC' => 'Seychelles',
  1177 + 'SLE' => 'Sierra Leone',
  1178 + 'SGP' => 'Singapore',
  1179 + 'SXM' => 'Sint Maarten (Dutch part)',
  1180 + 'SVK' => 'Slovakia',
  1181 + 'SVN' => 'Slovenia',
  1182 + 'SLB' => 'Solomon Islands',
  1183 + 'SOM' => 'Somalia',
  1184 + 'ZAF' => 'South Africa',
  1185 + 'SGS' => 'South Georgia and the South Sandwich Islands',
  1186 + 'SSD' => 'South Sudan',
  1187 + 'ESP' => 'Spain',
  1188 + 'LKA' => 'Sri Lanka',
  1189 + 'SDN' => 'Sudan',
  1190 + 'SUR' => 'Suriname',
  1191 + 'SJM' => 'Svalbard and Jan Mayen',
  1192 + 'SWE' => 'Sweden',
  1193 + 'CHE' => 'Switzerland',
  1194 + 'SYR' => 'Syrian Arab Republic',
  1195 + 'TWN' => 'Taiwan, Province of China',
  1196 + 'TJK' => 'Tajikistan',
  1197 + 'TZA' => 'Tanzania, United Republic of',
  1198 + 'THA' => 'Thailand',
  1199 + 'TLS' => 'Timor-Leste',
  1200 + 'TGO' => 'Togo',
  1201 + 'TKL' => 'Tokelau',
  1202 + 'TON' => 'Tonga',
  1203 + 'TTO' => 'Trinidad and Tobago',
  1204 + 'TUN' => 'Tunisia',
  1205 + 'TUR' => 'Turkey',
  1206 + 'TKM' => 'Turkmenistan',
  1207 + 'TCA' => 'Turks and Caicos Islands',
  1208 + 'TUV' => 'Tuvalu',
  1209 + 'UGA' => 'Uganda',
  1210 + 'UKR' => 'Ukraine',
  1211 + 'ARE' => 'United Arab Emirates',
  1212 + 'GBR' => 'United Kingdom',
  1213 + 'USA' => 'United States',
  1214 + 'URY' => 'Uruguay',
  1215 + 'UZB' => 'Uzbekistan',
  1216 + 'VUT' => 'Vanuatu',
  1217 + 'VEN' => 'Venezuela (Bolivarian Republic of)',
  1218 + 'VNM' => 'Viet Nam',
  1219 + 'WLF' => 'Wallis and Futuna',
  1220 + 'ESH' => 'Western Sahara',
  1221 + 'YEM' => 'Yemen',
  1222 + 'ZMB' => 'Zambia',
  1223 + 'ZWE' => 'Zimbabwe',
  1224 + ];
  1225 + // 检查国家码是否存在于数组中
  1226 + if (array_key_exists($alpha3, $countries)) {
  1227 + return $countries[$alpha3];
  1228 + } else {
  1229 + return false;
  1230 + }
  1231 + }
976 1232
977 } 1233 }
@@ -119,7 +119,7 @@ if (!function_exists('http_get')) { @@ -119,7 +119,7 @@ if (!function_exists('http_get')) {
119 $access_txt = curl_exec($ch1); 119 $access_txt = curl_exec($ch1);
120 if (curl_errno($ch1)) { 120 if (curl_errno($ch1)) {
121 $error_message = curl_error($ch1); 121 $error_message = curl_error($ch1);
122 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($error_message, true) . PHP_EOL, FILE_APPEND); 122 + errorLog('请求失败', $url, $error_message);
123 } 123 }
124 curl_close($ch1); 124 curl_close($ch1);
125 return json_decode($access_txt, true); 125 return json_decode($access_txt, true);
@@ -12,6 +12,7 @@ namespace App\Http\Controllers\Bside\GoogleKeywordInsight; @@ -12,6 +12,7 @@ namespace App\Http\Controllers\Bside\GoogleKeywordInsight;
12 use App\Enums\Common\Code; 12 use App\Enums\Common\Code;
13 use App\Http\Controllers\Bside\BaseController; 13 use App\Http\Controllers\Bside\BaseController;
14 use App\Http\Logic\Bside\GoogleKeywordInsight\GoogleKeywordInsightLogic; 14 use App\Http\Logic\Bside\GoogleKeywordInsight\GoogleKeywordInsightLogic;
  15 +use App\Models\GoogleKeywordInsight\GoogleKeywordInsightDetail;
15 16
16 /** 17 /**
17 * @remark :谷歌洞察数据 18 * @remark :谷歌洞察数据
@@ -35,7 +36,9 @@ class GoogleKeywordInsightController extends BaseController @@ -35,7 +36,9 @@ class GoogleKeywordInsightController extends BaseController
35 ],[ 36 ],[
36 'keyword.required' => '关键词不能为空', 37 'keyword.required' => '关键词不能为空',
37 ]); 38 ]);
38 - $data = $logic->getGoogleInsight(); 39 + $logic->getGoogleInsight();
  40 + $detailModel = new GoogleKeywordInsightDetail();
  41 + $data = $detailModel->lists(['search'=>$this->param['keyword']],$this->page,$this->row);
39 $this->response('success',Code::SUCCESS,$data); 42 $this->response('success',Code::SUCCESS,$data);
40 } 43 }
41 } 44 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :GoogleSearchController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/3/27 13:53
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\GoogleKeywordInsight;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Bside\BaseController;
  14 +use App\Services\GoogleSearchService;
  15 +
  16 +class GoogleSearchController extends BaseController
  17 +{
  18 + /**
  19 + * @remark :google搜索数据
  20 + * @name :searchList
  21 + * @author :lyh
  22 + * @method :post
  23 + * @time :2025/3/27 13:59
  24 + */
  25 + public function searchList(){
  26 + $this->request->validate([
  27 + 'search' => 'required'
  28 + ],[
  29 + 'search.required' => '搜索类型不能为空',
  30 + ]);
  31 + //获取当前项目域名
  32 + $domain = parse_url($this->user['domain'], PHP_URL_HOST);
  33 + $googleService = new GoogleSearchService();
  34 + $googleService->googleSearch();
  35 + $data = [];
  36 + $this->response('success',Code::SUCCESS,$data);
  37 + }
  38 +}
@@ -45,11 +45,11 @@ class DomainSettingController extends BaseController @@ -45,11 +45,11 @@ class DomainSettingController extends BaseController
45 public function save(DomainSettingLogic $logic) 45 public function save(DomainSettingLogic $logic)
46 { 46 {
47 $this->request->validate([ 47 $this->request->validate([
  48 + 'type' => ['required'],
48 'domain' => ['required'], 49 'domain' => ['required'],
49 - 'record' => ['required'],  
50 ], [ 50 ], [
  51 + 'type.required' => '服务器类型不能为空',
51 'domain.required' => '主域名不能为空', 52 'domain.required' => '主域名不能为空',
52 - 'record.required' => '解析记录不能为空',  
53 ]); 53 ]);
54 $logic->saveDomain(); 54 $logic->saveDomain();
55 $this->response('success', Code::SUCCESS); 55 $this->response('success', Code::SUCCESS);
@@ -28,7 +28,7 @@ use App\Models\Project\Project; @@ -28,7 +28,7 @@ use App\Models\Project\Project;
28 use App\Models\Project\ProjectAiSetting; 28 use App\Models\Project\ProjectAiSetting;
29 use App\Models\RouteMap\RouteMap; 29 use App\Models\RouteMap\RouteMap;
30 use App\Services\AiBlogService; 30 use App\Services\AiBlogService;
31 -use App\Services\GoogleKeywordInsightService; 31 +use App\Services\GoogleSearchService;
32 use App\Services\ProjectServer; 32 use App\Services\ProjectServer;
33 use Illuminate\Support\Facades\DB; 33 use Illuminate\Support\Facades\DB;
34 34
@@ -13,7 +13,7 @@ use App\Helper\Translate; @@ -13,7 +13,7 @@ use App\Helper\Translate;
13 use App\Http\Logic\Bside\BaseLogic; 13 use App\Http\Logic\Bside\BaseLogic;
14 use App\Models\GoogleKeywordInsight\GoogleKeywordInsight; 14 use App\Models\GoogleKeywordInsight\GoogleKeywordInsight;
15 use App\Models\GoogleKeywordInsight\GoogleKeywordInsightDetail; 15 use App\Models\GoogleKeywordInsight\GoogleKeywordInsightDetail;
16 -use App\Services\GoogleKeywordInsightService; 16 +use App\Services\GoogleSearchService;
17 use Illuminate\Support\Facades\DB; 17 use Illuminate\Support\Facades\DB;
18 18
19 class GoogleKeywordInsightLogic extends BaseLogic 19 class GoogleKeywordInsightLogic extends BaseLogic
@@ -35,9 +35,9 @@ class GoogleKeywordInsightLogic extends BaseLogic @@ -35,9 +35,9 @@ class GoogleKeywordInsightLogic extends BaseLogic
35 * @time :2025/3/25 14:36 35 * @time :2025/3/25 14:36
36 */ 36 */
37 public function getGoogleInsight(){ 37 public function getGoogleInsight(){
38 - $data = $this->model->read(['search'=>$this->param['keyword']]); 38 + $data = $this->model->read(['search'=>$this->param['keyword']],['id']);
39 if($data === false){ 39 if($data === false){
40 - $this->service = new GoogleKeywordInsightService(); 40 + $this->service = new GoogleSearchService();
41 $data = $this->service->requestUrl($this->param['keyword']); 41 $data = $this->service->requestUrl($this->param['keyword']);
42 if(!empty($data)){ 42 if(!empty($data)){
43 DB::beginTransaction(); 43 DB::beginTransaction();
@@ -53,6 +53,6 @@ class GoogleKeywordInsightLogic extends BaseLogic @@ -53,6 +53,6 @@ class GoogleKeywordInsightLogic extends BaseLogic
53 } 53 }
54 } 54 }
55 } 55 }
56 - return $this->success($data); 56 + return $this->success();
57 } 57 }
58 } 58 }
@@ -9,7 +9,9 @@ @@ -9,7 +9,9 @@
9 9
10 namespace App\Http\Logic\Bside\SeoSetting; 10 namespace App\Http\Logic\Bside\SeoSetting;
11 11
  12 +use App\Helper\Arr;
12 use App\Http\Logic\Bside\BaseLogic; 13 use App\Http\Logic\Bside\BaseLogic;
  14 +use App\Models\Devops\ServerConfig;
13 use App\Models\Devops\Servers; 15 use App\Models\Devops\Servers;
14 use App\Models\Devops\ServersIp; 16 use App\Models\Devops\ServersIp;
15 use App\Models\Domain\DomainCreateTask; 17 use App\Models\Domain\DomainCreateTask;
@@ -37,11 +39,11 @@ class DomainSettingLogic extends BaseLogic @@ -37,11 +39,11 @@ class DomainSettingLogic extends BaseLogic
37 public function infoDomain() 39 public function infoDomain()
38 { 40 {
39 $domain_info = $this->model->read(['project_id' => $this->user['project_id']], ['seo_type', 'seo_domain', 'seo_ftp']); 41 $domain_info = $this->model->read(['project_id' => $this->user['project_id']], ['seo_type', 'seo_domain', 'seo_ftp']);
40 - $domain = $domain_info['seo_domain'] ?: '';  
41 - $ftp = $domain_info['seo_ftp'] ? json_decode($domain['seo_ftp'], true) : ['url' => '', 'username' => '', 'password' => '', 'port' => ''];  
42 - $type = $domain_info['seo_type'] ?: 1;  
43 - $record = ''; 42 + $type = $domain_info['seo_type'] ?? WebSetting::SEO_TYPE_PUBLIC;
  43 + $domain = $domain_info['seo_domain'] ?? '';
  44 + $ftp = isset($domain_info['seo_ftp']) && $domain_info['seo_ftp'] ? Arr::s2a($domain_info['seo_ftp']) : ['url' => '', 'username' => '', 'password' => '', 'port' => ''];
44 45
  46 + $record = '';
45 if ($type == WebSetting::SEO_TYPE_PUBLIC) { 47 if ($type == WebSetting::SEO_TYPE_PUBLIC) {
46 //公共服务器 48 //公共服务器
47 if ($domain) { 49 if ($domain) {
@@ -65,7 +67,8 @@ class DomainSettingLogic extends BaseLogic @@ -65,7 +67,8 @@ class DomainSettingLogic extends BaseLogic
65 67
66 /** 68 /**
67 * @remark :保存设置 69 * @remark :保存设置
68 - * @name :saveDomain 70 + * @throws \App\Exceptions\AsideGlobalException
  71 + * @throws \App\Exceptions\BsideGlobalException
69 * @author :lyh 72 * @author :lyh
70 * @method :post 73 * @method :post
71 * @time :2025/3/20 16:12 74 * @time :2025/3/20 16:12
@@ -79,13 +82,6 @@ class DomainSettingLogic extends BaseLogic @@ -79,13 +82,6 @@ class DomainSettingLogic extends BaseLogic
79 $this->fail('主域名填写错误'); 82 $this->fail('主域名填写错误');
80 } 83 }
81 84
82 - //获取解析服务器详情  
83 - $server_ip_model = new ServersIp();  
84 - $record_info = $server_ip_model->read(['domain' => $this->param['record']], ['id', 'servers_id', 'ip', 'domain', 'total']);  
85 - if (!$record_info) {  
86 - $this->fail('解析记录不存在');  
87 - }  
88 -  
89 //获取项目详情 85 //获取项目详情
90 $project_model = new Project(); 86 $project_model = new Project();
91 $project_info = $project_model->read(['id' => $this->user['project_id']], ['company']); 87 $project_info = $project_model->read(['id' => $this->user['project_id']], ['company']);
@@ -93,64 +89,125 @@ class DomainSettingLogic extends BaseLogic @@ -93,64 +89,125 @@ class DomainSettingLogic extends BaseLogic
93 $this->fail('获取项目数据失败'); 89 $this->fail('获取项目数据失败');
94 } 90 }
95 91
96 - //构建blog二级域名  
97 - $domain_array = explode('.', $domain);  
98 - if (count($domain_array) == 1) {  
99 - $this->fail('请填写正确的主域名');  
100 - } elseif (count($domain_array) == 2) {  
101 - array_unshift($domain_array, 'blog');  
102 - } else {  
103 - $domain_array[0] = 'blog';  
104 - }  
105 - $blog_domain = implode('.', $domain_array); 92 + $server_ip_model = new ServersIp();
  93 + $domain_model = new DomainInfo();
  94 + $server_model = new Servers();
  95 + $optimize_model = new DeployOptimize();
  96 + if ($this->param['type'] == WebSetting::SEO_TYPE_PUBLIC) {
  97 + //公共服务器
  98 + $record = $this->param['record'] ?? '';
  99 + if (empty($record)) {
  100 + $this->fail('解析记录不能为空');
  101 + }
106 102
107 - //判断blog二级域名是否已经解析  
108 - if (!check_domain_record($blog_domain, $record_info)) {  
109 - $this->fail($blog_domain . '还未解析cname至' . $this->param['record']);  
110 - } 103 + //获取解析服务器详情
  104 + $record_info = $server_ip_model->read(['domain' => $record], ['id', 'servers_id', 'ip', 'domain', 'total']);
  105 + if (!$record_info) {
  106 + $this->fail('解析记录不存在');
  107 + }
111 108
112 - DB::beginTransaction();  
113 - try {  
114 - //保存一条主域名记录  
115 - $setting_info = $this->model->read(['project_id' => $this->user['project_id']]);  
116 - if ($setting_info === false) {  
117 - $this->model->add(['seo_domain' => $domain, 'project_id' => $this->user['project_id']]); 109 + //构建blog二级域名
  110 + $domain_array = explode('.', $domain);
  111 + if (count($domain_array) == 1) {
  112 + $this->fail('请填写正确的主域名');
  113 + } elseif (count($domain_array) == 2) {
  114 + array_unshift($domain_array, 'blog');
118 } else { 115 } else {
119 - $this->model->edit(['seo_domain' => $domain], ['id' => $setting_info['id']]); 116 + $domain_array[0] = 'blog';
120 } 117 }
  118 + $blog_domain = implode('.', $domain_array);
121 119
122 - //添加域名到域名管理  
123 - $domain_model = new DomainInfo();  
124 - $info = $domain_model->read(['domain' => $blog_domain]);  
125 - if ($info === false) {  
126 - $id = $domain_model->addReturnId(['domain' => $blog_domain, 'project_id' => $this->user['project_id'], 'belong_to' => 2, 'status' => 1, 'remark' => $project_info['company']]);  
127 -  
128 - //保存优化设置  
129 - $optimize_model = new DeployOptimize();  
130 - $optimize_model->edit(['domain' => $id], ['project_id' => $this->user['project_id']]);  
131 -  
132 - //保存项目ip  
133 - $project_model->edit(['serve_id' => $record_info['id']], ['id' => $this->user['project_id']]);  
134 -  
135 - //变更ip使用数量  
136 - $server_ip_model->edit(['total' => $record_info['total'] + 1], ['id' => $record_info['id']]);  
137 - $server_model = new Servers();  
138 - $server_model->edit(['being_number' => $record_info['total'] + 1], ['id' => $record_info['servers_id']]);  
139 -  
140 - //创建建站任务  
141 - $domain_create_model = new DomainCreateTask();  
142 - $domain_create_model->add([  
143 - 'server_id' => $record_info['servers_id'],  
144 - 'project_id' => $this->user['project_id'],  
145 - 'domain_id' => $id,  
146 - 'type' => DomainCreateTask::TYPE_BLOG  
147 - ]); 120 + //判断blog二级域名是否已经解析
  121 + if (!check_domain_record($blog_domain, $record_info)) {
  122 + $this->fail($blog_domain . '还未解析cname至' . $record);
148 } 123 }
149 124
150 - DB::commit();  
151 - } catch (\Exception $e) {  
152 - DB::rollBack();  
153 - $this->fail('保存失败,请联系管理员'); 125 + DB::beginTransaction();
  126 + try {
  127 + //保存一条主域名记录
  128 + $setting_info = $this->model->read(['project_id' => $this->user['project_id']]);
  129 + if ($setting_info === false) {
  130 + $this->model->add(['seo_type' => WebSetting::SEO_TYPE_PUBLIC, 'seo_domain' => $domain, 'project_id' => $this->user['project_id']]);
  131 + } else {
  132 + $this->model->edit(['seo_type' => WebSetting::SEO_TYPE_PUBLIC, 'seo_domain' => $domain], ['id' => $setting_info['id']]);
  133 + }
  134 +
  135 + //添加域名到域名管理
  136 + $info = $domain_model->read(['domain' => $blog_domain]);
  137 + if ($info === false) {
  138 + $id = $domain_model->addReturnId(['domain' => $blog_domain, 'project_id' => $this->user['project_id'], 'belong_to' => 2, 'status' => 1, 'remark' => $project_info['company']]);
  139 +
  140 + //保存优化设置
  141 + $optimize_model->edit(['domain' => $id], ['project_id' => $this->user['project_id']]);
  142 +
  143 + //保存项目ip
  144 + $project_model->edit(['serve_id' => $record_info['id']], ['id' => $this->user['project_id']]);
  145 +
  146 + //变更ip使用数量
  147 + $server_ip_model->edit(['total' => $record_info['total'] + 1], ['id' => $record_info['id']]);
  148 + $server_model->edit(['being_number' => $record_info['total'] + 1], ['id' => $record_info['servers_id']]);
  149 +
  150 + //创建建站任务
  151 + $domain_create_model = new DomainCreateTask();
  152 + $domain_create_model->add([
  153 + 'server_id' => $record_info['servers_id'],
  154 + 'project_id' => $this->user['project_id'],
  155 + 'domain_id' => $id,
  156 + 'type' => DomainCreateTask::TYPE_BLOG
  157 + ]);
  158 + }
  159 +
  160 + DB::commit();
  161 + } catch (\Exception $e) {
  162 + DB::rollBack();
  163 + $this->fail('保存失败,请联系管理员');
  164 + }
  165 + } else {
  166 + //个人服务器
  167 + $ftp = $this->param['ftp'] ?? [];
  168 + if (empty($ftp) || empty($ftp['url']) || empty($ftp['username']) || empty($ftp['password']) || empty($ftp['port'])) {
  169 + $this->fail('ftp信息填写未完整');
  170 + }
  171 +
  172 + //获取自建站服务器详情
  173 + $record_info = $server_ip_model->read(['servers_id' => ServerConfig::SELF_SITE_ID], ['id', 'servers_id', 'total']);
  174 + if (!$record_info) {
  175 + $this->fail('解析记录不存在');
  176 + }
  177 +
  178 + DB::beginTransaction();
  179 + try {
  180 + //保存一条主域名记录
  181 + $setting_info = $this->model->read(['project_id' => $this->user['project_id']]);
  182 + if ($setting_info === false) {
  183 + $this->model->add(['seo_type' => WebSetting::SEO_TYPE_OWN, 'seo_domain' => $domain, 'seo_ftp' => Arr::a2s($ftp), 'project_id' => $this->user['project_id']]);
  184 + } else {
  185 + $this->model->edit(['seo_type' => WebSetting::SEO_TYPE_OWN, 'seo_domain' => $domain, 'seo_ftp' => Arr::a2s($ftp)], ['id' => $setting_info['id']]);
  186 + }
  187 +
  188 + //添加域名到域名管理
  189 + $info = $domain_model->read(['domain' => $domain]);
  190 + if ($info === false) {
  191 + $id = $domain_model->addReturnId(['domain' => $domain, 'project_id' => $this->user['project_id'], 'belong_to' => 2, 'status' => 1, 'remark' => $project_info['company']]);
  192 +
  193 + //保存优化设置
  194 + $optimize_model->edit(['domain' => $id], ['project_id' => $this->user['project_id']]);
  195 +
  196 + //保存项目ip
  197 + $project_model->edit(['serve_id' => $record_info['id']], ['id' => $this->user['project_id']]);
  198 +
  199 + //变更ip使用数量
  200 + $server_ip_model->edit(['total' => $record_info['total'] + 1], ['id' => $record_info['id']]);
  201 + $server_model->edit(['being_number' => $record_info['total'] + 1], ['id' => $record_info['servers_id']]);
  202 + }
  203 +
  204 + DB::commit();
  205 + } catch (\Exception $e) {
  206 + DB::rollBack();
  207 + $this->fail('保存失败,请联系管理员');
  208 + }
154 } 209 }
  210 +
  211 + return $this->success();
155 } 212 }
156 } 213 }
1 <?php 1 <?php
2 /** 2 /**
3 * @remark : 3 * @remark :
4 - * @name :GoogleKeywordInsightService.php 4 + * @name :GoogleSearchService.php
5 * @author :lyh 5 * @author :lyh
6 * @method :post 6 * @method :post
7 * @time :2025/3/25 11:36 7 * @time :2025/3/25 11:36
@@ -11,12 +11,12 @@ namespace App\Services; @@ -11,12 +11,12 @@ namespace App\Services;
11 11
12 /** 12 /**
13 * @remark :google关键字扩展 13 * @remark :google关键字扩展
14 - * @name :GoogleKeywordInsightService 14 + * @name :GoogleSearchService
15 * @author :lyh 15 * @author :lyh
16 * @method :post 16 * @method :post
17 * @time :2025/3/25 11:38 17 * @time :2025/3/25 11:38
18 */ 18 */
19 -class GoogleKeywordInsightService 19 +class GoogleSearchService
20 { 20 {
21 public $url = ""; 21 public $url = "";
22 22
@@ -54,4 +54,28 @@ class GoogleKeywordInsightService @@ -54,4 +54,28 @@ class GoogleKeywordInsightService
54 return json_decode($response,true); 54 return json_decode($response,true);
55 } 55 }
56 } 56 }
  57 +
  58 +
  59 +
  60 + /**
  61 + * @remark :google搜索
  62 + * @name :googleSearch
  63 + * @author :lyh
  64 + * @method :post
  65 + * @time :2025/3/27 11:18
  66 + * @param :date,query,page,device,country/时间、聚合、前页、设备、国家
  67 + */
  68 + public function googleSearch($domain,$search){
  69 + $data = [
  70 + 1=>'date',
  71 + 2=>'query',
  72 + 3=>'page',
  73 + 4=>'device',
  74 + 5=>'country'
  75 + ];
  76 + $this->url = 'https://www.cmer.site/api/google/search';
  77 + $url = $this->url.'?domain='.$domain.'&q='.$data[$search];
  78 + return http_get($url);
  79 + }
  80 +
57 } 81 }