作者 Your Name
@@ -156,7 +156,9 @@ class ReplaceHtml extends Command @@ -156,7 +156,9 @@ class ReplaceHtml extends Command
156 foreach ($bTemplateList as $v){ 156 foreach ($bTemplateList as $v){
157 $source_id = $v['source'] == 1 ? 0 : $v['source_id']; 157 $source_id = $v['source'] == 1 ? 0 : $v['source_id'];
158 $name_route = $this->getSourceName($v['source'],$source_id,$v['is_list'],$v['is_custom']); 158 $name_route = $this->getSourceName($v['source'],$source_id,$v['is_list'],$v['is_custom']);
159 - $saveData[] = $this->saveData($info,$v,$source_id,$name_route); 159 + if($name_route !== false){
  160 + $saveData[] = $this->saveData($info,$v,$source_id,$name_route);
  161 + }
160 } 162 }
161 } 163 }
162 if(!empty($saveData)){ 164 if(!empty($saveData)){
@@ -205,7 +207,7 @@ class ReplaceHtml extends Command @@ -205,7 +207,7 @@ class ReplaceHtml extends Command
205 return $this->getCustomName($source,$source_id,$is_list); 207 return $this->getCustomName($source,$source_id,$is_list);
206 } 208 }
207 if($source == BTemplate::SOURCE_HOME){ 209 if($source == BTemplate::SOURCE_HOME){
208 - return ''; 210 + return ['name'=>'','route'=>''];;
209 }elseif ($source == BTemplate::SOURCE_PRODUCT){ 211 }elseif ($source == BTemplate::SOURCE_PRODUCT){
210 return $this->getProductName($source_id,$is_list); 212 return $this->getProductName($source_id,$is_list);
211 }elseif ($source == BTemplate::SOURCE_BLOG){ 213 }elseif ($source == BTemplate::SOURCE_BLOG){
@@ -42,27 +42,27 @@ class Demo extends Command @@ -42,27 +42,27 @@ class Demo extends Command
42 { 42 {
43 $this->param['project_id'] = 181; 43 $this->param['project_id'] = 181;
44 $imageModel = new ImageModel(); 44 $imageModel = new ImageModel();
45 -// //获取当前项目的所有图片  
46 -// $imageList = $imageModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','size']);  
47 -// if(!empty($imageList)){  
48 -// $amazonS3Service = new AmazonS3Service();  
49 -// foreach ($imageList as $k => $v){  
50 -// $amazonS3Service->syncImageFiles(getImageUrl($v['path']));  
51 -// $imageModel->edit(['is_cos'=>0],['id'=>$v['id']]);  
52 -// }  
53 -// }  
54 -  
55 - $fileModel = new FileModel();  
56 - $fileList = $fileModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','name']);  
57 - if(!empty($fileList)){ 45 + //获取当前项目的所有图片
  46 + $imageList = $imageModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','size']);
  47 + if(!empty($imageList)){
58 $amazonS3Service = new AmazonS3Service(); 48 $amazonS3Service = new AmazonS3Service();
59 - foreach ($fileList as $k => $v){  
60 - echo date('Y-m-d H:i:s') . '执行的数据id:' . $v['id'] . '名称:'.$v['name'] . PHP_EOL;  
61 - $amazonS3Service->syncImageFiles(getFileUrl($v['path']));  
62 - $fileModel->edit(['is_cos'=>0],['id'=>$v['id']]);  
63 - gc_collect_cycles(); 49 + foreach ($imageList as $k => $v){
  50 + $amazonS3Service->syncImageFiles(getImageUrl($v['path']));
  51 + $imageModel->edit(['is_cos'=>0],['id'=>$v['id']]);
64 } 52 }
65 } 53 }
  54 +
  55 +// $fileModel = new FileModel();
  56 +// $fileList = $fileModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','name']);
  57 +// if(!empty($fileList)){
  58 +// $amazonS3Service = new AmazonS3Service();
  59 +// foreach ($fileList as $k => $v){
  60 +// echo date('Y-m-d H:i:s') . '执行的数据id:' . $v['id'] . '名称:'.$v['name'] . PHP_EOL;
  61 +// $amazonS3Service->syncImageFiles(getFileUrl($v['path']));
  62 +// $fileModel->edit(['is_cos'=>0],['id'=>$v['id']]);
  63 +// gc_collect_cycles();
  64 +// }
  65 +// }
66 return true; 66 return true;
67 } 67 }
68 68
@@ -688,7 +688,7 @@ class ProjectLogic extends BaseLogic @@ -688,7 +688,7 @@ class ProjectLogic extends BaseLogic
688 */ 688 */
689 public function copyProject(){ 689 public function copyProject(){
690 CopyProjectJob::dispatch(['project_id'=>$this->param['project_id']]); 690 CopyProjectJob::dispatch(['project_id'=>$this->param['project_id']]);
691 - return $this->success(); 691 + return $this->success('项目复制中,请稍后前往初始化项目查看;');
692 } 692 }
693 693
694 /** 694 /**
@@ -60,10 +60,20 @@ class CopyProjectJob implements ShouldQueue @@ -60,10 +60,20 @@ class CopyProjectJob implements ShouldQueue
60 $data['status'] = 0; 60 $data['status'] = 0;
61 $data['finish_remain_day'] = 0; 61 $data['finish_remain_day'] = 0;
62 $data['title'] = $data['title'].'-copy'; 62 $data['title'] = $data['title'].'-copy';
  63 + $data['delete_status'] = 1;
63 unset($data['id']); 64 unset($data['id']);
64 $project_id = $projectModel->insertGetId($data); 65 $project_id = $projectModel->insertGetId($data);
65 $hashids = new Hashids($data['from_order_id'], 13, 'abcdefghjkmnpqrstuvwxyz1234567890'); 66 $hashids = new Hashids($data['from_order_id'], 13, 'abcdefghjkmnpqrstuvwxyz1234567890');
66 $projectModel->edit(['from_order_id'=>$hashids->encode($project_id)],['id'=>$project_id]); 67 $projectModel->edit(['from_order_id'=>$hashids->encode($project_id)],['id'=>$project_id]);
  68 + //复制设置的模版
  69 + $settingTemplateModel = new Setting();
  70 + $settingData = $settingTemplateModel::where('project_id', $this->param['project_id'])->first();
  71 + if(!empty($settingData)){
  72 + $settingData = $settingData->getAttributes();
  73 + unset($settingData['id']);
  74 + $settingData['project_id'] = $project_id;
  75 + $settingTemplateModel->insert($settingData);
  76 + }
67 //复制部署表 77 //复制部署表
68 $buildModel = new DeployBuild(); 78 $buildModel = new DeployBuild();
69 $buildData = $buildModel::where('project_id', $this->param['project_id'])->first(); 79 $buildData = $buildModel::where('project_id', $this->param['project_id'])->first();
@@ -114,15 +124,6 @@ class CopyProjectJob implements ShouldQueue @@ -114,15 +124,6 @@ class CopyProjectJob implements ShouldQueue
114 $userData['project_id'] = $project_id; 124 $userData['project_id'] = $project_id;
115 $userModel->insert($userData); 125 $userModel->insert($userData);
116 } 126 }
117 - //复制设置的模版  
118 - $settingTemplateModel = new Setting();  
119 - $settingData = $settingTemplateModel::where('project_id', $this->param['project_id'])->first();  
120 - if(!empty($settingData)){  
121 - $settingData = $settingData->getAttributes();  
122 - unset($settingData['id']);  
123 - $settingData['project_id'] = $project_id;  
124 - $settingTemplateModel->insert($settingData);  
125 - }  
126 DB::commit(); 127 DB::commit();
127 }catch (\Exception $e){ 128 }catch (\Exception $e){
128 DB::rollBack(); 129 DB::rollBack();
@@ -131,6 +132,8 @@ class CopyProjectJob implements ShouldQueue @@ -131,6 +132,8 @@ class CopyProjectJob implements ShouldQueue
131 if($type != 0){ 132 if($type != 0){
132 $this->copyMysql($this->param['project_id'],$project_id); 133 $this->copyMysql($this->param['project_id'],$project_id);
133 } 134 }
  135 + //修改项目状态
  136 + $projectModel->edit(['delete_status'=>0],['id'=>$project_id]);
134 return true; 137 return true;
135 } 138 }
136 139