作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

@@ -53,7 +53,7 @@ class AiBlogAuthorTask extends Command @@ -53,7 +53,7 @@ class AiBlogAuthorTask extends Command
53 continue; 53 continue;
54 } 54 }
55 $info = $info->toArray(); 55 $info = $info->toArray();
56 - echo '开始->project_id:' . $info['project_id'] . PHP_EOL . date('Y-m-d H:i:s'); 56 + echo date('Y-m-d H:i:s').'开始->project_id:' . $info['project_id'] . PHP_EOL;
57 //获取配置 57 //获取配置
58 $aiSettingInfo = $this->getSetting($info['project_id']); 58 $aiSettingInfo = $this->getSetting($info['project_id']);
59 if(empty($aiSettingInfo)){ 59 if(empty($aiSettingInfo)){
@@ -82,7 +82,7 @@ class AiBlogAuthorTask extends Command @@ -82,7 +82,7 @@ class AiBlogAuthorTask extends Command
82 DB::disconnect('custom_mysql'); 82 DB::disconnect('custom_mysql');
83 //修改任务状态 83 //修改任务状态
84 $aiBlogTaskModel->edit(['status'=>2],['id'=>$info['id']]); 84 $aiBlogTaskModel->edit(['status'=>2],['id'=>$info['id']]);
85 - echo '结束->任务id:' . $info['id'] . PHP_EOL . date('Y-m-d H:i:s'); 85 + echo date('Y-m-d H:i:s').'结束->任务id:' . $info['id'] . PHP_EOL;
86 } 86 }
87 return true; 87 return true;
88 } 88 }
@@ -144,7 +144,7 @@ class AiBlogAuthorTask extends Command @@ -144,7 +144,7 @@ class AiBlogAuthorTask extends Command
144 $aiBlogService->key = $aiSettingInfo['key']; 144 $aiBlogService->key = $aiSettingInfo['key'];
145 $aiBlogService->updateAuthorInfo(['author_id'=>$param['author_id'],'route'=>$param['route'],'title'=>$param['title'],'picture'=>$param['image'],'description'=>$param['description']]); 145 $aiBlogService->updateAuthorInfo(['author_id'=>$param['author_id'],'route'=>$param['route'],'title'=>$param['title'],'picture'=>$param['image'],'description'=>$param['description']]);
146 }catch (\Exception $e){ 146 }catch (\Exception $e){
147 - echo 'error:'.$e->getMessage(); 147 + echo 'error:'.$e->getMessage().PHP_EOL;
148 continue; 148 continue;
149 } 149 }
150 } 150 }
@@ -21,11 +21,13 @@ use App\Models\Project\Project; @@ -21,11 +21,13 @@ use App\Models\Project\Project;
21 use App\Models\Project\ProjectAiSetting; 21 use App\Models\Project\ProjectAiSetting;
22 use App\Models\RouteMap\RouteMap; 22 use App\Models\RouteMap\RouteMap;
23 use App\Services\AiBlogService; 23 use App\Services\AiBlogService;
  24 +use App\Services\DingService;
24 use App\Services\ProjectServer; 25 use App\Services\ProjectServer;
25 use Illuminate\Console\Command; 26 use Illuminate\Console\Command;
26 use App\Models\Project\AiBlogTask as AiBlogTaskModel; 27 use App\Models\Project\AiBlogTask as AiBlogTaskModel;
27 use Illuminate\Support\Facades\Cache; 28 use Illuminate\Support\Facades\Cache;
28 use Illuminate\Support\Facades\DB; 29 use Illuminate\Support\Facades\DB;
  30 +use Illuminate\Support\Facades\Redis;
29 use function Symfony\Component\String\s; 31 use function Symfony\Component\String\s;
30 32
31 class AiBlogTask extends Command 33 class AiBlogTask extends Command
@@ -37,6 +39,10 @@ class AiBlogTask extends Command @@ -37,6 +39,10 @@ class AiBlogTask extends Command
37 */ 39 */
38 protected $signature = 'save_ai_blog'; 40 protected $signature = 'save_ai_blog';
39 41
  42 + public $updateProject = [];//需更新的列表
  43 +
  44 +
  45 +
