作者 lyh

gx

@@ -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);
@@ -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
@@ -37,7 +37,7 @@ class GoogleKeywordInsightLogic extends BaseLogic @@ -37,7 +37,7 @@ class GoogleKeywordInsightLogic extends BaseLogic
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']]);
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();
@@ -52,6 +52,9 @@ class GoogleKeywordInsightLogic extends BaseLogic @@ -52,6 +52,9 @@ class GoogleKeywordInsightLogic extends BaseLogic
52 $this->fail('保存失败,请联系管理员'); 52 $this->fail('保存失败,请联系管理员');
53 } 53 }
54 } 54 }
  55 + }else{
  56 + $googleDetailModel = new GoogleKeywordInsightDetail();
  57 + $data = $googleDetailModel->list(['search'=>$this->param['keyword']]);
55 } 58 }
56 return $this->success($data); 59 return $this->success($data);
57 } 60 }
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,19 @@ class GoogleKeywordInsightService @@ -54,4 +54,19 @@ class GoogleKeywordInsightService
54 return json_decode($response,true); 54 return json_decode($response,true);
55 } 55 }
56 } 56 }
  57 +
  58 + /**
  59 + * @remark :google搜索
  60 + * @name :googleSearch
  61 + * @author :lyh
  62 + * @method :post
  63 + * @time :2025/3/27 11:18
  64 + * @param :date,query,page,device,country
  65 + */
  66 + public function googleSearch($data){
  67 + $this->url = 'https://www.cmer.site/api/google/search?domain=www.suertetextile.com&q=';
  68 + $url = $this->url.$data;
  69 + return http_get($url);
  70 + }
  71 +
57 } 72 }