作者 刘锟

白帽二级域名设置

@@ -63,6 +63,10 @@ class AiBlogAutoPublish extends Command @@ -63,6 +63,10 @@ class AiBlogAutoPublish extends Command
63 63
64 foreach ($projects as $project) { 64 foreach ($projects as $project) {
65 $this->output("项目{$project->id}开始自动发布"); 65 $this->output("项目{$project->id}开始自动发布");
  66 + if(($project->deploy_optimize['start_date'] > date('Y-m-d')) || !$project->deploy_optimize['start_date']){
  67 + $this->output("项目{$project->id}未到推广时间" . $project->deploy_optimize['start_date']);
  68 + continue;
  69 + }
66 $next_auto_date = AiBlogTaskModel::where('project_id', $project->id)->where('type', 2)->whereNotNull('next_auto_date')->orderBy('id', 'desc')->value('next_auto_date'); 70 $next_auto_date = AiBlogTaskModel::where('project_id', $project->id)->where('type', 2)->whereNotNull('next_auto_date')->orderBy('id', 'desc')->value('next_auto_date');
67 if($next_auto_date && $next_auto_date > date('Y-m-d')){ 71 if($next_auto_date && $next_auto_date > date('Y-m-d')){
68 $this->output("项目{$project->id}未到执行时间" . $next_auto_date); 72 $this->output("项目{$project->id}未到执行时间" . $next_auto_date);
@@ -157,8 +161,8 @@ class AiBlogAutoPublish extends Command @@ -157,8 +161,8 @@ class AiBlogAutoPublish extends Command
157 $project->is_ai_blog = 1; 161 $project->is_ai_blog = 1;
158 $project->save(); 162 $project->save();
159 //创建AI博客项目 163 //创建AI博客项目
160 - $deploy_optimize = $project->deploy_optimize();  
161 - (new ProjectLogic())->setAiBlog($project->id, $project->main_lang_id, 1, $project->title, $deploy_optimize->company_en_name, $deploy_optimize->company_en_description); 164 + $deploy_optimize = $project->deploy_optimize;
  165 + (new ProjectLogic())->setAiBlog($project->id, $project->main_lang_id, 1, $project->company, $deploy_optimize->company_en_name, $deploy_optimize->company_en_description);
162 //开启日志 166 //开启日志
163 AiBlogOpenLog::addLog($project->id); 167 AiBlogOpenLog::addLog($project->id);
164 168
@@ -52,9 +52,9 @@ class LyhImportTest extends Command @@ -52,9 +52,9 @@ class LyhImportTest extends Command
52 * @time :2023/11/20 15:13 52 * @time :2023/11/20 15:13
53 */ 53 */
54 public function handle(){ 54 public function handle(){
55 - ProjectServer::useProject(3283); 55 + ProjectServer::useProject(2140);
56 echo date('Y-m-d H:i:s') . 'start' . PHP_EOL; 56 echo date('Y-m-d H:i:s') . 'start' . PHP_EOL;
57 -// $this->importProduct('https://ecdn6.globalso.com/upload/p/3283/file/2025-03/2-1.csv',3283); 57 + $this->import2140CustomModule('https://ecdn6.globalso.com/upload/p/2140/file/2025-03/2140.csv',2140);
58 DB::disconnect('custom_mysql'); 58 DB::disconnect('custom_mysql');
59 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 59 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
60 } 60 }
@@ -437,4 +437,73 @@ class LyhImportTest extends Command @@ -437,4 +437,73 @@ class LyhImportTest extends Command
437 } 437 }
438 return true; 438 return true;
439 } 439 }
  440 +
  441 + public function import2140CustomModule($url,$project_id){
  442 + $line_of_text = [];
  443 + $opts = [
  444 + 'http' => [
  445 + 'method' => 'GET',
  446 + 'header' => 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246'
  447 + ],
  448 + 'ssl' => [
  449 + 'verify_peer' => false,
  450 + 'verify_peer_name' => false
  451 + ]
  452 + ];
  453 + $file_handle = fopen($url, 'r', null, stream_context_create($opts));
  454 + while (!feof($file_handle)) {
  455 + $line_of_text[] = fgetcsv($file_handle, 0, ',');
  456 + }
  457 + fclose($file_handle);
  458 + $customContentModel = new CustomModuleContent();
  459 + $customCategoryModel = new CustomModuleCategory();;
  460 + $customExtendContentTModel = new CustomModuleExtentContent();
  461 + foreach ($line_of_text as $k => $item){
  462 +// try {
  463 + //添加内容
  464 + $contentId = $customContentModel->addReturnId(['name'=>$item[0],'module_id'=>2,'project_id'=>$project_id]);
  465 + echo date('Y-m-d H:i:s') . '当前扩展数据id:'. $contentId . PHP_EOL;
  466 + //注册路由
  467 + $route = RouteMap::setRoute($item[0], RouteMap::SOURCE_MODULE,
  468 + $contentId, $project_id);
  469 + $customContentModel->edit(['route'=>$route],['id'=>$contentId]);
  470 + if(!empty($item[1])){
  471 + $categoryId = ',';
  472 + $cateArr = explode('/',$item[1]);
  473 + foreach ($cateArr as $cateV){
  474 + $cateInfo = $customCategoryModel->read(['name'=>$cateV,'module_id'=>2,'project_id'=>$project_id]);
  475 + if($cateInfo !== false){
  476 + $categoryId .= $cateInfo['id'].',';
  477 + }else{
  478 + $cateVId = $customCategoryModel->addReturnId(['name'=>$cateV,'module_id'=>2,'project_id'=>$project_id]);
  479 + $cateRoute = RouteMap::setRoute($cateV, RouteMap::SOURCE_MODULE_CATE,
  480 + $cateVId, $project_id);
  481 + $customCategoryModel->edit(['route'=>$cateRoute],['id'=>$cateVId]);
  482 + $categoryId .= $cateVId.',';
  483 + }
  484 + }
  485 + $customContentModel->edit(['category_id'=>$categoryId],['id'=>$contentId]);
  486 + }
  487 + $saveData = [
  488 + ['key'=>'pd_extended_field_1', 'type'=>1, 'values'=>$item[2], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
  489 + ['key'=>'pd_extended_field_2', 'type'=>1, 'values'=>$item[4], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
  490 + ['key'=>'pd_extended_field_3', 'type'=>1, 'values'=>$item[5], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
  491 + ['key'=>'pd_extended_field_4', 'type'=>1, 'values'=>$item[3], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
  492 + ['key'=>'pd_extended_field_5', 'type'=>1, 'values'=>$item[8], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
  493 + ['key'=>'pd_extended_field_6', 'type'=>1, 'values'=>$item[6], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
  494 + ['key'=>'pd_extended_field_7', 'type'=>1, 'values'=>$item[9], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
  495 + ['key'=>'pd_extended_field_8', 'type'=>1, 'values'=>$item[10], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
  496 + ['key'=>'pd_extended_field_9', 'type'=>1, 'values'=>$item[11], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
  497 + ['key'=>'pd_extended_field_10', 'type'=>1, 'values'=>$item[12], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
  498 + ['key'=>'pd_extended_field_11', 'type'=>1, 'values'=>$item[13], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
  499 + ['key'=>'pd_extended_field_12', 'type'=>1, 'values'=>$item[14] ?? '', 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
  500 + ['key'=>'pd_extended_field_14', 'type'=>1, 'values'=>$item[7], 'content_id'=>$contentId, 'project_id'=>$project_id, 'module_id'=>2, 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s')],
  501 + ];
  502 + $customExtendContentTModel->insert($saveData);
  503 +// }catch (\Exception $e){
  504 +// echo date('Y-m-d H:i:s') . '错误name:'. $item[0] . PHP_EOL;
  505 +// continue;
  506 +// }
  507 + }
  508 + }
440 } 509 }
@@ -140,7 +140,7 @@ class ComController extends BaseController @@ -140,7 +140,7 @@ class ComController extends BaseController
140 if($is_comment != 1){ 140 if($is_comment != 1){
141 $info['role_menu'] = trim(str_replace(',55,',',',','.$info['role_menu'].','),','); 141 $info['role_menu'] = trim(str_replace(',55,',',',','.$info['role_menu'].','),',');
142 } 142 }
143 - $is_blogs = $this->getIsBlog(); 143 + $is_blogs = $this->getIsAiBlog();
144 if($is_blogs != 1){ 144 if($is_blogs != 1){
145 $info['role_menu'] = trim(str_replace(',57,',',',','.$info['role_menu'].','),','); 145 $info['role_menu'] = trim(str_replace(',57,',',',','.$info['role_menu'].','),',');
146 } 146 }
@@ -89,6 +89,8 @@ class CategoryController extends BaseController @@ -89,6 +89,8 @@ class CategoryController extends BaseController
89 public function get3283Lists($filed){ 89 public function get3283Lists($filed){
90 if(!isset($this->map['title'])){ 90 if(!isset($this->map['title'])){
91 $this->map['pid'] = $this->map['pid'] ?? 0; 91 $this->map['pid'] = $this->map['pid'] ?? 0;
  92 + }else{
  93 + $this->map['title'] = ['like','%'.$this->map['title'].'%'];
92 } 94 }
93 $list = $this->model->list($this->map,['sort','id'],$filed); 95 $list = $this->model->list($this->map,['sort','id'],$filed);
94 $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST);//获取模版id 96 $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST);//获取模版id
@@ -168,7 +168,7 @@ class ProjectLogic extends BaseLogic @@ -168,7 +168,7 @@ class ProjectLogic extends BaseLogic
168 $this->setServers($this->param['serve_id'],$this->param['id']); 168 $this->setServers($this->param['serve_id'],$this->param['id']);
169 //ai_blog 169 //ai_blog
170 $this->setAiBlog($this->param['id'],$this->param['main_lang_id'],$this->param['is_ai_blog'], 170 $this->setAiBlog($this->param['id'],$this->param['main_lang_id'],$this->param['is_ai_blog'],
171 - $this->param['title'], $this->param['deploy_optimize']['company_en_name'] ?? '',$this->param['deploy_optimize']['company_en_description'] ?? ''); 171 + $this->param['company']??"", $this->param['deploy_optimize']['company_en_name'] ?? '',$this->param['deploy_optimize']['company_en_description'] ?? '');
172 //保存项目信息 172 //保存项目信息
173 $this->saveProject($this->param); 173 $this->saveProject($this->param);
174 //保存建站部署信息 174 //保存建站部署信息
@@ -203,7 +203,7 @@ class ProjectLogic extends BaseLogic @@ -203,7 +203,7 @@ class ProjectLogic extends BaseLogic
203 * @method :post 203 * @method :post
204 * @time :2025/2/13 16:02 204 * @time :2025/2/13 16:02
205 */ 205 */
206 - public function setAiBlog($project_id,$main_lang_id,$is_ai_blog,$title,$company_en_name,$company_en_description){ 206 + public function setAiBlog($project_id,$main_lang_id,$is_ai_blog,$company,$company_en_name,$company_en_description){
207 if(empty($main_lang_id) || empty($is_ai_blog)){ 207 if(empty($main_lang_id) || empty($is_ai_blog)){
208 return true; 208 return true;
209 } 209 }
@@ -219,7 +219,7 @@ class ProjectLogic extends BaseLogic @@ -219,7 +219,7 @@ class ProjectLogic extends BaseLogic
219 $aiSettingInfo = $aiSettingModel->read(['project_id'=>$project_id]); 219 $aiSettingInfo = $aiSettingModel->read(['project_id'=>$project_id]);
220 if($aiSettingInfo === false){ 220 if($aiSettingInfo === false){
221 $aiBlogService = new AiBlogService(); 221 $aiBlogService = new AiBlogService();
222 - $result = $aiBlogService->createProject($projectInfo['company'] ?? $title,$languageInfo['short'],$company_en_description,$company_en_name); 222 + $result = $aiBlogService->createProject($projectInfo['company']?:$projectInfo['title'],$languageInfo['short'],$company_en_description,$company_en_name);
223 if(isset($result['status']) && $result['status'] == 200){ 223 if(isset($result['status']) && $result['status'] == 200){
224 //查看当前项目是否已有记录 224 //查看当前项目是否已有记录
225 $resData = [ 225 $resData = [
@@ -232,12 +232,12 @@ class ProjectLogic extends BaseLogic @@ -232,12 +232,12 @@ class ProjectLogic extends BaseLogic
232 } 232 }
233 }else{ 233 }else{
234 //有信息更新 234 //有信息更新
235 - if(($projectInfo['title'] != $title) || ($projectInfo['main_lang_id'] != $main_lang_id) 235 + if(($projectInfo['company'] != $company) || ($projectInfo['main_lang_id'] != $main_lang_id)
236 || ($projectOptimize['company_en_name'] != $company_en_name) || ($projectOptimize['company_en_description'] != $company_en_description)){ 236 || ($projectOptimize['company_en_name'] != $company_en_name) || ($projectOptimize['company_en_description'] != $company_en_description)){
237 $aiBlogService = new AiBlogService(); 237 $aiBlogService = new AiBlogService();
238 $aiBlogService->mch_id = $aiSettingInfo['mch_id']; 238 $aiBlogService->mch_id = $aiSettingInfo['mch_id'];
239 $aiBlogService->key = $aiSettingInfo['key']; 239 $aiBlogService->key = $aiSettingInfo['key'];
240 - $aiBlogService->updatedProject($title,$languageInfo['short'],$company_en_description,$company_en_name); 240 + $aiBlogService->updatedProject($projectInfo['company']?:$projectInfo['title'],$languageInfo['short'],$company_en_description,$company_en_name);
241 } 241 }
242 } 242 }
243 return true; 243 return true;
@@ -762,7 +762,7 @@ class ProductLogic extends BaseLogic @@ -762,7 +762,7 @@ class ProductLogic extends BaseLogic
762 try { 762 try {
763 if(!isset($this->param['is_cover']) || ($this->param['is_cover'] == 1)){ 763 if(!isset($this->param['is_cover']) || ($this->param['is_cover'] == 1)){
764 $category_ids = ','.implode(',',$this->param['category_id']).','; 764 $category_ids = ','.implode(',',$this->param['category_id']).',';
765 - $this->model->edit(['category_id'=>$category_ids],['id'=>['in',$this->param['id']]]); 765 + $this->model->edit(['category_id'=>$category_ids,'status'=>$this->param['status'] ?? 1],['id'=>['in',$this->param['id']]]);
766 //分类关联 766 //分类关联
767 foreach ($this->param['id'] as $id){ 767 foreach ($this->param['id'] as $id){
768 CategoryRelated::saveRelated($id, $this->param['category_id']); 768 CategoryRelated::saveRelated($id, $this->param['category_id']);
@@ -773,7 +773,7 @@ class ProductLogic extends BaseLogic @@ -773,7 +773,7 @@ class ProductLogic extends BaseLogic
773 $productInfo = $this->model->read(['id'=>$id],['id','category_id']); 773 $productInfo = $this->model->read(['id'=>$id],['id','category_id']);
774 $category_ids_arr = array_values(array_unique(array_merge($productInfo['category_id'],$this->param['category_id']))); 774 $category_ids_arr = array_values(array_unique(array_merge($productInfo['category_id'],$this->param['category_id'])));
775 $category_ids = ','.implode(',',$category_ids_arr).','; 775 $category_ids = ','.implode(',',$category_ids_arr).',';
776 - $this->model->edit(['category_id'=>$category_ids],['id'=>$id]); 776 + $this->model->edit(['category_id'=>$category_ids,'status'=>$this->param['status'] ?? 1],['id'=>$id]);
777 CategoryRelated::saveRelated($id, $category_ids_arr); 777 CategoryRelated::saveRelated($id, $category_ids_arr);
778 } 778 }
779 } 779 }