作者 赵彬吉
@@ -67,6 +67,10 @@ class AiBlogAuthorTask extends Command @@ -67,6 +67,10 @@ class AiBlogAuthorTask extends Command
67 sleep(10); 67 sleep(10);
68 continue; 68 continue;
69 } 69 }
  70 + if(empty($result['data'])){
  71 + sleep(20);
  72 + continue;
  73 + }
70 //保存当前项目ai_blog数据 74 //保存当前项目ai_blog数据
71 ProjectServer::useProject($info['project_id']); 75 ProjectServer::useProject($info['project_id']);
72 $this->saveAiBlogAuthor($result['data'] ?? [],$info['project_id']); 76 $this->saveAiBlogAuthor($result['data'] ?? [],$info['project_id']);
@@ -109,6 +113,8 @@ class AiBlogAuthorTask extends Command @@ -109,6 +113,8 @@ class AiBlogAuthorTask extends Command
109 return true; 113 return true;
110 } 114 }
111 $aiBlogAuthorModel = new AiBlogAuthor(); 115 $aiBlogAuthorModel = new AiBlogAuthor();
  116 + $info = $aiBlogAuthorModel->count(['project_id'=>$project_id]);
  117 + if($info === false){
112 foreach ($data as $v){ 118 foreach ($data as $v){
113 $param = [ 119 $param = [
114 'author_id'=>$v['id'], 120 'author_id'=>$v['id'],
@@ -120,6 +126,7 @@ class AiBlogAuthorTask extends Command @@ -120,6 +126,7 @@ class AiBlogAuthorTask extends Command
120 $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $id, $project_id); 126 $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $id, $project_id);
121 $aiBlogAuthorModel->edit(['route'=>$route],['id'=>$id]); 127 $aiBlogAuthorModel->edit(['route'=>$route],['id'=>$id]);
122 } 128 }
  129 + }
