作者 lyh

gx

@@ -40,15 +40,7 @@ class TestController extends BaseController @@ -40,15 +40,7 @@ class TestController extends BaseController
40 $aiBlogService = new AiBlogService(); 40 $aiBlogService = new AiBlogService();
41 $aiBlogService->mch_id = '100008'; 41 $aiBlogService->mch_id = '100008';
42 $aiBlogService->key = '8a9c925bdcca'; 42 $aiBlogService->key = '8a9c925bdcca';
43 - $result = $aiBlogService->updatedProject('v6-演示','en');  
44 - if($result['status'] == 200){  
45 - $resData = [  
46 - 'mch_id'=>$result['data']['mch_id'],  
47 - 'key'=>$result['data']['key'],  
48 - ];  
49 - $aiSettingModel = new ProjectAiSetting();  
50 - $aiSettingModel->edit($resData,['project_id'=>1]);  
51 - }  
52 - $this->response('success',Code::SUCCESS,$resData); 43 + $result = $aiBlogService->createTask('v6-演示项目','en');
  44 + $this->response('success',Code::SUCCESS,$result);
53 } 45 }
54 } 46 }
@@ -160,6 +160,8 @@ class ProjectLogic extends BaseLogic @@ -160,6 +160,8 @@ class ProjectLogic extends BaseLogic
160 $this->setServers($this->param['serve_id'],$this->param['id']); 160 $this->setServers($this->param['serve_id'],$this->param['id']);
161 //保存项目信息 161 //保存项目信息
162 $this->saveProject($this->param); 162 $this->saveProject($this->param);
  163 + //ai_blog
  164 + $this->setAiBlog($this->param['id'],$this->param['main_lang_id'],$this->param['is_ai_blog'],$this->param['title']);
