作者 张关杰

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

@@ -6,10 +6,16 @@ use App\Helper\Arr; @@ -6,10 +6,16 @@ use App\Helper\Arr;
6 use App\Models\Collect\CollectTask; 6 use App\Models\Collect\CollectTask;
7 use App\Models\Com\UpdateLog; 7 use App\Models\Com\UpdateLog;
8 use App\Models\Com\UpdateVisit; 8 use App\Models\Com\UpdateVisit;
  9 +use App\Models\Devops\ServerConfig;
  10 +use App\Models\Domain\DomainInfo;
9 use App\Models\Product\Product; 11 use App\Models\Product\Product;
  12 +use App\Models\Project\Project;
10 use App\Services\ProjectServer; 13 use App\Services\ProjectServer;
  14 +use App\Utils\HttpUtils;
  15 +use GuzzleHttp\Exception\GuzzleException;
11 use Illuminate\Console\Command; 16 use Illuminate\Console\Command;
12 use Illuminate\Support\Facades\DB; 17 use Illuminate\Support\Facades\DB;
  18 +use Symfony\Component\Process\Process;
13 19
14 class Temp extends Command 20 class Temp extends Command
15 { 21 {
@@ -30,17 +36,106 @@ class Temp extends Command @@ -30,17 +36,106 @@ class Temp extends Command
30 36
31 public function handle() 37 public function handle()
32 { 38 {
33 - $project = ProjectServer::useProject(626);  
34 - if ($project) {  
35 - CollectTask::select(['id', 'language'])->where('status', 0)->chunk(1000, function ($query) { 39 + $domain_model = new DomainInfo();
  40 + $server_model = new ServerConfig();
  41 + $project_model = new Project();
36 42
37 - foreach ($query as $item) {  
38 - $item->domain = 'lecusostreetlight.quanqiusou.cn/' . $item->language;  
39 - $item->save(); 43 + $domain_list = $domain_model->list(['domain' => ['like', 'www.%']], 'id', ['id', 'domain', 'project_id'], 'asc');
  44 + foreach ($domain_list as $info) {
  45 + $this->output('domain:' . $info['domain'] . ',开始');
  46 +
  47 + $project_info = $project_model->read(['id' => $info['project_id']], 'serve_id');
  48 + if ($project_info === false) {
  49 + $this->output('获取项目数据失败');
  50 + continue;
  51 + }
  52 +
  53 + $server_info = $server_model->read(['id' => $project_info['serve_id']], ['init_domain', 'host']);
  54 + if ($server_info === false) {
  55 + $this->output('获取服务器数据失败');
  56 + continue;
40 } 57 }
41 - }); 58 +
  59 + $domain_array = parse_url($info['domain']);
  60 + $host = $domain_array['host'] ?? $domain_array['path'];
  61 + $host_array = explode('.', $host);
  62 + if (count($host_array) <= 2) {
  63 + array_unshift($host_array, 'm');
  64 + } else {
  65 + $host_array[0] = 'm';
42 } 66 }
43 - DB::disconnect('custom_mysql'); 67 + $amp_domain = implode('.', $host_array);
  68 + if (!$this->check_cname($amp_domain, $server_info)) {
  69 + $this->output('AMP站点域名' . $amp_domain . '未解析至目标服务器');
  70 + continue;
  71 + }
  72 +
  73 + $api_url = 'http://' . $server_info['init_domain'] . '/api/createSiteAmp';
  74 + $api_param = [
  75 + 'domain' => $info['domain'],
  76 + 'private_key' => '',
  77 + 'cert' => ''
  78 + ];
  79 +
  80 + try {
  81 + $rs = HttpUtils::get($api_url, $api_param);
  82 + $rs = json_decode($rs, true);
  83 + if (isset($rs['status']) && $rs['status'] == 200) {
  84 + $this->output('创建AMP站点成功');
  85 + } else {
  86 + $this->output($rs['message'] ?? '');
  87 + continue;
  88 + }
  89 + } catch (\Exception | GuzzleException $e) {
  90 + errorLog('创建AMP站点', $api_param, $e);
  91 + $this->output('创建AMP站点失败');
  92 + continue;
  93 + }
  94 +
  95 + $data = [
  96 + 'amp_status' => 1,
  97 + 'amp_type' => 1,
  98 + ];
  99 + $domain_model->edit($data, ['id' => $info['id']]);
  100 + }
  101 +
44 echo '成功' . PHP_EOL; 102 echo '成功' . PHP_EOL;
45 } 103 }
  104 +
  105 + public function check_cname($domain, $server_info)
  106 + {
  107 + $checkA = false;
  108 + $checkCname = false;
  109 +
  110 + $process = new Process(['nslookup', '-qt=a', $domain]);
  111 + $process->run();
  112 + $output = explode(PHP_EOL, $process->getOutput());
  113 + foreach ($output as $line) {
  114 + if ($line) {
  115 + $checkA = strpos($line, $server_info['host']) !== false;
  116 + if ($checkA) {
  117 + return $domain;
  118 + }
  119 + }
  120 + }
  121 +
  122 + //是否cname
  123 + $process = new Process(['nslookup', '-qt=cname', $domain]);
  124 + $process->run();
  125 + $output = explode(PHP_EOL, $process->getOutput());
  126 + foreach ($output as $line) {
  127 + if ($line) {
  128 + $checkCname = (strpos($line, $server_info['init_domain']) !== false);
  129 + if ($checkCname) {
  130 + return $domain;
  131 + }
  132 + }
  133 + }
  134 + return false;
  135 + }
  136 +
  137 + public function output($msg)
  138 + {
  139 + echo $msg . PHP_EOL;
  140 + }
46 } 141 }
@@ -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'=>1091]);
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;
@@ -298,7 +298,7 @@ class WebTrafficRussia extends Command @@ -298,7 +298,7 @@ class WebTrafficRussia extends Command
298 $page++; 298 $page++;
299 } 299 }
300 }catch (\Exception $e){ 300 }catch (\Exception $e){
301 - Log::channel('traffic')->error("ru:" . $e->getMessage()); 301 + Log::channel('traffic')->error("ru:line" . $e->getLine() . ',error:' . $e->getMessage());
302 } 302 }
303 } 303 }
304 304
@@ -92,13 +92,19 @@ class KeywordVideoController extends BaseController @@ -92,13 +92,19 @@ class KeywordVideoController extends BaseController
92 'project_id.required' => '项目唯一标识不为空', 92 'project_id.required' => '项目唯一标识不为空',
93 'number.required' => 'number不为空', 93 'number.required' => 'number不为空',
94 ]); 94 ]);
  95 + //查看当前项目是否已添加
  96 + $keywordModel = new KeywordVideoTask();
  97 + $keywordInfo = $keywordModel->read(['project_id'=>$this->param['project_id']]);
  98 + if($keywordInfo !== false){
  99 + $this->response('当前项目已添加');
  100 + }
