作者 李宇航

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

Lyh server



查看合并请求 !2002
... ... @@ -147,7 +147,7 @@ class AiVideoTask extends Command
if($route != $result['data']['url']){
$aiVideoService->updateDetail(['url'=>$route,'task_id'=>$item['task_id']]);
}
$description = explode(",",$result['data']['content']);
$description = explode(".",$result['data']['content']);
$saveData = [
'title'=>$result['data']['title'],
'image'=>$result['data']['thumb'],
... ...
... ... @@ -11,6 +11,7 @@ namespace App\Console\Commands\LyhTest;
use App\Console\Commands\Domain\DomainInfo;
use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Models\Ai\AiBlog;
use App\Models\Ai\AiBlogAuthor;
use App\Models\Com\NoticeLog;
use App\Models\Com\V6WeeklyReport;
... ... @@ -49,168 +50,45 @@ class lyhDemo extends Command
protected $description = '更新路由';
public function handle(){
$projectArr = [3257,1835,1834];
$v6WeekModel = new V6WeeklyReport();
foreach ($projectArr as $item){
$projectModel = new Project();
$latest = $v6WeekModel->formatQuery(['project_id'=>$item])->orderBy('id', 'desc')->first();
$list = $projectModel->read(['delete_status'=>0,'id'=>$item],['id','title','is_weekly_report','main_lang_id']);
$latest['main_lang_id'] = $list['main_lang_id'];
$latest['is_weekly_report'] = $list['is_weekly_report'];
$latest['title'] = $list['title'];
$this->workChatMessage($latest,$item);
}
return true;
}
public function workChatMessage($data,$project_id){
$arr = [];
//项目是否有绑定群
$friend_id = ProjectAssociation::where('project_id', $project_id)
->where('status', ProjectAssociation::STATUS_NORMAL)
->where('binding_app', ProjectAssociation::ENTERPRISE_WECHAT)
->value('friend_id');
if(!$friend_id){
echo date('Y-m-d H:i:s') . '没有绑定企微群:'.$project_id . PHP_EOL;
return false;
}
$content = '';
$content1 = '';
if(!empty($data['inquiry_total'])){
$content1 .= '项目共计已收到询盘 '.$data['inquiry_total'].'条,';
if(!empty($data['week_inquiry_total'])){
$content1 .= '本周新收 '.$data['week_inquiry_total'].' 封询盘。';
}
if(!empty($data['inquiry_country'])){
$data['inquiry_country'] = json_decode($data['inquiry_country'],true);
arsort($data['inquiry_country']);
$data['inquiry_country'] = array_slice($data['inquiry_country'], 0, 4, true);
$country = '';
foreach ($data['inquiry_country'] as $k => $v){
$country .= $k.',';
};
$country = trim($country,',');
if(!empty($country)){
$content1 .= '询盘主要来源于'.$country.'等国家地区。';
}
}
$content1 .= '如有高质量客户,请您密切关注与跟进;';
}
if(!empty($content1)){
$arr[] = $content1;
}
$content2 = '';
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'])){
$content2 .= '项目截止目前';
if($data['main_lang_id'] == 8){
$title = 'Yandex';
$lists = $projectModel->list(['delete_status' => 0,'extend_type'=>0,'type'=>['in',[1,2,3,4,6]]], 'id', ['id']);
foreach ($lists as $val) {
echo date('Y-m-d H:i:s') . '开始--项目的id:'. $val['id'] . PHP_EOL;
ProjectServer::useProject($val['id']);
$aiBlogModel = new AiBlog();
$aiLists = $aiBlogModel->list(['status'=>2],'id',['id','seo_description']);
if(!empty($aiLists)){
foreach ($aiLists as $item){
if(!empty($item['seo_description'])){
//查看当前是否包含句号。
$result = $this->hasAnyPeriod($item['seo_description']);
if($result === false){
$text = $this->trimToLastFullWord($item['seo_description']);
}else{
$title = '谷歌';
}
if(!empty($data['google_indexed_num'])){
$content2 .= $title.'收录量:'.$data['google_indexed_num'].'条,';
}
if(!empty($data['google_links_num'])){
//获取上一次的外链数
$latestRecord = V6WeeklyReport::where(['project_id'=>$project_id])->orderBy('id', 'desc')->first();
if(!empty($latestRecord)){
if($latestRecord['google_links_num'] != $data['google_links_num']){
$content2 .= '外链量:'.$data['google_links_num'].'条,';
}
}else{
$content2 .= '外链量:'.$data['google_links_num'].'条,';
}
}
if(!empty($data['keyword_home_num']) || !empty($data['keyword_three_num']) || !empty($data['keyword_five_num']) || !empty($data['keyword_ten_num'])){
$content2 .= $title.'搜索排名';
if(!empty($data['keyword_home_num'])){
$content2 .= '首页关键词数量为:'.$data['keyword_home_num'].'个,';
}
if(!empty($data['keyword_three_num'])){
$content2 .= '前三页关键词数量为:'.$data['keyword_three_num'].'个,';
}
if(!empty($data['keyword_five_num'])){
$content2 .= '前五页关键词数量为:'.$data['keyword_five_num'].'个,';
}
if(!empty($data['keyword_ten_num'])){
$content2 .= '前十页关键词数量为:'.$data['keyword_ten_num'].'个,';
$arr = explode('.',$item['seo_description']);
$text = $arr[0].'.';
}
$aiBlogModel->edit(['seo_description'=>$text],['id'=>$item['id']]);
}
if(!empty($data['daily_average_num'])){
$content2 .= '本周日均访客量:'.$data['daily_average_num'].'+。';
}
$content2 .= PHP_EOL.'全球搜建议用户持续分析、选择、添加企业、产品、服务等相关关键词进行优化和监控,以覆盖更多相关排名和流量;';
}
if(!empty($content2)){
$arr[] = $content2;
DB::disconnect('custom_mysql');
echo date('Y-m-d H:i:s') . '结束--项目的id:'. $val['id'] . PHP_EOL;
}
$content3 = '';
if(!empty($data['product_num']) || !empty($data['news_num']) || !empty($data['week_product_num']) || !empty($data['week_news_num'])){
if(!empty($data['product_num']) || !empty($data['news_num'])){
$content3 .= '项目截止目前';
if(!empty($data['product_num'])){
$content3 .= '发布产品:'.$data['product_num'].'条,';
}
if(!empty($data['news_num'])){
$content3 .= '发布新闻:'.$data['news_num'].'条。';
}
}
if(!empty($data['week_product_num']) || !empty($data['week_news_num'])){
$content3 .= '本周新增';
if(!empty($data['week_product_num'])){
$content3 .= '产品:'.$data['week_product_num'].'条,';
}
if(!empty($data['week_news_num'])){
$content3 .= '新闻:'.$data['week_news_num'].'条。';
}
}
$content3 .= PHP_EOL.'全球搜建议用户保持网站内容的持续更新与完善,可参考谷歌关于创建实用、可靠、以用户为中心的内容的相关建议:https://developers.google.com/search/docs/fundamentals/creating-helpful-content?hl=zh-cn;';
}
if(!empty($content3)){
$arr[] = $content3;
}
$content4 = '';
if(!empty($data['main_update_num'])){
$content4 .= '网站加载速度维护及主站页面更新'.$data['main_update_num'].'次。';
}
if(!empty($data['aggregation_update_num'])){
$content4 .= '聚合页主站页面更新'.$data['aggregation_update_num'].'次。';
}
if(!empty($data['minor_update_num'])){
$content4 .= '小语种站页面更新'.$data['minor_update_num'].'次。';
}
if(!empty($data['aggregation_minor_update_num'])){
$content4 .= '聚合页小语种站页面'.$data['aggregation_minor_update_num'].'次。';
}
if(!empty($content4)){
$content4 = PHP_EOL.'本周主要优化工作包括:TDK、H标签、Img标签等优化设置排查与进一步完善,Sitemap更新与网页收录提交,外链新增与排查。'.$content4;
}
if(!empty($content4)){
$arr[] = $content4;
}
if(empty($arr)){
return true;
}
foreach ($arr as $key => $val){
$content .= ($key+1).','.$val.PHP_EOL.PHP_EOL;
public function trimToLastFullWord($text) {
// 去掉结尾非字母数字字符
$text = rtrim($text);
// 如果最后一个单词被截断,就删除它
if (preg_match('/^(.*?\b)\w*$/', $text, $matches)) {
return $matches[1];
}
$tomorrowNineAM = date('Y-m-d 09:00:00', time());
if(empty($content)){
return true;
return trim($text); // fallback
}
$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和网站相关网页上同步发布视频;';
$message = "【全球搜V6.0周报】" . PHP_EOL . $content . PHP_EOL . $tips;
$param = [
'project_id'=>$project_id,
'friend_id'=>$friend_id,
'type'=>MessagePush::TYPE_WEEK,
'content'=> $message,
'ref_ids'=>'',
'send_time'=>$tomorrowNineAM,
'status'=>0,
];
//写入一条推送消息 自动消费
$messagePushModel = new MessagePush();
$messagePushModel->add($param);
return true;
public function hasAnyPeriod($text) {
return strpos($text, '.') !== false || mb_strpos($text, '。') !== false;
}
}
... ...