Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
18 个修改的文件
包含
688 行增加
和
51 行删除
| @@ -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']]); |
app/Console/Commands/Ai/AiVideoListTask.php
0 → 100644
| 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 | +} |
app/Console/Commands/Ai/AiVideoTask.php
0 → 100644
| 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\Models\Ai\AiBlogAuthor; | ||
| 13 | +use App\Models\Ai\AiVideo; | ||
| 14 | +use App\Models\Ai\AiVideoList; | ||
| 15 | +use App\Models\Project\AiVideoTask as AiVideoTaskModel; | ||
| 16 | +use App\Models\RouteMap\RouteMap; | ||
| 17 | +use App\Services\AiBlogService; | ||
| 18 | +use App\Services\AiVideoService; | ||
| 19 | +use App\Services\DingService; | ||
| 20 | +use App\Services\ProjectServer; | ||
| 21 | +use Illuminate\Console\Command; | ||
| 22 | +use Illuminate\Support\Facades\DB; | ||
| 23 | +use Illuminate\Support\Facades\Redis; | ||
| 24 | + | ||
| 25 | +class AiVideoTask extends Command | ||
| 26 | +{ | ||
| 27 | + /** | ||
| 28 | + * The name and signature of the console command. | ||
| 29 | + * | ||
| 30 | + * @var string | ||
| 31 | + */ | ||
| 32 | + protected $signature = 'save_ai_video'; | ||
| 33 | + | ||
| 34 | + public $updateProject = [];//需更新的列表 | ||
| 35 | + public $routes = [];//需要更新的路由 | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * The console command description. | ||
| 39 | + * | ||
| 40 | + * @var string | ||
| 41 | + */ | ||
| 42 | + protected $description = '查询ai_video是否已经生成'; | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * @return bool | ||
| 46 | + * @throws \Exception | ||
| 47 | + */ | ||
| 48 | + public function handle(){ | ||
| 49 | + while (true){ | ||
| 50 | + //获取任务id | ||
| 51 | + $task_id = $this->getTaskId(); | ||
| 52 | + if(empty($task_id)){ | ||
| 53 | + sleep(300); | ||
| 54 | + continue; | ||
| 55 | + } | ||
| 56 | + $this->_action($task_id); | ||
| 57 | + } | ||
| 58 | + return true; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * 获取任务id | ||
| 63 | + * @param int $finish_at | ||
| 64 | + * @return mixed | ||
| 65 | + */ | ||
| 66 | + public function getTaskId($finish_at = 2) | ||
| 67 | + { | ||
| 68 | + $task_id = Redis::rpop('ai_video_task'); | ||
| 69 | + if (empty($task_id)) { | ||
| 70 | + if(!empty($this->updateProject)){ | ||
| 71 | + $this->updateProject($this->updateProject); | ||
| 72 | + $this->updateProject = []; | ||
| 73 | + } | ||
| 74 | + if(!empty($this->routes)){ | ||
| 75 | + $this->updateRoutes($this->routes); | ||
| 76 | + $this->routes = []; | ||
| 77 | + } | ||
| 78 | + $aiVideoTaskModel = new AiVideoTaskModel(); | ||
| 79 | + $finish_at = date('Y-m-d H:i:s', strtotime('-' . $finish_at . ' hour')); | ||
| 80 | + $ids = $aiVideoTaskModel->formatQuery(['status'=>$aiVideoTaskModel::STATUS_RUNNING,'updated_at'=>['<=',$finish_at]])->pluck('id'); | ||
| 81 | + if(!empty($ids)){ | ||
| 82 | + foreach ($ids as $id) { | ||
| 83 | + Redis::lpush('ai_video_task', $id); | ||
| 84 | + } | ||
| 85 | + } | ||
| 86 | + $task_id = Redis::rpop('ai_video_task'); | ||
| 87 | + } | ||
| 88 | + return $task_id; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + /** | ||
| 92 | + * @remark :请求 | ||
| 93 | + * @name :sendRequest | ||
| 94 | + * @author :lyh | ||
| 95 | + * @method :post | ||
| 96 | + * @time :2025/4/30 11:31 | ||
| 97 | + */ | ||
| 98 | + public function _action($task_id){ | ||
| 99 | + $aiVideoTaskModel = new AiVideoTaskModel(); | ||
| 100 | + $item = $aiVideoTaskModel->read(['id'=>$task_id]); | ||
| 101 | + $this->output('ai_video->start:project ID: ' . $item['project_id'] . ',task ID: ' . $task_id); | ||
| 102 | + $aiVideoService = new AiVideoService($item['project_id']); | ||
| 103 | + $aiVideoService->task_id = $item['task_id']; | ||
| 104 | + //拉取文章数据 | ||
| 105 | + $result = $aiVideoService->getVideoDetail(); | ||
| 106 | + if(empty($result['status']) || ($result['status'] != 200)){ | ||
| 107 | + if($item['number'] < 5){ | ||
| 108 | + $aiVideoTaskModel->edit(['number'=>$item['number'] + 1],['id'=>$item['id']]); | ||
| 109 | + }else{ | ||
| 110 | + $aiVideoTaskModel->edit(['status'=>9],['id'=>$item['id']]); | ||
| 111 | + // 钉钉通知 | ||
| 112 | + $dingService = new DingService(); | ||
| 113 | + $body = [ | ||
| 114 | + 'keyword' => 'AI_VIDEO获取失败', | ||
| 115 | + 'msg' => '任务ID:' . $item['task_id'] . PHP_EOL . '返回信息:' . json_encode($result,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), | ||
| 116 | + 'isAtAll' => false, // 是否@所有人 | ||
| 117 | + ]; | ||
| 118 | + $dingService->handle($body); | ||
| 119 | + } | ||
| 120 | + $this->output('error: 数据获取失败,status:' . $result['status'] . ',message: ' . ($result['message'] ?? 'null')); | ||
| 121 | + return false; | ||
| 122 | + } | ||
| 123 | + //保存当前项目ai_blog数据 | ||
| 124 | + ProjectServer::useProject($item['project_id']); | ||
| 125 | + $aiVideoModel = new AiVideo(); | ||
| 126 | + $aiVideoInfo = $aiVideoModel->read(['task_id'=>$item['task_id']],['id','route']); | ||
| 127 | + if($aiVideoInfo === false){ | ||
| 128 | + // 钉钉通知 | ||
| 129 | + $dingService = new DingService(); | ||
| 130 | + $body = [ | ||
| 131 | + 'keyword' => 'AI_VIDEO生成错误', | ||
| 132 | + 'msg' => '任务ID:' . $item['task_id'] . ', 子库获取数据失败, 检查子库数据是否被删除!', | ||
| 133 | + 'isAtAll' => false, // 是否@所有人 | ||
| 134 | + ]; | ||
| 135 | + $dingService->handle($body); | ||
| 136 | + $this->output('error: 子库获取数据失败, task id: ' . $task_id); | ||
| 137 | + $aiVideoTaskModel->edit(['status'=>9],['id'=>$item['id']]); | ||
| 138 | + DB::disconnect('custom_mysql'); | ||
| 139 | + return false; | ||
| 140 | + } | ||
| 141 | + //拿到返回的路由查看是否重复 | ||
| 142 | + $route = RouteMap::setRoute($result['data']['url'], RouteMap::SOURCE_AI_VIDEO, $aiVideoInfo['id'], $item['project_id']); | ||
| 143 | + if($route != $result['data']['url']){ | ||
| 144 | + $aiVideoService->updateDetail(['route'=>$route,'task_id'=>$item['task_id']]); | ||
| 145 | + } | ||
| 146 | + $saveData = [ | ||
| 147 | + 'title'=>$result['data']['title'], | ||
| 148 | + 'image'=>$result['data']['thumb'], | ||
| 149 | + 'video_url'=>$result['data']['video_url'], | ||
| 150 | + 'route'=>$route, | ||
| 151 | + 'author_id'=>$result['data']['author_id'], | ||
| 152 | + 'keyword'=>json_encode($result['data']['keyword'],true), | ||
| 153 | + 'content'=>$result['data']['content'], | ||
| 154 | + 'text'=>$result['data']['section'], | ||
| 155 | + 'status'=>$aiVideoTaskModel::STATUS_FINISH | ||
| 156 | + ]; | ||
| 157 | + $aiVideoModel->edit($saveData,['task_id'=>$item['task_id']]); | ||
| 158 | + //需要更新的路由 | ||
| 159 | + if (!in_array($result['data']['author_id'], $this->updateProject[$item['project_id']] ?? [])) { | ||
| 160 | + $this->updateProject[$item['project_id']][] = $result['data']['author_id']; | ||
| 161 | + } | ||
| 162 | + if (!in_array($route, $this->routes[$item['project_id']] ?? [])) { | ||
| 163 | + $this->routes[$item['project_id']][] = $route; | ||
| 164 | + } | ||
| 165 | + DB::disconnect('custom_mysql'); | ||
| 166 | + $aiVideoTaskModel->edit(['status'=>$aiVideoTaskModel::STATUS_FINISH],['id'=>$item['id']]); | ||
| 167 | + $this->output('success: task id: ' . $task_id); | ||
| 168 | + return true; | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + /** | ||
| 172 | + * @remark :更新项目作者页面及列表页 | ||
| 173 | + * @name :updateProject | ||
| 174 | + * @author :lyh | ||
| 175 | + * @method :post | ||
| 176 | + * @time :2025/4/30 15:43 | ||
| 177 | + */ | ||
| 178 | + public function updateProject($updateProject){ | ||
| 179 | + if(empty($updateProject)){ | ||
| 180 | + return true; | ||
| 181 | + } | ||
| 182 | + foreach ($updateProject as $project_id => $author){ | ||
| 183 | + ProjectServer::useProject($project_id); | ||
| 184 | + $this->output('sync: list start, project_id: ' . $project_id); | ||
| 185 | + $this->updateBlogList($project_id); | ||
| 186 | + $this->output('sync: list end'); | ||
| 187 | + //更新作者 | ||
| 188 | + $this->output('sync: author start, project_id: ' . $project_id); | ||
| 189 | + foreach ($author as $val){ | ||
| 190 | + $this->updateAiBlogAuthor($val,$project_id); | ||
| 191 | + } | ||
| 192 | + $this->output('sync: author end'); | ||
| 193 | + DB::disconnect('custom_mysql'); | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + return true; | ||
| 197 | + } | ||
| 198 | + | ||
| 199 | + /** | ||
| 200 | + * @remark :更新作者页面 | ||
| 201 | + * @name :updateAiBlogAuthor | ||
| 202 | + * @author :lyh | ||
| 203 | + * @method :post | ||
| 204 | + * @time :2025/4/30 15:52 | ||
| 205 | + */ | ||
| 206 | + public function updateAiBlogAuthor($author_id,$project_id){ | ||
| 207 | + if(empty($author_id)){ | ||
| 208 | + return true; | ||
| 209 | + } | ||
| 210 | + $aiBlogService = new AiBlogService($project_id); | ||
| 211 | + $aiBlogService->author_id = $author_id; | ||
| 212 | + $result = $aiBlogService->getAuthorDetail(); | ||
| 213 | + if(isset($result['status']) && $result['status'] == 200){ | ||
| 214 | + //当前作者的页面 | ||
| 215 | + $aiBlogAuthorModel = new AiBlogAuthor(); | ||
| 216 | + $authorInfo = $aiBlogAuthorModel->read(['author_id'=>$author_id],['id','route']); | ||
| 217 | + if($authorInfo !== false && !empty($result['data']['section'])){ | ||
| 218 | + //需要更新的路由 | ||
| 219 | + if (!in_array($authorInfo['route'], $this->routes[$project_id] ?? [])) { | ||
| 220 | + $this->routes[$project_id][] = $authorInfo['route']; | ||
| 221 | + } | ||
| 222 | + $aiBlogAuthorModel->edit(['text'=>$result['data']['section']],['author_id'=>$author_id]); | ||
| 223 | + } | ||
| 224 | + } | ||
| 225 | + return true; | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + /** | ||
| 229 | + * @remark :更新 | ||
| 230 | + * @name :updateBlogList | ||
| 231 | + * @author :lyh | ||
| 232 | + * @method :post | ||
| 233 | + * @time :2025/4/30 15:45 | ||
| 234 | + */ | ||
| 235 | + public function updateBlogList($project_id){ | ||
| 236 | + $aiVideoService = new AiVideoService($project_id); | ||
| 237 | + $page = 1; | ||
| 238 | + $saveData = []; | ||
| 239 | + $result = $aiVideoService->getAiVideoList($page,15); | ||
| 240 | + if(!isset($result['status']) && $result['status'] != 200){ | ||
| 241 | + return true; | ||
| 242 | + } | ||
| 243 | + $total_page = $result['data']['total_page']; | ||
| 244 | + //组装数据保存 | ||
| 245 | + $saveData[] = [ | ||
| 246 | + 'route'=>$page, | ||
| 247 | + 'text'=>$result['data']['section'], | ||
| 248 | + ]; | ||
| 249 | + while ($total_page > $page){ | ||
| 250 | + $page++; | ||
| 251 | + $result = $aiVideoService->getAiVideoList($page,15); | ||
| 252 | + if(isset($result['status']) && $result['status'] == 200){ | ||
| 253 | + $saveData[] = [ | ||
| 254 | + 'route'=>$page, | ||
| 255 | + 'text'=>$result['data']['section'], | ||
| 256 | + ]; | ||
| 257 | + } | ||
| 258 | + } | ||
| 259 | + $aiVideoListModel = new AiVideoList(); | ||
| 260 | + if(!empty($saveData)){ | ||
| 261 | + //写一条路由信息 | ||
| 262 | + $aiVideoListModel->truncate(); | ||
| 263 | + $aiVideoListModel->insertAll($saveData); | ||
| 264 | + } | ||
| 265 | + return true; | ||
| 266 | + } | ||
| 267 | + /** | ||
| 268 | + * 输入日志 | ||
| 269 | + * @param $message | ||
| 270 | + * @return bool | ||
| 271 | + */ | ||
| 272 | + public function output($message) | ||
| 273 | + { | ||
| 274 | + $message = date('Y-m-d H:i:s') . ' ' . $message . PHP_EOL; | ||
| 275 | + echo $message; | ||
| 276 | + return true; | ||
| 277 | + } | ||
| 278 | +} |
| @@ -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, |
| @@ -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)){ |
| @@ -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){ |
| @@ -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 |
| @@ -86,6 +86,25 @@ class AiBlogController extends BaseController | @@ -86,6 +86,25 @@ class AiBlogController extends BaseController | ||
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | /** | 88 | /** |
| 89 | + * @remark : | ||
| 90 | + * @name :saveText | ||
| 91 | + * @author :lyh | ||
| 92 | + * @method :post | ||
| 93 | + * @time :2025/4/30 18:05 | ||
| 94 | + */ | ||
| 95 | + public function saveText(AiBlogLogic $aiBlogLogic){ | ||
| 96 | + $this->request->validate([ | ||
| 97 | + 'id'=>['required'], | ||
| 98 | + 'text'=>['required'], | ||
| 99 | + ],[ | ||
| 100 | + 'id.required' => '关键字不能为空', | ||
| 101 | + 'text.required' => '场景不能为空', | ||
| 102 | + ]); | ||
| 103 | + $aiBlogLogic->blogSaveText(); | ||
| 104 | + $this->response('success'); | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + /** | ||
| 89 | * @remark :获取作者列表 | 108 | * @remark :获取作者列表 |
| 90 | * @name :getAiBlogAuthor | 109 | * @name :getAiBlogAuthor |
| 91 | * @author :lyh | 110 | * @author :lyh |
| @@ -24,7 +24,7 @@ class AiVideoController extends BaseController | @@ -24,7 +24,7 @@ class AiVideoController extends BaseController | ||
| 24 | * @time :2025/3/5 14:12 | 24 | * @time :2025/3/5 14:12 |
| 25 | */ | 25 | */ |
| 26 | public function lists(AiVideo $aiVideo){ | 26 | 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']); | 27 | + $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'])){ | 28 | if(!empty($lists) && !empty($lists['list'])){ |
| 29 | foreach ($lists['list'] as $k => $v){ | 29 | foreach ($lists['list'] as $k => $v){ |
| 30 | $v['image'] = getImageUrl($v['image']); | 30 | $v['image'] = getImageUrl($v['image']); |
| @@ -51,7 +51,6 @@ class AiVideoController extends BaseController | @@ -51,7 +51,6 @@ class AiVideoController extends BaseController | ||
| 51 | 'id.required' => '主键不能为空', | 51 | 'id.required' => '主键不能为空', |
| 52 | ]); | 52 | ]); |
| 53 | $info = $aiVideo->read(['id'=>$this->param['id']]); | 53 | $info = $aiVideo->read(['id'=>$this->param['id']]); |
| 54 | - $info['image'] = getImageUrl($info['image']); | ||
| 55 | $this->response('success',Code::SUCCESS,$info); | 54 | $this->response('success',Code::SUCCESS,$info); |
| 56 | } | 55 | } |
| 57 | 56 | ||
| @@ -64,11 +63,13 @@ class AiVideoController extends BaseController | @@ -64,11 +63,13 @@ class AiVideoController extends BaseController | ||
| 64 | */ | 63 | */ |
| 65 | public function sendTask(AiVideoLogic $aiVideoLogic){ | 64 | public function sendTask(AiVideoLogic $aiVideoLogic){ |
| 66 | $this->request->validate([ | 65 | $this->request->validate([ |
| 67 | - 'keyword'=>['required'], | ||
| 68 | - 'type'=>['required'], | 66 | + 'title'=>['required'], |
| 67 | + 'description'=>['required'], | ||
| 68 | + 'images'=>['required'], | ||
| 69 | ],[ | 69 | ],[ |
| 70 | - 'keyword.required' => '关键字不能为空', | ||
| 71 | - 'type.required' => '场景不能为空', | 70 | + 'title.required' => '标题不能为空', |
| 71 | + 'description.required' => '短描述不能为空', | ||
| 72 | + 'images.required' => '图片集合不能为空', | ||
| 72 | ]); | 73 | ]); |
| 73 | $result = $aiVideoLogic->sendTask(); | 74 | $result = $aiVideoLogic->sendTask(); |
| 74 | $this->response('success',Code::SUCCESS,$result); | 75 | $this->response('success',Code::SUCCESS,$result); |
| @@ -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 | } |
| @@ -268,12 +268,13 @@ class ProjectLogic extends BaseLogic | @@ -268,12 +268,13 @@ class ProjectLogic extends BaseLogic | ||
| 268 | public function checkAiBlog($param){ | 268 | public function checkAiBlog($param){ |
| 269 | $main_lang_id = $param['main_lang_id'] ?? 0; | 269 | $main_lang_id = $param['main_lang_id'] ?? 0; |
| 270 | $is_ai_blog = $param['is_ai_blog'] ?? 0; | 270 | $is_ai_blog = $param['is_ai_blog'] ?? 0; |
| 271 | + $is_ai_video = $param['is_ai_video'] ?? 0; | ||
| 271 | $company = $param['company'] ?? ''; | 272 | $company = $param['company'] ?? ''; |
| 272 | $company_en_name = $param['deploy_optimize']['company_en_name'] ?? ''; | 273 | $company_en_name = $param['deploy_optimize']['company_en_name'] ?? ''; |
| 273 | $company_en_description = $param['deploy_optimize']['company_en_description'] ?? ''; | 274 | $company_en_description = $param['deploy_optimize']['company_en_description'] ?? ''; |
| 274 | - if($is_ai_blog == 1){ | 275 | + if($is_ai_blog == 1 || $is_ai_video){ |
| 275 | if(empty($main_lang_id) || empty($company) || empty($company_en_name) || empty($company_en_description)){ | 276 | if(empty($main_lang_id) || empty($company) || empty($company_en_name) || empty($company_en_description)){ |
| 276 | - $this->fail('开启ai_blog--请填写主语种+公司名称+公司英文名称+公司英文介绍'); | 277 | + $this->fail('开启ai博客/视频功能--请填写主语种+公司名称+公司英文名称+公司英文介绍'); |
| 277 | } | 278 | } |
| 278 | } | 279 | } |
| 279 | return true; | 280 | return true; |
| @@ -63,11 +63,10 @@ class AiBlogLogic extends BaseLogic | @@ -63,11 +63,10 @@ class AiBlogLogic extends BaseLogic | ||
| 63 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | 63 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; |
| 64 | $aiBlogService->key = $aiSettingInfo['key']; | 64 | $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']]); | 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']]);//重新走拉取流程 | ||
| 68 | }catch (\Exception $e){ | 66 | }catch (\Exception $e){ |
| 69 | $this->fail('保存失败,请联系管理员'); | 67 | $this->fail('保存失败,请联系管理员'); |
| 70 | } | 68 | } |
| 69 | + shell_exec("php artisan save_ai_blog_list {$this->user['project_id']} > /dev/null 2>&1 &"); | ||
| 71 | return $this->success(); | 70 | return $this->success(); |
| 72 | } | 71 | } |
| 73 | 72 |
| @@ -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 :视频模块 |
| @@ -52,16 +54,11 @@ class AiVideoLogic extends BaseLogic | @@ -52,16 +54,11 @@ class AiVideoLogic extends BaseLogic | ||
| 52 | */ | 54 | */ |
| 53 | public function videoSave(){ | 55 | public function videoSave(){ |
| 54 | try { | 56 | 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']); | 57 | $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_VIDEO, $this->param['id'], $this->user['project_id']); |
| 59 | $this->model->edit($this->param,['id'=>$this->param['id']]); | 58 | $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']]); | 59 | + $aiVideoService = new AiVideoService($this->user['project_id']); |
| 60 | + $aiVideoService->updateDetail(['task_id'=>$this->param['task_id'],'title'=>$this->param['title'], | ||
| 61 | + 'content'=>$this->param['content'] ?? '','video_url'=>$this->param['video_url'],'thumb'=>$this->param['image'],'url'=>$this->param['route'],'author_id'=>$this->param['author_id']]); | ||
| 65 | }catch (\Exception $e){ | 62 | }catch (\Exception $e){ |
| 66 | $this->fail('保存失败,请联系管理员'); | 63 | $this->fail('保存失败,请联系管理员'); |
| 67 | } | 64 | } |
| @@ -74,20 +71,16 @@ class AiVideoLogic extends BaseLogic | @@ -74,20 +71,16 @@ class AiVideoLogic extends BaseLogic | ||
| 74 | * @author :lyh | 71 | * @author :lyh |
| 75 | * @method :post | 72 | * @method :post |
| 76 | * @time :2025/2/14 10:28 | 73 | * @time :2025/2/14 10:28 |
| 77 | - * @detail :createTask =>type=2/生成文章 | ||
| 78 | * @detail :status=1/待执行 | 74 | * @detail :status=1/待执行 |
| 79 | */ | 75 | */ |
| 80 | public function sendTask(){ | 76 | 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'] ?? []); | 77 | + $aiVideoService = new AiVideoService($this->user['project_id']); |
| 78 | + $result = $aiVideoService->createTask($this->param['title'],$this->param['description'],$this->param['images'],$this->param['anchor'] ?? []); | ||
| 87 | if($result['status'] == 200){ | 79 | 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)]); | 80 | + $aiVideoTaskModel = new AiVideoTask(); |
| 81 | + $aiVideoTaskModel->addReturnId(['task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id']]); | ||
| 82 | + $id = $this->model->addReturnId(['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)]); | ||
| 83 | + return $this->success(['id'=>$id]); | ||
| 91 | } | 84 | } |
| 92 | return $this->success(); | 85 | return $this->success(); |
| 93 | } | 86 | } |
| @@ -101,13 +94,10 @@ class AiVideoLogic extends BaseLogic | @@ -101,13 +94,10 @@ class AiVideoLogic extends BaseLogic | ||
| 101 | */ | 94 | */ |
| 102 | public function videoDelete(){ | 95 | public function videoDelete(){ |
| 103 | try { | 96 | try { |
| 104 | - $aiSettingInfo = $this->getProjectAiSetting(); | ||
| 105 | - $aiBlogService = new AiBlogService(); | 97 | + $aiBlogService = new AiVideoService($this->user['project_id']); |
| 106 | foreach ($this->param['ids'] as $id) { | 98 | foreach ($this->param['ids'] as $id) { |
| 107 | $info = $this->model->read(['id'=>$id],['task_id']); | 99 | $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']); | 100 | + $aiBlogService->delVideoDetail($info['task_id']); |
| 111 | //删除路由映射 | 101 | //删除路由映射 |
| 112 | RouteMap::delRoute(RouteMap::SOURCE_AI_VIDEO, $id, $this->user['project_id']); | 102 | RouteMap::delRoute(RouteMap::SOURCE_AI_VIDEO, $id, $this->user['project_id']); |
| 113 | $this->model->del(['id'=>$id]); | 103 | $this->model->del(['id'=>$id]); |
app/Models/Ai/AiVideoList.php
0 → 100644
| 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 | +} |
app/Models/Project/AiVideoTask.php
0 → 100644
| 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 |
app/Services/AiVideoService.php
0 → 100644
| 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 | +} |
-
请 注册 或 登录 后发表评论