|
...
|
...
|
@@ -6,10 +6,12 @@ use App\Helper\Translate; |
|
|
|
use App\Http\Logic\Bside\BaseLogic;
|
|
|
|
use App\Models\Ai\AiBlog;
|
|
|
|
use App\Models\Ai\AiBlogAuthor;
|
|
|
|
use App\Models\Com\Notify;
|
|
|
|
use App\Models\Project\AiBlogTask;
|
|
|
|
use App\Models\Project\ProjectAiSetting;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
use App\Services\AiBlogService;
|
|
|
|
use Illuminate\Support\Facades\Artisan;
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
|
|
|
|
class AiBlogLogic extends BaseLogic
|
|
...
|
...
|
@@ -60,10 +62,11 @@ class AiBlogLogic extends BaseLogic |
|
|
|
$aiBlogService = new AiBlogService();
|
|
|
|
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
|
|
|
|
$aiBlogService->key = $aiSettingInfo['key'];
|
|
|
|
$res = $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']]);
|
|
|
|
$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']]);
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('保存失败,请联系管理员');
|
|
|
|
}
|
|
|
|
$this->sendHttpC([$this->param['route'],'top-blog']);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -90,6 +93,7 @@ class AiBlogLogic extends BaseLogic |
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('保存失败,请联系管理员');
|
|
|
|
}
|
|
|
|
$this->sendHttpC([$this->param['route'],'top-blog']);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -108,12 +112,14 @@ class AiBlogLogic extends BaseLogic |
|
|
|
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
|
|
|
|
$aiBlogService->key = $aiSettingInfo['key'];
|
|
|
|
$aiBlogService->route = generateRoute(Translate::tran($this->param['keyword'], 'en'));
|
|
|
|
$result = $aiBlogService->createTask($this->param['keyword'],2,'blog',$this->param['anchor'] ?? []);
|
|
|
|
$result = $aiBlogService->createTask($this->param['keyword'],2,'blog',$this->param['anchor'] ?? [],$this->param['title'] ?? '');
|
|
|
|
if($result['status'] == 200){
|
|
|
|
$aiBlogTaskModel = new AiBlogTask();
|
|
|
|
$aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'type'=>2,'task_id'=>$result['data']['task_id'],'status'=>1]);
|
|
|
|
$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)
|
|
|
|
]);
|
|
|
|
}else{
|
|
|
|
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($result, true) . PHP_EOL, FILE_APPEND);
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
...
|
...
|
@@ -130,20 +136,20 @@ class AiBlogLogic extends BaseLogic |
|
|
|
$aiSettingInfo = $this->getProjectAiSetting();
|
|
|
|
$aiBlogService = new AiBlogService();
|
|
|
|
foreach ($this->param['ids'] as $id) {
|
|
|
|
$info = $this->model->read(['id'=>$id],['task_id']);
|
|
|
|
$info = $this->model->read(['id'=>$id],['task_id','route']);
|
|
|
|
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
|
|
|
|
$aiBlogService->key = $aiSettingInfo['key'];
|
|
|
|
$aiBlogService->delDetail($info['task_id']);
|
|
|
|
//删除路由映射
|
|
|
|
RouteMap::delRoute(RouteMap::SOURCE_AI_BLOG, $id, $this->user['project_id']);
|
|
|
|
$this->model->del(['id'=>$id]);
|
|
|
|
$this->curlDelRoute(['old_route'=>$info['route']]);
|
|
|
|
}
|
|
|
|
shell_exec('php artisan save_ai_blog_list '.$this->user['project_id'].' > /dev/null 2>&1 &');
|
|
|
|
Artisan::call('save_ai_blog_list', ['project_id' => $this->user['project_id']]);
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('删除失败');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|