作者 刘锟

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

@@ -81,14 +81,16 @@ class Count extends Command @@ -81,14 +81,16 @@ class Count extends Command
81 $arr['updated_at'] = date('Y-m-d H:i:s'); 81 $arr['updated_at'] = date('Y-m-d H:i:s');
82 //询盘统计 82 //询盘统计
83 $arr = $this->inquiry($arr,$v['test_domain']); 83 $arr = $this->inquiry($arr,$v['test_domain']);
  84 + echo date('Y-m-d H:i:s') . json_encode($arr) . '->' . PHP_EOL;
84 $data[] = $arr; 85 $data[] = $arr;
85 } 86 }
86 //判断数据是否存在 87 //判断数据是否存在
87 DB::table('gl_count')->insert($data); 88 DB::table('gl_count')->insert($data);
88 } 89 }
89 }catch (\Exception $e){ 90 }catch (\Exception $e){
90 - Log::error('同步数据执行失败'); 91 + echo date('Y-m-d H:i:s') . ' error: ' . $v['test_domain'] . '->' . $e->getMessage() . PHP_EOL;
91 } 92 }
  93 + echo date('Y-m-d H:i:s') . ' end: ' . $v['test_domain'] . PHP_EOL;
92 echo $this->error; 94 echo $this->error;
93 } 95 }
94 96
@@ -126,6 +128,7 @@ class Count extends Command @@ -126,6 +128,7 @@ class Count extends Command
126 $inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000); 128 $inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
127 if($inquiry_list['status'] == self::STATUS_ERROR){ 129 if($inquiry_list['status'] == self::STATUS_ERROR){
128 $arr['inquiry_num'] = 0; 130 $arr['inquiry_num'] = 0;
  131 + $arr['country'] = json_encode([]);
129 }else{ 132 }else{
130 $arr['inquiry_num'] = $inquiry_list['data']['total']; 133 $arr['inquiry_num'] = $inquiry_list['data']['total'];
131 //询盘国家统计 134 //询盘国家统计
@@ -40,12 +40,8 @@ class UpdateProgress extends Command @@ -40,12 +40,8 @@ class UpdateProgress extends Command
40 */ 40 */
41 public function handle() 41 public function handle()
42 { 42 {
43 - while (true){  
44 - $project_id = Redis::rpop('updateProgress');  
45 - if(!$project_id){  
46 - sleep(2);  
47 - continue;  
48 - } 43 + $project_id = Redis::rpop('updateProgress');
  44 + while ($project_id){
49 echo date('Y-m-d H:i:s') . ' start: ' . $project_id . PHP_EOL; 45 echo date('Y-m-d H:i:s') . ' start: ' . $project_id . PHP_EOL;
50 try { 46 try {
51 ProjectServer::useProject($project_id); 47 ProjectServer::useProject($project_id);
@@ -152,20 +152,27 @@ class UpdateSeoTdk extends Command @@ -152,20 +152,27 @@ class UpdateSeoTdk extends Command
152 public function seo_tdk($project_id) 152 public function seo_tdk($project_id)
153 { 153 {
154 $data = []; 154 $data = [];
155 - $update = [];//更新统计 155 + $update = [
  156 + 'created_at'=>date('Y-m-d H:i:s'),
  157 + 'updated_at'=>date('Y-m-d H:i:s'),
  158 + 'project_id'=>$project_id,
  159 + ];//更新统计
156 $ai_commands = AiCommand::where('is_batch', 1)->select('key', 'scene', 'ai')->get()->toArray(); 160 $ai_commands = AiCommand::where('is_batch', 1)->select('key', 'scene', 'ai')->get()->toArray();
157 $ai_commands = Arr::setValueToKey($ai_commands, 'key'); 161 $ai_commands = Arr::setValueToKey($ai_commands, 'key');
158 foreach ($this->maps as $table => $map) { 162 foreach ($this->maps as $table => $map) {
159 $update[$table] = ['total_page'=>0, 'title'=>0, 'keyword'=>0, 'des'=>0]; 163 $update[$table] = ['total_page'=>0, 'title'=>0, 'keyword'=>0, 'des'=>0];
160 - echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . PHP_EOL;  
161 - $list = DB::connection('custom_mysql')->table($table)->get()->toArray(); 164 + echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . PHP_EOL . json_encode($update[$table]);
  165 + $list = DB::connection('custom_mysql')->table($table)->get();
162 if (!empty($list)) { 166 if (!empty($list)) {
  167 + $list = $list->toArray();
163 foreach ($list as $v) { 168 foreach ($list as $v) {
  169 + echo '打印数据:'.date('Y-m-d H:i:s') . $update[$table]['total_page'].PHP_EOL;
164 $update[$table]['total_page']++; 170 $update[$table]['total_page']++;
165 $v = (array)$v; 171 $v = (array)$v;
166 echo date('Y-m-d H:i:s') . '更新--' . $table . ':id' . $v['id'] . PHP_EOL; 172 echo date('Y-m-d H:i:s') . '更新--' . $table . ':id' . $v['id'] . PHP_EOL;
167 $data = []; 173 $data = [];
168 $json_field = ''; 174 $json_field = '';
  175 + echo date('Y-m-d H:i:s') . json_encode($map) . PHP_EOL;
169 foreach ($map as $ai_key => $field) { 176 foreach ($map as $ai_key => $field) {
170 $field_arr = explode('.', $field); 177 $field_arr = explode('.', $field);
171 if (count($field_arr) > 1) { 178 if (count($field_arr) > 1) {
@@ -185,7 +192,6 @@ class UpdateSeoTdk extends Command @@ -185,7 +192,6 @@ class UpdateSeoTdk extends Command
185 if(!$prompt){ 192 if(!$prompt){
186 continue; 193 continue;
187 } 194 }
188 -  
189 if (count($field_arr) > 1) { 195 if (count($field_arr) > 1) {
190 if($field_arr[1] == 'title'){ 196 if($field_arr[1] == 'title'){
191 $update[$table]['title']++; 197 $update[$table]['title']++;
@@ -202,7 +208,7 @@ class UpdateSeoTdk extends Command @@ -202,7 +208,7 @@ class UpdateSeoTdk extends Command
202 if($field == 'keywords' || $field == 'seo_keywords'){ 208 if($field == 'keywords' || $field == 'seo_keywords'){
203 $update[$table]['keyword']++; 209 $update[$table]['keyword']++;
204 } 210 }
205 - if($field == 'seo_description' || $field == 'description'){ 211 + if($field == 'seo_description' || $field == 'description' || $field == 'seo_des'){
206 $update[$table]['des']++; 212 $update[$table]['des']++;
207 } 213 }
208 $data[$field] = $this->ai_send($prompt); 214 $data[$field] = $this->ai_send($prompt);
@@ -229,14 +235,14 @@ class UpdateSeoTdk extends Command @@ -229,14 +235,14 @@ class UpdateSeoTdk extends Command
229 //使用核心关键词 235 //使用核心关键词
230 if(in_array($ai_key, array_keys($this->core_keyword_keys))){ 236 if(in_array($ai_key, array_keys($this->core_keyword_keys))){
231 $data[$field] = $this->mainKeywords($project_id, $this->core_keyword_keys[$ai_key]); 237 $data[$field] = $this->mainKeywords($project_id, $this->core_keyword_keys[$ai_key]);
232 - if(!empty($data[$field_arr[0]][$field_arr[1]])){ 238 + if(!empty($data[$field])){
233 if($field == 'title' || $field == 'seo_title'){ 239 if($field == 'title' || $field == 'seo_title'){
234 $update[$table]['title']++; 240 $update[$table]['title']++;
235 } 241 }
236 if($field == 'keywords' || $field == 'seo_keywords'){ 242 if($field == 'keywords' || $field == 'seo_keywords'){
237 $update[$table]['keyword']++; 243 $update[$table]['keyword']++;
238 } 244 }
239 - if($field == 'seo_description' || $field == 'description'){ 245 + if($field == 'seo_description' || $field == 'description' || $field == 'seo_des'){
240 $update[$table]['des']++; 246 $update[$table]['des']++;
241 } 247 }
242 } 248 }
@@ -254,11 +260,12 @@ class UpdateSeoTdk extends Command @@ -254,11 +260,12 @@ class UpdateSeoTdk extends Command
254 } 260 }
255 $data[$json_field] = json_encode($data[$json_field]); 261 $data[$json_field] = json_encode($data[$json_field]);
256 } 262 }
257 - $update[$table] = json_encode($update[$table]);  
258 DB::connection('custom_mysql')->table($table)->where(['id' => $v['id']])->update($data); 263 DB::connection('custom_mysql')->table($table)->where(['id' => $v['id']])->update($data);
259 } 264 }
  265 + $update[$table] = json_encode($update[$table]);
260 } 266 }
261 } 267 }
  268 + DB::table('gl_project_update_tdk')->insert($update);
262 } 269 }
263 270
264 public function getPrompt($project_id, $prompt, $table, $data){ 271 public function getPrompt($project_id, $prompt, $table, $data){
@@ -25,7 +25,7 @@ class Kernel extends ConsoleKernel @@ -25,7 +25,7 @@ class Kernel extends ConsoleKernel
25 $schedule->command('rank_data_recomm_domain')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-引荐域名,每周一凌晨执行一次 25 $schedule->command('rank_data_recomm_domain')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-引荐域名,每周一凌晨执行一次
26 $schedule->command('rank_data_week')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次 26 $schedule->command('rank_data_week')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次
27 // $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次 27 // $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次
28 - $schedule->command('count')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次 28 + $schedule->command('count')->dailyAt('01:00')->withoutOverlapping(1); //每天凌晨1点执行一次
29 $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次 29 $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次
30 $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次 30 $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次
31 $schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次 31 $schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次
@@ -36,6 +36,7 @@ class Kernel extends ConsoleKernel @@ -36,6 +36,7 @@ class Kernel extends ConsoleKernel
36 $schedule->command('inquiry_count')->dailyAt('01:00')->withoutOverlapping(1); // 询盘统计数据,每天凌晨执行一次 36 $schedule->command('inquiry_count')->dailyAt('01:00')->withoutOverlapping(1); // 询盘统计数据,每天凌晨执行一次
37 $schedule->command('domain_info')->dailyAt('01:00')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次 37 $schedule->command('domain_info')->dailyAt('01:00')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次
38 $schedule->command('last_inquiry')->dailyAt('04:00')->withoutOverlapping(1);// 最近一次询盘信息 38 $schedule->command('last_inquiry')->dailyAt('04:00')->withoutOverlapping(1);// 最近一次询盘信息
  39 + $schedule->command('update_progress')->everyThirtyMinutes()->withoutOverlapping(1);//监控更新
39 } 40 }
40 41
41 /** 42 /**
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 namespace App\Http\Controllers\Aside\Project; 3 namespace App\Http\Controllers\Aside\Project;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
  6 +use App\Helper\Arr;
6 use App\Helper\QuanqiusouApi; 7 use App\Helper\QuanqiusouApi;
7 use App\Http\Controllers\Aside\BaseController; 8 use App\Http\Controllers\Aside\BaseController;
8 use App\Http\Logic\Aside\Manage\ManageLogic; 9 use App\Http\Logic\Aside\Manage\ManageLogic;
@@ -25,6 +26,7 @@ use App\Models\Project\DeployBuild; @@ -25,6 +26,7 @@ use App\Models\Project\DeployBuild;
25 use App\Models\Project\DeployOptimize; 26 use App\Models\Project\DeployOptimize;
26 use App\Models\Project\Payment; 27 use App\Models\Project\Payment;
27 use App\Models\Project\Project; 28 use App\Models\Project\Project;
  29 +use App\Models\Project\ProjectUpdateTdk;
28 use App\Models\Project\RenewLog; 30 use App\Models\Project\RenewLog;
29 use App\Models\RankData\RankData; 31 use App\Models\RankData\RankData;
30 use App\Models\Task\Task; 32 use App\Models\Task\Task;
@@ -701,5 +703,68 @@ class ProjectController extends BaseController @@ -701,5 +703,68 @@ class ProjectController extends BaseController
701 $this->response('success',Code::SUCCESS,$lists); 703 $this->response('success',Code::SUCCESS,$lists);
702 } 704 }
703 705
  706 + /**
  707 + * @remark :tdk更新记录
  708 + * @name :tdkList
  709 + * @author :lyh
  710 + * @method :post
  711 + * @time :2023/11/8 11:17
  712 + */
  713 + public function tdkList(){
  714 + $this->request->validate([
  715 + 'project_id'=>'required',
  716 + ],[
  717 + 'project_id.required' => '项目ID不能为空',
  718 + ]);
  719 + $tdkModel = new ProjectUpdateTdk();
  720 + $list = $tdkModel->list(['project_id'=>$this->map['project_id']],'id',['*'],'desc',5);
  721 + if(!empty($list)){
  722 + foreach ($list as $k => $v){
  723 + $list[$k] = $this->handleTdk($v);
  724 + }
  725 + }
  726 + $this->response('success',Code::SUCCESS,$list);
  727 + }
  728 +
  729 + public function handleTdk($item){
  730 + $data = [
  731 + 'gl_product'=>'产品',
  732 + 'gl_product_category'=>'产品分类',
  733 + 'gl_product_keyword'=>'产品关键字',
  734 + 'gl_news'=>'新闻',
  735 + 'gl_news_category'=>'新闻分类',
  736 + 'gl_blog'=>'博客',
  737 + 'gl_blog_category'=>'博客分类',
  738 + 'gl_web_custom_template'=>'自定义页面',
  739 + ];
  740 + foreach ($data as $k => $v){
  741 + if(isset($item[$k])){
  742 + $item[$k] = Arr::s2a($item[$k]);
  743 + $item[$k] = $v.'总条数:'.$item[$k]['total_page'].
  744 + ', title更新数:'.$item[$k]['title'].
  745 + ',keyword更新数据:'.$item[$k]['keyword'].
  746 + ',des更新数据:'.$item[$k]['des'];
  747 + }
  748 +
  749 + }
  750 + return $item;
  751 + }
  752 +
  753 + /**
  754 + * @remark :复制项目
  755 + * @name :copyProject
  756 + * @author :lyh
  757 + * @method :post
  758 + * @time :2023/11/8 14:17
  759 + */
  760 + public function copyProject(ProjectLogic $logic){
  761 + $this->request->validate([
  762 + 'project_id'=>'required',
  763 + ],[
  764 + 'project_id.required' => 'project_id不能为空',
  765 + ]);
  766 + $data = $logic->copyProject();
  767 + $this->response('success',Code::SUCCESS,$data);
  768 + }
704 769
705 } 770 }
@@ -513,4 +513,29 @@ class ProjectLogic extends BaseLogic @@ -513,4 +513,29 @@ class ProjectLogic extends BaseLogic
513 } 513 }
514 } 514 }
515 } 515 }
  516 +
  517 + /**
  518 + * @remark :复制项目
  519 + * @name :copyProject
  520 + * @author :lyh
  521 + * @method :post
  522 + * @time :2023/11/8 14:23
  523 + */
  524 + public function copyProject(){
  525 + //复制初始项目
  526 + $data = $this->model::where('id', $this->param['project_id'])->first();
  527 + $data = $data->getAttributes();
  528 + unset($data['id']);
  529 + $project_id = $this->model->insertGetId($data);
  530 + //复制部署表
  531 + $buildModel = new DeployBuild();
  532 + $buildData = $buildModel::where('id', $this->param['project_id'])->first();
  533 + $buildData = $buildData->getAttributes();
  534 + $buildData['project_id'] = $project_id;
  535 + unset($buildData['id']);
  536 + $buildModel->insert($buildData);
  537 + //复制优化表
  538 + $optimizeModel = new DeployOptimize();
  539 + return $this->success($data);
  540 + }
516 } 541 }
@@ -63,11 +63,14 @@ class CustomTemplateLogic extends BaseLogic @@ -63,11 +63,14 @@ class CustomTemplateLogic extends BaseLogic
63 try { 63 try {
64 $this->param['url'] = str_replace_url($this->param['url']); 64 $this->param['url'] = str_replace_url($this->param['url']);
65 if(isset($this->param['id']) && !empty($this->param['id'])){ 65 if(isset($this->param['id']) && !empty($this->param['id'])){
66 - $id = $this->editCustomRoute($this->param['id'],$this->param['url']); 66 + $id = $this->param['id'];
  67 + $this->param['url'] = $this->editCustomRoute($this->param['url']);
67 $this->model->edit($this->param,['id'=>$this->param['id']]); 68 $this->model->edit($this->param,['id'=>$this->param['id']]);
68 }else{ 69 }else{
69 if($this->param['url'] == $this->model::NOT_FOUND_PAGE_URL){ 70 if($this->param['url'] == $this->model::NOT_FOUND_PAGE_URL){
70 $this->fail('404页面已存在'); 71 $this->fail('404页面已存在');
  72 + }else{
  73 + $this->param['url'] = $this->param['url'].'-tag';
71 } 74 }
72 $this->param['project_id'] = $this->user['project_id']; 75 $this->param['project_id'] = $this->user['project_id'];
73 $id = $this->model->addReturnId($this->param); 76 $id = $this->model->addReturnId($this->param);
@@ -166,7 +169,7 @@ class CustomTemplateLogic extends BaseLogic @@ -166,7 +169,7 @@ class CustomTemplateLogic extends BaseLogic
166 * @method :post 169 * @method :post
167 * @time :2023/9/7 10:02 170 * @time :2023/9/7 10:02
168 */ 171 */
169 - public function editCustomRoute($id,$route){ 172 + public function editCustomRoute($route){
170 $info = $this->model->read(['id'=>$this->param['id']]); 173 $info = $this->model->read(['id'=>$this->param['id']]);
171 if($info['url'] == $this->model::NOT_FOUND_PAGE_URL && $route['url'] != '404'){ 174 if($info['url'] == $this->model::NOT_FOUND_PAGE_URL && $route['url'] != '404'){
172 $this->fail('404页面链接不可修改'); 175 $this->fail('404页面链接不可修改');
@@ -178,8 +181,12 @@ class CustomTemplateLogic extends BaseLogic @@ -178,8 +181,12 @@ class CustomTemplateLogic extends BaseLogic
178 'route'=>$info['url'], 181 'route'=>$info['url'],
179 ]; 182 ];
180 $this->setRouteDeleteSave($data); 183 $this->setRouteDeleteSave($data);
  184 + //"字符串以\"-product\"结尾"
  185 + if (!endsWith($route, "-tag")) {
  186 + $route = $route."-tag";
  187 + }
181 } 188 }
182 - return $id; 189 + return $route;
183 } 190 }
184 191
185 /** 192 /**
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 namespace App\Http\Logic\Bside\Blog; 3 namespace App\Http\Logic\Bside\Blog;
4 4
  5 +use App\Helper\Translate;
5 use App\Http\Logic\Bside\BaseLogic; 6 use App\Http\Logic\Bside\BaseLogic;
6 use App\Models\Blog\Blog as BlogModel; 7 use App\Models\Blog\Blog as BlogModel;
7 use App\Models\Blog\BlogCategory as BlogCategoryModel; 8 use App\Models\Blog\BlogCategory as BlogCategoryModel;
@@ -32,19 +33,23 @@ class BlogCategoryLogic extends BaseLogic @@ -32,19 +33,23 @@ class BlogCategoryLogic extends BaseLogic
32 try { 33 try {
33 if(isset($this->param['id']) && !empty($this->param['id'])){ 34 if(isset($this->param['id']) && !empty($this->param['id'])){
34 //查看路由是否更新 35 //查看路由是否更新
35 - $id = $this->editCategoryRoute($this->param['id'], $this->param['alias']); 36 + $id = $this->param['id'];
  37 + $this->editCategoryRoute($this->param['id'], $this->param['alias']);
36 $this->editHandleCategory($this->param['id'],$this->param['pid']); 38 $this->editHandleCategory($this->param['id'],$this->param['pid']);
37 $this->param['operator_id'] = $this->user['id']; 39 $this->param['operator_id'] = $this->user['id'];
38 $this->edit($this->param,['id'=>$this->param['id']]); 40 $this->edit($this->param,['id'=>$this->param['id']]);
39 }else{ 41 }else{
  42 + //路由拼接
  43 + if(!isset($this->param['alias']) || empty($this->param['alias'])){
  44 + $this->param['alias'] = Translate::tran($this->param['name'], 'en');
  45 + }
40 //拼接参数 46 //拼接参数
41 $this->param = $this->addParamProcessing($this->param); 47 $this->param = $this->addParamProcessing($this->param);
42 $id = $this->model->addReturnId($this->param); 48 $id = $this->model->addReturnId($this->param);
43 //处理子集 49 //处理子集
44 $this->addProcessingSon($id); 50 $this->addProcessingSon($id);
45 } 51 }
46 - $route = RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'],  
47 - RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']); 52 + $route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']);
48 $this->edit(['alias'=>$route],['id'=>$id]); 53 $this->edit(['alias'=>$route],['id'=>$id]);
49 DB::commit(); 54 DB::commit();
50 }catch (\Exception $e){ 55 }catch (\Exception $e){
@@ -115,7 +120,7 @@ class BlogCategoryLogic extends BaseLogic @@ -115,7 +120,7 @@ class BlogCategoryLogic extends BaseLogic
115 ]; 120 ];
116 $this->setRouteDeleteSave($data); 121 $this->setRouteDeleteSave($data);
117 } 122 }
118 - return $this->success($id); 123 + return true;
119 } 124 }
120 125
121 /** 126 /**
@@ -35,7 +35,8 @@ class BlogLogic extends BaseLogic @@ -35,7 +35,8 @@ class BlogLogic extends BaseLogic
35 $this->param = $this->paramProcessing($this->param); 35 $this->param = $this->paramProcessing($this->param);
36 if(isset($this->param['id']) && !empty($this->param['id'])){ 36 if(isset($this->param['id']) && !empty($this->param['id'])){
37 //是否更新路由 37 //是否更新路由
38 - $id = $this->editNewsRoute($this->param['id'],$this->param['url']); 38 + $id = $this->param['id'];
  39 + $this->editNewsRoute($this->param['id'],$this->param['url']);
39 $this->edit($this->param,['id'=>$this->param['id']]); 40 $this->edit($this->param,['id'=>$this->param['id']]);
40 }else{ 41 }else{
41 $this->param['url'] = $this->param['url'].'-'.RouteMap::SOURCE_BLOG; 42 $this->param['url'] = $this->param['url'].'-'.RouteMap::SOURCE_BLOG;
@@ -70,7 +71,7 @@ class BlogLogic extends BaseLogic @@ -70,7 +71,7 @@ class BlogLogic extends BaseLogic
70 ]; 71 ];
71 $this->setRouteDeleteSave($data); 72 $this->setRouteDeleteSave($data);
72 } 73 }
73 - return $id; 74 + return true;
74 } 75 }
75 76
76 /** 77 /**
@@ -46,16 +46,20 @@ class NewsCategoryLogic extends BaseLogic @@ -46,16 +46,20 @@ class NewsCategoryLogic extends BaseLogic
46 if(isset($this->param['id']) && !empty($this->param['id'])){ 46 if(isset($this->param['id']) && !empty($this->param['id'])){
47 $this->param['operator_id'] = $this->user['id']; 47 $this->param['operator_id'] = $this->user['id'];
48 //查看路由是否更新 48 //查看路由是否更新
49 - $id = $this->editCategoryRoute($this->param['id'],$this->param['alias']); 49 + $id = $this->param['id'];
  50 + $this->editCategoryRoute($this->param['id'],$this->param['alias']);
50 $this->editHandleCategory($this->param['id'],$this->param['pid']); 51 $this->editHandleCategory($this->param['id'],$this->param['pid']);
51 $this->edit($this->param,['id'=>$this->param['id']]); 52 $this->edit($this->param,['id'=>$this->param['id']]);
52 }else{ 53 }else{
  54 + if(!isset($this->param['alias']) || empty($this->param['alias'])){
  55 + $this->param['alias'] = Translate::tran($this->param['name'], 'en');
  56 + }
53 $this->param = $this->addParamProcessing($this->param); 57 $this->param = $this->addParamProcessing($this->param);
54 $id = $this->model->addReturnId($this->param); 58 $id = $this->model->addReturnId($this->param);
55 //当父级分类拥有产品时,处理子集 59 //当父级分类拥有产品时,处理子集
56 $this->addProcessingSon($id); 60 $this->addProcessingSon($id);
57 } 61 }
58 - $route = RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']); 62 + $route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
59 $this->model->edit(['alias'=>$route],['id'=>$id]); 63 $this->model->edit(['alias'=>$route],['id'=>$id]);
60 DB::commit(); 64 DB::commit();
61 }catch (\Exception $e){ 65 }catch (\Exception $e){
@@ -126,7 +130,7 @@ class NewsCategoryLogic extends BaseLogic @@ -126,7 +130,7 @@ class NewsCategoryLogic extends BaseLogic
126 ]; 130 ];
127 $this->setRouteDeleteSave($data); 131 $this->setRouteDeleteSave($data);
128 } 132 }
129 - return $id; 133 + return true;
130 } 134 }
131 135
132 136
@@ -64,7 +64,8 @@ class NewsLogic extends BaseLogic @@ -64,7 +64,8 @@ class NewsLogic extends BaseLogic
64 $this->param = $this->paramProcessing($this->param); 64 $this->param = $this->paramProcessing($this->param);
65 if (isset($this->param['id']) && !empty($this->param['id'])) { 65 if (isset($this->param['id']) && !empty($this->param['id'])) {
66 //是否更新路由 66 //是否更新路由
67 - $id = $this->editNewsRoute($this->param['id'], $this->param['url']); 67 + $this->editNewsRoute($this->param['id'], $this->param['url']);
  68 + $id = $this->param['id'];
68 $this->edit($this->param, ['id' => $this->param['id']]); 69 $this->edit($this->param, ['id' => $this->param['id']]);
69 } else { 70 } else {
70 $this->param['url'] = $this->param['url'].'-'.RouteMap::SOURCE_NEWS; 71 $this->param['url'] = $this->param['url'].'-'.RouteMap::SOURCE_NEWS;
@@ -101,7 +102,7 @@ class NewsLogic extends BaseLogic @@ -101,7 +102,7 @@ class NewsLogic extends BaseLogic
101 ]; 102 ];
102 $this->setRouteDeleteSave($data); 103 $this->setRouteDeleteSave($data);
103 } 104 }
104 - return $id; 105 + return true;
105 } 106 }
106 107
107 108
@@ -115,6 +115,7 @@ class CategoryLogic extends BaseLogic @@ -115,6 +115,7 @@ class CategoryLogic extends BaseLogic
115 if(isset($this->param['id']) && !empty($this->param['id'])){ 115 if(isset($this->param['id']) && !empty($this->param['id'])){
116 //是否编辑路由 116 //是否编辑路由
117 $id = $this->editCategoryRoute($this->param['id'],$this->param['route']); 117 $id = $this->editCategoryRoute($this->param['id'],$this->param['route']);
  118 + //处理子集
118 $this->editHandleCategory($this->param['id'],$this->param['pid']); 119 $this->editHandleCategory($this->param['id'],$this->param['pid']);
119 $this->model->edit($this->param,['id'=>$this->param['id']]); 120 $this->model->edit($this->param,['id'=>$this->param['id']]);
120 }else{ 121 }else{
@@ -154,7 +155,6 @@ class CategoryLogic extends BaseLogic @@ -154,7 +155,6 @@ class CategoryLogic extends BaseLogic
154 //查看当前上级分类下是否有其他子分类 155 //查看当前上级分类下是否有其他子分类
155 $cate_info = $this->model->read(['pid' => $this->param['pid'], 'id' => ['!=', $cate_id]]); 156 $cate_info = $this->model->read(['pid' => $this->param['pid'], 'id' => ['!=', $cate_id]]);
156 if ($cate_info === false) { 157 if ($cate_info === false) {
157 - //查看当前上一级分类下是否有新闻  
158 $productModel = new Product(); 158 $productModel = new Product();
159 $blog_count = $productModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count(); 159 $blog_count = $productModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count();
160 if ($blog_count > 0) { 160 if ($blog_count > 0) {
@@ -163,6 +163,9 @@ class CategoryLogic extends BaseLogic @@ -163,6 +163,9 @@ class CategoryLogic extends BaseLogic
163 //更新所有商品到当前分类 163 //更新所有商品到当前分类
164 $productModel->where('category_id', 'like', '%' . $old . '%') 164 $productModel->where('category_id', 'like', '%' . $old . '%')
165 ->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]); 165 ->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]);
  166 + //同步更新关联表
  167 + $categoryRelatedModel = new CategoryRelated();
  168 + $categoryRelatedModel->edit(['category_id'=>$cate_id],['category_id'=>$this->param['pid']]);
166 } 169 }
167 } 170 }
168 } 171 }
@@ -190,6 +193,15 @@ class CategoryLogic extends BaseLogic @@ -190,6 +193,15 @@ class CategoryLogic extends BaseLogic
190 ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',')")]); 193 ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',')")]);
191 $productModel->where('category_id', 'like', '%,' . $pid . ',%') 194 $productModel->where('category_id', 'like', '%,' . $pid . ',%')
192 ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',$replacement,')")]); 195 ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',$replacement,')")]);
  196 + //同步更新关联表
  197 + $categoryRelatedModel = new CategoryRelated();
  198 + $cateRelateList = $categoryRelatedModel->list(['category_id'=>$pid]);
  199 + if(!empty($cateRelateList)){
  200 + foreach ($cateRelateList as $v){
  201 + $categoryRelatedModel->del(['category_id'=>$replacement,'product_id'=>$v['product_id']]);
  202 + }
  203 + }
  204 + $categoryRelatedModel->edit(['category_id'=>$replacement],['category_id'=>$pid]);
193 } 205 }
194 } 206 }
195 return $this->success(); 207 return $this->success();
@@ -60,9 +60,10 @@ class KeywordLogic extends BaseLogic @@ -60,9 +60,10 @@ class KeywordLogic extends BaseLogic
60 $this->param['project_id'] = $this->user['project_id']; 60 $this->param['project_id'] = $this->user['project_id'];
61 $this->param['created_at'] = date('Y-m-d H:i:s'); 61 $this->param['created_at'] = date('Y-m-d H:i:s');
62 $this->param['updated_at'] = $this->param['created_at']; 62 $this->param['updated_at'] = $this->param['created_at'];
  63 + $this->param['route'] = $this->param['route'].'-'.RouteMap::SOURCE_PRODUCT;
63 $id = $this->model->insertGetId($this->param); 64 $id = $this->model->insertGetId($this->param);
64 //路由映射 65 //路由映射
65 - $route = RouteMap::setRoute($this->param['title'].'-tag', RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); 66 + $route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
66 $this->model->edit(['route'=>$route],['id'=>$id]); 67 $this->model->edit(['route'=>$route],['id'=>$id]);
67 } 68 }
68 //清除缓存 69 //清除缓存
@@ -200,7 +201,6 @@ class KeywordLogic extends BaseLogic @@ -200,7 +201,6 @@ class KeywordLogic extends BaseLogic
200 201
201 //清除缓存 202 //清除缓存
202 Common::del_user_cache('product_keyword',$project_id); 203 Common::del_user_cache('product_keyword',$project_id);
203 -  
204 return ','.implode(',',$return).','; 204 return ','.implode(',',$return).',';
205 } 205 }
206 } 206 }
@@ -37,26 +37,31 @@ class ProductLogic extends BaseLogic @@ -37,26 +37,31 @@ class ProductLogic extends BaseLogic
37 * @time :2023/8/21 18:35 37 * @time :2023/8/21 18:35
38 */ 38 */
39 public function productSave(){ 39 public function productSave(){
40 - //参数处理  
41 $this->param = $this->handleSaveParam($this->param); 40 $this->param = $this->handleSaveParam($this->param);
  41 + //单独处理分类
  42 + $category_ids = [];
  43 + if(isset($this->param['category_id']) && !empty($this->param['category_id'])) {
  44 + $category_ids = $this->getLastCategoryArr($this->param['category_id']);
  45 + $this->param['category_id'] = ','.implode(',',$category_ids).',';
  46 + }
42 DB::connection('custom_mysql')->beginTransaction(); 47 DB::connection('custom_mysql')->beginTransaction();
43 try { 48 try {
44 if(isset($this->param['id']) && !empty($this->param['id'])){ 49 if(isset($this->param['id']) && !empty($this->param['id'])){
  50 + $id = $this->param['id'];
45 //查看路由是否更新 51 //查看路由是否更新
46 - $id = $this->editProductRoute($this->param['id'],$this->param['route']); 52 + $this->param['route'] = $this->editProductRoute($this->param['route']);
47 $this->model->edit($this->param,['id'=>$this->param['id']]); 53 $this->model->edit($this->param,['id'=>$this->param['id']]);
48 }else{ 54 }else{
49 $this->param['project_id'] = $this->user['project_id']; 55 $this->param['project_id'] = $this->user['project_id'];
50 $this->param['created_at'] = date('Y-m-d H:i:s'); 56 $this->param['created_at'] = date('Y-m-d H:i:s');
51 $this->param['updated_at'] = $this->param['created_at']; 57 $this->param['updated_at'] = $this->param['created_at'];
52 - //路由映射  
53 $this->param['route'] = $this->param['route'].'-'.RouteMap::SOURCE_PRODUCT; 58 $this->param['route'] = $this->param['route'].'-'.RouteMap::SOURCE_PRODUCT;
54 $id = $this->model->addReturnId($this->param); 59 $id = $this->model->addReturnId($this->param);
55 } 60 }
56 $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']); 61 $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
57 $this->model->edit(['route'=>$route],['id'=>$id]); 62 $this->model->edit(['route'=>$route],['id'=>$id]);
58 //产品分类关联 63 //产品分类关联
59 -// CategoryRelated::saveRelated($id, $category_ids); 64 + CategoryRelated::saveRelated($id, $category_ids);
60 DB::connection('custom_mysql')->commit(); 65 DB::connection('custom_mysql')->commit();
61 }catch (\Exception $e){ 66 }catch (\Exception $e){
62 DB::connection('custom_mysql')->rollBack(); 67 DB::connection('custom_mysql')->rollBack();
@@ -135,9 +140,6 @@ class ProductLogic extends BaseLogic @@ -135,9 +140,6 @@ class ProductLogic extends BaseLogic
135 } 140 }
136 $param['attrs'] = Arr::a2s($param['attrs'] ?? ''); 141 $param['attrs'] = Arr::a2s($param['attrs'] ?? '');
137 $param['attr_id'] = Arr::arrToSet($param['attr_id'] ?? ''); 142 $param['attr_id'] = Arr::arrToSet($param['attr_id'] ?? '');
138 - if(isset($param['category_id']) && !empty($param['category_id'])) {  
139 - $param['category_id'] = $this->getLastCategory($param['category_id']);  
140 - }  
141 if(isset($param['keyword_id']) && !empty($param['keyword_id'])){ 143 if(isset($param['keyword_id']) && !empty($param['keyword_id'])){
142 $param['keyword_id'] = ','.Arr::arrToSet($param['keyword_id']).','; 144 $param['keyword_id'] = ','.Arr::arrToSet($param['keyword_id']).',';
143 } 145 }
@@ -156,7 +158,7 @@ class ProductLogic extends BaseLogic @@ -156,7 +158,7 @@ class ProductLogic extends BaseLogic
156 } 158 }
157 159
158 /** 160 /**
159 - * @remark :获取最后一级分类id 161 + * @remark :获取最后一级分类id(字符串)
160 * @name :getLastCategory 162 * @name :getLastCategory
161 * @author :lyh 163 * @author :lyh
162 * @method :post 164 * @method :post
@@ -177,13 +179,34 @@ class ProductLogic extends BaseLogic @@ -177,13 +179,34 @@ class ProductLogic extends BaseLogic
177 } 179 }
178 180
179 /** 181 /**
  182 + * @remark :获取最后一级分类id(数组)
  183 + * @name :getLastCategory
  184 + * @author :lyh
  185 + * @method :post
  186 + * @time :2023/10/20 9:02
  187 + */
  188 + public function getLastCategoryArr($category){
  189 + $arr = [];
  190 + if(isset($category) && !empty($category)){
  191 + $cateModel = new Category();
  192 + foreach ($category as $v){
  193 + $info = $cateModel->read(['pid'=>$v]);
  194 + if($info === false){
  195 + $arr[] = $v;
  196 + }
  197 + }
  198 + }
  199 + return $arr;
  200 + }
  201 +
  202 + /**
180 * @remark :编辑产品 203 * @remark :编辑产品
181 * @name :editProduct 204 * @name :editProduct
182 * @author :lyh 205 * @author :lyh
183 * @method :post 206 * @method :post
184 * @time :2023/9/7 10:02 207 * @time :2023/9/7 10:02
185 */ 208 */
186 - public function editProductRoute($id,$route){ 209 + public function editProductRoute($route){
187 $info = $this->model->read(['id'=>$this->param['id']]); 210 $info = $this->model->read(['id'=>$this->param['id']]);
188 if($info['route'] != $route){ 211 if($info['route'] != $route){
189 //生成一条删除路由记录 212 //生成一条删除路由记录
@@ -192,8 +215,12 @@ class ProductLogic extends BaseLogic @@ -192,8 +215,12 @@ class ProductLogic extends BaseLogic
192 'route'=>$route, 215 'route'=>$route,
193 ]; 216 ];
194 $this->setRouteDeleteSave($data); 217 $this->setRouteDeleteSave($data);
  218 + //"字符串以\"-product\"结尾"
  219 + if (!endsWith($route, "-product")) {
  220 + $route = $route."-product";
  221 + }
195 } 222 }
196 - return $id; 223 + return $route;
197 } 224 }
198 225
199 /** 226 /**
@@ -410,23 +437,27 @@ class ProductLogic extends BaseLogic @@ -410,23 +437,27 @@ class ProductLogic extends BaseLogic
410 * @time :2023/8/15 17:53 437 * @time :2023/8/15 17:53
411 */ 438 */
412 public function batchSetCategory(){ 439 public function batchSetCategory(){
413 - DB::connection('custom_mysql')->beginTransaction();  
414 - try {  
415 - //批量  
416 - $param = [  
417 - 'category_id'=>','.Arr::arrToSet($this->param['category_id']).',',  
418 - 'status'=>$this->param['status']  
419 - ];  
420 - $this->model->edit($param,['id'=>['in',$this->param['id']]]);  
421 - //分类关联  
422 - foreach ($this->param['id'] as $id){  
423 - CategoryRelated::saveRelated($id, $this->param['category_id']);  
424 - }  
425 - DB::connection('custom_mysql')->commit();  
426 - //对应添加关联表  
427 - }catch (\Exception $e){  
428 - DB::connection('custom_mysql')->rollBack();  
429 - $this->fail('系统错误,请联系管理员'); 440 + if(isset($this->param['category_id']) && !empty($this->param['category_id'])) {
  441 + DB::connection('custom_mysql')->beginTransaction();
  442 + $category_ids = $this->getLastCategoryArr($this->param['category_id']);
  443 + $this->param['category_id'] = ','.implode(',',$category_ids).',';
  444 + try {
  445 + //批量
  446 + $param = [
  447 + 'category_id'=>$this->param['category_id'],
  448 + 'status'=>$this->param['status']
  449 + ];
  450 + $this->model->edit($param,['id'=>['in',$this->param['id']]]);
  451 + //分类关联
  452 + foreach ($this->param['id'] as $id){
  453 + CategoryRelated::saveRelated($id, $category_ids);
  454 + }
  455 + DB::connection('custom_mysql')->commit();
  456 + //对应添加关联表
  457 + }catch (\Exception $e){
  458 + DB::connection('custom_mysql')->rollBack();
  459 + $this->fail('系统错误,请联系管理员');
  460 + }
430 } 461 }
431 return $this->success(); 462 return $this->success();
432 } 463 }
@@ -3,6 +3,8 @@ @@ -3,6 +3,8 @@
3 namespace App\Models; 3 namespace App\Models;
4 4
5 use Illuminate\Database\Eloquent\Model; 5 use Illuminate\Database\Eloquent\Model;
  6 +use Illuminate\Support\Facades\DB;
  7 +
6 class Base extends Model 8 class Base extends Model
7 { 9 {
8 protected $table = ''; 10 protected $table = '';
@@ -51,9 +53,12 @@ class Base extends Model @@ -51,9 +53,12 @@ class Base extends Model
51 * @author :liyuhang 53 * @author :liyuhang
52 * @method 54 * @method
53 */ 55 */
54 - public function list($map = [],$order = 'id',$fields = ['*'],$sort = 'desc'): array 56 + public function list($map = [],$order = 'id',$fields = ['*'],$sort = 'desc',$row = 0): array
55 { 57 {
56 $query = $this->formatQuery($map); 58 $query = $this->formatQuery($map);
  59 + if($row != 0){
  60 + $query = $query->limit($row);
  61 + }
57 $query = $this->sortOrder($query,$order,$sort); 62 $query = $this->sortOrder($query,$order,$sort);
58 $lists = $query->select($fields)->get(); 63 $lists = $query->select($fields)->get();
59 if (empty($lists)) { 64 if (empty($lists)) {
@@ -32,15 +32,17 @@ class CategoryRelated extends Base @@ -32,15 +32,17 @@ class CategoryRelated extends Base
32 } 32 }
33 //先删除 33 //先删除
34 self::where('product_id', $product_id)->delete(); 34 self::where('product_id', $product_id)->delete();
35 -  
36 //批量保存 35 //批量保存
37 $data = []; 36 $data = [];
38 - foreach ($cate_ids as $cate_id){  
39 - $data[] = [  
40 - 'product_id' => $product_id,  
41 - 'cate_id' => $cate_id  
42 - ]; 37 + if(!empty($cate_ids)){
  38 + foreach ($cate_ids as $cate_id){
  39 + $data[] = [
  40 + 'product_id' => $product_id,
  41 + 'cate_id' => $cate_id
  42 + ];
  43 + }
  44 + self::insert($data);
43 } 45 }
44 - self::insert($data); 46 + return true;
45 } 47 }
46 } 48 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ProjectUpdateTdk.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/11/8 11:18
  8 + */
  9 +
  10 +namespace App\Models\Project;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class ProjectUpdateTdk extends Base
  15 +{
  16 + //设置关联表名
  17 + protected $table = 'gl_project_update_tdk';
  18 +}
@@ -109,6 +109,15 @@ class RouteMap extends Base @@ -109,6 +109,15 @@ class RouteMap extends Base
109 if(!$route_map){ 109 if(!$route_map){
110 $route_map = new self(); 110 $route_map = new self();
111 $route_map->source = $source; 111 $route_map->source = $source;
  112 + if($source == self::SOURCE_NEWS){
  113 + $route_map->path = self::SOURCE_NEWS;
  114 + }elseif($source == self::SOURCE_NEWS_CATE){
  115 + $route_map->path = self::PATH_NEWS_CATE;
  116 + }elseif ($source == self::SOURCE_BLOG){
  117 + $route_map->path = self::SOURCE_BLOG;
  118 + }elseif ($source == self::SOURCE_BLOG_CATE){
  119 + $route_map->path = self::PATH_BLOG_CATE;
  120 + }
112 $route_map->source_id = $source_id; 121 $route_map->source_id = $source_id;
113 $route_map->project_id = $project_id; 122 $route_map->project_id = $project_id;
114 } 123 }
@@ -168,6 +168,8 @@ Route::middleware(['aloginauth'])->group(function () { @@ -168,6 +168,8 @@ Route::middleware(['aloginauth'])->group(function () {
168 Route::any('/getDomain', [Aside\Project\ProjectController::class, 'getDomain'])->name('admin.project_getDomain');//获取域名列表 168 Route::any('/getDomain', [Aside\Project\ProjectController::class, 'getDomain'])->name('admin.project_getDomain');//获取域名列表
169 Route::any('/del', [Aside\Project\ProjectController::class, 'del'])->name('admin.project_del'); 169 Route::any('/del', [Aside\Project\ProjectController::class, 'del'])->name('admin.project_del');
170 Route::any('/getRenewLog', [Aside\Project\ProjectController::class, 'getRenewLog'])->name('admin.project_getRenewLog'); 170 Route::any('/getRenewLog', [Aside\Project\ProjectController::class, 'getRenewLog'])->name('admin.project_getRenewLog');
  171 + Route::any('/tdkList', [Aside\Project\ProjectController::class, 'tdkList'])->name('admin.project_tdkList');
  172 + Route::any('/copyProject', [Aside\Project\ProjectController::class, 'copyProject'])->name('admin.project_copyProject');
171 //获取关键词前缀和后缀 173 //获取关键词前缀和后缀
172 Route::prefix('keyword')->group(function () { 174 Route::prefix('keyword')->group(function () {
173 Route::any('/getKeywordPrefix', [Aside\Project\KeywordPrefixController::class, 'getKeywordPrefix'])->name('admin.keyword_getKeywordPrefix'); 175 Route::any('/getKeywordPrefix', [Aside\Project\KeywordPrefixController::class, 'getKeywordPrefix'])->name('admin.keyword_getKeywordPrefix');