作者 lyh

gx

... ... @@ -40,15 +40,7 @@ class TestController extends BaseController
$aiBlogService = new AiBlogService();
$aiBlogService->mch_id = '100008';
$aiBlogService->key = '8a9c925bdcca';
$result = $aiBlogService->updatedProject('v6-演示','en');
if($result['status'] == 200){
$resData = [
'mch_id'=>$result['data']['mch_id'],
'key'=>$result['data']['key'],
];
$aiSettingModel = new ProjectAiSetting();
$aiSettingModel->edit($resData,['project_id'=>1]);
}
$this->response('success',Code::SUCCESS,$resData);
$result = $aiBlogService->createTask('v6-演示项目','en');
$this->response('success',Code::SUCCESS,$result);
}
}
... ...
... ... @@ -160,6 +160,8 @@ class ProjectLogic extends BaseLogic
$this->setServers($this->param['serve_id'],$this->param['id']);
//保存项目信息
$this->saveProject($this->param);
//ai_blog
$this->setAiBlog($this->param['id'],$this->param['main_lang_id'],$this->param['is_ai_blog'],$this->param['title']);
//保存建站部署信息
$this->saveProjectDeployBuild($this->param['deploy_build']);
//保存付费信息
... ... @@ -192,18 +194,15 @@ class ProjectLogic extends BaseLogic
* @method :post
* @time :2025/2/13 16:02
*/
public function setAiBlog($project_id){
if(empty($this->param['main_lang_id'])){
return true;
}
if($this->param['is_ai_blog'] == 0){
public function setAiBlog($project_id,$main_lang_id,$is_ai_blog,$title){
if(empty($main_lang_id) || empty($is_ai_blog)){
return true;
}
$projectModel = new Project();
$projectInfo = $projectModel->read(['id'=>$project_id],['is_ai_blog','main_lang_id']);
//获取项目主语种
$languageModel = new WebLanguage();
$languageInfo = $languageModel->read(['id'=>$this->param['main_lang_id']],['short']);
$languageInfo = $languageModel->read(['id'=>$main_lang_id],['short']);
if($languageInfo == false){
return true;
}
... ... @@ -211,7 +210,7 @@ class ProjectLogic extends BaseLogic
$aiSettingInfo = $aiSettingModel->read(['project_id'=>$project_id]);
if($aiSettingInfo === false){
$aiBlogService = new AiBlogService();
$result = $aiBlogService->createProject($this->param['title'],$languageInfo['short'],$projectInfo['company']);
$result = $aiBlogService->createProject($title,$languageInfo['short'],$projectInfo['company']);
if($result['status'] == 200){
//查看当前项目是否已有记录
$resData = [
... ... @@ -223,11 +222,11 @@ class ProjectLogic extends BaseLogic
}
}else{
//有信息更新
if(($projectInfo['title'] != $this->param['title']) || ($languageInfo['short'] != $this->param['short'])){
if(($projectInfo['title'] != $title) || ($projectInfo['main_lang_id'] != $main_lang_id)){
$aiBlogService = new AiBlogService();
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
$aiBlogService->key = $aiSettingInfo['key'];
$result = $aiBlogService->updatedProject($this->param['title'],$languageInfo['short']);
$result = $aiBlogService->updatedProject($title,$languageInfo['short']);
if($result['status'] == 200){
$resData = [
'mch_id'=>$result['data']['mch_id'],
... ...
... ... @@ -17,6 +17,8 @@ class AiBlogService
public $sign = '';//签名
public $key = 'b3e4c722b821';//默认key
public $webhook = 'https://develop.globalso.com/api/ai_webhook';//回调地址
/**
* @remark :创建项目
... ... @@ -67,18 +69,19 @@ class AiBlogService
* @time :2025/2/13 14:39
* @param :type=(1作者2文章) keyword=关键词 subtype=blog url=回调url
*/
public function createTask($keyword,$type = 1,$subtype,$url,$template_id){
public function createTask($keyword,$type = 1,$subtype = 'Blog',$template_id = 1){
$request_url = $this->url.'api/task/create';
$param = [
'mch_id'=>$this->mch_id,
'sign'=>$this->sign,
'keyword'=>$keyword,
'type'=>$type,
'subtype'=>$subtype,
'url'=>$url,
'url'=>$this->webhook,
'template_id'=>$template_id
];
$result = http_post($request_url,$param);
$this->sign = $this->generateSign($param,$this->key);
$param['sign'] = $this->sign;
$result = http_post($request_url,json_encode($param,true));
return $result;
}
... ...