95 //查看当前项目是否有正式域名 101 //查看当前项目是否有正式域名
96 $domainModel = new DomainInfo(); 102 $domainModel = new DomainInfo();
97 $info = $domainModel->read(['project_id'=>$this->param['project_id']]); 103 $info = $domainModel->read(['project_id'=>$this->param['project_id']]);
98 if($info === false){ 104 if($info === false){
99 $this->response('请先设置域名',Code::SYSTEM_ERROR); 105 $this->response('请先设置域名',Code::SYSTEM_ERROR);
100 } 106 }
101 - $keywordModel = new KeywordVideoTask(); 107 +
102 $rs = $keywordModel->add($this->param); 108 $rs = $keywordModel->add($this->param);
103 if($rs === false){ 109 if($rs === false){
104 $this->response('添加失败',Code::SYSTEM_ERROR); 110 $this->response('添加失败',Code::SYSTEM_ERROR);
@@ -724,7 +724,8 @@ class ProjectController extends BaseController @@ -724,7 +724,8 @@ class ProjectController extends BaseController
724 "start_date" => $item['deploy_optimize']['start_date'] ?? '', 724 "start_date" => $item['deploy_optimize']['start_date'] ?? '',
725 "domain" => $domain ? 'https://' . $domain : $domain, 725 "domain" => $domain ? 'https://' . $domain : $domain,
726 "test_domain" => $item['deploy_build']['test_domain'] ?? '', 726 "test_domain" => $item['deploy_build']['test_domain'] ?? '',
727 - "online_time" => $item['online_check']['qa_check_time'] ?? '', 727 +// "online_time" => $item['online_check']['qa_check_time'] ?? '',
  728 + "online_time" => $item['uptime'] ?? '',
728 "cooperate_date" => $item['cooperate_date'], 729 "cooperate_date" => $item['cooperate_date'],
729 "project_manager_name" => $manage->getName($item['deploy_build']['manager_mid']), //项目经理 730 "project_manager_name" => $manage->getName($item['deploy_build']['manager_mid']), //项目经理
730 "after_sales_manager_name" => $manage->getName($item['deploy_optimize']['manager_mid']), //售后服务经理 731 "after_sales_manager_name" => $manage->getName($item['deploy_optimize']['manager_mid']), //售后服务经理
@@ -9,6 +9,7 @@ use App\Http\Logic\Logic; @@ -9,6 +9,7 @@ use App\Http\Logic\Logic;
9 use App\Models\Com\UpdateNotify; 9 use App\Models\Com\UpdateNotify;
10 use App\Models\Project\Project; 10 use App\Models\Project\Project;
11 use App\Models\RouteMap\RouteDelete; 11 use App\Models\RouteMap\RouteDelete;
  12 +use App\Models\Service\Service;
12 use Illuminate\Support\Facades\Cache; 13 use Illuminate\Support\Facades\Cache;
13 use Illuminate\Support\Str; 14 use Illuminate\Support\Str;
14 15
@@ -173,7 +174,7 @@ class BaseLogic extends Logic @@ -173,7 +174,7 @@ class BaseLogic extends Logic
173 $data['project_id'] = $this->user['project_id']; 174 $data['project_id'] = $this->user['project_id'];
174 $str = http_build_query($data); 175 $str = http_build_query($data);
175 $url = $this->user['domain'].'api/delHtml/?'.$str; 176 $url = $this->user['domain'].'api/delHtml/?'.$str;
176 - if($this->user['project_id'] == 672){//TODO::当前项目通知不过 ,跳过自动更新 177 + if(isset($this->project['serve_id']) && ($this->project['serve_id'] == 3)){//TODO::当前项目通知不过 ,跳过自动更新
177 exec('curl -k "'.$url.'" > /dev/null 2>&1 &'); 178 exec('curl -k "'.$url.'" > /dev/null 2>&1 &');
178 }else{ 179 }else{
179 shell_exec('curl -k "'.$url.'"'); 180 shell_exec('curl -k "'.$url.'"');
@@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside\HomeCount; @@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside\HomeCount;
4 4
5 5
6 use App\Http\Logic\Bside\BaseLogic; 6 use App\Http\Logic\Bside\BaseLogic;
  7 +use App\Models\RouteMap\RouteMap;
7 use App\Models\Visit\Visit; 8 use App\Models\Visit\Visit;
8 use App\Models\Visit\VisitItem; 9 use App\Models\Visit\VisitItem;
9 use App\Models\HomeCount\Count; 10 use App\Models\HomeCount\Count;
@@ -116,7 +117,7 @@ class CountLogic extends BaseLogic @@ -116,7 +117,7 @@ class CountLogic extends BaseLogic
116 public function with_data_count(){ 117 public function with_data_count(){
117 $product_count = (new Product())->where(['project_id' => $this->user['project_id']])->count(); 118 $product_count = (new Product())->where(['project_id' => $this->user['project_id']])->count();
118 $news_count = (new News())->where(['project_id' => $this->user['project_id']])->count(); 119 $news_count = (new News())->where(['project_id' => $this->user['project_id']])->count();
119 - $page_count = (new BTemplate())->where(['project_id' => $this->user['project_id']])->count(); 120 + $page_count = (new RouteMap())->where(['project_id' => $this->user['project_id']])->count();
120 $data = [ 121 $data = [
121 'product_count' => $product_count, 122 'product_count' => $product_count,
122 'news_count' => $news_count, 123 'news_count' => $news_count,
@@ -77,7 +77,7 @@ class UserLogic extends BaseLogic @@ -77,7 +77,7 @@ class UserLogic extends BaseLogic
77 } 77 }
78 $this->param['type'] = 1; 78 $this->param['type'] = 1;
79 $this->param['operator_id'] = $this->user['id']; 79 $this->param['operator_id'] = $this->user['id'];
80 - if(isset($this->param['password']) && empty($this->param['password'])){ 80 + if(isset($this->param['password']) && !empty($this->param['password'])){
81 $this->param['password'] = base64_encode(md5($this->param['password'])); 81 $this->param['password'] = base64_encode(md5($this->param['password']));
82 } 82 }
83 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); 83 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
  1 +<?php
  2 +
  3 +namespace App\Models\Com;
  4 +
  5 +use App\Models\Base;
  6 +
  7 +class Notify extends Base
  8 +{
  9 + protected $table = 'gl_notify';
  10 +}
@@ -322,14 +322,18 @@ class Project extends Base @@ -322,14 +322,18 @@ class Project extends Base
322 $project_id = DeployBuild::where('test_domain', 'https://' . $domain . '/')->value('project_id'); 322 $project_id = DeployBuild::where('test_domain', 'https://' . $domain . '/')->value('project_id');
323 //是否正式域名 323 //是否正式域名
324 if (!$project_id) { 324 if (!$project_id) {
325 - //是否小语种域名 325 + //是否小语种域名或amp站域名
326 $domainPrefix = explode(".",$domain); 326 $domainPrefix = explode(".",$domain);
327 if (!empty($domainPrefix)){ 327 if (!empty($domainPrefix)){
  328 + if($domainPrefix[0] == 'm'){
  329 + $domain = "www.".$domainPrefix[1].".".$domainPrefix[2];
  330 + }else{
328 $isLang = Translate::getTls($domainPrefix[0]); 331 $isLang = Translate::getTls($domainPrefix[0]);
329 if ($isLang) { 332 if ($isLang) {
330 $domain = "www.".$domainPrefix[1].".".$domainPrefix[2]; 333 $domain = "www.".$domainPrefix[1].".".$domainPrefix[2];
331 } 334 }
332 } 335 }
  336 + }
333 $project_id = \App\Models\Domain\DomainInfo::where('domain', $domain)->value('project_id'); 337 $project_id = \App\Models\Domain\DomainInfo::where('domain', $domain)->value('project_id');
334 } 338 }
335 $project = self::find($project_id ?: 0); 339 $project = self::find($project_id ?: 0);
@@ -42,7 +42,7 @@ class HttpUtils @@ -42,7 +42,7 @@ class HttpUtils
42 public static function get($url, $data, $headers = []) 42 public static function get($url, $data, $headers = [])
43 { 43 {
44 LogUtils::info("HttpUtils-GET请求URL:" . $url); 44 LogUtils::info("HttpUtils-GET请求URL:" . $url);
45 - $response = Http::timeout(20)->withHeaders($headers)->get($url, $data); 45 + $response = Http::timeout(60)->withHeaders($headers)->get($url, $data);
46 self::checkSuccess($response); 46 self::checkSuccess($response);
47 return $response->getBody()->getContents(); 47 return $response->getBody()->getContents();
48 } 48 }
@@ -50,7 +50,7 @@ class HttpUtils @@ -50,7 +50,7 @@ class HttpUtils
50 public static function post($url, $data, $headers = []) 50 public static function post($url, $data, $headers = [])
51 { 51 {
52 LogUtils::info("HttpUtils-POST请求URL:" . $url); 52 LogUtils::info("HttpUtils-POST请求URL:" . $url);
53 - $response = Http::timeout(20)->withHeaders($headers)->post($url, $data); 53 + $response = Http::timeout(60)->withHeaders($headers)->post($url, $data);
54 self::checkSuccess($response); 54 self::checkSuccess($response);
55 return $response->getBody()->getContents(); 55 return $response->getBody()->getContents();
56 } 56 }