作者 赵彬吉
@@ -139,9 +139,9 @@ class DomainInfo extends Command @@ -139,9 +139,9 @@ class DomainInfo extends Command
139 $serverIpModel = new ServersIp(); 139 $serverIpModel = new ServersIp();
140 $domainCreateTaskModel = new DomainCreateTask(); 140 $domainCreateTaskModel = new DomainCreateTask();
141 $end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期 141 $end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期
142 - $list = $domainModel->where('status', '=', 1)->where('type', '!=', 2)->where('certificate_end_time', '<', $end_day)->get()->toArray(); 142 + $list = $domainModel->where('status', '=', 1)->where('type', '=', 1)->where('certificate_end_time', '<', $end_day)->get()->toArray();
143 foreach ($list as $v) { 143 foreach ($list as $v) {
144 - $project_info = $projectModel->read(['id' => $v['project_id'], 'type' => ['!=', Project::TYPE_CLOSE]], ['serve_id']); 144 + $project_info = $projectModel->read(['id' => $v['project_id'], 'type' => ['!=', Project::TYPE_CLOSE]], ['serve_id', 'project_type']);
145 if (!$project_info) { 145 if (!$project_info) {
146 continue; 146 continue;
147 } 147 }
@@ -161,14 +161,20 @@ class DomainInfo extends Command @@ -161,14 +161,20 @@ class DomainInfo extends Command
161 continue; 161 continue;
162 } 162 }
163 163
  164 + if ($project_info['project_type'] == Project::PROJECT_TYPE_SEO) {
  165 + $type = DomainCreateTask::TYPE_BLOG;
  166 + } else {
  167 + $type = DomainCreateTask::TYPE_MAIN;
  168 + }
  169 +
