作者 李宇航

合并分支 'lyh-server' 到 'master'

Lyh server



查看合并请求 !2002
@@ -147,7 +147,7 @@ class AiVideoTask extends Command @@ -147,7 +147,7 @@ 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']); 150 + $description = explode(".",$result['data']['content']);
151 $saveData = [ 151 $saveData = [
152 'title'=>$result['data']['title'], 152 'title'=>$result['data']['title'],
153 'image'=>$result['data']['thumb'], 153 'image'=>$result['data']['thumb'],
@@ -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,45 @@ class lyhDemo extends Command @@ -49,168 +50,45 @@ 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 - }  
95 - }  
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 = '谷歌';  
108 - }  
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'].'条,'; 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 + echo date('Y-m-d H:i:s') . '开始--项目的id:'. $val['id'] . PHP_EOL;
  57 + ProjectServer::useProject($val['id']);
  58 + $aiBlogModel = new AiBlog();
  59 + $aiLists = $aiBlogModel->list(['status'=>2],'id',['id','seo_description']);
  60 + if(!empty($aiLists)){
  61 + foreach ($aiLists as $item){
  62 + if(!empty($item['seo_description'])){
  63 + //查看当前是否包含句号。
  64 + $result = $this->hasAnyPeriod($item['seo_description']);
  65 + if($result === false){
  66 + $text = $this->trimToLastFullWord($item['seo_description']);
  67 + }else{
  68 + $arr = explode('.',$item['seo_description']);
  69 + $text = $arr[0].'.';
  70 + }
  71 + $aiBlogModel->edit(['seo_description'=>$text],['id'=>$item['id']]);
118 } 72 }
119 - }else{  
120 - $content2 .= '外链量:'.$data['google_links_num'].'条,';  
121 - }  
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 } 73 }
134 - if(!empty($data['keyword_ten_num'])){  
135 - $content2 .= '前十页关键词数量为:'.$data['keyword_ten_num'].'个,';  
136 - }  
137 - }  
138 - if(!empty($data['daily_average_num'])){  
139 - $content2 .= '本周日均访客量:'.$data['daily_average_num'].'+。';  
140 } 74 }
141 - $content2 .= PHP_EOL.'全球搜建议用户持续分析、选择、添加企业、产品、服务等相关关键词进行优化和监控,以覆盖更多相关排名和流量;';  
142 - }  
143 - if(!empty($content2)){  
144 - $arr[] = $content2; 75 + DB::disconnect('custom_mysql');
  76 + echo date('Y-m-d H:i:s') . '结束--项目的id:'. $val['id'] . PHP_EOL;
145 } 77 }
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 - }  
156 - }  
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'].'条。';  
164 - }  
165 - }  
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'].'次。';  
183 - }  
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; 78 return true;
215 } 79 }
  80 +
  81 + public function trimToLastFullWord($text) {
  82 + // 去掉结尾非字母数字字符
  83 + $text = rtrim($text);
  84 + // 如果最后一个单词被截断,就删除它
  85 + if (preg_match('/^(.*?\b)\w*$/', $text, $matches)) {
  86 + return $matches[1];
  87 + }
  88 + return trim($text); // fallback
  89 + }
  90 +
  91 + public function hasAnyPeriod($text) {
  92 + return strpos($text, '.') !== false || mb_strpos($text, '。') !== false;
  93 + }
216 } 94 }