作者 lyh

gx

  1 +<?php
  2 +
  3 +namespace App\Http\Logic\Aside\Project;
  4 +
  5 +
  6 +use App\Http\Logic\Aside\BaseLogic;
  7 +use App\Models\Project\DomainInfo;
  8 +use App\Models\Project\Payment;
  9 +use MongoDB\Client;
  10 +
  11 +class DomainInfoLogic extends BaseLogic
  12 +{
  13 + public function __construct()
  14 + {
  15 + parent::__construct();
  16 +
  17 + $this->model = new DomainInfo();
  18 + }
  19 +
  20 + public function getDomainInfo($project_id)
  21 + {
  22 + $project = app(ProjectLogic::class)->getInfo($project_id);
  23 + $domain = $project['deploy_optimize']['domain'] ?? '';
  24 + $info = $this->model->where('project_id', $project_id)->first();
  25 + //不存在或时间过期了 重新获取信息
  26 + $expiration_date = $info['domain_info']['expiration_date'] ?? '';
  27 + $end_time = $info['ssl']['end_time'] ?? '';
  28 + if(!$info || $expiration_date < date("Y-m-d") || $end_time < date('Y-m-d')){
  29 + try {
  30 + $mongo = new Client("mongodb://root:globalso8837840@23.228.125.2:27017");
  31 + $db = $mongo->globalso_monitor;
  32 + $collection = $db->project_v1;
  33 + $project_zk = $collection->findOne(['main_url' => $domain]);
  34 + $info['domain'] = $domain;
  35 + $info['domain_info'] = (array) $project_zk['domain_info'] ?? [];
  36 + $info['ssl'] = (array) $project_zk['ssl'] ?? [];
  37 + parent::save($info);
  38 + }catch (\Exception $e){
  39 + return [];
  40 + }
  41 + }
  42 + return $info;
  43 + }
  44 +}
@@ -70,8 +70,8 @@ class ProductLogic extends BaseLogic @@ -70,8 +70,8 @@ class ProductLogic extends BaseLogic
70 public function save($param){ 70 public function save($param){
71 //封面取第一个图片 71 //封面取第一个图片
72 $param['thumb'] = $param['gallery'][0] ?? ''; 72 $param['thumb'] = $param['gallery'][0] ?? '';
73 - DB::beginTransaction();  
74 - try { 73 +// DB::beginTransaction();
  74 +// try {
75 $data = $param; 75 $data = $param;
76 $data['created_uid'] = $this->user['id']; 76 $data['created_uid'] = $this->user['id'];
77 $res = parent::save($data); 77 $res = parent::save($data);
@@ -81,12 +81,12 @@ class ProductLogic extends BaseLogic @@ -81,12 +81,12 @@ class ProductLogic extends BaseLogic
81 KeywordRelated::saveRelated($res['id'], $data['keyword_id']); 81 KeywordRelated::saveRelated($res['id'], $data['keyword_id']);
82 //路由映射 82 //路由映射
83 $route = RouteMap::setRoute($param['route'], RouteMap::SOURCE_PRODUCT, $res['id'], $this->user['project_id']); 83 $route = RouteMap::setRoute($param['route'], RouteMap::SOURCE_PRODUCT, $res['id'], $this->user['project_id']);
84 - DB::commit();  
85 - }catch (\Exception $e){  
86 - DB::rollBack();  
87 - errorLog('产品保存失败', $param, $e);  
88 - $this->fail('保存失败');  
89 - } 84 +// DB::commit();
  85 +// }catch (\Exception $e){
  86 +// DB::rollBack();
  87 +// errorLog('产品保存失败', $param, $e);
  88 +// $this->fail('保存失败');
  89 +// }
90 //通知更新 90 //通知更新
91 $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT, 'route'=>$route]); 91 $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT, 'route'=>$route]);
92 return $this->success(); 92 return $this->success();