164 //创建更新站点证书任务 170 //创建更新站点证书任务
165 - $task_info = $domainCreateTaskModel->read(['type' => DomainCreateTask::TYPE_MAIN, 'domain_id' => $v['id'], 'status' => ['<', DomainCreateTask::STATUS_SUC]]); 171 + $task_info = $domainCreateTaskModel->read(['type' => $type, 'domain_id' => $v['id'], 'status' => ['<', DomainCreateTask::STATUS_SUC]]);
166 if (!$task_info) { 172 if (!$task_info) {
167 $domainCreateTaskModel->add([ 173 $domainCreateTaskModel->add([
168 'server_id' => $servers_ip_info['servers_id'], 174 'server_id' => $servers_ip_info['servers_id'],
169 'project_id' => $v['project_id'], 175 'project_id' => $v['project_id'],
170 'domain_id' => $v['id'], 176 'domain_id' => $v['id'],
171 - 'type' => DomainCreateTask::TYPE_MAIN 177 + 'type' => $type
172 ]); 178 ]);
173 } 179 }
174 } 180 }
@@ -186,7 +192,7 @@ class DomainInfo extends Command @@ -186,7 +192,7 @@ class DomainInfo extends Command
186 $serverIpModel = new ServersIp(); 192 $serverIpModel = new ServersIp();
187 $domainCreateTaskModel = new DomainCreateTask(); 193 $domainCreateTaskModel = new DomainCreateTask();
188 $end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期 194 $end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期
189 - $list = $domainModel->where('status', '=', 1)->where('amp_status', 1)->where('amp_type', '!=', 2)->where('amp_certificate_end_time', '<', $end_day)->get()->toArray(); 195 + $list = $domainModel->where('status', '=', 1)->where('amp_status', 1)->where('amp_type', '=', 1)->where('amp_certificate_end_time', '<', $end_day)->get()->toArray();
190 foreach ($list as $v) { 196 foreach ($list as $v) {
191 $domain_array = parse_url($v['domain']); 197 $domain_array = parse_url($v['domain']);
192 $host = $domain_array['host'] ?? $domain_array['path']; 198 $host = $domain_array['host'] ?? $domain_array['path'];
@@ -243,7 +249,7 @@ class DomainInfo extends Command @@ -243,7 +249,7 @@ class DomainInfo extends Command
243 $serverIpModel = new ServersIp(); 249 $serverIpModel = new ServersIp();
244 $domainCreateTaskModel = new DomainCreateTask(); 250 $domainCreateTaskModel = new DomainCreateTask();
245 $end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期 251 $end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期
246 - $list = $customModel->where('status', 1)->where('is_create', 1)->where('type', '!=', 2)->where('certificate_end_time', '<', $end_day)->get()->toArray(); 252 + $list = $customModel->where('status', 1)->where('is_create', 1)->where('type', '=', 1)->where('certificate_end_time', '<', $end_day)->get()->toArray();
247 foreach ($list as $v) { 253 foreach ($list as $v) {
248 $project_info = $projectModel->read(['id' => $v['project_id'], 'type' => ['!=', Project::TYPE_CLOSE]], ['serve_id']); 254 $project_info = $projectModel->read(['id' => $v['project_id'], 'type' => ['!=', Project::TYPE_CLOSE]], ['serve_id']);
249 if (!$project_info) { 255 if (!$project_info) {
@@ -67,10 +67,14 @@ class SendKeyword extends Command @@ -67,10 +67,14 @@ class SendKeyword extends Command
67 $send_num = [30 => 1000, 50 => 2000, 60 => 4000, 70 => 6000]; 67 $send_num = [30 => 1000, 50 => 2000, 60 => 4000, 70 => 6000];
68 $ban_domain = $this->banDomain(); 68 $ban_domain = $this->banDomain();
69 foreach ($projects as $item) { 69 foreach ($projects as $item) {
70 - if (empty($item->is_auto_keywords)) 70 + if (empty($item->is_auto_keywords)) {
  71 + $this->output('项目ID:' . $item->id . ', 未开启推送配置;');
71 continue; 72 continue;
72 - if (in_array($item->domain, $ban_domain)) 73 + }
  74 + if (in_array($item->domain, $ban_domain)) {
  75 + $this->output('项目ID:' . $item->id . ', 域名被禁用;');
73 continue; 76 continue;
  77 + }
74 if (empty($item->api_no)) { 78 if (empty($item->api_no)) {
75 $this->output('项目ID:' . $item->id . ', api_no为空;'); 79 $this->output('项目ID:' . $item->id . ', api_no为空;');
76 continue; 80 continue;
@@ -89,11 +93,15 @@ class SendKeyword extends Command @@ -89,11 +93,15 @@ class SendKeyword extends Command
89 93
90 // 项目是否达标 94 // 项目是否达标
91 $compliance = RankData::where(['project_id' => $item->id, 'api_no' => $item->api_no, 'lang' => ''])->value('is_compliance'); 95 $compliance = RankData::where(['project_id' => $item->id, 'api_no' => $item->api_no, 'lang' => ''])->value('is_compliance');
92 - if (FALSE == empty($compliance))  
93 - return false; 96 + if (FALSE == empty($compliance)) {
  97 + $this->output('项目ID:' . $item->id . ', 项目已达标,不需要推送;');
  98 + continue;
  99 + }
  100 +
94 101
95 $project = ProjectServer::useProject($item->id); 102 $project = ProjectServer::useProject($item->id);
96 if (empty($project)) { 103 if (empty($project)) {
  104 + $this->output('项目ID:' . $item->id . ', 项目链接失败;');
97 DB::disconnect('custom_mysql'); 105 DB::disconnect('custom_mysql');
98 continue; 106 continue;
99 } 107 }
@@ -109,6 +117,7 @@ class SendKeyword extends Command @@ -109,6 +117,7 @@ class SendKeyword extends Command
109 $item['apino'] = $item['api_no']; 117 $item['apino'] = $item['api_no'];
110 $this->sendNotice($item); 118 $this->sendNotice($item);
111 } 119 }
  120 + $this->output('项目ID:' . $item['id'] . ', ' . ($send ? '推送完成' : '无推送关键词;'));
112 } 121 }
113 return true; 122 return true;
114 } 123 }
@@ -162,18 +162,16 @@ class RecommendedSuppliers extends Command @@ -162,18 +162,16 @@ class RecommendedSuppliers extends Command
162 $res = http_post($url,json_encode($param)); 162 $res = http_post($url,json_encode($param));
163 echo '请求返回状态'. ($res['code']?? '').PHP_EOL; 163 echo '请求返回状态'. ($res['code']?? '').PHP_EOL;
164 // echo date('Y-m-d H:i:s') . json_encode($res) . PHP_EOL; 164 // echo date('Y-m-d H:i:s') . json_encode($res) . PHP_EOL;
165 - if(isset($res['code']) && $res['code'] == 200){  
166 - //保存多条数据  
167 - $saveData = [  
168 - 'project_id'=>$project_id,  
169 - 'keyword'=>$keyword,  
170 - 'data'=>json_encode($res['data'])  
171 - ];  
172 - $purchaserModel = new Purchaser();  
173 - $purchaserModel->add($saveData);  
174 - if(!empty($res['data'])){  
175 - $this->savePurchaserInfo($project_id,$keyword,$res['data']);  
176 - } 165 + //保存多条数据
  166 + $saveData = [
  167 + 'project_id'=>$project_id,
  168 + 'keyword'=>$keyword,
  169 + 'data'=>json_encode($res['data'] ?? [])
  170 + ];
  171 + $purchaserModel = new Purchaser();
  172 + $purchaserModel->add($saveData);
  173 + if(isset($res['code']) && $res['code'] == 200 && !empty($res['data'])){
  174 + $this->savePurchaserInfo($project_id,$keyword,$res['data']);
177 }else{ 175 }else{
178 echo '未正常返回数据,跳过项目'.PHP_EOL; 176 echo '未正常返回数据,跳过项目'.PHP_EOL;
179 } 177 }
@@ -190,7 +188,7 @@ class RecommendedSuppliers extends Command @@ -190,7 +188,7 @@ class RecommendedSuppliers extends Command
190 public function getKeywords($project_id){ 188 public function getKeywords($project_id){
191 $keywordModel = new Keyword(); 189 $keywordModel = new Keyword();
192 $keyword_array = $this->getPurchaserList($project_id); 190 $keyword_array = $this->getPurchaserList($project_id);
193 - $title = $keywordModel->where('title', 'not in', $keyword_array)->orderRaw('RAND()')->limit(1)->value('title'); // 只返回 title 字段 191 + $title = $keywordModel->whereNotIn('title', $keyword_array)->inRandomOrder()->limit(1)->value('title');
194 if(empty($title)){ 192 if(empty($title)){
195 return ''; 193 return '';
196 } 194 }
@@ -207,6 +205,9 @@ class RecommendedSuppliers extends Command @@ -207,6 +205,9 @@ class RecommendedSuppliers extends Command
207 public function savePurchaserInfo($project_id,$keyword,$data){ 205 public function savePurchaserInfo($project_id,$keyword,$data){
208 $purchaserInfoModel = new PurchaserInfo(); 206 $purchaserInfoModel = new PurchaserInfo();
209 foreach ($data as $k =>$v){ 207 foreach ($data as $k =>$v){
  208 + if(empty($v['buyer_id'])){
  209 + continue;
  210 + }
210 $v['project_id'] = $project_id; 211 $v['project_id'] = $project_id;
211 $v['keyword'] = $keyword; 212 $v['keyword'] = $keyword;
212 $v['email'] = json_encode($v['email']??[],JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); 213 $v['email'] = json_encode($v['email']??[],JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
@@ -44,6 +44,20 @@ class CheckListController extends BaseController @@ -44,6 +44,20 @@ class CheckListController extends BaseController
44 } 44 }
45 45
46 /** 46 /**
  47 + * @remark :获取分页检查清单数据
  48 + * @name :lists
  49 + * @author :lyh
  50 + * @method :post
  51 + * @time :2025/4/17 9:31
  52 + */
  53 + public function list(){
  54 + $this->map['status'] = 1;
  55 + $field = ['id','status','sort','text','created_at'];
  56 + $data = $this->model->list($this->map,'id',$field);
  57 + $this->response('success',Code::SUCCESS,$data);
  58 + }
  59 +
  60 + /**
47 * @remark :获取数据详情 61 * @remark :获取数据详情
48 * @name :info 62 * @name :info
49 * @author :lyh 63 * @author :lyh
@@ -68,6 +82,7 @@ class CheckListController extends BaseController @@ -68,6 +82,7 @@ class CheckListController extends BaseController
68 * @time :2025/4/17 9:32 82 * @time :2025/4/17 9:32
69 */ 83 */
70 public function save(){ 84 public function save(){
  85 + $this->param['operator_id'] = $this->manage['id'];
71 if(isset($this->param['id']) && !empty($this->param['id'])){ 86 if(isset($this->param['id']) && !empty($this->param['id'])){
72 $id = $this->param['id']; 87 $id = $this->param['id'];
73 $this->model->edit($this->param,['id'=>$this->param['id']]); 88 $this->model->edit($this->param,['id'=>$this->param['id']]);
@@ -321,6 +321,9 @@ class NewsController extends BaseController @@ -321,6 +321,9 @@ class NewsController extends BaseController
321 'keyword.required' => 'keyword不能为空', 321 'keyword.required' => 'keyword不能为空',
322 ]); 322 ]);
323 $data = curl_get('http://gnews.globalso.com/gnews_news.php?keyword='.$this->param['keyword'],true); 323 $data = curl_get('http://gnews.globalso.com/gnews_news.php?keyword='.$this->param['keyword'],true);
  324 + if(isset($data['data']['p'][0]) && !empty($data['data']['p'][0])){
  325 + $data['data']['p'][0] = str_replace('&nbsp' ,' ',$data['data']['p'][0]);
  326 + }
324 $this->response('success',Code::SUCCESS,$data); 327 $this->response('success',Code::SUCCESS,$data);
325 } 328 }
326 329
@@ -212,7 +212,7 @@ class DomainInfoLogic extends BaseLogic @@ -212,7 +212,7 @@ class DomainInfoLogic extends BaseLogic
212 $ssl_records = dns_get_record($ssl_domain,DNS_CNAME); 212 $ssl_records = dns_get_record($ssl_domain,DNS_CNAME);
213 $ssl_target = $ssl_records[0]['target']??''; 213 $ssl_target = $ssl_records[0]['target']??'';
214 if($ssl_target != '_acme-challenge.globalsosslcheck.com'){ 214 if($ssl_target != '_acme-challenge.globalsosslcheck.com'){
215 - $this->fail('域名' . $ssl_domain . '未解析至目标服务器'); 215 + $this->fail('缺少通配符证书必要的解析记录:'.$ssl_domain);
216 } 216 }
217 } 217 }
218 218
@@ -309,7 +309,8 @@ Route::middleware(['aloginauth'])->group(function () { @@ -309,7 +309,8 @@ Route::middleware(['aloginauth'])->group(function () {
309 309
310 //检查列表 310 //检查列表
311 Route::prefix('check_list')->group(function () { 311 Route::prefix('check_list')->group(function () {
312 - Route::any('/', [Aside\Optimize\CheckListController::class, 'lists'])->name('admin.check_list'); 312 + Route::any('/', [Aside\Optimize\CheckListController::class, 'lists'])->name('admin.check_lists');
  313 + Route::any('/list', [Aside\Optimize\CheckListController::class, 'list'])->name('admin.check_list');
313 Route::any('/info', [Aside\Optimize\CheckListController::class, 'info'])->name('admin.check_list_info'); 314 Route::any('/info', [Aside\Optimize\CheckListController::class, 'info'])->name('admin.check_list_info');
314 Route::any('/save', [Aside\Optimize\CheckListController::class, 'save'])->name('admin.check_list_save'); 315 Route::any('/save', [Aside\Optimize\CheckListController::class, 'save'])->name('admin.check_list_save');
315 Route::any('/del', [Aside\Optimize\CheckListController::class, 'del'])->name('admin.check_list_del'); 316 Route::any('/del', [Aside\Optimize\CheckListController::class, 'del'])->name('admin.check_list_del');