作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

@@ -128,7 +128,7 @@ class AiBlogAutoPublish extends Command @@ -128,7 +128,7 @@ class AiBlogAutoPublish extends Command
128 public function createTask($keywords, $project_id, $frequency){ 128 public function createTask($keywords, $project_id, $frequency){
129 $keyword = $keywords[array_rand($keywords)]; 129 $keyword = $keywords[array_rand($keywords)];
130 $aiBlogService = new AiBlogService($project_id); 130 $aiBlogService = new AiBlogService($project_id);
131 - $result = $aiBlogService->setRoute($keyword)->createTask($keyword); 131 + $result = $aiBlogService->createTask($keyword);
132 if ($result['status'] == 200) { 132 if ($result['status'] == 200) {
133 $aiBlogTaskModel = new AiBlogTaskModel(); 133 $aiBlogTaskModel = new AiBlogTaskModel();
134 $next_auto_date = date('Y-m-d', strtotime('+' . mt_rand($frequency[0],$frequency[1]) . 'days')); //每3-6天自动发布 134 $next_auto_date = date('Y-m-d', strtotime('+' . mt_rand($frequency[0],$frequency[1]) . 'days')); //每3-6天自动发布
@@ -147,7 +147,6 @@ class AiVideoTask extends Command @@ -147,7 +147,6 @@ class AiVideoTask extends Command
147 if($route != $result['data']['url']){ 147 if($route != $result['data']['url']){
148 $aiVideoService->updateDetail(['url'=>$route,'task_id'=>$item['task_id']]); 148 $aiVideoService->updateDetail(['url'=>$route,'task_id'=>$item['task_id']]);
149 } 149 }
150 - $description = explode(",",$result['data']['content']);  
151 $saveData = [ 150 $saveData = [
152 'title'=>$result['data']['title'], 151 'title'=>$result['data']['title'],
153 'image'=>$result['data']['thumb'], 152 'image'=>$result['data']['thumb'],
@@ -160,7 +159,7 @@ class AiVideoTask extends Command @@ -160,7 +159,7 @@ class AiVideoTask extends Command
160 'status'=>$aiVideoTaskModel::STATUS_FINISH, 159 'status'=>$aiVideoTaskModel::STATUS_FINISH,
161 'seo_title'=>$result['data']['title'], 160 'seo_title'=>$result['data']['title'],
162 'seo_keyword'=>implode(',',$result['data']['keyword']), 161 'seo_keyword'=>implode(',',$result['data']['keyword']),
163 - 'seo_description'=>$description[0] ?? '', 162 + 'seo_description'=>$result['data']['description'] ?? '',
164 ]; 163 ];
165 $aiVideoModel->edit($saveData,['task_id'=>$item['task_id']]); 164 $aiVideoModel->edit($saveData,['task_id'=>$item['task_id']]);
166 //需要更新的路由 165 //需要更新的路由
@@ -771,7 +771,7 @@ class RelayInquiry extends Command @@ -771,7 +771,7 @@ class RelayInquiry extends Command
771 */ 771 */
772 public function getInquiry($num = 10) 772 public function getInquiry($num = 10)
773 { 773 {
774 - $result = ReInquiryForm::where(['status' => ReInquiryForm::STATUS_INIT])->where('created_at', '>', '2025-04-27 00:00:00')->orderBy('id', 'asc')->limit($num)->get(); 774 + $result = ReInquiryForm::where(['status' => ReInquiryForm::STATUS_INIT])->where('created_at', '>', '2025-05-22 18:00:00')->orderBy('id', 'asc')->limit($num)->get();
775 return $result; 775 return $result;
776 } 776 }
777 777
@@ -11,6 +11,7 @@ namespace App\Console\Commands\LyhTest; @@ -11,6 +11,7 @@ namespace App\Console\Commands\LyhTest;
11 11
12 use App\Console\Commands\Domain\DomainInfo; 12 use App\Console\Commands\Domain\DomainInfo;
13 use App\Http\Logic\Aside\Project\ProjectLogic; 13 use App\Http\Logic\Aside\Project\ProjectLogic;
  14 +use App\Models\Ai\AiBlog;
14 use App\Models\Ai\AiBlogAuthor; 15 use App\Models\Ai\AiBlogAuthor;
15 use App\Models\Com\NoticeLog; 16 use App\Models\Com\NoticeLog;
16 use App\Models\Com\V6WeeklyReport; 17 use App\Models\Com\V6WeeklyReport;
@@ -49,168 +50,79 @@ class lyhDemo extends Command @@ -49,168 +50,79 @@ class lyhDemo extends Command
49 protected $description = '更新路由'; 50 protected $description = '更新路由';
50 51
51 public function handle(){ 52 public function handle(){
52 - $projectArr = [3257,1835,1834];  
53 - $v6WeekModel = new V6WeeklyReport();  
54 - foreach ($projectArr as $item){  
55 - $projectModel = new Project();  
56 - $latest = $v6WeekModel->formatQuery(['project_id'=>$item])->orderBy('id', 'desc')->first();  
57 - $list = $projectModel->read(['delete_status'=>0,'id'=>$item],['id','title','is_weekly_report','main_lang_id']);  
58 - $latest['main_lang_id'] = $list['main_lang_id'];  
59 - $latest['is_weekly_report'] = $list['is_weekly_report'];  
60 - $latest['title'] = $list['title'];  
61 - $this->workChatMessage($latest,$item);  
62 - }  
63 - return true;  
64 - }  
65 - public function workChatMessage($data,$project_id){  
66 - $arr = [];  
67 - //项目是否有绑定群  
68 - $friend_id = ProjectAssociation::where('project_id', $project_id)  
69 - ->where('status', ProjectAssociation::STATUS_NORMAL)  
70 - ->where('binding_app', ProjectAssociation::ENTERPRISE_WECHAT)  
71 - ->value('friend_id');  
72 - if(!$friend_id){  
73 - echo date('Y-m-d H:i:s') . '没有绑定企微群:'.$project_id . PHP_EOL;  
74 - return false;  
75 - }  
76 - $content = '';  
77 - $content1 = '';  
78 - if(!empty($data['inquiry_total'])){  
79 - $content1 .= '项目共计已收到询盘 '.$data['inquiry_total'].'条,';  
80 - if(!empty($data['week_inquiry_total'])){  
81 - $content1 .= '本周新收 '.$data['week_inquiry_total'].' 封询盘。';  
82 - }  
83 - if(!empty($data['inquiry_country'])){  
84 - $data['inquiry_country'] = json_decode($data['inquiry_country'],true);  
85 - arsort($data['inquiry_country']);  
86 - $data['inquiry_country'] = array_slice($data['inquiry_country'], 0, 4, true);  
87 - $country = '';  
88 - foreach ($data['inquiry_country'] as $k => $v){  
89 - $country .= $k.',';  
90 - };  
91 - $country = trim($country,',');  
92 - if(!empty($country)){  
93 - $content1 .= '询盘主要来源于'.$country.'等国家地区。';  
94 - } 53 + $projectModel = new Project();
  54 + $lists = $projectModel->list(['delete_status' => 0,'extend_type'=>0,'type'=>['in',[1,2,3,4,6]]], 'id', ['id']);
  55 + foreach ($lists as $val) {
  56 + $aiSettingInfo = $this->getSetting($val['id']);
  57 + if($aiSettingInfo === false){
  58 + echo '当前项目未注册。'.$val['id'].PHP_EOL;
  59 + continue;
95 } 60 }
96 - $content1 .= '如有高质量客户,请您密切关注与跟进;';  
97 - }  
98 - if(!empty($content1)){  
99 - $arr[] = $content1;  
100 - }  
101 - $content2 = '';  
102 - if(!empty($data['google_indexed_num']) || !empty($data['google_links_num']) || !empty($data['keyword_home_num']) || !empty($data['keyword_three_num']) || !empty($data['keyword_five_num']) || !empty($data['keyword_ten_num']) || !empty($data['daily_average_num'])){  
103 - $content2 .= '项目截止目前';  
104 - if($data['main_lang_id'] == 8){  
105 - $title = 'Yandex';  
106 - }else{  
107 - $title = '谷歌'; 61 + $aiBlogTaskModel = new AiBlogTask();
  62 + $blog_lists = $aiBlogTaskModel->list(['type'=>2,'status'=>2,'project_id'=>$val['id']]);
  63 + if(empty($blog_lists)){
  64 + echo '未获取到ao_blog'.PHP_EOL;
  65 + continue;
108 } 66 }
109 - if(!empty($data['google_indexed_num'])){  
110 - $content2 .= $title.'收录量:'.$data['google_indexed_num'].'条,';  
111 - }  
112 - if(!empty($data['google_links_num'])){  
113 - //获取上一次的外链数  
114 - $latestRecord = V6WeeklyReport::where(['project_id'=>$project_id])->orderBy('id', 'desc')->first();  
115 - if(!empty($latestRecord)){  
116 - if($latestRecord['google_links_num'] != $data['google_links_num']){  
117 - $content2 .= '外链量:'.$data['google_links_num'].'条,';  
118 - }  
119 - }else{  
120 - $content2 .= '外链量:'.$data['google_links_num'].'条,'; 67 + echo date('Y-m-d H:i:s') . '开始--项目的id:'. $val['id'] . PHP_EOL;
  68 + ProjectServer::useProject($val['id']);
  69 + $aiBlogService = new AiBlogService($val['id']);
  70 + foreach ($blog_lists as $item) {
  71 + $aiBlogModel = new AiBlog();
  72 + $aiBlogInfo = $aiBlogModel->read(['task_id' => $item['task_id']], ['id']);
  73 + if ($aiBlogInfo === false) {
  74 + continue;
121 } 75 }
122 - }  
123 - if(!empty($data['keyword_home_num']) || !empty($data['keyword_three_num']) || !empty($data['keyword_five_num']) || !empty($data['keyword_ten_num'])){  
124 - $content2 .= $title.'搜索排名';  
125 - if(!empty($data['keyword_home_num'])){  
126 - $content2 .= '首页关键词数量为:'.$data['keyword_home_num'].'个,';  
127 - }  
128 - if(!empty($data['keyword_three_num'])){  
129 - $content2 .= '前三页关键词数量为:'.$data['keyword_three_num'].'个,';  
130 - }  
131 - if(!empty($data['keyword_five_num'])){  
132 - $content2 .= '前五页关键词数量为:'.$data['keyword_five_num'].'个,';  
133 - }  
134 - if(!empty($data['keyword_ten_num'])){  
135 - $content2 .= '前十页关键词数量为:'.$data['keyword_ten_num'].'个,'; 76 + try {
  77 + $aiBlogService->task_id = $item['task_id'];
  78 + //拉取文章数据
  79 + $result = $aiBlogService->getDetail();
  80 + if (isset($result) && ($result['status'] == 200)) {
  81 + $aiBlogModel->edit(['seo_description' => $result['data']['description']], ['task_id' => $item['task_id']]);
  82 + }
  83 + } catch (\Exception $e) {
  84 + echo '跳过。' . PHP_EOL;
  85 + continue;
136 } 86 }
137 } 87 }
138 - if(!empty($data['daily_average_num'])){  
139 - $content2 .= '本周日均访客量:'.$data['daily_average_num'].'+。';  
140 - }  
141 - $content2 .= PHP_EOL.'全球搜建议用户持续分析、选择、添加企业、产品、服务等相关关键词进行优化和监控,以覆盖更多相关排名和流量;';  
142 - }  
143 - if(!empty($content2)){  
144 - $arr[] = $content2; 88 + DB::disconnect('custom_mysql');
  89 + echo date('Y-m-d H:i:s') . '结束--项目的id:'. $val['id'] . PHP_EOL;
145 } 90 }
146 - $content3 = '';  
147 - if(!empty($data['product_num']) || !empty($data['news_num']) || !empty($data['week_product_num']) || !empty($data['week_news_num'])){  
148 - if(!empty($data['product_num']) || !empty($data['news_num'])){  
149 - $content3 .= '项目截止目前';  
150 - if(!empty($data['product_num'])){  
151 - $content3 .= '发布产品:'.$data['product_num'].'条,';  
152 - }  
153 - if(!empty($data['news_num'])){  
154 - $content3 .= '发布新闻:'.$data['news_num'].'条。';  
155 - } 91 + return true;
  92 + }
  93 +
  94 + public function _action(){
  95 + $aiBlogTaskModel = new AiBlogTask();
  96 + $lists = $aiBlogTaskModel->list(['type'=>2,'status'=>2,'project_id'=>467]);
  97 + foreach ($lists as $item){
  98 + echo date('Y-m-d H:i:s') . '开始--项目的id:'. $item['project_id'] . PHP_EOL;
  99 + ProjectServer::useProject($item['project_id']);
  100 + $aiBlogModel = new AiBlog();
  101 + $aiBlogInfo = $aiBlogModel->read(['task_id'=>$item['task_id']],['id','route']);
  102 + if($aiBlogInfo === false){
  103 + continue;
156 } 104 }
157 - if(!empty($data['week_product_num']) || !empty($data['week_news_num'])){  
158 - $content3 .= '本周新增';  
159 - if(!empty($data['week_product_num'])){  
160 - $content3 .= '产品:'.$data['week_product_num'].'条,';  
161 - }  
162 - if(!empty($data['week_news_num'])){  
163 - $content3 .= '新闻:'.$data['week_news_num'].'条。'; 105 + try {
  106 + $aiBlogService = new AiBlogService($item['project_id']);
  107 + $aiBlogService->task_id = $item['task_id'];
  108 + //拉取文章数据
  109 + $result = $aiBlogService->getDetail();
  110 + if(isset($result) && ($result['status'] == 200)){
  111 + $aiBlogModel->edit(['seo_description'=>$result['data']['description']],['task_id'=>$item['task_id']]);
164 } 112 }
  113 + }catch (\Exception $e){
  114 + echo '跳过。'.PHP_EOL;
165 } 115 }
166 - $content3 .= PHP_EOL.'全球搜建议用户保持网站内容的持续更新与完善,可参考谷歌关于创建实用、可靠、以用户为中心的内容的相关建议:https://developers.google.com/search/docs/fundamentals/creating-helpful-content?hl=zh-cn;';  
167 - }  
168 - if(!empty($content3)){  
169 - $arr[] = $content3;  
170 - }  
171 - $content4 = '';  
172 - if(!empty($data['main_update_num'])){  
173 - $content4 .= '网站加载速度维护及主站页面更新'.$data['main_update_num'].'次。';  
174 - }  
175 - if(!empty($data['aggregation_update_num'])){  
176 - $content4 .= '聚合页主站页面更新'.$data['aggregation_update_num'].'次。';  
177 - }  
178 - if(!empty($data['minor_update_num'])){  
179 - $content4 .= '小语种站页面更新'.$data['minor_update_num'].'次。';  
180 - }  
181 - if(!empty($data['aggregation_minor_update_num'])){  
182 - $content4 .= '聚合页小语种站页面'.$data['aggregation_minor_update_num'].'次。'; 116 + DB::disconnect('custom_mysql');
  117 + echo date('Y-m-d H:i:s') . '结束--项目的id:'. $item['project_id'] . PHP_EOL;
183 } 118 }
184 - if(!empty($content4)){  
185 - $content4 = PHP_EOL.'本周主要优化工作包括:TDK、H标签、Img标签等优化设置排查与进一步完善,Sitemap更新与网页收录提交,外链新增与排查。'.$content4;  
186 - }  
187 - if(!empty($content4)){  
188 - $arr[] = $content4;  
189 - }  
190 - if(empty($arr)){  
191 - return true;  
192 - }  
193 - foreach ($arr as $key => $val){  
194 - $content .= ($key+1).','.$val.PHP_EOL.PHP_EOL;  
195 - }  
196 - $tomorrowNineAM = date('Y-m-d 09:00:00', time());  
197 - if(empty($content)){  
198 - return true;  
199 - }  
200 - $tips = 'Tips:'.PHP_EOL.'1、全球搜V6.0系统提供网页TDK、H标签、Img标签等用户自定义编辑接口且辅以AI创作工具,用户可进一步对相关优化设置进行精细化优化与调整;'.PHP_EOL.'2、全球搜V6.0系统提供小语种页面精准校对翻译功能,用户可进一步对已翻译小语种页面进行人工翻译校对;'.PHP_EOL.'3、全球搜V6.0系统支持绑定Facebook、LinkedIn、X(原Twitter)等社媒账号,可一键同步转发网站上发布的产品和新闻至社媒账号动态,建议用户用起来哦;'.PHP_EOL.'4、如用户有较丰富的企业、产品、服务相关视频素材,全球搜建议用户及时创建YouTube主页,并在YouTube和网站相关网页上同步发布视频;';  
201 - $message = "【全球搜V6.0周报】" . PHP_EOL . $content . PHP_EOL . $tips;  
202 - $param = [  
203 - 'project_id'=>$project_id,  
204 - 'friend_id'=>$friend_id,  
205 - 'type'=>MessagePush::TYPE_WEEK,  
206 - 'content'=> $message,  
207 - 'ref_ids'=>'',  
208 - 'send_time'=>$tomorrowNineAM,  
209 - 'status'=>0,  
210 - ];  
211 - //写入一条推送消息 自动消费  
212 - $messagePushModel = new MessagePush();  
213 - $messagePushModel->add($param);  
214 - return true;  
215 } 119 }
  120 +
  121 + public function getSetting($project_id)
  122 + {
  123 + $projectAiSettingModel = new ProjectAiSetting();
  124 + $aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$project_id]);
  125 + return $aiSettingInfo;
  126 + }
  127 +
216 } 128 }
@@ -52,6 +52,12 @@ class SyncSubmitTask extends Command @@ -52,6 +52,12 @@ class SyncSubmitTask extends Command
52 continue; 52 continue;
53 } 53 }
54 try { 54 try {
  55 + //有globalso-domain时,用globalso-domain,兼容白帽版的-海龙
  56 + if(!empty($task_info['data']['data']['globalso-domain'])){
  57 + $data = $task_info['data'];
  58 + $data['domain'] = $task_info['data']['data']['globalso-domain'];
  59 + $task_info['data'] = $data;
  60 + }
55 $project = Project::getProjectByDomain($task_info['data']['domain'] ?? ''); 61 $project = Project::getProjectByDomain($task_info['data']['domain'] ?? '');
56 if(!$project){ 62 if(!$project){
57 //是否有关联的域名 63 //是否有关联的域名
@@ -291,7 +291,7 @@ class OptimizationReportController extends BaseController @@ -291,7 +291,7 @@ class OptimizationReportController extends BaseController
291 //复制站点域名 291 //复制站点域名
292 $ext_projects = $this->getExtendProjects(); 292 $ext_projects = $this->getExtendProjects();
293 $flg_ext = $this->getExtFlag($ext_projects, $domain, $api_no); 293 $flg_ext = $this->getExtFlag($ext_projects, $domain, $api_no);
294 - $ext_domain = str_replace('www.', '', $this->getExtendProjects($api_no)['ext'] ?? '');//关联域名 294 + $ext_domain = explode(',', str_replace('www.', '', $this->getExtendProjects($api_no)['ext'] ?? ''));//关联域名
295 //关联域名 295 //关联域名
296 $relate_domain = str_replace('www.', '', InquiryRelateDomain::getRelateDomain($domain, 'globalso_domain')); 296 $relate_domain = str_replace('www.', '', InquiryRelateDomain::getRelateDomain($domain, 'globalso_domain'));
297 //AI站点域名 297 //AI站点域名
@@ -316,11 +316,11 @@ class OptimizationReportController extends BaseController @@ -316,11 +316,11 @@ class OptimizationReportController extends BaseController
316 $domain_text = 'AI域名:' . $last['r']; 316 $domain_text = 'AI域名:' . $last['r'];
317 if (in_array($flg_ext, [1, 2]) || $flg_ai == 1) { 317 if (in_array($flg_ext, [1, 2]) || $flg_ai == 1) {
318 if ($last['r'] == $ai_domain) { 318 if ($last['r'] == $ai_domain) {
319 - $domain_text = '星链域名:' . $ai_domain;  
320 - } else if ($last['r'] == $ext_domain) {  
321 - $domain_text = '主域名2:' . $ext_domain; 319 + $domain_text = '星链域名:' . $last['r'];
  320 + } else if (in_array($last['r'], $ext_domain)) {
  321 + $domain_text = '主域名2:' . $last['r'];
322 } else if ($last['r'] == $relate_domain) { 322 } else if ($last['r'] == $relate_domain) {
323 - $domain_text = '主域名2:' . $relate_domain; 323 + $domain_text = '主域名2:' . $last['r'];
324 } else { 324 } else {
325 $domain_text = 'AI域名:' . $last['r']; 325 $domain_text = 'AI域名:' . $last['r'];
326 } 326 }
@@ -235,7 +235,7 @@ class RankDataLogic extends BaseLogic @@ -235,7 +235,7 @@ class RankDataLogic extends BaseLogic
235 //复制站点域名 235 //复制站点域名
236 $ext_projects = $this->getExtendProjects(); 236 $ext_projects = $this->getExtendProjects();
237 $flg_ext = $this->getExtFlag($ext_projects, $domain, $api_no); 237 $flg_ext = $this->getExtFlag($ext_projects, $domain, $api_no);
238 - $ext_domain = str_replace('www.', '', $this->getExtendProjects($api_no)['ext'] ?? ''); 238 + $ext_domain = explode(',', str_replace('www.', '', $this->getExtendProjects($api_no)['ext'] ?? ''));//关联域名
239 $main_domain = str_replace('www.', '', $this->getExtendProjects($api_no)['url'] ?? ''); 239 $main_domain = str_replace('www.', '', $this->getExtendProjects($api_no)['url'] ?? '');
240 //关联域名 240 //关联域名
241 $relate_domain = str_replace('www.', '', InquiryRelateDomain::getRelateDomain($domain, 'globalso_domain')); 241 $relate_domain = str_replace('www.', '', InquiryRelateDomain::getRelateDomain($domain, 'globalso_domain'));
@@ -266,11 +266,11 @@ class RankDataLogic extends BaseLogic @@ -266,11 +266,11 @@ class RankDataLogic extends BaseLogic
266 $domain_text = 'AI域名:' . $last['r']; 266 $domain_text = 'AI域名:' . $last['r'];
267 if (in_array($flg_ext, [1, 2]) || $flg_ai == 1) { 267 if (in_array($flg_ext, [1, 2]) || $flg_ai == 1) {
268 if ($last['r'] == $ai_domain) { 268 if ($last['r'] == $ai_domain) {
269 - $domain_text = '星链域名:' . $ai_domain;  
270 - } else if ($last['r'] == $ext_domain) {  
271 - $domain_text = '主域名2:' . $ext_domain; 269 + $domain_text = '星链域名:' . $last['r'];
  270 + } else if (in_array($last['r'], $ext_domain)) {
  271 + $domain_text = '主域名2:' . $last['r'];
272 } else if ($last['r'] == $relate_domain) { 272 } else if ($last['r'] == $relate_domain) {
273 - $domain_text = '主域名2:' . $relate_domain; 273 + $domain_text = '主域名2:' . $last['r'];
274 } else { 274 } else {
275 $domain_text = 'AI域名:' . $last['r']; 275 $domain_text = 'AI域名:' . $last['r'];
276 } 276 }
@@ -43,7 +43,7 @@ class SyncSubmitTask extends Model @@ -43,7 +43,7 @@ class SyncSubmitTask extends Model
43 } 43 }
44 try { 44 try {
45 $data = [ 45 $data = [
46 - 'data' => $data['data'], 46 + 'data' => $data['data'] ?? $data,
47 'domain' => !empty($data['domain']) ? $data['domain'] : request()->getHost(), 47 'domain' => !empty($data['domain']) ? $data['domain'] : request()->getHost(),
48 'ip' => !empty($data['ip']) ? $data['ip'] : request()->getClientIp(), 48 'ip' => !empty($data['ip']) ? $data['ip'] : request()->getClientIp(),
49 'referer' => !empty($data['referer']) ? $data['referer'] : request()->header('Referer'), 49 'referer' => !empty($data['referer']) ? $data['referer'] : request()->header('Referer'),
@@ -99,7 +99,6 @@ class AiBlogService @@ -99,7 +99,6 @@ class AiBlogService
99 $param['title'] = $title; 99 $param['title'] = $title;
100 } 100 }
101 $param['anchor'] = $anchor; 101 $param['anchor'] = $anchor;
102 - $param['url'] = $this->route;  
103 $param['mch_id'] = $this->mch_id; 102 $param['mch_id'] = $this->mch_id;
104 $param['template_id'] = 1; 103 $param['template_id'] = 1;
105 $this->sign = $this->generateSign($param,$this->key); 104 $this->sign = $this->generateSign($param,$this->key);