|
...
|
...
|
@@ -10,6 +10,7 @@ |
|
|
|
namespace App\Console\Commands\AiBlog;
|
|
|
|
|
|
|
|
use App\Models\Ai\AiBlog;
|
|
|
|
use App\Models\Ai\AiBlogAuthor;
|
|
|
|
use App\Models\Project\ProjectAiSetting;
|
|
|
|
use App\Services\AiBlogService;
|
|
|
|
use App\Services\ProjectServer;
|
|
...
|
...
|
@@ -38,7 +39,7 @@ class AiBlogTask extends Command |
|
|
|
public function handle(){
|
|
|
|
$aiBlogTaskModel = new AiBlogTaskModel();
|
|
|
|
while (true){
|
|
|
|
$info = $aiBlogTaskModel->where('status',1)->inRandomOrder()->first();
|
|
|
|
$info = $aiBlogTaskModel->where('status',1)->where('type',2)->inRandomOrder()->first();
|
|
|
|
if(empty($info)){
|
|
|
|
sleep(300);
|
|
|
|
continue;
|
|
...
|
...
|
@@ -53,8 +54,6 @@ class AiBlogTask extends Command |
|
|
|
$aiBlogService->task_id = $info['task_id'];
|
|
|
|
$result = $aiBlogService->getDetail();
|
|
|
|
if(!isset($result['status'])){
|
|
|
|
//修改任务状态
|
|
|
|
$aiBlogTaskModel->edit(['status'=>3],['id'=>$info['id']]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if($result['status'] != 200){
|
|
...
|
...
|
@@ -67,12 +66,14 @@ class AiBlogTask extends Command |
|
|
|
ProjectServer::useProject($info['project_id']);
|
|
|
|
$aiBlogModel = new AiBlog();
|
|
|
|
$aiBlogModel->edit(['new_title'=>$result['data']['title'],'image'=>$result['data']['thumb'],'text'=>$result['data']['section'],'status'=>2],['task_id'=>$info['task_id']]);
|
|
|
|
$this->updateAiBlogAuthor($aiSettingInfo,$result['data']['author_id']);
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
echo '结束->任务id:' . $info['task_id'] . PHP_EOL . date('Y-m-d H:i:s');
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取项目配置
|
|
|
|
* @name :getSetting
|
|
...
|
...
|
@@ -90,4 +91,30 @@ class AiBlogTask extends Command |
|
|
|
Cache::put('ai_blog_'.$project_id,$aiSettingInfo,3600);
|
|
|
|
return $aiSettingInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :更新作者的页面
|
|
|
|
* @name :updateAiBlogAuthor
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/2/21 11:53
|
|
|
|
*/
|
|
|
|
public function updateAiBlogAuthor($aiSettingInfo,$author_id){
|
|
|
|
if(empty($author_id)){
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
$aiBlogService = new AiBlogService();
|
|
|
|
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
|
|
|
|
$aiBlogService->key = $aiSettingInfo['key'];
|
|
|
|
$aiBlogService->author_id = $author_id;
|
|
|
|
$result = $aiBlogService->getAuthorDetail();
|
|
|
|
if(isset($result['status']) && $result['status'] == 200){
|
|
|
|
//当前作者的页面
|
|
|
|
$aiBlogAuthorModel = new AiBlogAuthor();
|
|
|
|
if(!empty($result['data']['section'])){
|
|
|
|
$aiBlogAuthorModel->edit(['text'=>$result['data']['section']],['author_id'=>$author_id]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|