40 /** 46 /**
41 * The console command description. 47 * The console command description.
42 * 48 *
@@ -45,31 +51,53 @@ class AiBlogTask extends Command @@ -45,31 +51,53 @@ class AiBlogTask extends Command
45 protected $description = '查询ai_blog是否已经生成'; 51 protected $description = '查询ai_blog是否已经生成';
46 52
47 public function handle(){ 53 public function handle(){
48 - $aiBlogTaskModel = new AiBlogTaskModel();  
49 while (true){ 54 while (true){
50 - $list = $aiBlogTaskModel->formatQuery(['status'=>1,'type'=>2])->inRandomOrder()->limit(1000)->get();  
51 - if(empty($list)){ 55 + //获取任务id
  56 + $task_id = $this->getTaskId(2);
  57 + if(empty($task_id)){
52 sleep(300); 58 sleep(300);
53 continue; 59 continue;
54 } 60 }
55 - $list = $list->toArray();  
56 - $updateProject = [];  
57 - foreach ($list as $item){  
58 - echo '开始->任务id:' . $item['task_id'] . PHP_EOL . date('Y-m-d H:i:s'); 61 + $this->sendRequest($task_id);
  62 + }
  63 + return true;
  64 + }
  65 +
  66 + /**
  67 + * @remark :请求方法
  68 + * @name :sendRequest
  69 + * @author :lyh
  70 + * @method :post
  71 + * @time :2025/3/19 16:48
  72 + */
  73 + public function sendRequest($task_id){
  74 + $aiBlogTaskModel = new AiBlogTaskModel();
  75 + $item = $aiBlogTaskModel->read(['id'=>$task_id]);
  76 + echo date('Y-m-d H:i:s') . '开始->任务id:' . $item['task_id'] . PHP_EOL;
59 //获取配置 77 //获取配置
60 $aiSettingInfo = $this->getSetting($item['project_id']); 78 $aiSettingInfo = $this->getSetting($item['project_id']);
61 $aiBlogService = new AiBlogService(); 79 $aiBlogService = new AiBlogService();
62 $aiBlogService->mch_id = $aiSettingInfo['mch_id']; 80 $aiBlogService->mch_id = $aiSettingInfo['mch_id'];
63 $aiBlogService->key = $aiSettingInfo['key']; 81 $aiBlogService->key = $aiSettingInfo['key'];
64 $aiBlogService->task_id = $item['task_id']; 82 $aiBlogService->task_id = $item['task_id'];
  83 + //拉取文章数据
65 $result = $aiBlogService->getDetail(); 84 $result = $aiBlogService->getDetail();
66 - if(!isset($result['status'])){  
67 - echo json_encode($result,true).PHP_EOL;  
68 - continue; 85 + if(!isset($result['status']) || ($result['status'] != 200)){
  86 + if($item['sort'] < 5){
  87 + $aiBlogTaskModel->edit(['sort'=>$item['sort'] + 1],['id'=>$item['id']]);
  88 + }else{
  89 + $aiBlogTaskModel->edit(['status'=>9],['id'=>$item['id']]);
  90 + // 钉钉通知
  91 + $dingService = new DingService();
  92 + $body = [
  93 + 'keyword' => 'AI_BLOG生成错误',
  94 + 'msg' => '任务id:'.$item['task_id'].'拉取数据失败'.PHP_EOL.'返回信息:'.json_encode($result,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
  95 + 'isAtAll' => false, // 是否@所有人
  96 + ];
  97 + $dingService->handle($body);
69 } 98 }
70 - if($result['status'] != 200){  
71 - echo '错误状态码:'.$result['status'].PHP_EOL;  
72 - continue; 99 + echo date('Y-m-d H:i:s'). '错误信息:'.json_encode($result,true).PHP_EOL;
  100 + return false;
73 } 101 }
74 //保存当前项目ai_blog数据 102 //保存当前项目ai_blog数据
75 ProjectServer::useProject($item['project_id']); 103 ProjectServer::useProject($item['project_id']);
@@ -77,26 +105,63 @@ class AiBlogTask extends Command @@ -77,26 +105,63 @@ class AiBlogTask extends Command
77 $aiBlogInfo = $aiBlogModel->read(['task_id'=>$item['task_id']],['id']); 105 $aiBlogInfo = $aiBlogModel->read(['task_id'=>$item['task_id']],['id']);
78 if($aiBlogInfo === false){ 106 if($aiBlogInfo === false){
79 echo '任务id不存在:'.$item['task_id'].PHP_EOL; 107 echo '任务id不存在:'.$item['task_id'].PHP_EOL;
80 - $aiBlogTaskModel->edit(['status'=>2],['id'=>$item['id']]);  
81 - continue; 108 + $aiBlogTaskModel->edit(['status'=>$aiBlogModel::STATUS_FINISH],['id'=>$item['id']]);
  109 + DB::disconnect('custom_mysql');
  110 + return false;
82 } 111 }
83 - if (!in_array($result['data']['author_id'], $updateProject[$item['project_id']] ?? [])) {  
84 - $updateProject[$item['project_id']][] = $result['data']['author_id']; 112 + if (!in_array($result['data']['author_id'], $this->updateProject[$item['project_id']] ?? [])) {
  113 + $this->updateProject[$item['project_id']][] = $result['data']['author_id'];
85 } 114 }
86 //拿到返回的路由查看是否重复 115 //拿到返回的路由查看是否重复
87 $route = RouteMap::setRoute($result['data']['url'], RouteMap::SOURCE_AI_BLOG, $aiBlogInfo['id'], $item['project_id']); 116 $route = RouteMap::setRoute($result['data']['url'], RouteMap::SOURCE_AI_BLOG, $aiBlogInfo['id'], $item['project_id']);
88 if($route != $result['data']['url']){ 117 if($route != $result['data']['url']){
89 $aiBlogService->updateDetail(['route'=>$route,'task_id'=>$item['task_id']]); 118 $aiBlogService->updateDetail(['route'=>$route,'task_id'=>$item['task_id']]);
90 } 119 }
91 - $aiBlogModel->edit(['new_title'=>$result['data']['title'], 'image'=>$result['data']['thumb'], 'text'=>$result['data']['section'], 'author_id'=>$result['data']['author_id'],'seo_title'=>$result['data']['title'],'seo_keyword'=>$result['data']['keyword'],'seo_description'=>$result['data']['description'], 'route'=>$route ,'status'=>2], ['task_id'=>$item['task_id']]); 120 + $aiBlogModel->edit(['new_title'=>$result['data']['title'], 'image'=>$result['data']['thumb'], 'text'=>$result['data']['section'], 'author_id'=>$result['data']['author_id'],'seo_title'=>$result['data']['title'],'seo_keyword'=>$result['data']['keyword'],'seo_description'=>$result['data']['description'], 'route'=>$route ,'status'=>$aiBlogModel::STATUS_FINISH], ['task_id'=>$item['task_id']]);
92 DB::disconnect('custom_mysql'); 121 DB::disconnect('custom_mysql');
93 - $aiBlogTaskModel->edit(['status'=>2],['id'=>$item['id']]);  
94 - echo '结束->任务id:' . $item['task_id'] . PHP_EOL . date('Y-m-d H:i:s'); 122 + $aiBlogTaskModel->edit(['status'=>$aiBlogModel::STATUS_FINISH],['id'=>$item['id']]);
  123 + echo date('Y-m-d H:i:s').'结束->任务id:' . $item['task_id'] . PHP_EOL;
  124 + return true;
95 } 125 }
96 - //TODO::更新列表页及作者  
97 - $this->updateProject($updateProject); 126 +
  127 + /**
  128 + * @remark :g获取信息
  129 + * @name :getDetail
  130 + * @author :lyh
  131 + * @method :post
  132 + * @time :2025/3/19 17:24
  133 + */
  134 + public function getDetail(){
  135 +
98 } 136 }
99 - return true; 137 +
  138 + /**
  139 + * @remark :获取任务id
  140 + * @name :getTaskId
  141 + * @author :lyh
  142 + * @method :post
  143 + * @time :2025/3/19 16:16
  144 + * @param :
  145 + */
  146 + public function getTaskId($finish_at = 1)
  147 + {
  148 + $task_id = Redis::rpop('ai_blog_task');
  149 + if (empty($task_id)) {
  150 + if(!empty($this->updateProject)){
  151 + $this->updateProject($this->updateProject);
  152 + $this->updateProject = [];
  153 + }
  154 + $aiBlogTaskModel = new AiBlogTaskModel();
  155 + $finish_at = date('Y-m-d H:i:s', strtotime('-' . $finish_at . ' hour'));
  156 + $ids = $aiBlogTaskModel->formatQuery(['status'=>$aiBlogTaskModel::STATUS_RUNNING,'type'=>$aiBlogTaskModel::TYPE_BLOG,'created_at'=>['<=',$finish_at]])->limit(1000)->pluck('id');
  157 + if(!empty($ids)){
  158 + foreach ($ids as $id) {
  159 + Redis::lpush('ai_blog_task', $id);
  160 + }
  161 + }
  162 + $task_id = Redis::rpop('ai_blog_task');
  163 + }
  164 + return $task_id;
100 } 165 }
101 166
102 /** 167 /**
1 -<?php  
2 -/**  
3 - * @remark :  
4 - * @name :ImportCustomModule.php  
5 - * @author :lyh  
6 - * @method :post  
7 - * @time :2024/12/9 11:35  
8 - */  
9 -  
10 -namespace App\Console\Commands\CustomModule;  
11 -  
12 -use App\Models\CustomModule\CustomModuleCategory;  
13 -use App\Models\CustomModule\CustomModuleContent;  
14 -use App\Models\CustomModule\CustomModuleExtentContent;  
15 -use App\Models\RouteMap\RouteMap;  
16 -use App\Services\ProjectServer;  
17 -use Illuminate\Console\Command;  
18 -use Illuminate\Support\Facades\DB;  
19 -  
20 -class ImportCustomModule extends Command  
21 -{  
22 - /**  
23 - * The name and signature of the console command.  
24 - *  
25 - * @var string  
26 - */  
27 - protected $signature = 'import_custom_module';  
28 -  
29 - /**  
30 - * The console command description.  
31 - *  
32 - * @var string  
33 - */  
34 - protected $description = '特殊项目导入扩展模块及扩展数据';  
35 -  
36 - /**  
37 - * @remark :导入  
38 - * @name :handle  
39 - * @author :lyh  
40 - * @method :post  
41 - * @time :2024/12/9 11:36  
42 - */  
43 - public function handle(){  
44 - echo date('Y-m-d H:i:s') . 'project_id:' . PHP_EOL;  
45 - ProjectServer::useProject(2837);  
46 - $this->import_module_content();  
47 - DB::disconnect('custom_mysql');  
48 - }  
49 -  
50 - /**  
51 - * @remark :导入扩展模块 (保留)  
52 - * @name :ceshis  
53 - * @author :lyh  
54 - * @method :post  
55 - * @time :2024/12/6 17:02  
56 - */  
57 - public function import_module_content(){  
58 - $data = 'MBR10100CT,Rectifier/Schottky Barrier Rectifier,TO-220AB,100,5*2,common cathode,100,0.85,10,2500,175,-,Active,https://v6-file.globalso.com/upload/p/2837/files/MBR10100CT.pdf  
59 -MBR2060BCT,Rectifier/Schottky Barrier Rectifier,ITO-220AB,60,10*2,common cathode,150,0.75,50,5000,150,-,Active,https://v6-file.globalso.com/upload/p/2837/files/MBR2060BCT.pdf  
60 -MBR20150DCT,Rectifier/Schottky Barrier Rectifier,TO-263(D2PAK),150,10*2,common cathode,150,0.88,5,1500,175,-,Active,https://v6-file.globalso.com/upload/p/2837/files/MBR20150DCT.pdf  
61 -MUR2060CT,Rectifier/High Efficient Rectifier,TO-220AB,600,10*2,common cathode,150,1.7,1,500,150,50,Active,https://v6-file.globalso.com/upload/p/2837/files/MUR2060CT.pdf  
62 -MUR2040FCT,Rectifier/High Efficient Rectifier,ITO-220AB,400,10*2,common cathode,150,1.3,1,500,150,50,Active,https://v6-file.globalso.com/upload/p/2837/files/MUR2040FCT.pdf  
63 -DSEK20S04B,Rectifier/Ultra fast soft Recovery Rectifier,TO-252(DPAK),400,10*2,common cathode,125,1.25,2,500,175,35,Active,https://v6-file.globalso.com/upload/p/2837/files/DSEK20S04B.pdf  
64 -DSEK30S06D,Rectifier/Ultra fast soft Recovery Rectifier,TO-263(D2PAK),600,15*2,common cathode,150,1.7,2,500,175,35,Active,https://v6-file.globalso.com/upload/p/2837/files/DSEK30S06D.pdf  
65 -DSEK60H06P,Rectifier/Ultra fast soft Recovery Rectifier,TO-247AD,600,30*2,common cathode,300,1.7,5,500,175,60,Active,https://v6-file.globalso.com/upload/p/2837/files/DSEK60H06P.pdf  
66 -GBU410,Rectifier/Bridge Rectifier,GBU,1000,4,-,125,1,1,500,150,-,Active,https://v6-file.globalso.com/upload/p/2837/files/GBU410.pdf  
67 -GBU1510,Rectifier/Bridge Rectifier,GBU,1000,15,-,250,1,1,500,150,-,Active,https://v6-file.globalso.com/upload/p/2837/files/GBU1510.pdf  
68 -GBJ2510,Rectifier/Bridge Rectifier,GBJ,1000,25,-,300,1,1,500,150,-,Active,https://v6-file.globalso.com/upload/p/2837/files/GBJ2510.pdf  
69 -GBU1504H,Rectifier/High Efficient Bridge Rectifier,GBU,400,15,-,150,1.3,1,500,150,-,Active,https://v6-file.globalso.com/upload/p/2837/files/GBU1504H.pdf  
70 -GBU1506H,Rectifier/High Efficient Bridge Rectifier,GBU,400,15,-,150,1.7,1,500,150,-,Active,https://v6-file.globalso.com/upload/p/2837/files/GBU1506H.pdf  
71 -GBJ2504H,Rectifier/High Efficient Bridge Rectifier,GBJ,600,25,-,250,1.3,1,500,150,-,Active,https://v6-file.globalso.com/upload/p/2837/files/GBJ2504H.pdf  
72 -GBJ2506H,Rectifier/High Efficient Bridge Rectifier,GBJ,600,25,-,250,1.7,1,500,150,-,Active,https://v6-file.globalso.com/upload/p/2837/files/GBJ2506H.pdf  
73 -1N4007,Rectifier/Standard Recovery Rectifier,DO-41,1000,1,-,50,1,1,500,150,-,Active,https://v6-file.globalso.com/upload/p/2837/files/1N4007.pdf  
74 -1N5399,Rectifier/Standard Recovery Rectifier,DO-15,1000,1.5,-,75,1,1,500,150,-,Active,https://v6-file.globalso.com/upload/p/2837/files/1N5399.pdf  
75 -1N5408,Rectifier/Standard Recovery Rectifier,DO-27,1000,3,-,100,1,1,500,150,-,Active,https://v6-file.globalso.com/upload/p/2837/files/1N5408.pdf  
76 -RS1M,Rectifier/Fast Recovery Rectifier,SMA,1000,1,-,50,1.3,1,500,150,500,Active,https://v6-file.globalso.com/upload/p/2837/files/RS1M.pdf  
77 -RS2M,Rectifier/Fast Recovery Rectifier,SMB,1000,2,-,75,1.3,1,500,150,500,Active,https://v6-file.globalso.com/upload/p/2837/files/RS2M.pdf  
78 -RS3M,Rectifier/Fast Recovery Rectifier,SMC,1000,3,-,100,1.3,1,500,150,500,Active,https://v6-file.globalso.com/upload/p/2837/files/RS3M.pdf  
79 -SF28,Rectifier/Super fast Recovery Rectifier,DO-15,600,2,-,60,1.7,1,500,150,35,Active,https://v6-file.globalso.com/upload/p/2837/files/SF28.pdf  
80 -SF56G,Rectifier/Super fast Recovery Rectifier,DO-27,400,5,-,125,1.3,1,500,150,35,Active,https://v6-file.globalso.com/upload/p/2837/files/SF56G.pdf  
81 -DSE1006,Rectifier/Super fast Recovery Rectifier,TO-220AC,600,10,Single Positive,150,1.7,1,500,150,35,Active,https://v6-file.globalso.com/upload/p/2837/files/DSE1006.pdf  
82 -DSE1504F,Rectifier/Super fast Recovery Rectifier,ITO-220AC,400,15,Single Positive,150,1.4,1,500,150,35,Active,https://v6-file.globalso.com/upload/p/2837/files/DSE1504F.pdf';  
83 - $array = explode("\n", $data);  
84 - foreach ($array as $values){  
85 - $array1 = explode(',',$values);  
86 - $contentData = [  
87 - 'name'=>$array1[0],  
88 - 'route'=>'',  
89 - 'project_id'=>2837,  
90 - 'operator_id'=>6393,  
91 - 'module_id'=>2,  
92 - ];  
93 - $customModuleCategoryModel = new CustomModuleCategory();  
94 - if(!empty($array1[1])){  
95 - $cate_ids = '';  
96 - $cate_arr = explode('/',$array1[1]);  
97 - foreach ($cate_arr as $cateV){  
98 - $catInfo = $customModuleCategoryModel->read(['name'=>$cateV]);  
99 - if($catInfo !== false){  
100 - $cate_ids = $cate_ids.','.$catInfo['id'];  
101 - }  
102 - }  
103 - $contentData['category_id'] = empty($cate_ids) ? '' : $cate_ids.',';  
104 - }else{  
105 - $catInfo = $customModuleCategoryModel->read(['name'=>$array1[1]]);  
106 - if($catInfo !== false){  
107 - $contentData['category_id'] = ','.$catInfo['id'].',';  
108 - }  
109 - }  
110 - $customModuleContentModel = new CustomModuleContent();  
111 - $contentId = $customModuleContentModel->addReturnId($contentData);  
112 - $route = RouteMap::setRoute($array1[0],RouteMap::SOURCE_MODULE,$contentId,2837);  
113 - $customModuleContentModel->edit(['route'=>$route],['id'=>$contentId]);  
114 - $pd_extended_field_arr = [  
115 - [  
116 - 'key'=>'pd_extended_field_1',  
117 - 'type'=>1,  
118 - 'project_id'=>2837,  
119 - 'values'=>$array1[2],  
120 - 'content_id'=>$contentId,  
121 - 'module_id'=>2,  
122 - 'created_at'=>date('Y-m-d H:i:s'),  
123 - 'updated_at'=>date('Y-m-d H:i:s'),  
124 - ],  
125 - [  
126 - 'key'=>'pd_extended_field_2',  
127 - 'type'=>1,  
128 - 'project_id'=>2837,  
129 - 'values'=>$array1[3],  
130 - 'module_id'=>2,  
131 - 'content_id'=>$contentId,  
132 - 'created_at'=>date('Y-m-d H:i:s'),  
133 - 'updated_at'=>date('Y-m-d H:i:s'),  
134 - ],  
135 - [  
136 - 'key'=>'pd_extended_field_3',  
137 - 'type'=>1,  
138 - 'project_id'=>2837,  
139 - 'values'=>$array1[4],  
140 - 'module_id'=>2,  
141 - 'content_id'=>$contentId,  
142 - 'created_at'=>date('Y-m-d H:i:s'),  
143 - 'updated_at'=>date('Y-m-d H:i:s'),  
144 - ],  
145 - [  
146 - 'key'=>'pd_extended_field_4',  
147 - 'type'=>1,  
148 - 'project_id'=>2837,  
149 - 'values'=>$array1[5],  
150 - 'module_id'=>2,  
151 - 'content_id'=>$contentId,  
152 - 'created_at'=>date('Y-m-d H:i:s'),  
153 - 'updated_at'=>date('Y-m-d H:i:s'),  
154 - ],  
155 - [  
156 - 'key'=>'pd_extended_field_5',  
157 - 'type'=>1,  
158 - 'project_id'=>2837,  
159 - 'values'=>$array1[6],  
160 - 'module_id'=>2,  
161 - 'content_id'=>$contentId,  
162 - 'created_at'=>date('Y-m-d H:i:s'),  
163 - 'updated_at'=>date('Y-m-d H:i:s'),  
164 - ],  
165 - [  
166 - 'key'=>'pd_extended_field_6',  
167 - 'type'=>1,  
168 - 'project_id'=>2837,  
169 - 'values'=>$array1[7],  
170 - 'module_id'=>2,  
171 - 'content_id'=>$contentId,  
172 - 'created_at'=>date('Y-m-d H:i:s'),  
173 - 'updated_at'=>date('Y-m-d H:i:s'),  
174 - ],  
175 - [  
176 - 'key'=>'pd_extended_field_7',  
177 - 'type'=>1,  
178 - 'project_id'=>2837,  
179 - 'values'=>$array1[8],  
180 - 'module_id'=>2,  
181 - 'content_id'=>$contentId,  
182 - 'created_at'=>date('Y-m-d H:i:s'),  
183 - 'updated_at'=>date('Y-m-d H:i:s'),  
184 - ],  
185 - [  
186 - 'key'=>'pd_extended_field_8',  
187 - 'type'=>1,  
188 - 'project_id'=>2837,  
189 - 'values'=>$array1[9],  
190 - 'module_id'=>2,  
191 - 'content_id'=>$contentId,  
192 - 'created_at'=>date('Y-m-d H:i:s'),  
193 - 'updated_at'=>date('Y-m-d H:i:s'),  
194 - ],  
195 - [  
196 - 'key'=>'pd_extended_field_9',  
197 - 'type'=>1,  
198 - 'project_id'=>2837,  
199 - 'values'=>$array1[10],  
200 - 'module_id'=>2,  
201 - 'content_id'=>$contentId,  
202 - 'created_at'=>date('Y-m-d H:i:s'),  
203 - 'updated_at'=>date('Y-m-d H:i:s'),  
204 - ],  
205 - [  
206 - 'key'=>'pd_extended_field_10',  
207 - 'type'=>1,  
208 - 'project_id'=>2837,  
209 - 'values'=>$array1[11],  
210 - 'module_id'=>2,  
211 - 'content_id'=>$contentId,  
212 - 'created_at'=>date('Y-m-d H:i:s'),  
213 - 'updated_at'=>date('Y-m-d H:i:s'),  
214 - ],  
215 - [  
216 - 'key'=>'pd_extended_field_11',  
217 - 'type'=>1,  
218 - 'project_id'=>2837,  
219 - 'values'=>$array1[12],  
220 - 'module_id'=>2,  
221 - 'content_id'=>$contentId,  
222 - 'created_at'=>date('Y-m-d H:i:s'),  
223 - 'updated_at'=>date('Y-m-d H:i:s'),  
224 - ],  
225 - [  
226 - 'key'=>'pd_extended_field_12',  
227 - 'type'=>4,  
228 - 'project_id'=>2837,  
229 - 'values'=>json_encode([['url'=>$array1[13]]]),  
230 - 'module_id'=>2,  
231 - 'content_id'=>$contentId,  
232 - 'created_at'=>date('Y-m-d H:i:s'),  
233 - 'updated_at'=>date('Y-m-d H:i:s'),  
234 - ],  
235 - ];  
236 - $extendContentModel = new CustomModuleExtentContent();  
237 - $extendContentModel->insert($pd_extended_field_arr);  
238 - }  
239 - }  
240 -  
241 -}  
@@ -54,7 +54,7 @@ class LyhImportTest extends Command @@ -54,7 +54,7 @@ class LyhImportTest extends Command
54 public function handle(){ 54 public function handle(){
55 ProjectServer::useProject(3283); 55 ProjectServer::useProject(3283);
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->importProductCategory('https://ecdn6.globalso.com/upload/p/3283/file/2025-03/zy_boss_pricelistcat.csv',3283); 57 +// $this->importProduct('https://ecdn6.globalso.com/upload/p/3283/file/2025-03/2-1.csv',3283);
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 }
@@ -66,10 +66,11 @@ class UpdateRoute extends Command @@ -66,10 +66,11 @@ class UpdateRoute extends Command
66 foreach ($lists as $v){ 66 foreach ($lists as $v){
67 echo date('Y-m-d H:i:s') . '执行项目的project_id:'.$v['id'] . PHP_EOL; 67 echo date('Y-m-d H:i:s') . '执行项目的project_id:'.$v['id'] . PHP_EOL;
68 ProjectServer::useProject($v['id']); 68 ProjectServer::useProject($v['id']);
69 - $this->updateSeo($v['id']); 69 + $this->updateSeo();
70 DB::disconnect('custom_mysql'); 70 DB::disconnect('custom_mysql');
71 } 71 }
72 72
  73 +
73 // $this->updateProjectOp(); 74 // $this->updateProjectOp();
74 // $projectModel = new Project(); 75 // $projectModel = new Project();
75 // $lists = $projectModel->list(['delete_status'=>0],'id',['id']); 76 // $lists = $projectModel->list(['delete_status'=>0],'id',['id']);
@@ -526,22 +527,9 @@ class UpdateRoute extends Command @@ -526,22 +527,9 @@ class UpdateRoute extends Command
526 * @method :post 527 * @method :post
527 * @time :2025/3/14 14:39 528 * @time :2025/3/14 14:39
528 */ 529 */
529 - public function updateSeo($project_id){  
530 - $seoModel = new WebSettingSeo();  
531 - $seo_info = $seoModel->read(['project_id'=>$project_id]);  
532 - if($seo_info !== false){  
533 - $prefix = [];  
534 - $suffix = [];  
535 - if(!empty($seo_info['product_cate_prefix'])){  
536 - $prefix[] = ['val'=>[$seo_info['product_cate_prefix']],'level'=>1];  
537 - }  
538 - if(!empty($seo_info['product_cate_suffix'])){  
539 - $suffix[] = ['val'=>[$seo_info['product_cate_suffix']],'level'=>1];  
540 - }  
541 - if(!empty($prefix) && !empty($suffix)){  
542 - $seoModel->edit(['product_category_prefix'=>json_encode($prefix,true),'product_category_suffix'=>json_encode($suffix,true)],['project_id'=>$project_id]);  
543 - }  
544 - } 530 + public function updateSeo(){
  531 + $contentModel = new CustomModuleContent();
  532 + $contentModel->edit(['seo_title'=>''],['id'=>['!=',0]]);
545 return true; 533 return true;
546 } 534 }
547 } 535 }
@@ -32,7 +32,23 @@ class CategoryController extends BaseController @@ -32,7 +32,23 @@ class CategoryController extends BaseController
32 $this->map = $this->searchParam(); 32 $this->map = $this->searchParam();
33 $filed = ['id', 'project_id', 'pid', 'title', 'image', 'route', 'status','created_at','sort']; 33 $filed = ['id', 'project_id', 'pid', 'title', 'image', 'route', 'status','created_at','sort'];
34 $this->map['deleted_at'] = null; 34 $this->map['deleted_at'] = null;
35 - $this->map['pid'] = $this->map['pid'] ?? 0; 35 + if($this->user['project_id'] == 3283){//分类太多加载失败
  36 + $list = $this->get3283Lists($category,$filed);
  37 + return $this->response('success',Code::SUCCESS,$list);
  38 + }else{
  39 + $data = $this->getList($category,$filed);
  40 + return $this->response('success',Code::SUCCESS,$data);
  41 + }
  42 + }
  43 +
  44 + /**
  45 + * @remark :获取项目列表
  46 + * @name :getList
  47 + * @author :lyh
  48 + * @method :post
  49 + * @time :2025/3/19 14:41
  50 + */
  51 + public function getList(&$category,$filed){
36 $list = $category->list($this->map,['sort','id'],$filed); 52 $list = $category->list($this->map,['sort','id'],$filed);
37 $data = []; 53 $data = [];
38 if(!empty($list)){ 54 if(!empty($list)){
@@ -44,9 +60,52 @@ class CategoryController extends BaseController @@ -44,9 +60,52 @@ class CategoryController extends BaseController
44 $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST,$template_id,$v['id']); 60 $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST,$template_id,$v['id']);
45 $list[$k] = $v; 61 $list[$k] = $v;
46 } 62 }
  63 + if(!isset($this->map['title'])){
  64 + $data = $this->getListSon($list);
  65 + }else{
47 $data = $list; 66 $data = $list;
48 } 67 }
49 - return $this->response('success',Code::SUCCESS,$data); 68 + }
  69 + return $this->success($data);
  70 + }
  71 +
  72 + /**
  73 + * @remark :特殊项目特殊处理
  74 + * @name :get3283Lists
  75 + * @author :lyh
  76 + * @method :post
  77 + * @time :2025/3/19 14:38
  78 + */
  79 + public function get3283Lists(&$category,$filed){
  80 + if(!isset($this->map['title'])){
  81 + $this->map['pid'] = $this->map['pid'] ?? 0;
  82 + }
  83 + $list = $category->list($this->map,['sort','id'],$filed);
  84 + $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST);//获取模版id
  85 + foreach ($list as $k =>$v){
  86 + $v['url'] = $this->user['domain'] . $v['route'].'/';
  87 + $v['product_num'] = $category->getProductNum($list,$v['id']);
  88 + $v['hasChildren'] = $this->getCategoryHasChildren($category,$v['id']);
  89 + $v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
  90 + $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST,$template_id,$v['id']);
  91 + $list[$k] = $v;
  92 + }
  93 + return $this->success($list);
  94 + }
  95 +
  96 + /**
  97 + * @remark :查看是否拥有子集
  98 + * @name :getCategoryHasChildren
  99 + * @author :lyh
  100 + * @method :post
  101 + * @time :2025/3/20 9:18
  102 + */
  103 + public function getCategoryHasChildren(&$category,$id){
  104 + $count = $category->counts(['pid'=>$id]);
  105 + if($count != 0){
  106 + return true;
  107 + }
  108 + return false;
50 } 109 }
51 110
52 /** 111 /**
@@ -14,4 +14,17 @@ use App\Models\Base; @@ -14,4 +14,17 @@ use App\Models\Base;
14 class AiBlogTask extends Base 14 class AiBlogTask extends Base
15 { 15 {
16 protected $table = 'gl_ai_blog_task'; 16 protected $table = 'gl_ai_blog_task';
  17 +
  18 + /**
  19 + * 任务状态
  20 + */
  21 + const STATUS_RUNNING = 1;
  22 + const STATUS_FINISH = 2;
  23 +
  24 + /**
  25 + * 任务类型
  26 + */
  27 + const TYPE_AUTHOR = 1;
  28 + const TYPE_BLOG = 2;
  29 + const TYPE_VIDEO = 3;