123 return true; 130 return true;
124 } 131 }
125 } 132 }
@@ -77,6 +77,8 @@ class AiBlogListTask extends Command @@ -77,6 +77,8 @@ class AiBlogListTask extends Command
77 ProjectServer::useProject($v['project_id']); 77 ProjectServer::useProject($v['project_id']);
78 $aiBlogListModel = new AiBlogList(); 78 $aiBlogListModel = new AiBlogList();
79 if(!empty($saveData)){ 79 if(!empty($saveData)){
  80 + //写一条路由信息
  81 + RouteMap::setRoute('top-blog',RouteMap::SOURCE_AI_BLOG_LIST,0,$v['project_id']);
80 $aiBlogListModel->truncate(); 82 $aiBlogListModel->truncate();
81 $aiBlogListModel->insertAll($saveData); 83 $aiBlogListModel->insertAll($saveData);
82 } 84 }
@@ -7,17 +7,13 @@ @@ -7,17 +7,13 @@
7 * @time :2024/9/26 14:19 7 * @time :2024/9/26 14:19
8 */ 8 */
9 9
10 -namespace App\Console\Commands\Project; 10 +namespace App\Console\Commands\LyhTest;
11 11
12 use App\Helper\Common; 12 use App\Helper\Common;
13 -use App\Models\Domain\DomainInfo;  
14 use App\Models\Product\Category; 13 use App\Models\Product\Category;
15 use App\Models\Product\CategoryRelated; 14 use App\Models\Product\CategoryRelated;
16 -use App\Models\Product\Detail;  
17 use App\Models\Product\Product; 15 use App\Models\Product\Product;
18 use App\Models\RouteMap\RouteMap; 16 use App\Models\RouteMap\RouteMap;
19 -use App\Models\Visit\Visit;  
20 -use App\Models\Visit\VisitItem;  
21 use App\Services\ProjectServer; 17 use App\Services\ProjectServer;
22 use Illuminate\Console\Command; 18 use Illuminate\Console\Command;
23 use Illuminate\Support\Facades\DB; 19 use Illuminate\Support\Facades\DB;
@@ -41,7 +37,7 @@ class DownloadProject extends Command @@ -41,7 +37,7 @@ class DownloadProject extends Command
41 protected $description = '导出项目数据'; 37 protected $description = '导出项目数据';
42 38
43 public function handle(){ 39 public function handle(){
44 - ProjectServer::useProject(1225); 40 + ProjectServer::useProject(1646);
45 echo date('Y-m-d H:i:s') . 'start' . PHP_EOL; 41 echo date('Y-m-d H:i:s') . 'start' . PHP_EOL;
46 $data = $this->downloadProduct(); 42 $data = $this->downloadProduct();
47 DB::disconnect('custom_mysql'); 43 DB::disconnect('custom_mysql');
@@ -52,22 +48,23 @@ class DownloadProject extends Command @@ -52,22 +48,23 @@ class DownloadProject extends Command
52 public function downloadProduct() 48 public function downloadProduct()
53 { 49 {
54 $product = new Product(); 50 $product = new Product();
55 - $filed = ['id', 'project_id', 'title' ,'thumb' , 'route' ,'intro','content',  
56 - 'category_id', 'status','seo_mate']; 51 +// $filed = ['id', 'project_id', 'title' ,'thumb' , 'route' ,'intro','content',
  52 +// 'category_id', 'status','seo_mate'];
  53 + $filed = ['id','title'];
57 $this->order = 'sort'; 54 $this->order = 'sort';
58 $lists = $product->list(['status'=>1],'id',$filed); 55 $lists = $product->list(['status'=>1],'id',$filed);
59 if(!empty($lists)){ 56 if(!empty($lists)){
60 - $cate_data = $this->getCategoryList();//分类 57 +// $cate_data = $this->getCategoryList();//分类
61 foreach ($lists as $k => $v){ 58 foreach ($lists as $k => $v){
62 echo date('Y-m-d H:i:s') . '产品id:'.$v['id'] . PHP_EOL; 59 echo date('Y-m-d H:i:s') . '产品id:'.$v['id'] . PHP_EOL;
63 - $v['url'] = 'https://www.autsikinta.com/' . getRouteMap(RouteMap::SOURCE_PRODUCT,$v['id']);  
64 - $v['category_id_text'] = $this->categoryName($v['id'],$cate_data);  
65 - //ToDo::处理图片及文件  
66 - if(!empty($v['thumb']) && !empty($v['thumb']['url'])){  
67 - $v['images'] = getImageUrl($v['thumb']['url']);  
68 - }else{  
69 - $v['images'] = '';  
70 - } 60 +// $v['url'] = 'https://www.autsikinta.com/' . getRouteMap(RouteMap::SOURCE_PRODUCT,$v['id']);
  61 +// $v['category_id_text'] = $this->categoryName($v['id'],$cate_data);
  62 +// //ToDo::处理图片及文件
  63 +// if(!empty($v['thumb']) && !empty($v['thumb']['url'])){
  64 +// $v['images'] = getImageUrl($v['thumb']['url']);
  65 +// }else{
  66 +// $v['images'] = '';
  67 +// }
71 $lists[$k] = $v; 68 $lists[$k] = $v;
72 } 69 }
73 } 70 }
@@ -148,27 +145,27 @@ class DownloadProject extends Command @@ -148,27 +145,27 @@ class DownloadProject extends Command
148 $sheet = $spreadsheet->getActiveSheet(); 145 $sheet = $spreadsheet->getActiveSheet();
149 // 添加表头 146 // 添加表头
150 $sheet->setCellValue('A1', '产品名称'); 147 $sheet->setCellValue('A1', '产品名称');
151 - $sheet->setCellValue('B1', '产品短描述');  
152 - $sheet->setCellValue('C1', '产品内容');  
153 - $sheet->setCellValue('D1', '产品路由');  
154 - $sheet->setCellValue('E1', '产品分类');  
155 - $sheet->setCellValue('F1', '产品状态');  
156 - $sheet->setCellValue('G1', '产品主图');  
157 - $sheet->setCellValue('H1', '产品seo_title');  
158 - $sheet->setCellValue('I1', '产品seo_keyword');  
159 - $sheet->setCellValue('J1', '产品seo_title'); 148 +// $sheet->setCellValue('B1', '产品短描述');
  149 +// $sheet->setCellValue('C1', '产品内容');
  150 +// $sheet->setCellValue('D1', '产品路由');
  151 +// $sheet->setCellValue('E1', '产品分类');
  152 +// $sheet->setCellValue('F1', '产品状态');
  153 +// $sheet->setCellValue('G1', '产品主图');
  154 +// $sheet->setCellValue('H1', '产品seo_title');
  155 +// $sheet->setCellValue('I1', '产品seo_keyword');
  156 +// $sheet->setCellValue('J1', '产品seo_title');
160 $rowCount = 2; 157 $rowCount = 2;
161 foreach ($data as $v) { 158 foreach ($data as $v) {
162 $sheet->setCellValue('A' . $rowCount, $v['title']); 159 $sheet->setCellValue('A' . $rowCount, $v['title']);
163 - $sheet->setCellValue('B' . $rowCount, $v['intro']);  
164 - $sheet->setCellValue('C' . $rowCount, $v['content']);  
165 - $sheet->setCellValue('D' . $rowCount, $v['url']);  
166 - $sheet->setCellValue('E' . $rowCount, $v['category_id_text']);  
167 - $sheet->setCellValue('F' . $rowCount, '发布中');  
168 - $sheet->setCellValue('G' . $rowCount, $v['images']);  
169 - $sheet->setCellValue('H' . $rowCount, $v['seo_mate']['title']);  
170 - $sheet->setCellValue('I' . $rowCount, $v['seo_mate']['keyword']);  
171 - $sheet->setCellValue('J' . $rowCount, $v['seo_mate']['description']); 160 +// $sheet->setCellValue('B' . $rowCount, $v['intro']);
  161 +// $sheet->setCellValue('C' . $rowCount, $v['content']);
  162 +// $sheet->setCellValue('D' . $rowCount, $v['url']);
  163 +// $sheet->setCellValue('E' . $rowCount, $v['category_id_text']);
  164 +// $sheet->setCellValue('F' . $rowCount, '发布中');
  165 +// $sheet->setCellValue('G' . $rowCount, $v['images']);
  166 +// $sheet->setCellValue('H' . $rowCount, $v['seo_mate']['title']);
  167 +// $sheet->setCellValue('I' . $rowCount, $v['seo_mate']['keyword']);
  168 +// $sheet->setCellValue('J' . $rowCount, $v['seo_mate']['description']);
172 $rowCount++; 169 $rowCount++;
173 } 170 }
174 // 创建一个新的 Excel Writer 对象 171 // 创建一个新的 Excel Writer 对象
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :LyhImportTest.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/2/24 14:52
  8 + */
  9 +
  10 +namespace App\Console\Commands\LyhTest;
  11 +
  12 +use Illuminate\Console\Command;
  13 +
  14 +class LyhImportTest extends Command
  15 +{
  16 + /**
  17 + * The name and signature of the console command.
  18 + *
  19 + * @var string
  20 + */
  21 + protected $signature = 'lyh_import_test';
  22 +
  23 + /**
  24 + * The console command description.
  25 + *
  26 + * @var string
  27 + */
  28 + protected $description = '导入数据';
  29 +
  30 + /**
  31 + * @remark :统一更新路由
  32 + * @name :handle
  33 + * @author :lyh
  34 + * @method :post
  35 + * @time :2023/11/20 15:13
  36 + */
  37 + public function handle(){
  38 + $data = [];
  39 + echo date('Y-m-d H:i:s') . 'end'.json_encode($data) . PHP_EOL;
  40 + }
  41 +
  42 + /**
  43 + * @remark :导入扩展模块数据
  44 + * @name :importCustomModule
  45 + * @author :lyh
  46 + * @method :post
  47 + * @time :2025/2/24 14:54
  48 + */
  49 + public function importCustomModule(){
  50 +
  51 + }
  52 +}
@@ -67,6 +67,16 @@ class UpdateRoute extends Command @@ -67,6 +67,16 @@ class UpdateRoute extends Command
67 echo date('Y-m-d H:i:s') . 'end'.json_encode($data) . PHP_EOL; 67 echo date('Y-m-d H:i:s') . 'end'.json_encode($data) . PHP_EOL;
68 } 68 }
69 69
  70 + /**
  71 + * @remark :导入数据
  72 + * @name :importCustomModule
  73 + * @author :lyh
  74 + * @method :post
  75 + * @time :2025/2/24 14:44
  76 + */
  77 + public function importCustomModule(){
  78 +
  79 + }
70 80
71 public function ceshi($api_no = null) 81 public function ceshi($api_no = null)
72 { 82 {
@@ -9,6 +9,7 @@ use App\Http\Requests\Bside\Ai\AiBlogRequest; @@ -9,6 +9,7 @@ use App\Http\Requests\Bside\Ai\AiBlogRequest;
9 use App\Models\Ai\AiBlog; 9 use App\Models\Ai\AiBlog;
10 use App\Models\Ai\AiBlogAuthor; 10 use App\Models\Ai\AiBlogAuthor;
11 use App\Models\Ai\AiBlogList; 11 use App\Models\Ai\AiBlogList;
  12 +use App\Models\RouteMap\RouteMap;
12 use App\Services\AiBlogService; 13 use App\Services\AiBlogService;
13 use App\Services\ProjectServer; 14 use App\Services\ProjectServer;
14 use Illuminate\Support\Facades\DB; 15 use Illuminate\Support\Facades\DB;
@@ -59,10 +60,11 @@ class AiBlogController extends BaseController @@ -59,10 +60,11 @@ class AiBlogController extends BaseController
59 * @time :2025/2/14 13:59 60 * @time :2025/2/14 13:59
60 */ 61 */
61 public function getAiBlog(AiBlog $aiBlog){ 62 public function getAiBlog(AiBlog $aiBlog){
62 - $lists = $aiBlog->lists($this->map,$this->page,$this->row,'id',['id','new_title','image','task_id','status','created_at','updated_at']); 63 + $lists = $aiBlog->lists($this->map,$this->page,$this->row,'id',['id','keyword','new_title','route','image','task_id','status','created_at','updated_at']);
63 if(!empty($lists) && !empty($lists['list'])){ 64 if(!empty($lists) && !empty($lists['list'])){
64 foreach ($lists['list'] as $k => $v){ 65 foreach ($lists['list'] as $k => $v){
65 $v['image'] = getImageUrl($v['image']); 66 $v['image'] = getImageUrl($v['image']);
  67 + $v['route'] = $this->user['test_domain'] . 'blog/' . $v['route'];
66 $lists['list'][$k] = $v; 68 $lists['list'][$k] = $v;
67 } 69 }
68 } 70 }
@@ -99,6 +101,13 @@ class AiBlogController extends BaseController @@ -99,6 +101,13 @@ class AiBlogController extends BaseController
99 public function getAiBlogAuthor(AiBlogAuthor $aiBlogAuthor){ 101 public function getAiBlogAuthor(AiBlogAuthor $aiBlogAuthor){
100 $field = ['id','route','author_id','title','image','created_at','updated_at']; 102 $field = ['id','route','author_id','title','image','created_at','updated_at'];
101 $lists = $aiBlogAuthor->lists($this->map,$this->page,$this->row,'id',$field); 103 $lists = $aiBlogAuthor->lists($this->map,$this->page,$this->row,'id',$field);
  104 + if(!empty($lists) && !empty($lists['list'])){
  105 + foreach ($lists['list'] as $k => $v){
  106 + $v['image'] = getImageUrl($v['image']);
  107 + $v['route'] = $this->user['test_domain'] . 'user/' . $v['route'];
  108 + $lists['list'][$k] = $v;
  109 + }
  110 + }
102 $this->response('success',Code::SUCCESS,$lists); 111 $this->response('success',Code::SUCCESS,$lists);
103 } 112 }
104 113
@@ -143,7 +152,7 @@ class AiBlogController extends BaseController @@ -143,7 +152,7 @@ class AiBlogController extends BaseController
143 public function delete(AiBlogLogic $aiBlogLogic) 152 public function delete(AiBlogLogic $aiBlogLogic)
144 { 153 {
145 $this->request->validate([ 154 $this->request->validate([
146 - 'ids'=>['required', new Ids()] 155 + 'ids'=>['required'],
147 ],[ 156 ],[
148 'ids.required' => 'ID不能为空' 157 'ids.required' => 'ID不能为空'
149 ]); 158 ]);
@@ -160,6 +169,12 @@ class AiBlogController extends BaseController @@ -160,6 +169,12 @@ class AiBlogController extends BaseController
160 */ 169 */
161 public function getAiBlogList(AiBlogList $aiBlogList){ 170 public function getAiBlogList(AiBlogList $aiBlogList){
162 $lists = $aiBlogList->lists($this->map,$this->page,$this->row,'id',['id','route','created_at','updated_at']); 171 $lists = $aiBlogList->lists($this->map,$this->page,$this->row,'id',['id','route','created_at','updated_at']);
  172 + if(!empty($lists) && !empty($lists['list'])){
  173 + foreach ($lists['list'] as $k => $v){
  174 + $v['route'] = $this->user['test_domain'] . 'top-blog/' . $v['route'];
  175 + $lists['list'][$k] = $v;
  176 + }
  177 + }
163 $this->response('success',Code::SUCCESS,$lists); 178 $this->response('success',Code::SUCCESS,$lists);
164 } 179 }
165 180
@@ -248,7 +248,7 @@ class ProjectLogic extends BaseLogic @@ -248,7 +248,7 @@ class ProjectLogic extends BaseLogic
248 public function createAuthor($project_id,$mch_id,$key){ 248 public function createAuthor($project_id,$mch_id,$key){
249 //查看当前项目是否已经创建了作者 249 //查看当前项目是否已经创建了作者
250 $aiBlogTaskModel = new AiBlogTask(); 250 $aiBlogTaskModel = new AiBlogTask();
251 - $count = $aiBlogTaskModel->count(); 251 + $count = $aiBlogTaskModel->counts(['project_id'=>$project_id]);
252 if($count > 0){ 252 if($count > 0){
253 return true; 253 return true;
254 } 254 }
@@ -55,7 +55,7 @@ class AiBlogLogic extends BaseLogic @@ -55,7 +55,7 @@ class AiBlogLogic extends BaseLogic
55 $aiBlogService = new AiBlogService(); 55 $aiBlogService = new AiBlogService();
56 $aiBlogService->mch_id = $aiSettingInfo['mch_id']; 56 $aiBlogService->mch_id = $aiSettingInfo['mch_id'];
57 $aiBlogService->key = $aiSettingInfo['key']; 57 $aiBlogService->key = $aiSettingInfo['key'];
58 - $aiBlogService->updateDetail(['title'=>$this->param['title'],'thumb'=>$this->param['image'],'route'=>$this->param['route'],'author_id'=>$this->param['author_id']]); 58 + $aiBlogService->updateDetail(['title'=>$this->param['new_title'],'thumb'=>$this->param['image'],'route'=>$this->param['route'],'author_id'=>$this->param['author_id']]);
59 }catch (\Exception $e){ 59 }catch (\Exception $e){
60 $this->fail('保存失败,请联系管理员'); 60 $this->fail('保存失败,请联系管理员');
61 } 61 }
@@ -70,7 +70,7 @@ class AiBlogLogic extends BaseLogic @@ -70,7 +70,7 @@ class AiBlogLogic extends BaseLogic
70 * @time :2025/2/21 14:46 70 * @time :2025/2/21 14:46
71 */ 71 */
72 public function saveBlogAuthor(){ 72 public function saveBlogAuthor(){
73 - try { 73 +// try {
74 $aiAuthorModel = new AiBlogAuthor(); 74 $aiAuthorModel = new AiBlogAuthor();
75 if(!empty($this->param['image'])){ 75 if(!empty($this->param['image'])){
76 $this->param['image'] = str_replace_url($this->param['image']); 76 $this->param['image'] = str_replace_url($this->param['image']);
@@ -79,9 +79,9 @@ class AiBlogLogic extends BaseLogic @@ -79,9 +79,9 @@ class AiBlogLogic extends BaseLogic
79 $aiAuthorModel->edit($this->param,['id'=>$this->param['id']]); 79 $aiAuthorModel->edit($this->param,['id'=>$this->param['id']]);
80 $aiBlogService = new AiBlogService(); 80 $aiBlogService = new AiBlogService();
81 $aiBlogService->updateAuthorInfo(['author_id'=>$this->param['author_id'],'title'=>$this->param['title'],'picture'=>$this->param['image'],'description'=>$this->param['description']]); 81 $aiBlogService->updateAuthorInfo(['author_id'=>$this->param['author_id'],'title'=>$this->param['title'],'picture'=>$this->param['image'],'description'=>$this->param['description']]);
82 - }catch (\Exception $e){  
83 - $this->fail('保存失败,请联系管理员');  
84 - } 82 +// }catch (\Exception $e){
  83 +// $this->fail('保存失败,请联系管理员');
  84 +// }
85 return $this->success(); 85 return $this->success();
86 } 86 }
87 87
@@ -99,7 +99,7 @@ class AiBlogLogic extends BaseLogic @@ -99,7 +99,7 @@ class AiBlogLogic extends BaseLogic
99 $aiBlogService = new AiBlogService(); 99 $aiBlogService = new AiBlogService();
100 $aiBlogService->mch_id = $aiSettingInfo['mch_id']; 100 $aiBlogService->mch_id = $aiSettingInfo['mch_id'];
101 $aiBlogService->key = $aiSettingInfo['key']; 101 $aiBlogService->key = $aiSettingInfo['key'];
102 - $aiBlogService->route = generateRoute(Translate::tran($this->param['route'], 'en')); 102 + $aiBlogService->route = generateRoute(Translate::tran($this->param['keyword'], 'en'));
103 $result = $aiBlogService->createTask($this->param['keyword'],$this->param['type']); 103 $result = $aiBlogService->createTask($this->param['keyword'],$this->param['type']);
104 if($result['status'] == 200){ 104 if($result['status'] == 200){
105 $aiBlogTaskModel = new AiBlogTask(); 105 $aiBlogTaskModel = new AiBlogTask();
@@ -24,18 +24,14 @@ class AiBlogRequest extends FormRequest @@ -24,18 +24,14 @@ class AiBlogRequest extends FormRequest
24 public function rules() 24 public function rules()
25 { 25 {
26 return [ 26 return [
27 - 'keywords'=>'required',  
28 'new_title'=>'required', 27 'new_title'=>'required',
29 - 'text'=>'required',  
30 ]; 28 ];
31 } 29 }
32 30
33 public function messages() 31 public function messages()
34 { 32 {
35 return [ 33 return [
36 - 'keywords.required' => '关键字不能为空',  
37 'new_title.required' => '新标题不能为空', 34 'new_title.required' => '新标题不能为空',
38 - 'text.required' => '内容不能为空',  
39 ]; 35 ];
40 } 36 }
41 } 37 }
@@ -35,6 +35,7 @@ class RouteMap extends Base @@ -35,6 +35,7 @@ class RouteMap extends Base
35 const SOURCE_MODULE = 'module'; 35 const SOURCE_MODULE = 'module';
36 const SOURCE_AI_BLOG = 'ai_blog'; 36 const SOURCE_AI_BLOG = 'ai_blog';
37 const SOURCE_AI_BLOG_AUTHOR = 'ai_blog_author';//ai博客作者 37 const SOURCE_AI_BLOG_AUTHOR = 'ai_blog_author';//ai博客作者
  38 + const SOURCE_AI_BLOG_LIST = 'ai_blog_list';
38 //自定义模块分类 39 //自定义模块分类
39 const SOURCE_MODULE_CATE = 'module_category'; 40 const SOURCE_MODULE_CATE = 'module_category';
40 41