作者 刘锟

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

@@ -53,9 +53,13 @@ class UpdateRoute extends Command @@ -53,9 +53,13 @@ class UpdateRoute extends Command
53 * @time :2023/11/20 15:13 53 * @time :2023/11/20 15:13
54 */ 54 */
55 public function handle(){ 55 public function handle(){
56 - ProjectServer::useProject(75);  
57 - $this->getProductKeyword();  
58 - DB::disconnect('custom_mysql'); 56 + $projectModel = new Project();
  57 + $list = $projectModel->list(['type'=>['in',[1,2,3,4]]]);
  58 + foreach ($list as $v){
  59 + ProjectServer::useProject($v['id']);
  60 + $this->getProductKeyword($v['id']);
  61 + DB::disconnect('custom_mysql');
  62 + }
59 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 63 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
60 } 64 }
61 65
@@ -66,16 +70,21 @@ class UpdateRoute extends Command @@ -66,16 +70,21 @@ class UpdateRoute extends Command
66 * @method :post 70 * @method :post
67 * @time :2023/12/8 11:13 71 * @time :2023/12/8 11:13
68 */ 72 */
69 - public function getProductKeyword(){ 73 + public function getProductKeyword($project_id){
70 $keywordModel = new Keyword(); 74 $keywordModel = new Keyword();
71 - $lists = $keywordModel->list(['route'=>'']); 75 + $lists = $keywordModel->list(['status'=>1]);
72 if(!empty($lists)){ 76 if(!empty($lists)){
73 foreach ($lists as $v){ 77 foreach ($lists as $v){
74 - echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL;  
75 - $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $this->user['project_id']);  
76 - $this->curlDelRoute(['new_route'=>$route]);  
77 - $this->model->edit(['route'=>$route],['id'=>$v['id']]);  
78 - echo date('Y-m-d H:i:s') . 'end :'.$route . PHP_EOL; 78 + echo date('Y-m-d H:i:s') . '关键字id:'.$v['id'] . PHP_EOL;
  79 + $tag = "-tag";
  80 + if (!(substr($v['route'], -strlen($tag)) === $tag)) {
  81 + echo date('Y-m-d H:i:s') . '拼接'.$tag . PHP_EOL;
  82 + $route = $v['route'].$tag;
  83 + // 如果不是以 '-tag' 结尾,则拼接上 '-tag'
  84 + $routeModel = new RouteMap();
  85 + $routeModel->edit(['route'=>$route],['source'=>RouteMap::SOURCE_PRODUCT_KEYWORD,'source_id'=>$v['id']]);
  86 + $keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
  87 + }
79 } 88 }
80 } 89 }
81 } 90 }
@@ -58,15 +58,14 @@ class RouteMap extends Base @@ -58,15 +58,14 @@ class RouteMap extends Base
58 $i=1; 58 $i=1;
59 $sign = generateRoute($title); 59 $sign = generateRoute($title);
60 $info = self::where(['project_id' => $project_id, 'source' => $source, 'source_id'=>$source_id])->first(); 60 $info = self::where(['project_id' => $project_id, 'source' => $source, 'source_id'=>$source_id])->first();
61 - if($info === false){ 61 + $suffix = '';
  62 + if(empty($info)){
62 if($source == self::SOURCE_PRODUCT_KEYWORD){ 63 if($source == self::SOURCE_PRODUCT_KEYWORD){
63 $suffix = '-tag'; 64 $suffix = '-tag';
64 } 65 }
65 if($source == self::SOURCE_PRODUCT){ 66 if($source == self::SOURCE_PRODUCT){
66 $suffix = '-product'; 67 $suffix = '-product';
67 } 68 }
68 - }else{  
69 - $suffix = '';  
70 } 69 }
71 $route = $sign.$suffix; 70 $route = $sign.$suffix;
72 while(self::isExist($route, $source_id, $project_id)){ 71 while(self::isExist($route, $source_id, $project_id)){