17 } 30 }
@@ -15,7 +15,7 @@ class DingService @@ -15,7 +15,7 @@ class DingService
15 { 15 {
16 use RedisTrait; 16 use RedisTrait;
17 17
18 - const LINK = 'https://oapi.dingtalk.com/robot/send111?access_token=723c99369cc16806a26fee8b8ab2c5ae37a78ef842e6a3af89fed0b2a6211836'; 18 + const LINK = 'https://oapi.dingtalk.com/robot/send?access_token=2cdba958f11f24f961f13aba2d1acbcd60ed64c998a184492cc63814696e34e1';
19 const INFO = 'INFO'; 19 const INFO = 'INFO';
20 const ERROR = 'ERROR'; 20 const ERROR = 'ERROR';
21 const WARNNING = 'WARNNING'; 21 const WARNNING = 'WARNNING';
@@ -23,11 +23,11 @@ class DingService @@ -23,11 +23,11 @@ class DingService
23 23
24 24
25 /** 25 /**
26 - * @notes: 发送钉钉消息 同样的消息 1分钟内不重复  
27 - * @param array $body  
28 - * @return int|mixed  
29 - * @author:wlj  
30 - * @date: 2022/8/10 15:31 26 + * @remark :钉钉发送错误信息
  27 + * @name :handle
  28 + * @author :lyh
  29 + * @method :post
  30 + * @time :2025/3/19 18:03
31 */ 31 */
32 public function handle(array $body) 32 public function handle(array $body)
33 { 33 {