作者 zhl

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

@@ -79,6 +79,7 @@ class AiBlogAuthorTask extends Command @@ -79,6 +79,7 @@ class AiBlogAuthorTask extends Command
79 ProjectServer::useProject($info['project_id']); 79 ProjectServer::useProject($info['project_id']);
80 $this->saveAiBlogAuthor($result['data'] ?? [],$info['project_id']); 80 $this->saveAiBlogAuthor($result['data'] ?? [],$info['project_id']);
81 RouteMap::setRoute('top-blog',RouteMap::SOURCE_AI_BLOG_LIST,0,$info['project_id']);//写一条列表页路由 81 RouteMap::setRoute('top-blog',RouteMap::SOURCE_AI_BLOG_LIST,0,$info['project_id']);//写一条列表页路由
  82 + RouteMap::setRoute('top-video',RouteMap::SOURCE_AI_VIDEO_LIST,0,$info['project_id']);//写一条列表页路由
82 DB::disconnect('custom_mysql'); 83 DB::disconnect('custom_mysql');
83 //修改任务状态 84 //修改任务状态
84 $aiBlogTaskModel->edit(['status'=>2],['id'=>$info['id']]); 85 $aiBlogTaskModel->edit(['status'=>2],['id'=>$info['id']]);
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :AiBlogTask.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/2/14 11:14
  8 + */
  9 +
  10 +namespace App\Console\Commands\Ai;
  11 +
  12 +use App\Models\Ai\AiBlog;
  13 +use App\Models\Ai\AiBlogAuthor;
  14 +use App\Models\Ai\AiBlogList;
  15 +use App\Models\Ai\AiVideoList;
  16 +use App\Models\Domain\DomainInfo;
  17 +use App\Models\Project\ProjectAiSetting;
  18 +use App\Models\RouteMap\RouteMap;
  19 +use App\Services\AiBlogService;
  20 +use App\Services\AiVideoService;
  21 +use App\Services\ProjectServer;
  22 +use Illuminate\Console\Command;
  23 +use App\Models\Project\AiBlogTask as AiBlogTaskModel;
  24 +use Illuminate\Support\Facades\Cache;
  25 +use Illuminate\Support\Facades\DB;
  26 +use function Symfony\Component\String\s;
  27 +
  28 +/***
  29 + * @remark :根据项目更新blog列表
  30 + * @name :AiBlogListTask
  31 + * @author :lyh
  32 + * @method :post
  33 + * @time :2025/3/6 9:45
  34 + */
  35 +class AiVideoListTask extends Command
  36 +{
  37 + /**
  38 + * The name and signature of the console command.
  39 + *
  40 + * @var string
  41 + */
  42 + protected $signature = 'save_ai_video_list {project_id}';
  43 +
  44 + /**
  45 + * The console command description.
  46 + *
  47 + * @var string
  48 + */
  49 + protected $description = '生成video列表';
  50 +
  51 + public function handle(){
  52 + $project_id = $this->argument('project_id');
  53 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export('执行的项目id->'.$project_id, true) . PHP_EOL, FILE_APPEND);
  54 + ProjectServer::useProject($project_id);
  55 + $this->updateBlogList($project_id);
  56 +// $this->curlDelRoute($project_id);
  57 + DB::disconnect('custom_mysql');
  58 + return true;
  59 + }
  60 +
  61 + /**
  62 + * @remark :更新列表页数据
  63 + * @name :updateBlogList
  64 + * @author :lyh
  65 + * @method :post
  66 + * @time :2025/3/5 11:07
  67 + */
  68 + public function updateBlogList($project_id){
  69 + $aiVideoService = new AiVideoService($project_id);
  70 + $page = 1;
  71 + $saveData = [];
  72 + $result = $aiVideoService->getAiVideoList($page,15);
  73 + if(!isset($result['status']) && $result['status'] != 200){
  74 + return true;
  75 + }
  76 + $total_page = $result['data']['total_page'];
  77 + //组装数据保存
  78 + $saveData[] = [
  79 + 'route'=>$page,
  80 + 'text'=>$result['data']['section'],
  81 + ];
  82 + while ($total_page > $page){
  83 + $page++;
  84 + $result = $aiVideoService->getAiVideoList($page,15);
  85 + if(isset($result['status']) && $result['status'] == 200){
  86 + $saveData[] = [
  87 + 'route'=>$page,
  88 + 'text'=>$result['data']['section'],
  89 + ];
  90 + }
  91 + }
  92 + $aiVideoListModel = new AiVideoList();
  93 + if(!empty($saveData)){
  94 + //写一条路由信息
  95 + $aiVideoListModel->truncate();
  96 + $aiVideoListModel->insertAll($saveData);
  97 + }
  98 + return true;
  99 + }
  100 +
  101 + /**
  102 + * @remark :通知C端生成界面
  103 + * @name :sendNotice
  104 + * @author :lyh
  105 + * @method :post
  106 + * @time :2025/3/6 11:51
  107 + */
  108 + public function curlDelRoute($project_id){
  109 + $domainModel = new DomainInfo();
  110 + //获取项目域名
  111 + $domain = $domainModel->getProjectIdDomain($project_id);
  112 + if(!empty($domain)){
  113 + $c_url = $domain.'api/update_page/';
  114 + $param = [
  115 + 'project_id' => $project_id,
  116 + 'type' => 1,
  117 + 'route' => 3,
  118 + 'url' => ['top-blog'],
  119 + 'language'=> [],
  120 + 'is_sitemap' => 0
  121 + ];
  122 + http_post($c_url, json_encode($param));
  123 + }
  124 + return true;
  125 + }
  126 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :AiVideoTask.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/4/30 11:18
  8 + */
  9 +
  10 +namespace App\Console\Commands\Ai;
  11 +
  12 +use App\Helper\Arr;
  13 +use App\Models\Ai\AiBlogAuthor;
  14 +use App\Models\Ai\AiVideo;
  15 +use App\Models\Ai\AiVideoList;
  16 +use App\Models\Com\Notify;
  17 +use App\Models\Devops\ServerConfig;
  18 +use App\Models\Devops\ServersIp;
  19 +use App\Models\Domain\DomainInfo;
  20 +use App\Models\Project\AiVideoTask as AiVideoTaskModel;
  21 +use App\Models\Project\Project;
  22 +use App\Models\RouteMap\RouteMap;
  23 +use App\Services\AiBlogService;
  24 +use App\Services\AiVideoService;
  25 +use App\Services\DingService;
  26 +use App\Services\ProjectServer;
  27 +use Illuminate\Console\Command;
  28 +use Illuminate\Support\Facades\DB;
  29 +use Illuminate\Support\Facades\Redis;
  30 +
  31 +class AiVideoTask extends Command
  32 +{
  33 + /**
  34 + * The name and signature of the console command.
  35 + *
  36 + * @var string
  37 + */
  38 + protected $signature = 'save_ai_video';
  39 +
  40 + public $updateProject = [];//需更新的列表
  41 + public $routes = [];//需要更新的路由
  42 + /**
  43 + * The console command description.
  44 + *
  45 + * @var string
  46 + */
  47 + protected $description = '查询ai_video是否已经生成';
  48 + /**
  49 + * @return bool
  50 + * @throws \Exception
  51 + */
  52 + public function handle(){
  53 + while (true){
  54 + //获取任务id
  55 + $task_id = $this->getTaskId();
  56 + if(empty($task_id)){
  57 + sleep(300);
  58 + continue;
  59 + }
  60 + $this->_action($task_id);
  61 + }
  62 + return true;
  63 + }
  64 +
  65 + /**
  66 + * 获取任务id
  67 + * @param int $finish_at
  68 + * @return mixed
  69 + */
  70 + public function getTaskId($finish_at = 2)
  71 + {
  72 + $task_id = Redis::rpop('ai_video_task');
  73 + if (empty($task_id)) {
  74 + if(!empty($this->updateProject)){
  75 + $this->updateProject($this->updateProject);
  76 + $this->updateProject = [];
  77 + }
  78 + if(!empty($this->routes)){
  79 +// $this->updateRoutes($this->routes);
  80 + $this->routes = [];
  81 + }
  82 + $aiVideoTaskModel = new AiVideoTaskModel();
  83 + $finish_at = date('Y-m-d H:i:s', strtotime('-' . $finish_at . ' hour'));
  84 + $ids = $aiVideoTaskModel->formatQuery(['status'=>$aiVideoTaskModel::STATUS_RUNNING,'updated_at'=>['<=',$finish_at]])->pluck('id');
  85 + if(!empty($ids)){
  86 + foreach ($ids as $id) {
  87 + Redis::lpush('ai_video_task', $id);
  88 + }
  89 + }
  90 + $task_id = Redis::rpop('ai_video_task');
  91 + }
  92 + return $task_id;
  93 + }
  94 +
  95 + /**
  96 + * @remark :请求
  97 + * @name :sendRequest
  98 + * @author :lyh
  99 + * @method :post
  100 + * @time :2025/4/30 11:31
  101 + */
  102 + public function _action($task_id){
  103 + $aiVideoTaskModel = new AiVideoTaskModel();
  104 + $item = $aiVideoTaskModel->read(['id'=>$task_id]);
  105 + $this->output('ai_video->start:project ID: ' . $item['project_id'] . ',task ID: ' . $task_id);
  106 + $aiVideoService = new AiVideoService($item['project_id']);
  107 + $aiVideoService->task_id = $item['task_id'];
  108 + //拉取文章数据
  109 + $result = $aiVideoService->getVideoDetail();
  110 + if(empty($result['status']) || ($result['status'] != 200)){
  111 + if($item['number'] < 5){
  112 + $aiVideoTaskModel->edit(['number'=>$item['number'] + 1],['id'=>$item['id']]);
  113 + }else{
  114 + $aiVideoTaskModel->edit(['status'=>9],['id'=>$item['id']]);
  115 + // 钉钉通知
  116 + $dingService = new DingService();
  117 + $body = [
  118 + 'keyword' => 'AI_VIDEO获取失败',
  119 + 'msg' => '任务ID:' . $item['task_id'] . PHP_EOL . '返回信息:' . json_encode($result,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
  120 + 'isAtAll' => false, // 是否@所有人
  121 + ];
  122 + $dingService->handle($body);
  123 + }
  124 + $this->output('error: 数据获取失败,status:' . $result['status'] . ',message: ' . ($result['message'] ?? 'null'));
  125 + return false;
  126 + }
  127 + //保存当前项目ai_blog数据
  128 + ProjectServer::useProject($item['project_id']);
  129 + $aiVideoModel = new AiVideo();
  130 + $aiVideoInfo = $aiVideoModel->read(['task_id'=>$item['task_id']],['id','route']);
  131 + if($aiVideoInfo === false){
  132 + // 钉钉通知
  133 + $dingService = new DingService();
  134 + $body = [
  135 + 'keyword' => 'AI_VIDEO生成错误',
  136 + 'msg' => '任务ID:' . $item['task_id'] . ', 子库获取数据失败, 检查子库数据是否被删除!',
  137 + 'isAtAll' => false, // 是否@所有人
  138 + ];
  139 + $dingService->handle($body);
  140 + $this->output('error: 子库获取数据失败, task id: ' . $task_id);
  141 + $aiVideoTaskModel->edit(['status'=>9],['id'=>$item['id']]);
  142 + DB::disconnect('custom_mysql');
  143 + return false;
  144 + }
  145 + //拿到返回的路由查看是否重复
  146 + $route = RouteMap::setRoute($result['data']['url'], RouteMap::SOURCE_AI_VIDEO, $aiVideoInfo['id'], $item['project_id']);
  147 + if($route != $result['data']['url']){
  148 + $aiVideoService->updateDetail(['route'=>$route,'task_id'=>$item['task_id']]);
  149 + }
  150 + $saveData = [
  151 + 'title'=>$result['data']['title'],
  152 + 'image'=>$result['data']['thumb'],
  153 + 'video_url'=>$result['data']['video_url'],
  154 + 'route'=>$route,
  155 + 'author_id'=>$result['data']['author_id'],
  156 + 'keyword'=>json_encode($result['data']['keyword'],true),
  157 + 'content'=>$result['data']['content'],
  158 + 'text'=>$result['data']['section'],
  159 + 'status'=>$aiVideoTaskModel::STATUS_FINISH
  160 + ];
  161 + $aiVideoModel->edit($saveData,['task_id'=>$item['task_id']]);
  162 + //需要更新的路由
  163 + if (!in_array($result['data']['author_id'], $this->updateProject[$item['project_id']] ?? [])) {
  164 + $this->updateProject[$item['project_id']][] = $result['data']['author_id'];
  165 + }
  166 + if (!in_array($route, $this->routes[$item['project_id']] ?? [])) {
  167 + $this->routes[$item['project_id']][] = $route;
  168 + }
  169 + DB::disconnect('custom_mysql');
  170 + $aiVideoTaskModel->edit(['status'=>$aiVideoTaskModel::STATUS_FINISH],['id'=>$item['id']]);
  171 + $this->output('success: task id: ' . $task_id);
  172 + return true;
  173 + }
  174 +
  175 + /**
  176 + * @remark :更新项目作者页面及列表页
  177 + * @name :updateProject
  178 + * @author :lyh
  179 + * @method :post
  180 + * @time :2025/4/30 15:43
  181 + */
  182 + public function updateProject($updateProject){
  183 + if(empty($updateProject)){
  184 + return true;
  185 + }
  186 + foreach ($updateProject as $project_id => $author){
  187 + ProjectServer::useProject($project_id);
  188 + $this->output('sync: list start, project_id: ' . $project_id);
  189 + $this->updateBlogList($project_id);
  190 + $this->output('sync: list end');
  191 + //更新作者
  192 + $this->output('sync: author start, project_id: ' . $project_id);
  193 + foreach ($author as $val){
  194 + $this->updateAiBlogAuthor($val,$project_id);
  195 + }
  196 + $this->output('sync: author end');
  197 + DB::disconnect('custom_mysql');
  198 + }
  199 +
  200 + return true;
  201 + }
  202 +
  203 + /**
  204 + * @remark :更新作者页面
  205 + * @name :updateAiBlogAuthor
  206 + * @author :lyh
  207 + * @method :post
  208 + * @time :2025/4/30 15:52
  209 + */
  210 + public function updateAiBlogAuthor($author_id,$project_id){
  211 + if(empty($author_id)){
  212 + return true;
  213 + }
  214 + $aiBlogService = new AiBlogService($project_id);
  215 + $aiBlogService->author_id = $author_id;
  216 + $result = $aiBlogService->getAuthorDetail();
  217 + if(isset($result['status']) && $result['status'] == 200){
  218 + //当前作者的页面
  219 + $aiBlogAuthorModel = new AiBlogAuthor();
  220 + $authorInfo = $aiBlogAuthorModel->read(['author_id'=>$author_id],['id','route']);
  221 + if($authorInfo !== false && !empty($result['data']['section'])){
  222 + //需要更新的路由
  223 + if (!in_array($authorInfo['route'], $this->routes[$project_id] ?? [])) {
  224 + $this->routes[$project_id][] = $authorInfo['route'];
  225 + }
  226 + $aiBlogAuthorModel->edit(['text'=>$result['data']['section']],['author_id'=>$author_id]);
  227 + }
  228 + }
  229 + return true;
  230 + }
  231 +
  232 + /**
  233 + * @remark :更新
  234 + * @name :updateBlogList
  235 + * @author :lyh
  236 + * @method :post
  237 + * @time :2025/4/30 15:45
  238 + */
  239 + public function updateBlogList($project_id){
  240 + $aiVideoService = new AiVideoService($project_id);
  241 + $page = 1;
  242 + $saveData = [];
  243 + $result = $aiVideoService->getAiVideoList($page,15);
  244 + if(!isset($result['status']) && $result['status'] != 200){
  245 + return true;
  246 + }
  247 + $total_page = $result['data']['total_page'];
  248 + //组装数据保存
  249 + $saveData[] = [
  250 + 'route'=>$page,
  251 + 'text'=>$result['data']['section'],
  252 + ];
  253 + while ($total_page > $page){
  254 + $page++;
  255 + $result = $aiVideoService->getAiVideoList($page,15);
  256 + if(isset($result['status']) && $result['status'] == 200){
  257 + $saveData[] = [
  258 + 'route'=>$page,
  259 + 'text'=>$result['data']['section'],
  260 + ];
  261 + }
  262 + }
  263 + $aiVideoListModel = new AiVideoList();
  264 + if(!empty($saveData)){
  265 + //写一条路由信息
  266 + RouteMap::setRoute('top-video',RouteMap::SOURCE_AI_VIDEO_LIST,0,$project_id);//写一条列表页路由
  267 + $aiVideoListModel->truncate();
  268 + $aiVideoListModel->insertAll($saveData);
  269 + }
  270 + return true;
  271 + }
  272 + /**
  273 + * 输入日志
  274 + * @param $message
  275 + * @return bool
  276 + */
  277 + public function output($message)
  278 + {
  279 + $message = date('Y-m-d H:i:s') . ' ' . $message . PHP_EOL;
  280 + echo $message;
  281 + return true;
  282 + }
  283 +
  284 + /**
  285 + * 通知C端生成界面
  286 + * @param $project_id
  287 + * @return bool
  288 + */
  289 + public function updateRoutes($routes){
  290 + $domainModel = new DomainInfo();
  291 + $project_model = new Project();
  292 + foreach ($routes as $project_id => $route){
  293 + $route[] = 'top-video';
  294 + $domain = $domainModel->getProjectIdDomain($project_id);
  295 + if (empty($domain)) {
  296 + $this->output('send: 域名不存在, project id: ' . $project_id);
  297 + continue;
  298 + }
  299 + //判断是否是自建站服务器,如果是,不请求C端接口,数据直接入库
  300 + $project_info = $project_model->read(['id'=>$project_id],['serve_id']);
  301 + if(!$project_info){
  302 + $this->output('send: 项目不存在, project id: ' . $project_id);
  303 + continue;
  304 + }
  305 + $serve_ip_model = new ServersIp();
  306 + $serve_ip_info = $serve_ip_model->read(['id'=>$project_info['serve_id']],['servers_id']);
  307 + $servers_id = $serve_ip_info ? $serve_ip_info['servers_id'] : 0;
  308 + if($servers_id == ServerConfig::SELF_SITE_ID){
  309 + //判断是否已有更新进行中
  310 + $notify_model = new Notify();
  311 + $data = [
  312 + 'project_id' => $project_id,
  313 + 'type' => Notify::TYPE_MASTER,
  314 + 'route' => Notify::ROUTE_AI_BLOG,
  315 + 'server_id' => ServerConfig::SELF_SITE_ID,
  316 + 'status' => ['!=',Notify::STATUS_FINISH_SITEMAP]
  317 + ];
  318 + $notify = $notify_model->read($data,['id']);
  319 + if(!$notify){
  320 + $domain_array = parse_url($domain);
  321 + $data['data'] = Arr::a2s(['domain'=>$domain_array['host'],'url'=>$route,'language'=>[]]);
  322 + $data['status'] = Notify::STATUS_INIT;
  323 + $data['sort'] = 2;
  324 + $notify_model->add($data);
  325 + }
  326 + $this->output('send: 自建站项目, project id: ' . $project_id);
  327 + }else{
  328 + $c_url = $domain.'api/update_page/';
  329 + $param = [
  330 + 'project_id' => $project_id,
  331 + 'type' => 1,
  332 + 'route' => 3,
  333 + 'url' => $route,
  334 + 'language'=> [],
  335 + 'is_sitemap' => 0
  336 + ];
  337 + $res = http_post($c_url, json_encode($param,true));
  338 + $this->output('notify: project id: ' . $project_id . ', result: ' . json_encode($res,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
  339 + }
  340 + }
  341 + return true;
  342 + }
  343 +}
@@ -68,6 +68,7 @@ class AfterDayCount extends Command @@ -68,6 +68,7 @@ class AfterDayCount extends Command
68 $idArr = $this->managerHrModel->selectField(['name'=>['in',$valM]],'id'); 68 $idArr = $this->managerHrModel->selectField(['name'=>['in',$valM]],'id');
69 $project_count = $projectModel->where('gl_project.extend_type',0) 69 $project_count = $projectModel->where('gl_project.extend_type',0)
70 ->where('gl_project.delete_status',0) 70 ->where('gl_project.delete_status',0)
  71 + ->where('gl_project.old_project_id',0)
71 ->where('gl_project.created_at','<=',$todayMidnight) 72 ->where('gl_project.created_at','<=',$todayMidnight)
72 ->whereIn('gl_project_deploy_optimize.optimist_mid',$idArr) 73 ->whereIn('gl_project_deploy_optimize.optimist_mid',$idArr)
73 ->whereIn('gl_project.type',[2,4]) 74 ->whereIn('gl_project.type',[2,4])
@@ -77,6 +78,7 @@ class AfterDayCount extends Command @@ -77,6 +78,7 @@ class AfterDayCount extends Command
77 ->count(); 78 ->count();
78 $qualified_count = $projectModel->where('gl_project.extend_type',0) 79 $qualified_count = $projectModel->where('gl_project.extend_type',0)
79 ->where('gl_project.delete_status',0) 80 ->where('gl_project.delete_status',0)
  81 + ->where('gl_project.old_project_id',0)
80 ->where('gl_project.created_at','<=',$todayMidnight) 82 ->where('gl_project.created_at','<=',$todayMidnight)
81 ->where('gl_project.is_remain_today',1) 83 ->where('gl_project.is_remain_today',1)
82 ->where('gl_project_deploy_build.plan','!=',0) 84 ->where('gl_project_deploy_build.plan','!=',0)
@@ -88,10 +90,12 @@ class AfterDayCount extends Command @@ -88,10 +90,12 @@ class AfterDayCount extends Command
88 ->whereRaw("FIND_IN_SET('7', gl_project_deploy_optimize.special) = 0 AND FIND_IN_SET('8', gl_project_deploy_optimize.special) = 0") 90 ->whereRaw("FIND_IN_SET('7', gl_project_deploy_optimize.special) = 0 AND FIND_IN_SET('8', gl_project_deploy_optimize.special) = 0")
89 ->count(); 91 ->count();
90 $rate = number_format($qualified_count / $project_count, 2); 92 $rate = number_format($qualified_count / $project_count, 2);
91 - $threeMonthsAgo = date('Y-m-d 00:00:00', strtotime('-3 months')); 93 + $threeMonthsAgo = date('Y-m-d', strtotime('-3 months'));
92 $three_project_count = $projectModel->where('gl_project.extend_type',0) 94 $three_project_count = $projectModel->where('gl_project.extend_type',0)
93 ->where('gl_project.delete_status',0) 95 ->where('gl_project.delete_status',0)
94 - ->where('gl_project.created_at','<=',$threeMonthsAgo) 96 + ->where('gl_project.old_project_id',0)
  97 + ->where('gl_project.created_at','>=',$threeMonthsAgo.' 00:00:00')
  98 + ->where('gl_project.created_at','<=',$threeMonthsAgo.' 23:59:59')
95 ->whereIn('gl_project_deploy_optimize.optimist_mid',$idArr) 99 ->whereIn('gl_project_deploy_optimize.optimist_mid',$idArr)
96 ->whereIn('gl_project.type',[2,4]) 100 ->whereIn('gl_project.type',[2,4])
97 ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id') 101 ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
@@ -101,7 +105,9 @@ class AfterDayCount extends Command @@ -101,7 +105,9 @@ class AfterDayCount extends Command
101 $three_qualified_count = $projectModel->where('gl_project.extend_type',0) 105 $three_qualified_count = $projectModel->where('gl_project.extend_type',0)
102 ->whereIn('gl_project.id',$projectIdArr) 106 ->whereIn('gl_project.id',$projectIdArr)
103 ->where('gl_project.delete_status',0) 107 ->where('gl_project.delete_status',0)
104 - ->where('gl_project.created_at','<=',$threeMonthsAgo) 108 + ->where('gl_project.old_project_id',0)
  109 + ->where('gl_project.created_at','>=',$threeMonthsAgo.' 00:00:00')
  110 + ->where('gl_project.created_at','<=',$threeMonthsAgo.' 23:59:59')
105 ->whereIn('gl_project_deploy_optimize.optimist_mid',$idArr) 111 ->whereIn('gl_project_deploy_optimize.optimist_mid',$idArr)
106 ->whereIn('gl_project.type',[2,4]) 112 ->whereIn('gl_project.type',[2,4])
107 ->where('gl_project_deploy_build.plan','!=',0) 113 ->where('gl_project_deploy_build.plan','!=',0)
@@ -120,7 +126,7 @@ class AfterDayCount extends Command @@ -120,7 +126,7 @@ class AfterDayCount extends Command
120 ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id') 126 ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
121 ->whereRaw("FIND_IN_SET('2', gl_project.level) = 0 AND FIND_IN_SET('3', gl_project.level) = 0") 127 ->whereRaw("FIND_IN_SET('2', gl_project.level) = 0 AND FIND_IN_SET('3', gl_project.level) = 0")
122 ->whereRaw("FIND_IN_SET('7', gl_project_deploy_optimize.special) = 0 AND FIND_IN_SET('8', gl_project_deploy_optimize.special) = 0") 128 ->whereRaw("FIND_IN_SET('7', gl_project_deploy_optimize.special) = 0 AND FIND_IN_SET('8', gl_project_deploy_optimize.special) = 0")
123 - ->pluck('gl_project.title')->toArray(); 129 + ->select(['gl_project.title','gl_project.finish_remain_day','gl_project_deploy_optimize.start_date'])->get()->toArray();
124 $saveData[] = [ 130 $saveData[] = [
125 'date'=>date('Y-m-d', strtotime('yesterday')), 131 'date'=>date('Y-m-d', strtotime('yesterday')),
126 'type'=> $key, 132 'type'=> $key,
@@ -68,9 +68,10 @@ class DomainInfo extends Command @@ -68,9 +68,10 @@ class DomainInfo extends Command
68 $domainModel = new DomainInfoModel(); 68 $domainModel = new DomainInfoModel();
69 $projectModel = new Project(); 69 $projectModel = new Project();
70 $serverIpModel = new ServersIp(); 70 $serverIpModel = new ServersIp();
  71 + $domainCreateTaskModel = new DomainCreateTask();
71 $list = $domainModel->where('status', '=', 1)->get(); 72 $list = $domainModel->where('status', '=', 1)->get();
72 foreach ($list as $v) { 73 foreach ($list as $v) {
73 - $project_info = $projectModel->read(['id' => $v['project_id'], 'type' => ['!=', Project::TYPE_CLOSE]], ['serve_id']); 74 + $project_info = $projectModel->read(['id' => $v['project_id'], 'type' => ['!=', Project::TYPE_CLOSE]], ['serve_id', 'project_type']);
74 if (!$project_info) { 75 if (!$project_info) {
75 continue; 76 continue;
76 } 77 }
@@ -89,6 +90,17 @@ class DomainInfo extends Command @@ -89,6 +90,17 @@ class DomainInfo extends Command
89 } 90 }
90 } 91 }
91 92
  93 + //判断是否已经建站
  94 + if ($project_info['project_type'] == Project::PROJECT_TYPE_SEO) {
  95 + $type = DomainCreateTask::TYPE_BLOG;
  96 + } else {
  97 + $type = DomainCreateTask::TYPE_MAIN;
  98 + }
  99 + $task_info = $domainCreateTaskModel->read(['type' => $type, 'domain_id' => $v['id'], 'status' => DomainCreateTask::STATUS_SUC], ['id']);
  100 + if (!$task_info) {
  101 + continue;
  102 + }
  103 +
92 //获取主站证书有效期并更新 104 //获取主站证书有效期并更新
93 $ssl_time = $this->getDomainSslTime($v['domain']); 105 $ssl_time = $this->getDomainSslTime($v['domain']);
94 if ($ssl_time['from'] && $ssl_time['to']) { 106 if ($ssl_time['from'] && $ssl_time['to']) {
@@ -168,7 +180,7 @@ class DomainInfo extends Command @@ -168,7 +180,7 @@ class DomainInfo extends Command
168 } 180 }
169 181
170 //创建更新站点证书任务 182 //创建更新站点证书任务
171 - $task_info = $domainCreateTaskModel->read(['type' => $type, 'domain_id' => $v['id'], 'status' => ['<', DomainCreateTask::STATUS_SUC]]); 183 + $task_info = $domainCreateTaskModel->read(['type' => $type, 'domain_id' => $v['id'], 'status' => ['<', DomainCreateTask::STATUS_SUC]], ['id']);
172 if (!$task_info) { 184 if (!$task_info) {
173 $domainCreateTaskModel->add([ 185 $domainCreateTaskModel->add([
174 'server_id' => $servers_ip_info['servers_id'], 186 'server_id' => $servers_ip_info['servers_id'],
@@ -225,7 +237,7 @@ class DomainInfo extends Command @@ -225,7 +237,7 @@ class DomainInfo extends Command
225 } 237 }
226 238
227 //创建更新站点证书任务 239 //创建更新站点证书任务
228 - $task_info = $domainCreateTaskModel->read(['type' => DomainCreateTask::TYPE_AMP, 'domain_id' => $v['id'], 'status' => ['<', DomainCreateTask::STATUS_SUC]]); 240 + $task_info = $domainCreateTaskModel->read(['type' => DomainCreateTask::TYPE_AMP, 'domain_id' => $v['id'], 'status' => ['<', DomainCreateTask::STATUS_SUC]], ['id']);
229 if (!$task_info) { 241 if (!$task_info) {
230 $domainCreateTaskModel->add([ 242 $domainCreateTaskModel->add([
231 'server_id' => $servers_ip_info['servers_id'], 243 'server_id' => $servers_ip_info['servers_id'],
@@ -273,7 +285,7 @@ class DomainInfo extends Command @@ -273,7 +285,7 @@ class DomainInfo extends Command
273 } 285 }
274 286
275 //创建更新站点证书任务 287 //创建更新站点证书任务
276 - $task_info = $domainCreateTaskModel->read(['type' => DomainCreateTask::TYPE_CUSTOM, 'domain_id' => $v['id'], 'status' => ['<', DomainCreateTask::STATUS_SUC]]); 288 + $task_info = $domainCreateTaskModel->read(['type' => DomainCreateTask::TYPE_CUSTOM, 'domain_id' => $v['id'], 'status' => ['<', DomainCreateTask::STATUS_SUC]], ['id']);
277 if (!$task_info) { 289 if (!$task_info) {
278 $domainCreateTaskModel->add([ 290 $domainCreateTaskModel->add([
279 'server_id' => $servers_ip_info['servers_id'], 291 'server_id' => $servers_ip_info['servers_id'],
@@ -290,6 +290,7 @@ class postInquiry extends Command @@ -290,6 +290,7 @@ class postInquiry extends Command
290 Log::channel('inquiry_relay')->error('inquiry_relay shop inquiry error', [$res, $url, $data]); 290 Log::channel('inquiry_relay')->error('inquiry_relay shop inquiry error', [$res, $url, $data]);
291 return false; 291 return false;
292 } 292 }
  293 + return true;
293 } 294 }
294 295
295 public function FobInquiry($detail, $log){ 296 public function FobInquiry($detail, $log){
@@ -309,6 +310,7 @@ class postInquiry extends Command @@ -309,6 +310,7 @@ class postInquiry extends Command
309 Log::channel('inquiry_relay')->error('inquiry_relay fob inquiry error', [$res, 'https://fob.ai.cc/api/ad_to_scrm', $data]); 310 Log::channel('inquiry_relay')->error('inquiry_relay fob inquiry error', [$res, 'https://fob.ai.cc/api/ad_to_scrm', $data]);
310 return false; 311 return false;
311 } 312 }
  313 + return true;
312 } 314 }
313 315
314 public function output($message) 316 public function output($message)
@@ -52,9 +52,9 @@ class LyhImportTest extends Command @@ -52,9 +52,9 @@ class LyhImportTest extends Command
52 * @time :2023/11/20 15:13 52 * @time :2023/11/20 15:13
53 */ 53 */
54 public function handle(){ 54 public function handle(){
55 - ProjectServer::useProject(3283); 55 + ProjectServer::useProject(2140);
56 echo date('Y-m-d H:i:s') . 'start' . PHP_EOL; 56 echo date('Y-m-d H:i:s') . 'start' . PHP_EOL;
57 - $this->importProductCategory('https://ecdn6.globalso.com/upload/p/3283/file/2025-04/zhouyongpaxu.csv',3283); 57 + $this->import2140CustomModule('https://ecdn6.globalso.com/upload/p/2140/file/2025-05/all-202557.csv',2140);
58 DB::disconnect('custom_mysql'); 58 DB::disconnect('custom_mysql');
59 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 59 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
60 } 60 }
@@ -463,7 +463,7 @@ class LyhImportTest extends Command @@ -463,7 +463,7 @@ class LyhImportTest extends Command
463 foreach ($line_of_text as $k => $item){ 463 foreach ($line_of_text as $k => $item){
464 // try { 464 // try {
465 //添加内容 465 //添加内容
466 - $contentId = $customContentModel->addReturnId(['name'=>$item[0],'image'=>'/upload/p/2140/image/'.$item[2],'module_id'=>2,'project_id'=>$project_id]); 466 + $contentId = $customContentModel->addReturnId(['name'=>$item[0],'image'=>'/upload/p/2140/image/'.$item[2],'module_id'=>7,'project_id'=>$project_id]);
467 echo date('Y-m-d H:i:s') . '当前扩展数据id:'. $contentId . PHP_EOL; 467 echo date('Y-m-d H:i:s') . '当前扩展数据id:'. $contentId . PHP_EOL;
468 //注册路由 468 //注册路由
469 $route = RouteMap::setRoute($item[0], RouteMap::SOURCE_MODULE, 469 $route = RouteMap::setRoute($item[0], RouteMap::SOURCE_MODULE,
@@ -12,6 +12,7 @@ namespace App\Console\Commands\LyhTest; @@ -12,6 +12,7 @@ namespace App\Console\Commands\LyhTest;
12 use App\Helper\Arr; 12 use App\Helper\Arr;
13 use App\Helper\Translate; 13 use App\Helper\Translate;
14 use App\Models\Ai\AiBlog; 14 use App\Models\Ai\AiBlog;
  15 +use App\Models\Ai\AiBlogAuthor;
15 use App\Models\Blog\Blog; 16 use App\Models\Blog\Blog;
16 use App\Models\Com\WordCountry; 17 use App\Models\Com\WordCountry;
17 use App\Models\CustomModule\CustomModuleContent; 18 use App\Models\CustomModule\CustomModuleContent;
@@ -67,7 +68,7 @@ class UpdateRoute extends Command @@ -67,7 +68,7 @@ class UpdateRoute extends Command
67 */ 68 */
68 public function handle() 69 public function handle()
69 { 70 {
70 - return $this->getNullRoute(); 71 + return $this->getAiBlog();
71 } 72 }
72 73
73 /** 74 /**
@@ -77,16 +78,18 @@ class UpdateRoute extends Command @@ -77,16 +78,18 @@ class UpdateRoute extends Command
77 * @method :post 78 * @method :post
78 * @time :2025/4/21 11:52 79 * @time :2025/4/21 11:52
79 */ 80 */
80 - public function getNullRoute(){ 81 + public function getAiBlog(){
81 $projectModel = new Project(); 82 $projectModel = new Project();
82 $lists = $projectModel->list(['delete_status' => 0,'extend_type'=>0,'type'=>['in',[1,2,3,4]]], 'id', ['id']); 83 $lists = $projectModel->list(['delete_status' => 0,'extend_type'=>0,'type'=>['in',[1,2,3,4]]], 'id', ['id']);
83 foreach ($lists as $val) { 84 foreach ($lists as $val) {
84 - echo date('Y-m-d H:i:s') . '开始--项目的id:'. $val['id'] . PHP_EOL; 85 +// echo date('Y-m-d H:i:s') . '开始--项目的id:'. $val['id'] . PHP_EOL;
85 ProjectServer::useProject($val['id']); 86 ProjectServer::useProject($val['id']);
86 - $keywordModel = new Keyword();  
87 - $info = $keywordModel->read(['route'=>'']);  
88 - if($info !== false){  
89 - echo '存在路由为空--项目id:'.$val['id'].PHP_EOL; 87 + $aiBlogModel = new AiBlogAuthor();
  88 + $results = $aiBlogModel->whereColumn('title', '!=', 'seo_title')->get();
  89 + echo '项目id:'.json_encode($results,true).PHP_EOL;
  90 + if(!$results){
  91 + $aiBlogModel->edit(['seo_title'=>'','seo_keyword'=>'','seo_description'=>''],['id'=>['>',0]]);
  92 + echo '项目id:'.$val['id'].PHP_EOL;
90 } 93 }
91 DB::disconnect('custom_mysql'); 94 DB::disconnect('custom_mysql');
92 } 95 }
@@ -151,7 +154,7 @@ class UpdateRoute extends Command @@ -151,7 +154,7 @@ class UpdateRoute extends Command
151 * @method :post 154 * @method :post
152 * @time :2025/3/21 17:45 155 * @time :2025/3/21 17:45
153 */ 156 */
154 - public function getAiBlog($project_id){ 157 + public function getAiBlogs($project_id){
155 $aiBlogModel = new AiBlog(); 158 $aiBlogModel = new AiBlog();
156 $lists = $aiBlogModel->list(['updated_at'=>['<=','2025-03-21 00:00:00']]); 159 $lists = $aiBlogModel->list(['updated_at'=>['<=','2025-03-21 00:00:00']]);
157 if(!empty($lists)){ 160 if(!empty($lists)){
@@ -84,7 +84,11 @@ class CopyOldProject extends Command @@ -84,7 +84,11 @@ class CopyOldProject extends Command
84 'gl_customer_visit_item', 84 'gl_customer_visit_item',
85 'gl_inquiry_other', 85 'gl_inquiry_other',
86 'gl_inquiry_form_data', 86 'gl_inquiry_form_data',
87 - 'gl_inquiry_form' 87 + 'gl_inquiry_form',
  88 + 'gl_ai_blog',
  89 + 'gl_ai_blog_author',
  90 + 'gl_ai_blog_list',
  91 + 'gl_ai_blog_log',
88 ])) { 92 ])) {
89 continue; 93 continue;
90 } 94 }
@@ -238,17 +238,20 @@ class CopyProject extends Command @@ -238,17 +238,20 @@ class CopyProject extends Command
238 $tables = array_column($tables, 'Tables_in_' . $database_name); 238 $tables = array_column($tables, 'Tables_in_' . $database_name);
239 foreach ($tables as $table) { 239 foreach ($tables as $table) {
240 // 1. 删除目标数据库中的表 240 // 1. 删除目标数据库中的表
241 - DB::connection('custom_mysql')->statement("DROP TABLE IF EXISTS {$table}"); 241 + $result = DB::connection('custom_mysql')->statement("DROP TABLE IF EXISTS {$table}");
  242 + @file_put_contents(storage_path('logs/copy_mysql_error.log'), var_export('先删除对应数据库的对应表返回结果:'.$result, true) . PHP_EOL, FILE_APPEND);
242 // 2. 复制建表 SQL 243 // 2. 复制建表 SQL
243 $sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE `{$table}`"); 244 $sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE `{$table}`");
244 - DB::connection('custom_mysql')->statement(get_object_vars($sql[0])['Create Table']); 245 + $result1 = DB::connection('custom_mysql')->statement(get_object_vars($sql[0])['Create Table']);
  246 + @file_put_contents(storage_path('logs/copy_mysql_error.log'), var_export('创建对应表数据:'.$result1, true) . PHP_EOL, FILE_APPEND);
245 // 3. 跳过指定的表 247 // 3. 跳过指定的表
246 - if (in_array($table, ['gl_customer_visit', 'gl_customer_visit_item', 'gl_inquiry_other', 'gl_inquiry_form_data', 'gl_inquiry_form'])) { 248 + if (in_array($table, ['gl_customer_visit', 'gl_customer_visit_item', 'gl_inquiry_other', 'gl_inquiry_form_data', 'gl_inquiry_form','gl_ai_blog', 'gl_ai_blog_author', 'gl_ai_blog_list','gl_ai_blog_log'])) {
247 continue; 249 continue;
248 } 250 }
249 // 4. 原生 SQL 插入数据(完全复制) 251 // 4. 原生 SQL 插入数据(完全复制)
250 $insert_sql = "INSERT INTO `{$table}` SELECT * FROM `gl_data_{$project_id}`.`{$table}`"; 252 $insert_sql = "INSERT INTO `{$table}` SELECT * FROM `gl_data_{$project_id}`.`{$table}`";
251 - DB::connection('custom_mysql')->statement($insert_sql); 253 + $result2 = DB::connection('custom_mysql')->statement($insert_sql);
  254 + @file_put_contents(storage_path('logs/copy_mysql_error.log'), var_export('对应表插入数据:'.$result2, true) . PHP_EOL, FILE_APPEND);
252 // 5. 更新 project_id(如果存在) 255 // 5. 更新 project_id(如果存在)
253 if (Schema::connection('custom_mysql')->hasColumn($table, 'project_id')) { 256 if (Schema::connection('custom_mysql')->hasColumn($table, 'project_id')) {
254 DB::connection('custom_mysql')->table($table)->update(['project_id' => $news_project_id]); 257 DB::connection('custom_mysql')->table($table)->update(['project_id' => $news_project_id]);
@@ -56,6 +56,8 @@ class SyncMobile extends Command @@ -56,6 +56,8 @@ class SyncMobile extends Command
56 if(!empty($data)){ 56 if(!empty($data)){
57 $userModel = new User(); 57 $userModel = new User();
58 try { 58 try {
  59 + $data[] = '13083988828';
  60 + $data[] = '6591559603';
59 $userModel->edit(['status'=>1],['project_id'=>1,'mobile'=>['not in',$data]]); 61 $userModel->edit(['status'=>1],['project_id'=>1,'mobile'=>['not in',$data]]);
60 $userModel->edit(['status'=>0],['project_id'=>1,'mobile'=>['in',$data]]); 62 $userModel->edit(['status'=>0],['project_id'=>1,'mobile'=>['in',$data]]);
61 }catch (\Exception $e){ 63 }catch (\Exception $e){
@@ -34,7 +34,7 @@ class UpdateSeoTdkCrontab extends Command @@ -34,7 +34,7 @@ class UpdateSeoTdkCrontab extends Command
34 */ 34 */
35 public function handle() 35 public function handle()
36 { 36 {
37 - $project_ids = Project::where('type', Project::TYPE_TWO)->pluck('id')->toArray(); 37 + $project_ids = Project::where('type', Project::TYPE_TWO)->where('uptime', '<=', date('Y-m-d H:i:s'))->pluck('id')->toArray();
38 foreach ($project_ids as $project_id){ 38 foreach ($project_ids as $project_id){
39 try { 39 try {
40 ProjectUpdateTdk::add_task($project_id); 40 ProjectUpdateTdk::add_task($project_id);
@@ -39,8 +39,9 @@ class Temp extends Command @@ -39,8 +39,9 @@ class Temp extends Command
39 */ 39 */
40 protected $description = '临时脚本(akun)'; 40 protected $description = '临时脚本(akun)';
41 41
42 - public function handle(){  
43 - 42 + public function handle()
  43 + {
  44 + $this->create_all_amp_notify();
44 } 45 }
45 46
46 /** 47 /**
@@ -89,7 +90,6 @@ class Temp extends Command @@ -89,7 +90,6 @@ class Temp extends Command
89 } 90 }
90 91
91 92
92 -  
93 /** 93 /**
94 * 未被标注 特殊前后缀 && 未达标项目 && 优化开始时间 > 2025-01-01 00:00:00 ,开启自动添加聚合页关键词的前后缀关键词配置 94 * 未被标注 特殊前后缀 && 未达标项目 && 优化开始时间 > 2025-01-01 00:00:00 ,开启自动添加聚合页关键词的前后缀关键词配置
95 * @author Akun 95 * @author Akun
@@ -16,6 +16,7 @@ use App\Models\Domain\DomainInfo; @@ -16,6 +16,7 @@ use App\Models\Domain\DomainInfo;
16 use App\Models\HomeCount\Count; 16 use App\Models\HomeCount\Count;
17 use App\Models\HomeCount\MonthCount; 17 use App\Models\HomeCount\MonthCount;
18 use App\Models\Inquiry\InquiryFormData; 18 use App\Models\Inquiry\InquiryFormData;
  19 +use App\Models\Inquiry\InquiryRelateDomain;
19 use App\Models\Project\Project; 20 use App\Models\Project\Project;
20 use App\Models\RankData\ExternalLinks; 21 use App\Models\RankData\ExternalLinks;
21 use App\Models\RankData\IndexedPages; 22 use App\Models\RankData\IndexedPages;
@@ -290,7 +291,9 @@ class OptimizationReportController extends BaseController @@ -290,7 +291,9 @@ class OptimizationReportController extends BaseController
290 //复制站点域名 291 //复制站点域名
291 $ext_projects = $this->getExtendProjects(); 292 $ext_projects = $this->getExtendProjects();
292 $flg_ext = $this->getExtFlag($ext_projects, $domain, $api_no); 293 $flg_ext = $this->getExtFlag($ext_projects, $domain, $api_no);
293 - $ext_domain = str_replace('www.', '', $this->getExtendProjects($api_no)['ext'] ?? ''); 294 + $ext_domain = str_replace('www.', '', $this->getExtendProjects($api_no)['ext'] ?? '');//关联域名
  295 + //关联域名
  296 + $relate_domain = str_replace('www.', '', InquiryRelateDomain::getRelateDomain($domain, 'globalso_domain'));
294 //AI站点域名 297 //AI站点域名
295 $ai_projects = $this->getAiProjects()['data'] ?? []; 298 $ai_projects = $this->getAiProjects()['data'] ?? [];
296 $flg_ai = $this->getAiFlag($ai_projects, $domain); 299 $flg_ai = $this->getAiFlag($ai_projects, $domain);
@@ -316,6 +319,8 @@ class OptimizationReportController extends BaseController @@ -316,6 +319,8 @@ class OptimizationReportController extends BaseController
316 $domain_text = '星链域名:' . $ai_domain; 319 $domain_text = '星链域名:' . $ai_domain;
317 } else if ($last['r'] == $ext_domain) { 320 } else if ($last['r'] == $ext_domain) {
318 $domain_text = '主域名2:' . $ext_domain; 321 $domain_text = '主域名2:' . $ext_domain;
  322 + } else if ($last['r'] == $relate_domain) {
  323 + $domain_text = '主域名2:' . $relate_domain;
319 } else { 324 } else {
320 $domain_text = 'AI域名:' . $last['r']; 325 $domain_text = 'AI域名:' . $last['r'];
321 } 326 }
@@ -48,6 +48,9 @@ class AiBlogController extends BaseController @@ -48,6 +48,9 @@ class AiBlogController extends BaseController
48 'id.required' => '主键不能为空', 48 'id.required' => '主键不能为空',
49 ]); 49 ]);
50 $info = $aiBlog->read(['id'=>$this->param['id']]); 50 $info = $aiBlog->read(['id'=>$this->param['id']]);
  51 + if(!empty($info['anchor'])){
  52 + $info['anchor'] = json_decode($info['anchor'],true);
  53 + }
51 $info['image'] = getImageUrl($info['image']); 54 $info['image'] = getImageUrl($info['image']);
52 $this->response('success',Code::SUCCESS,$info); 55 $this->response('success',Code::SUCCESS,$info);
53 } 56 }
@@ -86,6 +89,25 @@ class AiBlogController extends BaseController @@ -86,6 +89,25 @@ class AiBlogController extends BaseController
86 } 89 }
87 90
88 /** 91 /**
  92 + * @remark :
  93 + * @name :saveText
  94 + * @author :lyh
  95 + * @method :post
  96 + * @time :2025/4/30 18:05
  97 + */
  98 + public function saveText(AiBlogLogic $aiBlogLogic){
  99 + $this->request->validate([
  100 + 'id'=>['required'],
  101 + 'text'=>['required'],
  102 + ],[
  103 + 'id.required' => '关键字不能为空',
  104 + 'text.required' => '场景不能为空',
  105 + ]);
  106 + $aiBlogLogic->blogSaveText();
  107 + $this->response('success');
  108 + }
  109 +
  110 + /**
89 * @remark :获取作者列表 111 * @remark :获取作者列表
90 * @name :getAiBlogAuthor 112 * @name :getAiBlogAuthor
91 * @author :lyh 113 * @author :lyh
@@ -13,6 +13,7 @@ use App\Enums\Common\Code; @@ -13,6 +13,7 @@ use App\Enums\Common\Code;
13 use App\Http\Controllers\Bside\BaseController; 13 use App\Http\Controllers\Bside\BaseController;
14 use App\Http\Logic\Bside\Ai\AiVideoLogic; 14 use App\Http\Logic\Bside\Ai\AiVideoLogic;
15 use App\Models\Ai\AiVideo; 15 use App\Models\Ai\AiVideo;
  16 +use App\Models\Ai\AiVideoList;
16 17
17 class AiVideoController extends BaseController 18 class AiVideoController extends BaseController
18 { 19 {
@@ -24,7 +25,7 @@ class AiVideoController extends BaseController @@ -24,7 +25,7 @@ class AiVideoController extends BaseController
24 * @time :2025/3/5 14:12 25 * @time :2025/3/5 14:12
25 */ 26 */
26 public function lists(AiVideo $aiVideo){ 27 public function lists(AiVideo $aiVideo){
27 - $lists = $aiVideo->lists($this->map,$this->page,$this->row,'id',['id','keyword','new_title','route','image','task_id','status','created_at','updated_at']); 28 + $lists = $aiVideo->lists($this->map,$this->page,$this->row,'id',['id','title','route','video_url','image','task_id','status','created_at','updated_at']);
28 if(!empty($lists) && !empty($lists['list'])){ 29 if(!empty($lists) && !empty($lists['list'])){
29 foreach ($lists['list'] as $k => $v){ 30 foreach ($lists['list'] as $k => $v){
30 $v['image'] = getImageUrl($v['image']); 31 $v['image'] = getImageUrl($v['image']);
@@ -51,7 +52,8 @@ class AiVideoController extends BaseController @@ -51,7 +52,8 @@ class AiVideoController extends BaseController
51 'id.required' => '主键不能为空', 52 'id.required' => '主键不能为空',
52 ]); 53 ]);
53 $info = $aiVideo->read(['id'=>$this->param['id']]); 54 $info = $aiVideo->read(['id'=>$this->param['id']]);
54 - $info['image'] = getImageUrl($info['image']); 55 + $info['anchor'] = json_decode($info['anchor'] ?? [],true);
  56 + $info['images'] = json_decode($info['images'] ?? [],true);
55 $this->response('success',Code::SUCCESS,$info); 57 $this->response('success',Code::SUCCESS,$info);
56 } 58 }
57 59
@@ -64,11 +66,13 @@ class AiVideoController extends BaseController @@ -64,11 +66,13 @@ class AiVideoController extends BaseController
64 */ 66 */
65 public function sendTask(AiVideoLogic $aiVideoLogic){ 67 public function sendTask(AiVideoLogic $aiVideoLogic){
66 $this->request->validate([ 68 $this->request->validate([
67 - 'keyword'=>['required'],  
68 - 'type'=>['required'], 69 + 'title'=>['required'],
  70 + 'description'=>['required'],
  71 + 'images'=>['required'],
69 ],[ 72 ],[
70 - 'keyword.required' => '关键字不能为空',  
71 - 'type.required' => '场景不能为空', 73 + 'title.required' => '标题不能为空',
  74 + 'description.required' => '短描述不能为空',
  75 + 'images.required' => '图片集合不能为空',
72 ]); 76 ]);
73 $result = $aiVideoLogic->sendTask(); 77 $result = $aiVideoLogic->sendTask();
74 $this->response('success',Code::SUCCESS,$result); 78 $this->response('success',Code::SUCCESS,$result);
@@ -108,4 +112,40 @@ class AiVideoController extends BaseController @@ -108,4 +112,40 @@ class AiVideoController extends BaseController
108 $result = $aiVideoLogic->videoDelete(); 112 $result = $aiVideoLogic->videoDelete();
109 $this->response('success',Code::SUCCESS,$result); 113 $this->response('success',Code::SUCCESS,$result);
110 } 114 }
  115 +
  116 +
  117 + /**
  118 + * @remark :获取列表页数据
  119 + * @name :getAiBlogList
  120 + * @author :lyh
  121 + * @method :post
  122 + * @time :2025/2/21 16:22
  123 + */
  124 + public function getAiVideoList(AiVideoList $aiVideoList){
  125 + $lists = $aiVideoList->lists($this->map,$this->page,$this->row,'id',['id','route','created_at','updated_at']);
  126 + if(!empty($lists) && !empty($lists['list'])){
  127 + foreach ($lists['list'] as $k => $v){
  128 + $v['route'] = $this->user['domain'] . 'top-video/' . (($v['route'] > 1) ? $v['route'] : '');
  129 + $lists['list'][$k] = $v;
  130 + }
  131 + }
  132 + $this->response('success',Code::SUCCESS,$lists);
  133 + }
  134 +
  135 + /**
  136 + * @remark :获取列表页数据详情
  137 + * @name :getAiBlogListInfo
  138 + * @author :lyh
  139 + * @method :post
  140 + * @time :2025/2/21 16:26
  141 + */
  142 + public function getAiBlogListInfo(AiVideoList $aiVideoList){
  143 + $this->request->validate([
  144 + 'id'=>['required'],
  145 + ],[
  146 + 'id.required' => '主键不能为空',
  147 + ]);
  148 + $info = $aiVideoList->read($this->map);
  149 + $this->response('success',Code::SUCCESS,$info);
  150 + }
111 } 151 }
@@ -147,6 +147,10 @@ class ComController extends BaseController @@ -147,6 +147,10 @@ class ComController extends BaseController
147 if($is_blogs != 1){ 147 if($is_blogs != 1){
148 $info['role_menu'] = trim(str_replace(',57,',',',','.$info['role_menu'].','),','); 148 $info['role_menu'] = trim(str_replace(',57,',',',','.$info['role_menu'].','),',');
149 } 149 }
  150 + $is_video = $this->getIsAiVideo();
  151 + if($is_video != 1){
  152 + $info['role_menu'] = trim(str_replace(',74,',',',','.$info['role_menu'].','),',');
  153 + }
150 $this->map = [ 154 $this->map = [
151 'status'=>0, 155 'status'=>0,
152 'is_role'=>0, 156 'is_role'=>0,
@@ -195,6 +199,10 @@ class ComController extends BaseController @@ -195,6 +199,10 @@ class ComController extends BaseController
195 if($is_ai_blog != 1){ 199 if($is_ai_blog != 1){
196 $data[] = 57; 200 $data[] = 57;
197 } 201 }
  202 + $is_ai_video = $this->getIsAiVideo();
  203 + if($is_ai_video != 1){
  204 + $data[] = 74;
  205 + }
198 if(!empty($data)){ 206 if(!empty($data)){
199 $this->map['id'] = ['not in',$data]; 207 $this->map['id'] = ['not in',$data];
200 } 208 }
@@ -291,6 +299,16 @@ class ComController extends BaseController @@ -291,6 +299,16 @@ class ComController extends BaseController
291 return $this->user['is_ai_blog'] ?? 0; 299 return $this->user['is_ai_blog'] ?? 0;
292 } 300 }
293 301
  302 + /**
  303 + * @remark :ai视频
  304 + * @name :getIsAiVideo
  305 + * @author :lyh
  306 + * @method :post
  307 + * @time :2025/5/6 14:33
  308 + */
  309 + public function getIsAiVideo(){
  310 + return $this->user['is_ai_video'] ?? 0;
  311 + }
294 312
295 /** 313 /**
296 * @name :登录用户编辑资料/修改密码 314 * @name :登录用户编辑资料/修改密码
@@ -28,6 +28,7 @@ use App\Models\Project\Project; @@ -28,6 +28,7 @@ use App\Models\Project\Project;
28 use App\Models\Project\ProjectAiSetting; 28 use App\Models\Project\ProjectAiSetting;
29 use App\Models\RouteMap\RouteMap; 29 use App\Models\RouteMap\RouteMap;
30 use App\Services\AiBlogService; 30 use App\Services\AiBlogService;
  31 +use App\Services\AiVideoService;
31 use App\Services\RapIdApIService; 32 use App\Services\RapIdApIService;
32 use App\Services\ProjectServer; 33 use App\Services\ProjectServer;
33 use Illuminate\Support\Facades\DB; 34 use Illuminate\Support\Facades\DB;
@@ -42,8 +43,16 @@ class TestController extends BaseController @@ -42,8 +43,16 @@ class TestController extends BaseController
42 * @time :2025/2/13 16:34 43 * @time :2025/2/13 16:34
43 */ 44 */
44 public function ceshi(){ 45 public function ceshi(){
45 - //获取上一周询盘数量  
46 - $transData = Translate::tran(['heidenhain programming','heidenhain tnc 620'], 'zh');  
47 - $this->response('success',Code::SUCCESS,$transData); 46 + $this->param = [
  47 + 'title'=>'apple',
  48 + 'description'=>'apples',
  49 + 'images'=>[
  50 + ['url'=>'https://ecdn6.globalso.com/upload/public/template/64e332671b32e25328.png','title'=>'apple'],
  51 + ['url'=>'https://ecdn6.globalso.com/upload/public/template/64e32a24b314a39425.png','title'=>'apples'],
  52 + ],
  53 + ];
  54 + $aiVideoService = new AiVideoService(467);
  55 + $result = $aiVideoService->createTask($this->param['title'],$this->param['description'],$this->param['images'],$this->param['anchor'] ?? []);
  56 + $this->response('success',Code::SUCCESS,$result);
48 } 57 }
49 } 58 }
@@ -166,7 +166,7 @@ class ProjectLogic extends BaseLogic @@ -166,7 +166,7 @@ class ProjectLogic extends BaseLogic
166 }else{ 166 }else{
167 $this->param = $this->handleLevelStr($this->param);//处理星级客户暂停优化默认参数 167 $this->param = $this->handleLevelStr($this->param);//处理星级客户暂停优化默认参数
168 $this->saveSeoPlan($this->param);//保存seo白帽类型,上线保存一条审核记录 168 $this->saveSeoPlan($this->param);//保存seo白帽类型,上线保存一条审核记录
169 - $this->checkAiBlog($this->param);//开启白帽验证参数 169 + $this->checkAiBlog($this->param);//开启ai相关功能验证参数
170 DB::beginTransaction(); 170 DB::beginTransaction();
171 try { 171 try {
172 //初始化项目 172 //初始化项目
@@ -174,8 +174,9 @@ class ProjectLogic extends BaseLogic @@ -174,8 +174,9 @@ class ProjectLogic extends BaseLogic
174 //双向绑定服务器,需放到保存项目的上方 174 //双向绑定服务器,需放到保存项目的上方
175 $this->setServers($this->param['serve_id'],$this->param['id']); 175 $this->setServers($this->param['serve_id'],$this->param['id']);
176 //ai_blog 176 //ai_blog
177 - $this->setAiBlog($this->param['id'],$this->param['main_lang_id'],$this->param['is_ai_blog'],  
178 - $this->param['company']??"", $this->param['deploy_optimize']['company_en_name'] ?? '',$this->param['deploy_optimize']['company_en_description'] ?? ''); 177 + $this->setAiBlog($this->param['id'],$this->param['main_lang_id'],$this->param['is_ai_blog'] ?? 0,
  178 + $this->param['company']??"", $this->param['deploy_optimize']['company_en_name'] ?? '',
  179 + $this->param['deploy_optimize']['company_en_description'] ?? '',$this->param['is_ai_video'] ?? 0);
179 //保存项目信息 180 //保存项目信息
180 $this->saveProject($this->param); 181 $this->saveProject($this->param);
181 //保存建站部署信息 182 //保存建站部署信息
@@ -217,6 +218,7 @@ class ProjectLogic extends BaseLogic @@ -217,6 +218,7 @@ class ProjectLogic extends BaseLogic
217 if (in_array('2', $param['level']) || in_array('3', $param['level'])) { 218 if (in_array('2', $param['level']) || in_array('3', $param['level'])) {
218 //优化设置默认关闭 219 //优化设置默认关闭
219 $param['is_ai_blog'] = 0; 220 $param['is_ai_blog'] = 0;
  221 + $param['is_ai_video'] = 0;
220 $param['deploy_optimize']['is_ai_blog_send'] = 0; 222 $param['deploy_optimize']['is_ai_blog_send'] = 0;
221 $param['deploy_optimize']['is_auto_keywords'] = 0; 223 $param['deploy_optimize']['is_auto_keywords'] = 0;
222 } 224 }
@@ -259,7 +261,7 @@ class ProjectLogic extends BaseLogic @@ -259,7 +261,7 @@ class ProjectLogic extends BaseLogic
259 } 261 }
260 262
261 /** 263 /**
262 - * @remark :开启白帽验证参数 264 + * @remark :开启ai博客及视频
263 * @name :checkAiBlog 265 * @name :checkAiBlog
264 * @author :lyh 266 * @author :lyh
265 * @method :post 267 * @method :post
@@ -268,12 +270,13 @@ class ProjectLogic extends BaseLogic @@ -268,12 +270,13 @@ class ProjectLogic extends BaseLogic
268 public function checkAiBlog($param){ 270 public function checkAiBlog($param){
269 $main_lang_id = $param['main_lang_id'] ?? 0; 271 $main_lang_id = $param['main_lang_id'] ?? 0;
270 $is_ai_blog = $param['is_ai_blog'] ?? 0; 272 $is_ai_blog = $param['is_ai_blog'] ?? 0;
  273 + $is_ai_video = $param['is_ai_video'] ?? 0;
271 $company = $param['company'] ?? ''; 274 $company = $param['company'] ?? '';
272 $company_en_name = $param['deploy_optimize']['company_en_name'] ?? ''; 275 $company_en_name = $param['deploy_optimize']['company_en_name'] ?? '';
273 $company_en_description = $param['deploy_optimize']['company_en_description'] ?? ''; 276 $company_en_description = $param['deploy_optimize']['company_en_description'] ?? '';
274 - if($is_ai_blog == 1){ 277 + if($is_ai_blog == 1 || $is_ai_video == 1){
275 if(empty($main_lang_id) || empty($company) || empty($company_en_name) || empty($company_en_description)){ 278 if(empty($main_lang_id) || empty($company) || empty($company_en_name) || empty($company_en_description)){
276 - $this->fail('开启ai_blog--请填写主语种+公司名称+公司英文名称+公司英文介绍'); 279 + $this->fail('开启ai博客/视频功能--请填写主语种+公司名称+公司英文名称+公司英文介绍');
277 } 280 }
278 } 281 }
279 return true; 282 return true;
@@ -286,11 +289,11 @@ class ProjectLogic extends BaseLogic @@ -286,11 +289,11 @@ class ProjectLogic extends BaseLogic
286 * @method :post 289 * @method :post
287 * @time :2025/2/13 16:02 290 * @time :2025/2/13 16:02
288 */ 291 */
289 - public function setAiBlog($project_id,$main_lang_id,$is_ai_blog,$company,$company_en_name,$company_en_description){  
290 - if(empty($main_lang_id) || empty($is_ai_blog)){ 292 + public function setAiBlog($project_id,$main_lang_id,$is_ai_blog,$company,$company_en_name,$company_en_description,$is_ai_video = 0){
  293 + if(empty($main_lang_id) || (empty($is_ai_blog) && empty($is_ai_video))){
291 return true; 294 return true;
292 } 295 }
293 - $projectInfo = $this->model->read(['id'=>$project_id],['title','is_ai_blog','main_lang_id','company']); 296 + $projectInfo = $this->model->read(['id'=>$project_id],['title','main_lang_id','company']);
294 $projectOptimize = DeployOptimize::where('project_id', $project_id)->first(); 297 $projectOptimize = DeployOptimize::where('project_id', $project_id)->first();
295 //获取项目主语种 298 //获取项目主语种
296 $languageModel = new WebLanguage(); 299 $languageModel = new WebLanguage();
@@ -57,17 +57,18 @@ class AiBlogLogic extends BaseLogic @@ -57,17 +57,18 @@ class AiBlogLogic extends BaseLogic
57 $this->param['image'] = str_replace_url($this->param['image']); 57 $this->param['image'] = str_replace_url($this->param['image']);
58 } 58 }
59 $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_BLOG, $this->param['id'], $this->user['project_id']); 59 $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_BLOG, $this->param['id'], $this->user['project_id']);
  60 + $anchor = $this->param['anchor'] ?? [];
  61 + $this->param['anchor'] = json_encode($anchor,true);
60 $this->model->edit($this->param,['id'=>$this->param['id']]); 62 $this->model->edit($this->param,['id'=>$this->param['id']]);
61 $aiSettingInfo = $this->getProjectAiSetting(); 63 $aiSettingInfo = $this->getProjectAiSetting();
62 $aiBlogService = new AiBlogService(); 64 $aiBlogService = new AiBlogService();
63 $aiBlogService->mch_id = $aiSettingInfo['mch_id']; 65 $aiBlogService->mch_id = $aiSettingInfo['mch_id'];
64 $aiBlogService->key = $aiSettingInfo['key']; 66 $aiBlogService->key = $aiSettingInfo['key'];
65 - $aiBlogService->updateDetail(['task_id'=>$this->param['task_id'],'title'=>$this->param['new_title'],'thumb'=>$this->param['image'],'route'=>$this->param['route'],'author_id'=>$this->param['author_id']]);  
66 - $aiBlogTaskModel = new AiBlogTask();  
67 - $aiBlogTaskModel->edit(['status'=>AiBlogTask::STATUS_RUNNING],['task_id'=>$this->param['task_id']]);//重新走拉取流程 67 + $aiBlogService->updateDetail(['task_id'=>$this->param['task_id'],'title'=>$this->param['new_title'],'thumb'=>$this->param['image'],'route'=>$this->param['route'],'author_id'=>$anchor]);
68 }catch (\Exception $e){ 68 }catch (\Exception $e){
69 $this->fail('保存失败,请联系管理员'); 69 $this->fail('保存失败,请联系管理员');
70 } 70 }
  71 + shell_exec("php artisan save_ai_blog_list {$this->user['project_id']} > /dev/null 2>&1 &");
71 return $this->success(); 72 return $this->success();
72 } 73 }
73 74
@@ -7,9 +7,11 @@ use App\Http\Logic\Bside\BaseLogic; @@ -7,9 +7,11 @@ use App\Http\Logic\Bside\BaseLogic;
7 use App\Models\Ai\AiBlogAuthor; 7 use App\Models\Ai\AiBlogAuthor;
8 use App\Models\Ai\AiVideo; 8 use App\Models\Ai\AiVideo;
9 use App\Models\Project\AiBlogTask; 9 use App\Models\Project\AiBlogTask;
  10 +use App\Models\Project\AiVideoTask;
10 use App\Models\Project\ProjectAiSetting; 11 use App\Models\Project\ProjectAiSetting;
11 use App\Models\RouteMap\RouteMap; 12 use App\Models\RouteMap\RouteMap;
12 use App\Services\AiBlogService; 13 use App\Services\AiBlogService;
  14 +use App\Services\AiVideoService;
13 15
14 /** 16 /**
15 * @remark :视频模块 17 * @remark :视频模块
@@ -27,21 +29,6 @@ class AiVideoLogic extends BaseLogic @@ -27,21 +29,6 @@ class AiVideoLogic extends BaseLogic
27 $this->model = new AiVideo(); 29 $this->model = new AiVideo();
28 } 30 }
29 31
30 - /**  
31 - * @remark :获取配置信息  
32 - * @name :getProjectAiSetting  
33 - * @author :lyh  
34 - * @method :post  
35 - * @time :2025/2/21 14:51  
36 - */  
37 - public function getProjectAiSetting(){  
38 - $projectAiSettingModel = new ProjectAiSetting();  
39 - $aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$this->user['project_id']]);  
40 - if($aiSettingInfo === false){  
41 - $this->fail('请先联系管理员开启Ai配置');  
42 - }  
43 - return $aiSettingInfo;  
44 - }  
45 32
46 /** 33 /**
47 * @remark :ai发布博客 34 * @remark :ai发布博客
@@ -52,16 +39,14 @@ class AiVideoLogic extends BaseLogic @@ -52,16 +39,14 @@ class AiVideoLogic extends BaseLogic
52 */ 39 */
53 public function videoSave(){ 40 public function videoSave(){
54 try { 41 try {
55 - if(!empty($this->param['image'])){  
56 - $this->param['image'] = str_replace_url($this->param['image']);  
57 - }  
58 $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_VIDEO, $this->param['id'], $this->user['project_id']); 42 $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_VIDEO, $this->param['id'], $this->user['project_id']);
  43 + $anchor = $this->param['anchor'] ?? [];
  44 + $this->param['anchor'] = json_encode($anchor,true);
  45 + $this->param['images'] = json_encode($this->param['images'],true);
59 $this->model->edit($this->param,['id'=>$this->param['id']]); 46 $this->model->edit($this->param,['id'=>$this->param['id']]);
60 - $aiSettingInfo = $this->getProjectAiSetting();  
61 - $aiBlogService = new AiBlogService();  
62 - $aiBlogService->mch_id = $aiSettingInfo['mch_id'];  
63 - $aiBlogService->key = $aiSettingInfo['key'];  
64 - $aiBlogService->updateDetail(['task_id'=>$this->param['task_id'],'title'=>$this->param['new_title'],'thumb'=>$this->param['image'],'route'=>$this->param['route'],'author_id'=>$this->param['author_id']]); 47 + $aiVideoService = new AiVideoService($this->user['project_id']);
  48 + $aiVideoService->updateDetail(['task_id'=>$this->param['task_id'],'title'=>$this->param['title'],
  49 + 'content'=>$this->param['content'] ?? '','video_url'=>$this->param['video_url'],'anchor'=>$anchor,'thumb'=>$this->param['image'],'url'=>$this->param['route'],'author_id'=>$this->param['author_id']]);
65 }catch (\Exception $e){ 50 }catch (\Exception $e){
66 $this->fail('保存失败,请联系管理员'); 51 $this->fail('保存失败,请联系管理员');
67 } 52 }
@@ -74,20 +59,16 @@ class AiVideoLogic extends BaseLogic @@ -74,20 +59,16 @@ class AiVideoLogic extends BaseLogic
74 * @author :lyh 59 * @author :lyh
75 * @method :post 60 * @method :post
76 * @time :2025/2/14 10:28 61 * @time :2025/2/14 10:28
77 - * @detail :createTask =>type=2/生成文章  
78 * @detail :status=1/待执行 62 * @detail :status=1/待执行
79 */ 63 */
80 public function sendTask(){ 64 public function sendTask(){
81 - $aiSettingInfo = $this->getProjectAiSetting();  
82 - $aiBlogService = new AiBlogService();  
83 - $aiBlogService->mch_id = $aiSettingInfo['mch_id'];  
84 - $aiBlogService->key = $aiSettingInfo['key'];  
85 - $aiBlogService->route = generateRoute(Translate::tran($this->param['keyword'], 'en'));  
86 - $result = $aiBlogService->createTask($this->param['keyword'],2,'video',$this->param['anchor'] ?? []); 65 + $aiVideoService = new AiVideoService($this->user['project_id']);
  66 + $result = $aiVideoService->createTask($this->param['title'],$this->param['description'],$this->param['images'],$this->param['anchor'] ?? []);
87 if($result['status'] == 200){ 67 if($result['status'] == 200){
88 - $aiBlogTaskModel = new AiBlogTask();  
89 - $aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'type'=>3,'task_id'=>$result['data']['task_id'],'status'=>1]);  
90 - $this->model->addReturnId(['keyword'=>$this->param['keyword'],'status'=>1,'task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id'],'anchor'=>json_encode($this->param['anchor'] ?? [],true)]); 68 + $aiVideoTaskModel = new AiVideoTask();
  69 + $aiVideoTaskModel->addReturnId(['task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id']]);
  70 + $id = $this->model->addReturnId(['title'=>$this->param['title'],'task_id'=>$result['data']['task_id'],'description'=>$this->param['description'],'project_id'=>$this->user['project_id'],'images'=>json_encode($this->param['images'],true),'anchor'=>json_encode($this->param['anchor'] ?? [],true)]);
  71 + return $this->success(['id'=>$id]);
91 } 72 }
92 return $this->success(); 73 return $this->success();
93 } 74 }
@@ -101,13 +82,10 @@ class AiVideoLogic extends BaseLogic @@ -101,13 +82,10 @@ class AiVideoLogic extends BaseLogic
101 */ 82 */
102 public function videoDelete(){ 83 public function videoDelete(){
103 try { 84 try {
104 - $aiSettingInfo = $this->getProjectAiSetting();  
105 - $aiBlogService = new AiBlogService(); 85 + $aiBlogService = new AiVideoService($this->user['project_id']);
106 foreach ($this->param['ids'] as $id) { 86 foreach ($this->param['ids'] as $id) {
107 $info = $this->model->read(['id'=>$id],['task_id']); 87 $info = $this->model->read(['id'=>$id],['task_id']);
108 - $aiBlogService->mch_id = $aiSettingInfo['mch_id'];  
109 - $aiBlogService->key = $aiSettingInfo['key'];  
110 - $aiBlogService->delDetail($info['task_id']); 88 + $aiBlogService->delVideoDetail($info['task_id']);
111 //删除路由映射 89 //删除路由映射
112 RouteMap::delRoute(RouteMap::SOURCE_AI_VIDEO, $id, $this->user['project_id']); 90 RouteMap::delRoute(RouteMap::SOURCE_AI_VIDEO, $id, $this->user['project_id']);
113 $this->model->del(['id'=>$id]); 91 $this->model->del(['id'=>$id]);
@@ -11,6 +11,7 @@ use App\Http\Logic\Aside\Project\DomainInfoLogic; @@ -11,6 +11,7 @@ use App\Http\Logic\Aside\Project\DomainInfoLogic;
11 use App\Http\Logic\Aside\Project\ProjectLogic; 11 use App\Http\Logic\Aside\Project\ProjectLogic;
12 use App\Http\Logic\Bside\BaseLogic; 12 use App\Http\Logic\Bside\BaseLogic;
13 use App\Models\Domain\DomainInfo; 13 use App\Models\Domain\DomainInfo;
  14 +use App\Models\Inquiry\InquiryRelateDomain;
14 use App\Models\Project\DeployBuild; 15 use App\Models\Project\DeployBuild;
15 use App\Models\Project\DeployOptimize; 16 use App\Models\Project\DeployOptimize;
16 use App\Models\Project\MinorLanguages; 17 use App\Models\Project\MinorLanguages;
@@ -233,6 +234,8 @@ class RankDataLogic extends BaseLogic @@ -233,6 +234,8 @@ class RankDataLogic extends BaseLogic
233 $flg_ext = $this->getExtFlag($ext_projects, $domain, $api_no); 234 $flg_ext = $this->getExtFlag($ext_projects, $domain, $api_no);
234 $ext_domain = str_replace('www.', '', $this->getExtendProjects($api_no)['ext'] ?? ''); 235 $ext_domain = str_replace('www.', '', $this->getExtendProjects($api_no)['ext'] ?? '');
235 $main_domain = str_replace('www.', '', $this->getExtendProjects($api_no)['url'] ?? ''); 236 $main_domain = str_replace('www.', '', $this->getExtendProjects($api_no)['url'] ?? '');
  237 + //关联域名
  238 + $relate_domain = str_replace('www.', '', InquiryRelateDomain::getRelateDomain($domain, 'globalso_domain'));
236 //AI站点域名 239 //AI站点域名
237 $ai_projects = $this->getAiProjects()['data'] ?? []; 240 $ai_projects = $this->getAiProjects()['data'] ?? [];
238 $flg_ai = $this->getAiFlag($ai_projects, $domain); 241 $flg_ai = $this->getAiFlag($ai_projects, $domain);
@@ -263,6 +266,8 @@ class RankDataLogic extends BaseLogic @@ -263,6 +266,8 @@ class RankDataLogic extends BaseLogic
263 $domain_text = '星链域名:' . $ai_domain; 266 $domain_text = '星链域名:' . $ai_domain;
264 } else if ($last['r'] == $ext_domain) { 267 } else if ($last['r'] == $ext_domain) {
265 $domain_text = '主域名2:' . $ext_domain; 268 $domain_text = '主域名2:' . $ext_domain;
  269 + } else if ($last['r'] == $relate_domain) {
  270 + $domain_text = '主域名2:' . $relate_domain;
266 } else { 271 } else {
267 $domain_text = 'AI域名:' . $last['r']; 272 $domain_text = 'AI域名:' . $last['r'];
268 } 273 }
@@ -540,7 +545,7 @@ class RankDataLogic extends BaseLogic @@ -540,7 +545,7 @@ class RankDataLogic extends BaseLogic
540 $without_project_ids = []; //不用处理排名的项目 545 $without_project_ids = []; //不用处理排名的项目
541 $without_extension_project_ids = [658]; //是否达标只统计主词的 546 $without_extension_project_ids = [658]; //是否达标只统计主词的
542 $extension_project_ids = [354]; //扩展词也到达标的 547 $extension_project_ids = [354]; //扩展词也到达标的
543 - $compliance_project_ids = [2163,257,823,1750]; //直接达标处理的 548 + $compliance_project_ids = [2163,257,823,1750,497]; //直接达标处理的
544 $ceaseProjectId = [47, 354, 378, 649, 1226, 1283, 1703, 1893, 2066, 2250];//暂停的项目 549 $ceaseProjectId = [47, 354, 378, 649, 1226, 1283, 1703, 1893, 2066, 2250];//暂停的项目
545 $uptimeProjectId = [1434,1812,276,2414,2974];//按上线时间统计的项目 550 $uptimeProjectId = [1434,1812,276,2414,2974];//按上线时间统计的项目
546 //一个项目多个api_no 551 //一个项目多个api_no
@@ -274,7 +274,8 @@ class UserLoginLogic @@ -274,7 +274,8 @@ class UserLoginLogic
274 $info['is_show_blog'] = $project['is_show_blog']; 274 $info['is_show_blog'] = $project['is_show_blog'];
275 $info['upload_config'] = $project['upload_config']; 275 $info['upload_config'] = $project['upload_config'];
276 $info['main_lang_id'] = $project['main_lang_id']; 276 $info['main_lang_id'] = $project['main_lang_id'];
277 - $info['is_ai_blog'] = $project['is_ai_blog']; 277 + $info['is_ai_blog'] = $project['is_ai_blog'] ?? 0;
  278 + $info['is_ai_video'] = $project['is_ai_video'] ?? 0;
278 $info['image_max'] = $project['image_max']; 279 $info['image_max'] = $project['image_max'];
279 $info['is_del_inquiry'] = $project['is_del_inquiry'] ?? 0; 280 $info['is_del_inquiry'] = $project['is_del_inquiry'] ?? 0;
280 $info['uptime_type'] = $this->getHistory($project); 281 $info['uptime_type'] = $this->getHistory($project);
@@ -21,4 +21,6 @@ use App\Models\Base; @@ -21,4 +21,6 @@ use App\Models\Base;
21 class AiVideo extends Base 21 class AiVideo extends Base
22 { 22 {
23 protected $table = 'gl_ai_video'; 23 protected $table = 'gl_ai_video';
  24 + //连接数据库
  25 + protected $connection = 'custom_mysql';
24 } 26 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :AiBlogList.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/2/21 15:57
  8 + */
  9 +
  10 +namespace App\Models\Ai;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class AiVideoList extends Base
  15 +{
  16 + protected $table = 'gl_ai_video_list';
  17 + //连接数据库
  18 + protected $connection = 'custom_mysql';
  19 +}
@@ -27,6 +27,9 @@ class GoogleKeywordInsightDetail extends Base @@ -27,6 +27,9 @@ class GoogleKeywordInsightDetail extends Base
27 $saveData = []; 27 $saveData = [];
28 $textArr = array_column($data, 'text'); 28 $textArr = array_column($data, 'text');
29 $transData = Translate::tran($textArr, 'zh'); 29 $transData = Translate::tran($textArr, 'zh');
  30 + if(!is_array($transData)){
  31 + $transData = [$transData];
  32 + }
30 foreach ($data as $key => $val){ 33 foreach ($data as $key => $val){
31 $saveData[] = [ 34 $saveData[] = [
32 'search'=>$keyword, 35 'search'=>$keyword,
@@ -28,8 +28,8 @@ class InquiryRelateDomain extends Base @@ -28,8 +28,8 @@ class InquiryRelateDomain extends Base
28 * @author zbj 28 * @author zbj
29 * @date 2025/4/12 29 * @date 2025/4/12
30 */ 30 */
31 - public static function getRelateDomain($domain){  
32 - $list_cache_key = 'RelateDomainList'; 31 + public static function getRelateDomain($domain, $k = 'domain'){
  32 + $list_cache_key = 'RelateDomainList_' . $k;
33 $data = Cache::get($list_cache_key); 33 $data = Cache::get($list_cache_key);
34 if(!$data){ 34 if(!$data){
35 $data = []; 35 $data = [];
@@ -41,7 +41,11 @@ class InquiryRelateDomain extends Base @@ -41,7 +41,11 @@ class InquiryRelateDomain extends Base
41 $res = Arr::s2a($res); 41 $res = Arr::s2a($res);
42 $arr = []; 42 $arr = [];
43 foreach ($res['data']['data'] as $item){ 43 foreach ($res['data']['data'] as $item){
  44 + if($k == 'domain'){
44 $arr[$item['domain']] = $item['globalso_domain']; 45 $arr[$item['domain']] = $item['globalso_domain'];
  46 + }else{
  47 + $arr[$item['globalso_domain']] = $item['domain'];
  48 + }
45 } 49 }
46 $data = array_merge($data, $arr); 50 $data = array_merge($data, $arr);
47 if ($res['data']['last_page'] == $page) { 51 if ($res['data']['last_page'] == $page) {
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :AiVideoTask.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/4/30 9:41
  8 + */
  9 +
  10 +namespace App\Models\Project;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class AiVideoTask extends Base
  15 +{
  16 + protected $table = 'gl_ai_video_task';
  17 +
  18 + /**
  19 + * 任务状态
  20 + */
  21 + const STATUS_RUNNING = 1;
  22 + const STATUS_FINISH = 2;
  23 +}
@@ -37,6 +37,7 @@ class RouteMap extends Base @@ -37,6 +37,7 @@ class RouteMap extends Base
37 const SOURCE_AI_VIDEO = 'ai_video'; 37 const SOURCE_AI_VIDEO = 'ai_video';
38 const SOURCE_AI_BLOG_AUTHOR = 'ai_blog_author';//ai博客作者 38 const SOURCE_AI_BLOG_AUTHOR = 'ai_blog_author';//ai博客作者
39 const SOURCE_AI_BLOG_LIST = 'ai_blog_list'; 39 const SOURCE_AI_BLOG_LIST = 'ai_blog_list';
  40 + const SOURCE_AI_VIDEO_LIST = 'ai_blog_video';
40 //自定义模块分类 41 //自定义模块分类
41 const SOURCE_MODULE_CATE = 'module_category'; 42 const SOURCE_MODULE_CATE = 'module_category';
42 43
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :AiVideoService.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/4/29 17:39
  8 + */
  9 +
  10 +namespace App\Services;
  11 +
  12 +use App\Helper\Translate;
  13 +use App\Models\Project\ProjectAiSetting;
  14 +
  15 +class AiVideoService
  16 +{
  17 + public $url = 'https://ai-extend.ai.cc/';
  18 +
  19 + public $mch_id = 1;//默认配置
  20 + public $sign = '';//签名
  21 + public $key = 'b3e4c722b821';//默认key
  22 + public $route = '';//回调地址
  23 + public $task_id = '';//任务id
  24 + public $author_id = '';//作者id
  25 +
  26 + public function __construct($project_id = 0)
  27 + {
  28 + if($project_id){
  29 + $projectAiSettingModel = new ProjectAiSetting();
  30 + $aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$project_id]);
  31 + $this->mch_id = $aiSettingInfo['mch_id'];
  32 + $this->key = $aiSettingInfo['key'];
  33 + }
  34 + }
  35 +
  36 + /**
  37 + * @remark :设置路由
  38 + * @name :setRoute
  39 + * @author :lyh
  40 + * @method :post
  41 + * @time :2025/3/25 9:45
  42 + */
  43 + public function setRoute($keyword)
  44 + {
  45 + $this->route = generateRoute(Translate::tran($keyword, 'en'));
  46 + return $this;
  47 + }
  48 +
  49 + /**
  50 + * @remark :创建任务
  51 + * @name :createTask
  52 + * @author :lyh
  53 + * @method :post
  54 + * @time :2025/4/29 17:59
  55 + */
  56 + public function createTask($title,$description,$images = [],$anchor = []){
  57 + $request_url = $this->url.'api/video/create';
  58 + $param = ['title'=>$title, 'description'=>$description, 'images'=>$images,'anchor'=>$anchor];
  59 + $param['mch_id'] = $this->mch_id;
  60 + $this->sign = $this->generateSign($param,$this->key);
  61 + $param['sign'] = $this->sign;
  62 + return http_post($request_url,json_encode($param,true));
  63 + }
  64 +
  65 + /**
  66 + * @remark :获取视频详情
  67 + * @name :getVideoDetail
  68 + * @author :lyh
  69 + * @method :post
  70 + * @time :2025/2/14 11:23
  71 + */
  72 + public function getVideoDetail(){
  73 + $request_url = $this->url.'api/video/detail';
  74 + $param = [
  75 + 'mch_id'=>$this->mch_id,
  76 + 'task_id'=>$this->task_id,
  77 + ];
  78 + $this->sign = $this->generateSign($param,$this->key);
  79 + $param['sign'] = $this->sign;
  80 + $result = http_post($request_url,json_encode($param,true));
  81 + return $result;
  82 + }
  83 +
  84 + /**
  85 + * @remark :更新文章
  86 + * @name :updateDetail
  87 + * @author :lyh
  88 + * @method :post
  89 + * @time :2025/2/21 14:38
  90 + * @param :task_id , title , video_url ,thumb , content , author_id , url ,
  91 + */
  92 + public function updateDetail($param){
  93 + $request_url = $this->url.'api/video/save';
  94 + $param['mch_id'] = $this->mch_id;
  95 + $this->sign = $this->generateSign($param,$this->key);
  96 + $param['sign'] = $this->sign;
  97 + $result = http_post($request_url,json_encode($param,true));
  98 + return $result;
  99 + }
  100 +
  101 + /**
  102 + * @remark :获取列表页数据
  103 + * @name :getAiVideoList
  104 + * @author :lyh
  105 + * @method :post
  106 + * @time :2025/4/30 15:48
  107 + */
  108 + public function getAiVideoList($page,$page_size){
  109 + $request_url = $this->url.'api/video/list';
  110 + $param['mch_id'] = $this->mch_id;
  111 + $param['page'] = $page;
  112 + $param['page_size'] = $page_size;
  113 + $this->sign = $this->generateSign($param,$this->key);
  114 + $param['sign'] = $this->sign;
  115 + $result = http_post($request_url,json_encode($param,true));
  116 + return $result;
  117 + }
  118 +
  119 + /**
  120 + * @remark :删除详情数据
  121 + * @name :delDetail
  122 + * @author :lyh
  123 + * @method :post
  124 + * @time :2025/4/30 16:00
  125 + */
  126 + public function delVideoDetail($task_id){
  127 + $param['task_id'] = $task_id;
  128 + $request_url = $this->url.'api/video/delete';
  129 + $param['mch_id'] = $this->mch_id;
  130 + $this->sign = $this->generateSign($param,$this->key);
  131 + $param['sign'] = $this->sign;
  132 + $result = http_post($request_url,json_encode($param,true));
  133 + return $result;
  134 + }
  135 +
  136 + /**
  137 + * @remark :计算签名
  138 + * @name :generateSign
  139 + * @author :lyh
  140 + * @method :post
  141 + * @time :2025/2/13 15:07
  142 + */
  143 + public function generateSign($params, $key)
  144 + {
  145 + // 去除数组中所有值为空的项
  146 + array_filter($params);
  147 + // 按照key值的ASCII码从小到大排序
  148 + ksort($params);
  149 + // 生成URL的查询字符串
  150 + $string = http_build_query($params);
  151 + // 生成签名
  152 + $sign = md5($string . $key);
  153 + // 转换成大写
  154 + $sign = strtoupper($sign);
  155 + return $sign;
  156 + }
  157 +}
@@ -157,7 +157,10 @@ Route::middleware(['bloginauth'])->group(function () { @@ -157,7 +157,10 @@ Route::middleware(['bloginauth'])->group(function () {
157 Route::any('/', [\App\Http\Controllers\Bside\Ai\AiVideoController::class, 'lists'])->name('ai_video_lists'); 157 Route::any('/', [\App\Http\Controllers\Bside\Ai\AiVideoController::class, 'lists'])->name('ai_video_lists');
158 Route::any('/getInfo', [\App\Http\Controllers\Bside\Ai\AiVideoController::class, 'getInfo'])->name('ai_video_getInfo'); 158 Route::any('/getInfo', [\App\Http\Controllers\Bside\Ai\AiVideoController::class, 'getInfo'])->name('ai_video_getInfo');
159 Route::any('/sendTask', [\App\Http\Controllers\Bside\Ai\AiVideoController::class, 'sendTask'])->name('ai_video_sendTask'); 159 Route::any('/sendTask', [\App\Http\Controllers\Bside\Ai\AiVideoController::class, 'sendTask'])->name('ai_video_sendTask');
  160 + Route::any('/save', [\App\Http\Controllers\Bside\Ai\AiVideoController::class, 'save'])->name('ai_video_save');
160 Route::any('/del', [\App\Http\Controllers\Bside\Ai\AiVideoController::class, 'delete'])->name('ai_video_delete'); 161 Route::any('/del', [\App\Http\Controllers\Bside\Ai\AiVideoController::class, 'delete'])->name('ai_video_delete');
  162 + Route::any('/getAiVideoList', [\App\Http\Controllers\Bside\Ai\AiVideoController::class, 'getAiVideoList'])->name('ai_video_getAiVideoList');
  163 + Route::any('/getAiBlogListInfo', [\App\Http\Controllers\Bside\Ai\AiVideoController::class, 'getAiBlogListInfo'])->name('ai_video_getAiBlogListInfo');
161 }); 164 });
162 //ai 165 //ai
163 Route::any('/news/', [\App\Http\Controllers\Bside\Ai\AiNewsController::class, 'save'])->name('ai_news_save'); 166 Route::any('/news/', [\App\Http\Controllers\Bside\Ai\AiNewsController::class, 'save'])->name('ai_news_save');