作者 赵彬吉
... ... @@ -123,7 +123,8 @@ class AiBlogAuthorTask extends Command
'description'=>$v['description'],
];
$id = $aiBlogAuthorModel->addReturnId($param);
$route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $id, $project_id);
$route = RouteMap::setRoute($v['route'] ?? $v['title'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $id, $project_id);
RouteMap::setRoute('top-blog',RouteMap::SOURCE_AI_BLOG_LIST,0,$project_id);//写一条列表页路由
$aiBlogAuthorModel->edit(['route'=>$route],['id'=>$id]);
}
}
... ...
<?php
/**
* @remark :
* @name :AiBlogTask.php
* @author :lyh
* @method :post
* @time :2025/2/14 11:14
*/
namespace App\Console\Commands\AiBlog;
use App\Models\Ai\AiBlog;
use App\Models\Ai\AiBlogAuthor;
use App\Models\Ai\AiBlogList;
use App\Models\Project\ProjectAiSetting;
use App\Models\RouteMap\RouteMap;
use App\Services\AiBlogService;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use App\Models\Project\AiBlogTask as AiBlogTaskModel;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use function Symfony\Component\String\s;
class AiBlogListTask extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'save_ai_blog_list';
/**
* The console command description.
*
* @var string
*/
protected $description = '查询ai_blog是否已经生成';
public function handle(){
$aiBlogTaskModel = new AiBlogTaskModel();
$lists = $aiBlogTaskModel->list(['type'=>3,'status'=>1]);
foreach ($lists as $k => $v){
echo '开始->项目id:' . $v['project_id'] . PHP_EOL . date('Y-m-d H:i:s');
$projectAiSettingModel = new ProjectAiSetting();
$aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$v['project_id']]);
if($aiSettingInfo === false){
continue;
}
$aiBlogService = new AiBlogService();
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
$aiBlogService->key = $aiSettingInfo['key'];
$page = 1;
$saveData = [];
$result = $aiBlogService->getAiBlogList($page,15);
if(!isset($result['status']) && $result['status'] != 200){
continue;
}
$total_page = $result['data']['total_page'];
//组装数据保存
$saveData[] = [
'route'=>$page,
'text'=>$result['data']['section'],
];
while ($total_page > $page){
$page++;
$result = $aiBlogService->getAiBlogList($page,15);
if(isset($result['status']) && $result['status'] == 200){
$saveData[] = [
'route'=>$page,
'text'=>$result['data']['section'],
];
}
}
//保存当前项目ai_blog数据
ProjectServer::useProject($v['project_id']);
$aiBlogListModel = new AiBlogList();
if(!empty($saveData)){
//写一条路由信息
RouteMap::setRoute('top-blog',RouteMap::SOURCE_AI_BLOG_LIST,0,$v['project_id']);
$aiBlogListModel->truncate();
$aiBlogListModel->insertAll($saveData);
}
DB::disconnect('custom_mysql');
//修改任务状态
$aiBlogTaskModel->edit(['status'=>2],['id'=>$v['id']]);
echo '结束->->项目id:' . $v['project_id'] . PHP_EOL . date('Y-m-d H:i:s');
}
return true;
}
}
... ... @@ -11,6 +11,7 @@ namespace App\Console\Commands\AiBlog;
use App\Models\Ai\AiBlog;
use App\Models\Ai\AiBlogAuthor;
use App\Models\Ai\AiBlogList;
use App\Models\Project\ProjectAiSetting;
use App\Models\RouteMap\RouteMap;
use App\Services\AiBlogService;
... ... @@ -76,6 +77,7 @@ class AiBlogTask extends Command
}
$aiBlogModel->edit(['new_title'=>$result['data']['title'], 'image'=>$result['data']['thumb'], 'text'=>$result['data']['section'], 'author_id'=>$result['data']['author_id'], 'route'=>$route ,'status'=>2], ['task_id'=>$info['task_id']]);
$this->updateAiBlogAuthor($aiSettingInfo,$result['data']['author_id']);
$this->updateBlogList($aiSettingInfo);
DB::disconnect('custom_mysql');
//修改任务状态
$aiBlogTaskModel->edit(['status'=>2],['id'=>$info['id']]);
... ... @@ -128,4 +130,46 @@ class AiBlogTask extends Command
}
return true;
}
/**
* @remark :更新列表页
* @name :updateBlogList
* @author :lyh
* @method :post
* @time :2025/2/26 15:42
*/
public function updateBlogList($aiSettingInfo){
$aiBlogService = new AiBlogService();
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
$aiBlogService->key = $aiSettingInfo['key'];
$page = 1;
$saveData = [];
$result = $aiBlogService->getAiBlogList($page,15);
if(!isset($result['status']) && $result['status'] != 200){
return true;
}
$total_page = $result['data']['total_page'];
//组装数据保存
$saveData[] = [
'route'=>$page,
'text'=>$result['data']['section'],
];
while ($total_page > $page){
$page++;
$result = $aiBlogService->getAiBlogList($page,15);
if(isset($result['status']) && $result['status'] == 200){
$saveData[] = [
'route'=>$page,
'text'=>$result['data']['section'],
];
}
}
$aiBlogListModel = new AiBlogList();
if(!empty($saveData)){
//写一条路由信息
$aiBlogListModel->truncate();
$aiBlogListModel->insertAll($saveData);
}
return true;
}
}
... ...
... ... @@ -10,10 +10,13 @@
namespace App\Console\Commands\LyhTest;
use App\Helper\Common;
use App\Models\Com\V6WeeklyReport;
use App\Models\Product\Category;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Product;
use App\Models\ProjectAssociation\ProjectAssociation;
use App\Models\RouteMap\RouteMap;
use App\Models\Workchat\MessagePush;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
... ... @@ -37,12 +40,14 @@ class DownloadProject extends Command
protected $description = '导出项目数据';
public function handle(){
ProjectServer::useProject(1646);
ProjectServer::useProject(5);
echo date('Y-m-d H:i:s') . 'start' . PHP_EOL;
$data = $this->downloadProduct();
$v6WeekModel = new V6WeeklyReport();
$data = $v6WeekModel->read(['id'=>28058]);
$data = $this->workChatMessage($data,5);
DB::disconnect('custom_mysql');
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
return $this->exportData($data);
return true;
}
public function downloadProduct()
... ... @@ -202,4 +207,121 @@ class DownloadProject extends Command
// }
// return $lists;
// }
public function workChatMessage($data,$project_id){
$arr = [];
$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,'、');
$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(!empty($data['google_indexed_num'])){
$content2 .= '谷歌收录量:'.$data['google_indexed_num'].'条,';
}
if(!empty($data['google_links_num'])){
$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 .= '谷歌搜索排名';
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'].'个,';
}
}
if(!empty($data['daily_average_num'])){
$content2 .= '本周日均访客量:'.$data['daily_average_num'].'+。';
}
$content2 .= '全球搜建议用户持续分析、选择、添加企业、产品、服务等相关关键词进行优化和监控,以覆盖更多相关排名和流量;';
}
if(!empty($content2)){
$arr[] = $content2;
}
$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 .= '全球搜建议用户保持网站内容的持续更新与完善,可参考谷歌关于创建实用、可靠、以用户为中心的内容的相关建议:https://developers.google.com/search/docs/fundamentals/creating-helpful-content?hl=zh-cn;';
$arr[] = $content3;
$content4 = '本周主要优化工作包括:TDK、H标签、Img标签等优化设置排查与进一步完善,Sitemap更新与网页收录提交,外链新增与排查。';
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['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'].'次。';
}
$arr[] = $content4;
foreach ($arr as $key => $val){
$content .= ($key+1).','.$val;
}
$timestamp = strtotime('tomorrow 9:00 AM');
$tomorrowNineAM = date('Y-m-d H:i:s', $timestamp);
$param = [
'project_id'=>$project_id,
'friend_id'=>1,
'type'=>MessagePush::TYPE_WEEK,
'content'=>$content,
'ref_ids'=>'',
'send_time'=>$tomorrowNineAM,
'status'=>3,
];
//写入一条推送消息 自动消费
$messagePushModel = new MessagePush();
$messagePushModel->add($param);
echo date('Y-m-d H:i:s') . '数据:'. $content . PHP_EOL;
}
}
... ...
... ... @@ -16,13 +16,16 @@ use App\Models\HomeCount\Count;
use App\Models\News\News;
use App\Models\Product\Product;
use App\Models\Project\Project;
use App\Models\ProjectAssociation\ProjectAssociation;
use App\Models\RankData\ExternalLinks;
use App\Models\RankData\RankData;
use App\Models\RankData\RankWeek;
use App\Models\Workchat\MessagePush;
use App\Services\ProjectServer;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class WeekProject extends Command
{
... ... @@ -49,7 +52,7 @@ class WeekProject extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['delete_status'=>0,'type'=>['in',[1,2,3,4,6]]],'id',['id','title']);
$list = $projectModel->list(['delete_status'=>0,'is_weekly_report'=>1,'type'=>['in',[1,2,3,4,6]]],'id',['id','title']);
foreach ($list as $k => $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
... ... @@ -97,8 +100,10 @@ class WeekProject extends Command
$data['keyword_ten_num'] = $rankInfo['first_ten_pages_num'] ?? 0;
$productModel = new Product();
$data['product_num'] = $productModel->counts(['status'=>1]) ?? 0;
$data['week_product_num'] = $productModel->counts(['status'=>1,'created_at'=>['between',[$startOfLastWeek,$endOfLastWeek]]]) ?? 0;
$newsModel = new News();
$data['news_num'] = $newsModel->counts(['status'=>1]) ?? 0;
$data['week_news_num'] = $newsModel->counts(['status'=>1,'created_at'=>['between',[$startOfLastWeek,$endOfLastWeek]]]) ?? 0;
$blogModel = new Blog();
$data['blog_num'] = $blogModel->counts(['status'=>1]) ?? 0;
$notifyModel = new Notify();
... ... @@ -115,6 +120,138 @@ class WeekProject extends Command
}
$v6WeeklyReportModel = new V6WeeklyReport();
$v6WeeklyReportModel->add($data);
$this->workChatMessage($data,$value['id']);
return true;
}
/**
* @remark :推送消息
* @name :workChatMessage
* @author :lyh
* @method :post
* @time :2025/2/26 10:15
*/
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;
}
$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']);
arsort($data);
$data['inquiry_country'] = array_slice($data, 0, 4, true);
$country = '';
foreach ($data['inquiry_country'] as $k => $v){
$country .= $k.'、';
};
$country = trim($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(!empty($data['google_indexed_num'])){
$content2 .= '谷歌收录量:'.$data['google_indexed_num'].'条,';
}
if(!empty($data['google_links_num'])){
$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 .= '谷歌搜索排名';
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'].'个,';
}
}
if(!empty($data['daily_average_num'])){
$content2 .= '本周日均访客量:'.$data['daily_average_num'].'+。';
}
$content2 .= '全球搜建议用户持续分析、选择、添加企业、产品、服务等相关关键词进行优化和监控,以覆盖更多相关排名和流量;';
}
if(!empty($content2)){
$arr[] = $content2;
}
$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 .= '全球搜建议用户保持网站内容的持续更新与完善,可参考谷歌关于创建实用、可靠、以用户为中心的内容的相关建议:https://developers.google.com/search/docs/fundamentals/creating-helpful-content?hl=zh-cn;';
$arr[] = $content3;
$content4 = '本周主要优化工作包括:TDK、H标签、Img标签等优化设置排查与进一步完善,Sitemap更新与网页收录提交,外链新增与排查。';
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['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'].'次。';
}
$arr[] = $content4;
foreach ($arr as $key => $val){
$content .= ($key + 1) .','.$val;
}
$timestamp = strtotime('tomorrow 9:00 AM');
$tomorrowNineAM = date('Y-m-d H:i:s', $timestamp);
$param = [
'project_id'=>$project_id,
'friend_id'=>$friend_id,
'type'=>MessagePush::TYPE_WEEK,
'content'=>'【全球搜V6.0周报】'.$content,
'ref_ids'=>'',
'send_time'=>$tomorrowNineAM
];
//写入一条推送消息 自动消费
$messagePushModel = new MessagePush();
echo date('Y-m-d H:i:s') . '生成推送消息:'.$project_id . PHP_EOL;
return $messagePushModel->add($param);
}
}
... ...
... ... @@ -538,6 +538,15 @@ class UpdateSeoTdk extends Command
return $str;
$keyword = array_slice($fix_keyword, 0, $num);
$str = implode(", ", $keyword);
// 前后缀内部去重
foreach ($keyword as $k=>$v){
$tmp = rtrim($v, 's');
if (substr_count($str, $tmp) > 1) {
unset($keyword[$k]);
$str = implode(", ", $keyword);
}
}
}
return $str;
}
... ...
... ... @@ -1104,6 +1104,14 @@ function getPrefixKeyword($project_id, $type, $num)
return $str;
$keyword = array_slice($fix_keyword, 0, $num);
$str = implode(", ", $keyword);
foreach ($keyword as $k=>$v){
$tmp = rtrim($v, 's');
if (substr_count($str, $tmp) > 1) {
unset($keyword[$k]);
$str = implode(", ", $keyword);
}
}
}
return $str;
}
... ...
... ... @@ -64,7 +64,9 @@ class AiBlogController extends BaseController
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$v['image'] = getImageUrl($v['image']);
if(!empty($v['route'])){
$v['route'] = $this->user['test_domain'] . 'blog/' . $v['route'];
}
$lists['list'][$k] = $v;
}
}
... ... @@ -171,7 +173,9 @@ class AiBlogController extends BaseController
$lists = $aiBlogList->lists($this->map,$this->page,$this->row,'id',['id','route','created_at','updated_at']);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$v['route'] = $this->user['test_domain'] . 'top-blog/' . $v['route'];
if(!empty($v['route'])){
$v['route'] = $this->user['test_domain'] . 'blog/' . $v['route'];
}
$lists['list'][$k] = $v;
}
}
... ...
... ... @@ -25,7 +25,7 @@ class WebSettingTextLogic extends BaseLogic
*/
public function setting_read(){
$web_setting = new WebSetting();
$setting_info = $web_setting->read(['project_id'=>$this->user['project_id']],['anchor_setting','anchor_is_enable','anchor_num','anchor_page_num']);
$setting_info = $web_setting->read(['project_id'=>$this->user['project_id']],['anchor_setting','anchor_is_enable','anchor_keyword_is_enable','anchor_num','anchor_page_num']);
if($setting_info === false){
$setting_info = [];
}
... ... @@ -60,11 +60,15 @@ class WebSettingTextLogic extends BaseLogic
DB::beginTransaction();
try {
//更新描文本设置
if($this->param['anchor_is_enable'] == 0){
$this->param['anchor_keyword_is_enable'] = 0;
}
$data = [
'anchor_setting'=>$this->param['anchor_setting'],
'anchor_is_enable'=>$this->param['anchor_is_enable'],
'anchor_num'=>$this->param['anchor_num'] ?? 0,
'anchor_page_num'=>$this->param['anchor_page_num'] ?? 0
'anchor_page_num'=>$this->param['anchor_page_num'] ?? 0,
'anchor_keyword_is_enable'=>$this->param['anchor_keyword_is_enable'] ?? 0
];
$web_setting->edit($data,['project_id'=>$this->user['project_id']]);
$this->model->del(['project_id'=>$this->user['project_id']]);
... ...
... ... @@ -90,7 +90,8 @@ class Project extends Base
11 => '俄语标准版',
12 => '俄语商务版',
14 => '俄语旗舰版',
13 => '体验版'
13 => '体验版',
15 => '白帽 SEO'
];
}
... ...
... ... @@ -25,7 +25,7 @@ class MessagePush extends Base
const STATUS_ERROR = 9;
const TYPE_INQUIRY = 'inquiry';
const TYPE_WEEK = 'week';
//设置关联表名
/**
* @var mixed
... ...