163 //保存建站部署信息 165 //保存建站部署信息
164 $this->saveProjectDeployBuild($this->param['deploy_build']); 166 $this->saveProjectDeployBuild($this->param['deploy_build']);
165 //保存付费信息 167 //保存付费信息
@@ -192,18 +194,15 @@ class ProjectLogic extends BaseLogic @@ -192,18 +194,15 @@ class ProjectLogic extends BaseLogic
192 * @method :post 194 * @method :post
193 * @time :2025/2/13 16:02 195 * @time :2025/2/13 16:02
194 */ 196 */
195 - public function setAiBlog($project_id){  
196 - if(empty($this->param['main_lang_id'])){  
197 - return true;  
198 - }  
199 - if($this->param['is_ai_blog'] == 0){ 197 + public function setAiBlog($project_id,$main_lang_id,$is_ai_blog,$title){
  198 + if(empty($main_lang_id) || empty($is_ai_blog)){
200 return true; 199 return true;
201 } 200 }
202 $projectModel = new Project(); 201 $projectModel = new Project();
203 $projectInfo = $projectModel->read(['id'=>$project_id],['is_ai_blog','main_lang_id']); 202 $projectInfo = $projectModel->read(['id'=>$project_id],['is_ai_blog','main_lang_id']);
204 //获取项目主语种 203 //获取项目主语种
205 $languageModel = new WebLanguage(); 204 $languageModel = new WebLanguage();
206 - $languageInfo = $languageModel->read(['id'=>$this->param['main_lang_id']],['short']); 205 + $languageInfo = $languageModel->read(['id'=>$main_lang_id],['short']);
207 if($languageInfo == false){ 206 if($languageInfo == false){
208 return true; 207 return true;
209 } 208 }
@@ -211,7 +210,7 @@ class ProjectLogic extends BaseLogic @@ -211,7 +210,7 @@ class ProjectLogic extends BaseLogic
211 $aiSettingInfo = $aiSettingModel->read(['project_id'=>$project_id]); 210 $aiSettingInfo = $aiSettingModel->read(['project_id'=>$project_id]);
212 if($aiSettingInfo === false){ 211 if($aiSettingInfo === false){
213 $aiBlogService = new AiBlogService(); 212 $aiBlogService = new AiBlogService();
214 - $result = $aiBlogService->createProject($this->param['title'],$languageInfo['short'],$projectInfo['company']); 213 + $result = $aiBlogService->createProject($title,$languageInfo['short'],$projectInfo['company']);
215 if($result['status'] == 200){ 214 if($result['status'] == 200){
216 //查看当前项目是否已有记录 215 //查看当前项目是否已有记录
217 $resData = [ 216 $resData = [
@@ -223,11 +222,11 @@ class ProjectLogic extends BaseLogic @@ -223,11 +222,11 @@ class ProjectLogic extends BaseLogic
223 } 222 }
224 }else{ 223 }else{
225 //有信息更新 224 //有信息更新
226 - if(($projectInfo['title'] != $this->param['title']) || ($languageInfo['short'] != $this->param['short'])){ 225 + if(($projectInfo['title'] != $title) || ($projectInfo['main_lang_id'] != $main_lang_id)){
227 $aiBlogService = new AiBlogService(); 226 $aiBlogService = new AiBlogService();
228 $aiBlogService->mch_id = $aiSettingInfo['mch_id']; 227 $aiBlogService->mch_id = $aiSettingInfo['mch_id'];
229 $aiBlogService->key = $aiSettingInfo['key']; 228 $aiBlogService->key = $aiSettingInfo['key'];
230 - $result = $aiBlogService->updatedProject($this->param['title'],$languageInfo['short']); 229 + $result = $aiBlogService->updatedProject($title,$languageInfo['short']);
231 if($result['status'] == 200){ 230 if($result['status'] == 200){
232 $resData = [ 231 $resData = [
233 'mch_id'=>$result['data']['mch_id'], 232 'mch_id'=>$result['data']['mch_id'],
@@ -17,6 +17,8 @@ class AiBlogService @@ -17,6 +17,8 @@ class AiBlogService
17 public $sign = '';//签名 17 public $sign = '';//签名
18 public $key = 'b3e4c722b821';//默认key 18 public $key = 'b3e4c722b821';//默认key
19 19
  20 + public $webhook = 'https://develop.globalso.com/api/ai_webhook';//回调地址
  21 +
20 22
21 /** 23 /**
22 * @remark :创建项目 24 * @remark :创建项目
@@ -67,18 +69,19 @@ class AiBlogService @@ -67,18 +69,19 @@ class AiBlogService
67 * @time :2025/2/13 14:39 69 * @time :2025/2/13 14:39
68 * @param :type=(1作者2文章) keyword=关键词 subtype=blog url=回调url 70 * @param :type=(1作者2文章) keyword=关键词 subtype=blog url=回调url
69 */ 71 */
70 - public function createTask($keyword,$type = 1,$subtype,$url,$template_id){ 72 + public function createTask($keyword,$type = 1,$subtype = 'Blog',$template_id = 1){
71 $request_url = $this->url.'api/task/create'; 73 $request_url = $this->url.'api/task/create';
72 $param = [ 74 $param = [
73 'mch_id'=>$this->mch_id, 75 'mch_id'=>$this->mch_id,
74 - 'sign'=>$this->sign,  
75 'keyword'=>$keyword, 76 'keyword'=>$keyword,
76 'type'=>$type, 77 'type'=>$type,
77 'subtype'=>$subtype, 78 'subtype'=>$subtype,
78 - 'url'=>$url, 79 + 'url'=>$this->webhook,
79 'template_id'=>$template_id 80 'template_id'=>$template_id
80 ]; 81 ];
81 - $result = http_post($request_url,$param); 82 + $this->sign = $this->generateSign($param,$this->key);
  83 + $param['sign'] = $this->sign;
  84 + $result = http_post($request_url,json_encode($param,true));
82 return $result; 85 return $result;
83 } 86 }
84 87