作者 张关杰

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into bate

@@ -26,7 +26,7 @@ class UpgradeProjectCount extends Command @@ -26,7 +26,7 @@ class UpgradeProjectCount extends Command
26 * 26 *
27 * @var string 27 * @var string
28 */ 28 */
29 - protected $signature = 'upgrade_month_count'; 29 + protected $signature = 'upgrade_month_count {project_id}';
30 30
31 /** 31 /**
32 * The console command description. 32 * The console command description.
@@ -36,13 +36,12 @@ class UpgradeProjectCount extends Command @@ -36,13 +36,12 @@ class UpgradeProjectCount extends Command
36 protected $description = '升级项目统计'; 36 protected $description = '升级项目统计';
37 37
38 public function handle(){ 38 public function handle(){
39 - $project_id = 769; 39 + $project_id = $this->argument('project_id');
40 $oldModel = new UpdateOldInfo(); 40 $oldModel = new UpdateOldInfo();
41 $info = $oldModel->read(['project_id'=>$project_id]); 41 $info = $oldModel->read(['project_id'=>$project_id]);
42 $url = $info['old_domain_online']; 42 $url = $info['old_domain_online'];
43 ProjectServer::useProject($project_id); 43 ProjectServer::useProject($project_id);
44 $this->count($project_id,$url); 44 $this->count($project_id,$url);
45 -  
46 DB::disconnect('custom_mysql'); 45 DB::disconnect('custom_mysql');
47 } 46 }
48 47
@@ -55,7 +55,7 @@ class UpdateRoute extends Command @@ -55,7 +55,7 @@ class UpdateRoute extends Command
55 */ 55 */
56 public function handle(){ 56 public function handle(){
57 $projectModel = new Project(); 57 $projectModel = new Project();
58 - $list = $projectModel->list(['id'=>645]); 58 + $list = $projectModel->list(['id'=>264]);
59 $data = []; 59 $data = [];
60 foreach ($list as $v){ 60 foreach ($list as $v){
61 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 61 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
@@ -189,6 +189,48 @@ class DomainInfoLogic extends BaseLogic @@ -189,6 +189,48 @@ class DomainInfoLogic extends BaseLogic
189 } 189 }
190 190
191 /** 191 /**
  192 + * 编辑amp网站证书
  193 + * @param $initDomain
  194 + * @param $domain
  195 + * @return array
  196 + * @throws \App\Exceptions\AsideGlobalException
  197 + * @throws \App\Exceptions\BsideGlobalException
  198 + * @author Akun
  199 + * @date 2024/02/22 14:58
  200 + */
  201 + public function setAmpDomainSsl($initDomain,$domain)
  202 + {
  203 + if($this->param['amp_type'] == 2){
  204 + if(empty($this->param['amp_key'])){
  205 + $this->fail('AMP站点证书KEY值不能为空');
  206 + }
  207 + if(empty($this->param['amp_cert'])){
  208 + $this->fail('AMP站点证书cert值不能为空');
  209 + }
  210 + }
  211 + $api_url = 'http://'.$initDomain.'/api/createSiteAmp';
  212 + $api_param = [
  213 + 'domain' => $domain,
  214 + 'private_key' => $this->param['amp_key']??'',
  215 + 'cert' => $this->param['amp_cert']??''
  216 + ];
  217 +
  218 + try {
  219 + $rs = HttpUtils::get($api_url, $api_param);
  220 + $rs = json_decode($rs, true);
  221 + if(isset($rs['status']) && $rs['status'] == 200){
  222 + return $this->success();
  223 + }else{
  224 + $this->fail($rs['message']??'');
  225 + }
  226 + } catch (\Exception | GuzzleException $e) {
  227 + errorLog('创建AMP站点', $api_param, $e);
  228 + $this->fail('编辑AMP站点证书失败');
  229 + }
  230 + return $this->success();
  231 + }
  232 +
  233 + /**
192 * @remark :保存证书相关配置 234 * @remark :保存证书相关配置
193 * @name :sslSave 235 * @name :sslSave
194 * @author :lyh 236 * @author :lyh
@@ -229,10 +271,20 @@ class DomainInfoLogic extends BaseLogic @@ -229,10 +271,20 @@ class DomainInfoLogic extends BaseLogic
229 'type'=>$this->param['type'], 271 'type'=>$this->param['type'],
230 'private_key' => $this->param['key'] ?? '', 272 'private_key' => $this->param['key'] ?? '',
231 'private_cert' => $this->param['cert'] ?? '', 273 'private_cert' => $this->param['cert'] ?? '',
  274 + 'amp_status' => $this->param['amp_status'] ?? 0,
  275 + 'amp_type' => $this->param['amp_type'] ?? 0,
  276 + 'amp_private_key' => $this->param['amp_key'] ?? '',
  277 + 'amp_private_cert' => $this->param['amp_cert'] ?? '',
232 ]; 278 ];
233 $this->model->edit($data,['id'=>$this->param['id']]); 279 $this->model->edit($data,['id'=>$this->param['id']]);
234 //生成证书 280 //生成证书
235 $this->setDomainSsl($server_info['init_domain'],$info['domain'],$this->param['extend_config'] ?? [],$this->param['other_domain'] ?? []); 281 $this->setDomainSsl($server_info['init_domain'],$info['domain'],$this->param['extend_config'] ?? [],$this->param['other_domain'] ?? []);
  282 +
  283 + //amp站点生成证书
  284 + if($data['amp_status']){
  285 + $this->setAmpDomainSsl($server_info['init_domain'],$info['domain']);
  286 + }
  287 +
236 return $this->success(); 288 return $this->success();
237 } 289 }
238 290
@@ -57,9 +57,12 @@ class CopyProjectJob implements ShouldQueue @@ -57,9 +57,12 @@ class CopyProjectJob implements ShouldQueue
57 $data = $data->getAttributes(); 57 $data = $data->getAttributes();
58 $type = $data['type']; 58 $type = $data['type'];
59 $data['type'] = 0; 59 $data['type'] = 0;
  60 + $data['old_project_id'] = $this->param['project_id'];
60 $data['title'] = $data['title'].'-copy'; 61 $data['title'] = $data['title'].'-copy';
61 unset($data['id']); 62 unset($data['id']);
62 $project_id = $projectModel->insertGetId($data); 63 $project_id = $projectModel->insertGetId($data);
  64 + $hashids = new Hashids($data['from_order_id'], 13, 'abcdefghjkmnpqrstuvwxyz1234567890');
  65 + $projectModel->edit(['from_order_id'=>$hashids->encode($project_id)],['id'=>$project_id]);
63 //复制部署表 66 //复制部署表
64 $buildModel = new DeployBuild(); 67 $buildModel = new DeployBuild();
65 $buildData = $buildModel::where('project_id', $this->param['project_id'])->first(); 68 $buildData = $buildModel::where('project_id', $this->param['project_id'])->first();