作者 赵彬吉

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

  1 +<?php
  2 +
  3 +namespace App\Console\Commands\Domain;
  4 +
  5 +use App\Exceptions\AsideGlobalException;
  6 +use App\Exceptions\BsideGlobalException;
  7 +use App\Helper\AyrShare as AyrShareHelper;
  8 +use App\Http\Logic\Aside\Domain\DomainInfoLogic;
  9 +use App\Models\AyrShare\AyrRelease as AyrReleaseModel;
  10 +use Carbon\Carbon;
  11 +use App\Models\AyrShare\AyrShare as AyrShareModel;
  12 +use Illuminate\Console\Command;
  13 +
  14 +class DomainTime extends Command
  15 +{
  16 + public $error = 0;
  17 + /**
  18 + * The name and signature of the console command.
  19 + *
  20 + * @var string
  21 + */
  22 + protected $signature = 'domain_time';
  23 +
  24 + /**
  25 + * The console command description.
  26 + *
  27 + * @var string
  28 + */
  29 + protected $description = '域名定时任务 更新域名|证书到期时间';
  30 +
  31 + /**
  32 + * @name :(定时执行)handle
  33 + * @author :lyh
  34 + * @method :post
  35 + * @time :2023/5/12 14:48
  36 + */
  37 + public function handle()
  38 + {
  39 + echo $this->update_domain_time();
  40 + }
  41 +
  42 + /**
  43 + * 更新域名|证书到期时间
  44 + * @return int|mixed|void
  45 + * @throws AsideGlobalException
  46 + * @throws BsideGlobalException
  47 + */
  48 + protected function update_domain_time()
  49 + {
  50 + $domainCon = new DomainInfoLogic();
  51 + $all = $domainCon->getAllDomain();
  52 + $all = $all->toArray();
  53 + if ( empty( $all ) ) {
  54 + $this->info( '未获取到数据' );
  55 + return;
  56 + }
  57 + foreach ( $all as $item ) {
  58 + $domain = $item['domain'];
  59 + // 域名到期时间
  60 + $domainT = $domainCon->getDomainTime( $domain );
  61 + if ( $domainT ) {
  62 + $domain_time = $item['domain_end_time'];
  63 + $domainValidFrom = $domainT['validFrom'];
  64 + $domainValidTo = $domainT['validTo'];
  65 + if ( strtotime( $domain_time ) < strtotime( $domainValidTo ) ) {
  66 + $this->info( $domain . '域名到期时间更新成功' );
  67 + $domainCon->updateDomain( $item['id'], [ 'domain_end_time' => $domainValidTo ] );
  68 + }
  69 + } else {
  70 + $this->error++;
  71 + $this->info( $domain . '域名到期时间获取失败' );
  72 + }
  73 + // 证书到期时间
  74 + $certificateT = $domainCon->getDomainCertificateTime( $domain );
  75 + if ( $certificateT ) {
  76 + $certificate_time = $item['certificate_end_time'];
  77 + $certificateValidFrom = $certificateT['validFrom'];
  78 + $certificateValidTo = $certificateT['validTo'];
  79 + if ( strtotime( $certificate_time ) < strtotime( $certificateValidTo ) ) {
  80 + $this->info( $domain . '证书到期时间更新成功' );
  81 + $domainCon->updateDomain( $item['id'], [ 'certificate_end_time' => $certificateValidTo ] );
  82 + }
  83 + } else {
  84 + $this->error++;
  85 + $this->info( $domain . '证书到期时间获取失败' );
  86 + }
  87 + }
  88 + return $this->error;
  89 + }
  90 +}
@@ -2,13 +2,17 @@ @@ -2,13 +2,17 @@
2 2
3 namespace App\Console\Commands\YesterdayCount; 3 namespace App\Console\Commands\YesterdayCount;
4 4
  5 +use App\Helper\Common;
  6 +use App\Helper\FormGlobalsoApi;
5 use App\Models\CustomerVisit\CustomerVisitItem; 7 use App\Models\CustomerVisit\CustomerVisitItem;
6 use App\Models\Project\DeployBuild; 8 use App\Models\Project\DeployBuild;
  9 +use Carbon\Carbon;
7 use Illuminate\Console\Command; 10 use Illuminate\Console\Command;
8 use Illuminate\Support\Facades\DB; 11 use Illuminate\Support\Facades\DB;
9 12
10 class Yesterday extends Command 13 class Yesterday extends Command
11 { 14 {
  15 + const STATUS_ERROR = 400;
12 public $error = 0; 16 public $error = 0;
13 /** 17 /**
14 * The name and signature of the console command. 18 * The name and signature of the console command.
@@ -24,7 +28,7 @@ class Yesterday extends Command @@ -24,7 +28,7 @@ class Yesterday extends Command
24 */ 28 */
25 protected $description = '统计昨日数据'; 29 protected $description = '统计昨日数据';
26 /** 30 /**
27 - * @name :(定时执行)handle 31 + * @name :(定时执行生成昨日数据统计)handle
28 * @author :lyh 32 * @author :lyh
29 * @method :post 33 * @method :post
30 * @time :2023/5/12 14:48 34 * @time :2023/5/12 14:48
@@ -34,16 +38,31 @@ class Yesterday extends Command @@ -34,16 +38,31 @@ class Yesterday extends Command
34 $deployModel = new DeployBuild(); 38 $deployModel = new DeployBuild();
35 $list = $deployModel->list(); 39 $list = $deployModel->list();
36 $data = []; 40 $data = [];
  41 + $yesterday = Carbon::yesterday()->toDateString();
37 foreach ($list as $v){ 42 foreach ($list as $v){
38 $arr = []; 43 $arr = [];
39 - $yesterday = now()->subDay();  
40 - $arr['yesterday_pv_num'] = DB::table('gl_customer_visit_item')->whereDate('created_at', $yesterday)->where('domain',$v['test_domain'])->count();  
41 - $arr['yesterday_ip_num'] = DB::table('gl_customer_visit')->whereDate('created_at', $yesterday)->where('domain',$v['test_domain'])->count();  
42 - $arr['inquiry_num'] = DB::table('gl_inquiry_set')->whereDate('created_at', $yesterday)->where('project_id',$v['project_id'])->count();  
43 - $arr['date'] = date('Y-m-d',time()); 44 + $arr['yesterday_pv_num'] = DB::table('gl_customer_visit_item')->whereDate('date', $yesterday)->where('domain',$v['test_domain'])->count();
  45 + $arr['yesterday_ip_num'] = DB::table('gl_customer_visit')->whereDate('date', $yesterday)->where('domain',$v['test_domain'])->count();
  46 + $inquiry_list = (new FormGlobalsoApi())->getInquiryList($v['test_domain']);
  47 + if($inquiry_list['status'] == self::STATUS_ERROR){
  48 + $arr['inquiry_num'] = 0;
  49 + }else{
  50 + $arr['inquiry_num'] = count($inquiry_list['data']['total']);
  51 + }
  52 + $arr['date'] = $yesterday;
  53 + $rank_info = DB::table('gl_rank_data')->where(['updated_date'=>$yesterday,'lang'=>''])->select(['compliance_day'])->first();
  54 + if(empty($rank_info)){
  55 + $arr['compliance_day'] = 0;
  56 + }else{
  57 + $arr['compliance_day'] = $rank_info->compliance_day;
  58 + }
  59 + $arr['service_day'] = $v['service_duration'] - Common::getDaysToTargetDate($v['created_at']);
  60 + $arr['project_id'] = $v['project_id'];
  61 + $arr['created_at'] = date('Y-m-d H:i:s');
  62 + $arr['updated_at'] = date('Y-m-d H:i:s');
44 $data[] = $arr; 63 $data[] = $arr;
45 } 64 }
46 - DB::table('gl_yesterday_count')->insert($data); 65 + DB::table('gl_count')->insert($data);
47 echo $this->error; 66 echo $this->error;
48 } 67 }
49 } 68 }
@@ -27,6 +27,7 @@ class Kernel extends ConsoleKernel @@ -27,6 +27,7 @@ class Kernel extends ConsoleKernel
27 $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次 27 $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次
28 $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次 28 $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次
29 $schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次 29 $schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次
  30 +// $schedule->command('domain_time')->dailyAt('01:00')->withoutOverlapping(1); // 更新域名|证书结束时间,每天凌晨1点执行一次
30 } 31 }
31 32
32 /** 33 /**
@@ -133,4 +133,19 @@ class Common @@ -133,4 +133,19 @@ class Common
133 $arr = array_map('unserialize', $arr); 133 $arr = array_map('unserialize', $arr);
134 return $arr; 134 return $arr;
135 } 135 }
  136 +
  137 + /**
  138 + * @param $targetDateTime
  139 + * @name :(获取时间差,精确时分秒,返回天数)getDaysToTargetDate
  140 + * @author :lyh
  141 + * @method :post
  142 + * @time :2023/5/24 9:38
  143 + */
  144 + public static function getDaysToTargetDate($targetDateTime)
  145 + {
  146 + $currentTimestamp = time();
  147 + $targetTimestamp = strtotime($targetDateTime);
  148 + $days = floor(($currentTimestamp - $targetTimestamp) / (60 * 60 * 24));
  149 + return (int)$days;
  150 + }
136 } 151 }
@@ -223,3 +223,24 @@ if (!function_exists('getThisWeekStarDate')) { @@ -223,3 +223,24 @@ if (!function_exists('getThisWeekStarDate')) {
223 return Carbon::now()->startOfWeek()->toDateString(); 223 return Carbon::now()->startOfWeek()->toDateString();
224 } 224 }
225 } 225 }
  226 +
  227 +if (!function_exists('object_to_array')) {
  228 + /**
  229 + * 获取本周一的日期
  230 + * @return mixed
  231 + * @author zbj
  232 + * @date 2023/5/11
  233 + */
  234 + function object_to_array($data)
  235 + {
  236 + if(is_object($data)){
  237 + $data = (array)$data;
  238 + }else{
  239 + foreach ($data as $k => $v){
  240 + $data[$k] = object_to_array($v);
  241 + }
  242 + }
  243 + return $data;
  244 + }
  245 +}
  246 +
@@ -22,9 +22,25 @@ class ServerInformationController extends BaseController @@ -22,9 +22,25 @@ class ServerInformationController extends BaseController
22 */ 22 */
23 public function lists($deleted = ServerInformation::DELETED_NORMAL) 23 public function lists($deleted = ServerInformation::DELETED_NORMAL)
24 { 24 {
  25 + $request = $this->param;
  26 + $search = [];
  27 + $search_array = [
  28 + 'ip' => 'ip',
  29 + 'title' => 'title'
  30 + ];
  31 + foreach ($search_array as $key => $item) {
  32 + if (isset($request[$key]) && $request[$key]) {
  33 + $search[$item] = $request[$key];
  34 + }
  35 + }
25 $size = request()->input('size', $this->row); 36 $size = request()->input('size', $this->row);
26 - $data = ServerInformation::query()->select(['id', 'title', 'ip'])  
27 - ->where('deleted', $deleted) 37 + $query = ServerInformation::query()->select(['id', 'title', 'ip']);
  38 + if ($search) {
  39 + foreach ($search as $key => $item) {
  40 + $query = $query->Where("{$key}", 'like', "%{$item}%");
  41 + }
  42 + }
  43 + $data = $query->where('deleted', $deleted)
28 ->orderBy('id', 'desc') 44 ->orderBy('id', 'desc')
29 ->paginate($size); 45 ->paginate($size);
30 return $this->response('success', Code::SUCCESS, $data); 46 return $this->response('success', Code::SUCCESS, $data);
@@ -58,9 +74,10 @@ class ServerInformationController extends BaseController @@ -58,9 +74,10 @@ class ServerInformationController extends BaseController
58 public function edit(ServerInformationRequest $serverInformationRequest, ServerInformationLogic $serverInformationLogic) 74 public function edit(ServerInformationRequest $serverInformationRequest, ServerInformationLogic $serverInformationLogic)
59 { 75 {
60 $serverInformationRequest->validate([ 76 $serverInformationRequest->validate([
61 - 'id' => ['required'], 77 + 'id' => 'required|integer',
62 ], [ 78 ], [
63 'id.required' => 'ID不能为空', 79 'id.required' => 'ID不能为空',
  80 + 'id.integer' => 'ID必须为整数',
64 ]); 81 ]);
65 $serverInformationLogic->update(); 82 $serverInformationLogic->update();
66 $this->response('服务器修改成功!'); 83 $this->response('服务器修改成功!');
@@ -110,7 +127,7 @@ class ServerInformationController extends BaseController @@ -110,7 +127,7 @@ class ServerInformationController extends BaseController
110 public function search(Request $request) 127 public function search(Request $request)
111 { 128 {
112 $search = []; 129 $search = [];
113 - $ip = $request->input('ip'); 130 + $ip = $request->input('ip');
114 if ($ip) { 131 if ($ip) {
115 $search['ip'] = $ip; 132 $search['ip'] = $ip;
116 } 133 }
@@ -125,7 +142,7 @@ class ServerInformationController extends BaseController @@ -125,7 +142,7 @@ class ServerInformationController extends BaseController
125 foreach ($search as $key => $item) { 142 foreach ($search as $key => $item) {
126 $query = $query->Where("{$key}", 'like', "%{$item}%"); 143 $query = $query->Where("{$key}", 'like', "%{$item}%");
127 } 144 }
128 - $size = $request->input('size', $this->row); 145 + $size = $request->input('size', $this->row);
129 $query = $query->orderBy('id', 'desc')->paginate($size); 146 $query = $query->orderBy('id', 'desc')->paginate($size);
130 return $this->response('success', Code::SUCCESS, $query); 147 return $this->response('success', Code::SUCCESS, $query);
131 } 148 }
@@ -142,7 +159,7 @@ class ServerInformationController extends BaseController @@ -142,7 +159,7 @@ class ServerInformationController extends BaseController
142 public function getServerInfo(int $deleted = ServerInformation::DELETED_NORMAL) 159 public function getServerInfo(int $deleted = ServerInformation::DELETED_NORMAL)
143 { 160 {
144 $serverInformationLogic = new ServerInformationLogic(); 161 $serverInformationLogic = new ServerInformationLogic();
145 - $data = $serverInformationLogic->serverInfo($deleted); 162 + $data = $serverInformationLogic->serverInfo($deleted);
146 if (!$data) { 163 if (!$data) {
147 return $this->response('服务器信息不存在', Code::USER_ERROR); 164 return $this->response('服务器信息不存在', Code::USER_ERROR);
148 } 165 }
@@ -150,6 +167,7 @@ class ServerInformationController extends BaseController @@ -150,6 +167,7 @@ class ServerInformationController extends BaseController
150 } 167 }
151 168
152 /** 169 /**
  170 + * 获取软删除的服务器信息
153 * @return JsonResponse 171 * @return JsonResponse
154 * @throws AsideGlobalException 172 * @throws AsideGlobalException
155 * @throws BsideGlobalException 173 * @throws BsideGlobalException
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Aside\Domain;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Exceptions\AsideGlobalException;
  7 +use App\Exceptions\BsideGlobalException;
  8 +use App\Http\Controllers\Aside\BaseController;
  9 +use App\Http\Logic\Aside\Domain\DomainInfoLogic;
  10 +use App\Http\Requests\Aside\Domain\DomainInfoRequest;
  11 +use App\Models\Aside\Domain\DomainInfo;
  12 +use App\Models\Aside\Domain\DomainInfoLog;
  13 +use Illuminate\Http\JsonResponse;
  14 +use Psr\Container\ContainerExceptionInterface;
  15 +use Psr\Container\NotFoundExceptionInterface;
  16 +
  17 +/**
  18 + * Class DomainInfoController
  19 + * @package App\Http\Controllers\Aside 域名管理
  20 + */
  21 +class DomainInfoController extends BaseController
  22 +{
  23 + /**
  24 + * 域名列表
  25 + * @param int $deleted
  26 + * @return JsonResponse
  27 + */
  28 + public function lists(int $deleted = DomainInfo::DELETED_NORMAL)
  29 + {
  30 + $request = $this->param;
  31 + $search = [];
  32 + $search_array = [
  33 + 'domain' => 'domain',
  34 + 'belong' => 'belong_to',
  35 + 'domain_time' => 'domain_end_time',
  36 + 'certificate_time' => 'certificate_end_time'
  37 + ];
  38 + foreach ($search_array as $key => $item) {
  39 + if (isset($request[$key]) && $request[$key]) {
  40 + $search[$item] = $request[$key];
  41 + }
  42 + }
  43 + // 每页条数
  44 + $size = request()->input('size', $this->row);
  45 + $query = DomainInfo::query()->select(['id', 'domain', 'belong_to']);
  46 + if ($search) {
  47 + foreach ($search as $key => $item) {
  48 + $query = $query->Where("{$key}", 'like', "%{$item}%");
  49 + }
  50 + }
  51 + $data = $query->where('deleted', $deleted)
  52 + ->orderBy('id', 'desc')
  53 + ->paginate($size);
  54 + return $this->response('success', Code::SUCCESS, $data);
  55 + }
  56 +
  57 + /**
  58 + * 获取软删除的数据
  59 + * @return JsonResponse
  60 + */
  61 + public function delete_list()
  62 + {
  63 + return $this->lists(DomainInfo::DELETED_DELETE);
  64 + }
  65 +
  66 + /**
  67 + * 添加域名
  68 + * @param DomainInfoRequest $domainInfoRequest
  69 + * @param DomainInfoLogic $domainInfoLogic
  70 + * @return void
  71 + * @throws AsideGlobalException
  72 + * @throws BsideGlobalException
  73 + */
  74 + public function add(DomainInfoRequest $domainInfoRequest, DomainInfoLogic $domainInfoLogic)
  75 + {
  76 + $domainInfoRequest->validated();
  77 + $domainInfoLogic->create();
  78 + $this->response('域名添加成功!');
  79 + }
  80 +
  81 + /**
  82 + * 编辑域名
  83 + * @param DomainInfoRequest $domainInfoRequest
  84 + * @param DomainInfoLogic $domainInfoLogic
  85 + * @return void
  86 + * @throws AsideGlobalException
  87 + * @throws BsideGlobalException
  88 + */
  89 + public function edit(DomainInfoRequest $domainInfoRequest, DomainInfoLogic $domainInfoLogic)
  90 + {
  91 + $domainInfoRequest->validate([
  92 + 'id' => 'required|integer'
  93 + ], [
  94 + 'id.required' => 'id不能为空',
  95 + 'id.integer' => 'id参数错误'
  96 + ]);
  97 + $domainInfoLogic->update();
  98 + $this->response('域名修改成功!');
  99 + }
  100 +
  101 + /**
  102 + * 删除
  103 + * @param DomainInfoLogic $domainInfoLogic
  104 + * @return void
  105 + * @throws AsideGlobalException
  106 + * @throws BsideGlobalException
  107 + */
  108 + public function delete(DomainInfoLogic $domainInfoLogic)
  109 + {
  110 + $domainInfoLogic->get_batch_update();
  111 + $this->response('域名删除成功!');
  112 + }
  113 +
  114 + /**
  115 + * 恢复数据
  116 + * @param DomainInfoLogic $domainInfoLogic
  117 + * @return void
  118 + * @throws AsideGlobalException
  119 + * @throws BsideGlobalException
  120 + */
  121 + public function restore(DomainInfoLogic $domainInfoLogic)
  122 + {
  123 + $domainInfoLogic->get_batch_update(DomainInfoLog::ACTION_RECOVER, DomainInfo::DELETED_DELETE);
  124 + $this->response('域名恢复成功!');
  125 + }
  126 +
  127 + /**
  128 + * 域名信息
  129 + * @param int $deleted
  130 + * @return JsonResponse
  131 + * @throws AsideGlobalException
  132 + * @throws BsideGlobalException
  133 + * @throws ContainerExceptionInterface
  134 + * @throws NotFoundExceptionInterface
  135 + */
  136 + public function info(int $deleted = DomainInfo::DELETED_NORMAL)
  137 + {
  138 + $domainInfoLogic = new DomainInfoLogic();
  139 + $data = $domainInfoLogic->domainInfo($deleted);
  140 + if (!$data) {
  141 + return $this->response('域名信息不存在', Code::USER_ERROR);
  142 + }
  143 + return $this->success($data->toArray());
  144 + }
  145 +
  146 + /**
  147 + * 获取软删除域名信息
  148 + * @return JsonResponse
  149 + * @throws AsideGlobalException
  150 + * @throws BsideGlobalException
  151 + * @throws ContainerExceptionInterface
  152 + * @throws NotFoundExceptionInterface
  153 + */
  154 + public function getDeleteDomainInfo()
  155 + {
  156 + return $this->info(DomainInfo::DELETED_DELETE);
  157 + }
  158 +}
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Aside\Domain;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Http\Controllers\Aside\BaseController;
  7 +use App\Models\Aside\Domain\DomainInfoLog;
  8 +use Illuminate\Http\Request;
  9 +
  10 +class DomainInfoLogController extends BaseController
  11 +{
  12 + public function lists(Request $request)
  13 + {
  14 + $size = $request->input('size', $this->row);
  15 + $data = DomainInfoLog::query()
  16 + ->orderBy('id', 'desc')
  17 + ->paginate($size);
  18 + return $this->response('success', Code::SUCCESS, $data);
  19 +
  20 + }
  21 +}
@@ -210,5 +210,4 @@ class BaseController extends Controller @@ -210,5 +210,4 @@ class BaseController extends Controller
210 } 210 }
211 211
212 212
213 -  
214 } 213 }
@@ -3,24 +3,83 @@ @@ -3,24 +3,83 @@
3 namespace App\Http\Controllers\Bside\HomeCount; 3 namespace App\Http\Controllers\Bside\HomeCount;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
  6 +use App\Helper\Common;
  7 +use App\Helper\FormGlobalsoApi;
6 use App\Http\Controllers\Bside\BaseController; 8 use App\Http\Controllers\Bside\BaseController;
  9 +use App\Http\Logic\Bside\HomeCount\CountLogic;
  10 +use App\Models\Project\DeployBuild;
  11 +use Carbon\Carbon;
  12 +use Illuminate\Support\Facades\DB;
7 13
8 class CountController extends BaseController 14 class CountController extends BaseController
9 { 15 {
  16 + const STATUS_ERROR = 400;
10 /** 17 /**
11 * @name :(昨日统计数据)yesterday_count 18 * @name :(昨日统计数据)yesterday_count
12 * @author :lyh 19 * @author :lyh
13 * @method :post 20 * @method :post
14 * @time :2023/5/23 17:23 21 * @time :2023/5/23 17:23
15 */ 22 */
16 - public function count(){ 23 + public function count(CountLogic $countLogic){
17 $data = []; 24 $data = [];
  25 + //TODO::昨日数据统计
  26 + $data['yesterday'] = $countLogic->yesterday_count();
18 //TODO::全球搜方案信息 27 //TODO::全球搜方案信息
  28 + $data['scheme_info'] = $countLogic->scheme_info();
19 //TODO::网站访问量统计 29 //TODO::网站访问量统计
  30 + $data['total_visit'] = $countLogic->total_count(isset($data['yesterday']['inquiry_num']) ? $data['yesterday']['inquiry_num'] : '');
20 //TODO::关键字排名数据 31 //TODO::关键字排名数据
21 - //TODO::关键字排名数据 32 + $data['keyword_data'] = $countLogic->keyword_data_count();
  33 + //TODO::相关数据统计
  34 + $data['with_data'] = $countLogic->with_data_count();
  35 + //TODO::30天pv,ip统计
  36 + $data['visit_data'] = $countLogic->visit_data_count();
  37 + //TODO::询盘国家统计
  38 + $data['country_data'] = $countLogic->inquiry_country_count();
  39 + //TODO::来源排名
  40 + $data['referrer_count'] = $countLogic->referrer_count();
  41 + //TODO::访问国家前10
  42 + $data['access_country_count'] = $countLogic->access_country_count();
  43 + //TODO::企业中心服务
  44 + $data['enterprise_service'] = $countLogic->enterprise_service();
22 return $this->response('success',Code::SUCCESS,$data); 45 return $this->response('success',Code::SUCCESS,$data);
23 } 46 }
24 47
25 - 48 + /***
  49 + * @name :(手动获取昨日数据统计)yesterday
  50 + * @author :lyh
  51 + * @method :post
  52 + * @time :2023/5/24 9:13
  53 + */
  54 + public function yesterday(){
  55 + $deployModel = new DeployBuild();
  56 + $list = $deployModel->list();
  57 + $data = [];
  58 + $yesterday = Carbon::yesterday()->toDateString();
  59 + foreach ($list as $v){
  60 + $arr = [];
  61 + $arr['yesterday_pv_num'] = DB::table('gl_customer_visit_item')->whereDate('date', $yesterday)->where('domain',$v['test_domain'])->count();
  62 + $arr['yesterday_ip_num'] = DB::table('gl_customer_visit')->whereDate('date', $yesterday)->where('domain',$v['test_domain'])->count();
  63 + $inquiry_list = (new FormGlobalsoApi())->getInquiryList($v['test_domain']);
  64 + if($inquiry_list['status'] == self::STATUS_ERROR){
  65 + $arr['inquiry_num'] = 0;
  66 + }else{
  67 + $arr['inquiry_num'] = count($inquiry_list['data']['total']);
  68 + }
  69 + $arr['date'] = $yesterday;
  70 + $rank_info = DB::table('gl_rank_data')->where(['updated_date'=>$yesterday,'lang'=>''])->select(['compliance_day'])->first();
  71 + if(empty($rank_info)){
  72 + $arr['compliance_day'] = 0;
  73 + }else{
  74 + $arr['compliance_day'] = $rank_info->compliance_day;
  75 + }
  76 + $arr['service_day'] = $v['service_duration'] - Common::getDaysToTargetDate($v['created_at']);
  77 + $arr['project_id'] = $v['project_id'];
  78 + $arr['created_at'] = date('Y-m-d H:i:s');
  79 + $arr['updated_at'] = date('Y-m-d H:i:s');
  80 + $data[] = $arr;
  81 + }
  82 + DB::table('gl_count')->insert($data);
  83 + $this->response('success');
  84 + }
26 } 85 }
@@ -120,92 +120,16 @@ class TemplateController extends BaseController @@ -120,92 +120,16 @@ class TemplateController extends BaseController
120 $source = $this->param['source']??''; 120 $source = $this->param['source']??'';
121 $source_id = $this->param['source_id']??0; 121 $source_id = $this->param['source_id']??0;
122 122
  123 +
123 $data = TemplateLogic::instance()->first($source,$source_id); 124 $data = TemplateLogic::instance()->first($source,$source_id);
124 125
125 - $def = '<div class=" d-flex align-items-center justify-content-between py-md-4">  
126 - <div class="logo w-25 w-sm-auto"><a href="#"><img class="img-fluid" src="img/logo.png" alt=""></a></div>  
127 - <nav class="navbar navbar-expand-md navbar-dark flex-fill justify-content-end mx-2 pe-md-5">  
128 - <button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#navMenu"  
129 - aria-controls="navMenu">  
130 - <span class="navbar-toggler-icon"></span>  
131 - </button>  
132 - <ul class="nav column-gap-5 justify-content-end text-white d-none d-md-flex">  
133 - <li><a href="#">Home</a></li>  
134 - <li class="dropdown">  
135 - <a href="#" class="dropdown-toggle" data-bs-toggle="dropdown">Products</a>  
136 - <ul class="dropdown-menu fs-6 text-body shadow-sm border-0">  
137 - <li><a href="#" class="dropdown-item py-2">Product Information</a></li>  
138 - <li><a href="#" class="dropdown-item py-2">Change of Insurance</a></li>  
139 - <li><a href="#" class="dropdown-item py-2">Traveling Oxygen Program</a></li>  
140 - <li><a href="#" class="dropdown-item py-2">Contact</a></li>  
141 - </ul>  
142 - </li>  
143 - <li><a href="#">News</a></li>  
144 - <li><a href="#">Download</a></li>  
145 - <li><a href="#">FAQ</a></li>  
146 - <li><a href="#">Contact</a></li>  
147 - </ul>  
148 - </nav>  
149 - <div class="d-flex align-items-center justify-content-end">  
150 - <div class="search">  
151 - <button type="button" class="btn border-0" data-bs-toggle="dropdown">  
152 - <svg viewBox="0 0 24 24" width="18" height="18" stroke="#ffffff" stroke-width="2"  
153 - fill="none" stroke-linecap="round" stroke-linejoin="round" class="css-i6dzq1">  
154 - <circle cx="11" cy="11" r="8"></circle>  
155 - <line x1="21" y1="21" x2="16.65" y2="16.65"></line>  
156 - </svg>  
157 - </button>  
158 - <div class="dropdown-menu p-3 shadow-sm border-0">  
159 - <form action="">  
160 - <div class="d-flex mb-2">  
161 - <input type="text" class="form-control" name="search" placeholder="Start Typing...">  
162 - <button class="btn btn-search border-0" type="submit">  
163 - <svg viewBox="0 0 24 24" width="18" height="18" stroke="#333333"  
164 - stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"  
165 - class="css-i6dzq1">  
166 - <circle cx="11" cy="11" r="8"></circle>  
167 - <line x1="21" y1="21" x2="16.65" y2="16.65"></line>  
168 - </svg>  
169 - </button>  
170 - </div>  
171 - <p class="search-attr">Hit enter to search or ESC to close</p>  
172 - </form>  
173 - </div>  
174 - </div>  
175 - <div class="change-language ms-md-4">  
176 - <div role="button" class="dropdown-toggle text-white d-flex align-items-center"  
177 - data-bs-toggle="dropdown">  
178 - <b class="country-flag language-flag-en"></b> <span>English</span>  
179 - </div>  
180 - <div class="dropdown-menu shadow-sm border-0">  
181 - <div class="d-flex flex-wrap p-3 text-body">  
182 - <a href="#" class="col-4 mb-3 pe-2 d-flex align-items-center" title="English">  
183 - <b class="country-flag language-flag-en"></b>  
184 - <span>English</span>  
185 - </a>  
186 - <a href="#" class="col-4 mb-3 pe-2 d-flex align-items-center" title="Françai">  
187 - <b class="country-flag language-flag-fr"></b>  
188 - <span>Françai</span>  
189 - </a>  
190 - <a href="#" class="col-4 mb-3 pe-2 d-flex align-items-center" title="Español">  
191 - <b class="country-flag language-flag-es"></b>  
192 - <span>Español</span>  
193 - </a>  
194 - <a href="#" class="col-4 mb-3 pe-2 d-flex align-items-center" title="Deutsch">  
195 - <b class="country-flag language-flag-de"></b>  
196 - <span>Deutsch</span>  
197 - </a>  
198 - <a href="#" class="col-4 mb-3 pe-2 d-flex align-items-center" title="Română">  
199 - <b class="country-flag language-flag-ro"></b>  
200 - <span>Română</span>  
201 - </a>  
202 - </div>  
203 - </div>  
204 - </div>  
205 - </div>  
206 - </div>';  
207 -  
208 - return $this->response('',Code::SUCCESS,$data?$data['html']:$def); 126 + $res = [
  127 + 'html' => $data['html']??'',
  128 + 'name' => 'example'
  129 + ];
  130 +
  131 +
  132 + return $this->response('',Code::SUCCESS,$res);
209 133
210 } 134 }
211 135
@@ -12,9 +12,7 @@ use App\Models\Devops\ServerInformationLog; @@ -12,9 +12,7 @@ use App\Models\Devops\ServerInformationLog;
12 use Illuminate\Database\Eloquent\Builder; 12 use Illuminate\Database\Eloquent\Builder;
13 use Illuminate\Database\Eloquent\Collection; 13 use Illuminate\Database\Eloquent\Collection;
14 use Illuminate\Database\Eloquent\Model; 14 use Illuminate\Database\Eloquent\Model;
15 -use Illuminate\Http\JsonResponse;  
16 use Illuminate\Support\Facades\DB; 15 use Illuminate\Support\Facades\DB;
17 -use Illuminate\Support\Facades\Log;  
18 16
19 class ServerInformationLogic extends BaseLogic 17 class ServerInformationLogic extends BaseLogic
20 { 18 {
@@ -41,31 +39,25 @@ class ServerInformationLogic extends BaseLogic @@ -41,31 +39,25 @@ class ServerInformationLogic extends BaseLogic
41 */ 39 */
42 public function create() 40 public function create()
43 { 41 {
44 - $request = $this->param; 42 + $request = $this->param ?? [];
45 $service = new ServerInformation(); 43 $service = new ServerInformation();
46 - $this->extracted($request, $service);  
47 - if ($this->checkIp($service->ip)) {  
48 - return $this->fail('服务器信息添加失败,ip已存在'); 44 + $this->extracted( $request, $service );
  45 + if ( $this->checkIp( $service->ip ) ) {
  46 + return $this->fail( '服务器信息添加失败,ip已存在' );
49 } 47 }
50 DB::beginTransaction(); 48 DB::beginTransaction();
51 49
52 - if ($service->save()) {  
53 - $original = [  
54 - 'id' => $service->id,  
55 - 'type' => $service->type,  
56 - 'ip' => $service->ip,  
57 - 'title' => $service->title,  
58 - 'belong_to' => $service->belong_to,  
59 - 'sshpass' => $service->sshpass,  
60 - 'ports' => $service->ports,  
61 - ]; 50 + if ( $service->save() ) {
  51 + $original = $service->getOriginal();
  52 + $original['type'] = $request['type'];
  53 + $original['belong_to'] = $request['belong_to'];
62 // 添加日志 54 // 添加日志
63 - $this->server_action_log(ServerInformationLog::ACTION_ADD, $original, $original, '添加服务器信息成功 - ID : ' . $service->id); 55 + $this->server_action_log( ServerInformationLog::ACTION_ADD, $original, $original, '添加服务器信息成功 - ID : ' . $service->id );
64 DB::commit(); 56 DB::commit();
65 return $this->success(); 57 return $this->success();
66 } 58 }
67 DB::rollBack(); 59 DB::rollBack();
68 - return $this->fail('服务器信息添加失败'); 60 + return $this->fail( '服务器信息添加失败' );
69 61
70 } 62 }
71 63
@@ -77,51 +69,55 @@ class ServerInformationLogic extends BaseLogic @@ -77,51 +69,55 @@ class ServerInformationLogic extends BaseLogic
77 */ 69 */
78 public function update() 70 public function update()
79 { 71 {
80 -  
81 - $service = new ServerInformation(); 72 + $service = $this->getService();
82 $fields_array = $service->FieldsArray(); 73 $fields_array = $service->FieldsArray();
83 - $request = $this->param;  
84 - $service = $this->ServerInfo();  
85 - $original = $service->toArray();  
86 - $this->extracted($request, $service);  
87 - 74 + $request = $this->param ?? [];
  75 + $original = $service->getOriginal();
  76 + $original['type'] = $service->ServiceStr( $original['type'] );
  77 + $original['belong_to'] = $service->BelongToStr( $original['belong_to'] );
  78 + $this->extracted( $request, $service, $original );
88 // 检查ip是否存在 79 // 检查ip是否存在
89 - if ($service->ip != $request['ip']) {  
90 - if ($this->checkIp($request['ip'])) {  
91 - $this->fail('服务器信息修改失败,ip已存在', Code::USER_ERROR); 80 + if ( $service->ip != $request['ip'] ) {
  81 + if ( $this->checkIp( $request['ip'] ) ) {
  82 + $this->fail( '服务器信息修改失败,ip已存在', Code::USER_ERROR );
92 } 83 }
93 } 84 }
94 DB::beginTransaction(); 85 DB::beginTransaction();
95 - if ($service->save()) {  
96 - $revised = [  
97 - 'id' => $service->id,  
98 - 'type' => $service->type,  
99 - 'ip' => $service->ip,  
100 - 'title' => $service->title,  
101 - 'belong_to' => $service->belong_to,  
102 - 'sshpass' => $service->sshpass,  
103 - 'ports' => $service->ports,  
104 - 'other' => $service->other,  
105 - 'delete' => $service->delete,  
106 - ];  
107 - $diff = array_diff_assoc($original, $revised);  
108 - unset($diff['create_at']);  
109 - unset($diff['update_at']);  
110 - unset($diff['deleted']); 86 + if ( $service->save() ) {
  87 + $revised = $service->getAttributes();
  88 + $diff = array_diff_assoc( $original, $revised );
  89 + unset( $diff['created_at'] );
  90 + unset( $diff['updated_at'] );
  91 + unset( $diff['deleted'] );
111 $remarks = ''; 92 $remarks = '';
112 - if ($diff) { 93 + if ( $diff ) {
113 $remarks .= '修改ID为 ' . $service->id . ' 的服务器信息,修改内容为:'; 94 $remarks .= '修改ID为 ' . $service->id . ' 的服务器信息,修改内容为:';
114 - foreach ($diff as $key => $value) { 95 + foreach ( $diff as $key => $value ) {
115 $remarks .= $fields_array[$key] . ' 由 ' . $value . ' 修改为 ' . $revised[$key] . '; '; 96 $remarks .= $fields_array[$key] . ' 由 ' . $value . ' 修改为 ' . $revised[$key] . '; ';
116 } 97 }
  98 + } else {
  99 + $remarks .= '修改ID为 ' . $service->id . ' 的服务器信息,无修改';
117 } 100 }
118 // 添加日志 101 // 添加日志
119 - $this->server_action_log(ServerInformationLog::ACTION_UPDATE, $original, $revised, $remarks); 102 + $this->server_action_log( ServerInformationLog::ACTION_UPDATE, $original, $revised, $remarks );
120 DB::commit(); 103 DB::commit();
121 return $this->success(); 104 return $this->success();
122 } 105 }
123 DB::rollBack(); 106 DB::rollBack();
124 - return $this->fail('服务器信息修改失败'); 107 + return $this->fail( '服务器信息修改失败' );
  108 + }
  109 +
  110 + public function getService( int $deleted = ServerInformation::DELETED_NORMAL )
  111 + {
  112 + $id = $this->param['id'] ?? 0;
  113 + if ( !$id ) {
  114 + return $this->fail( 'ID不能为空' );
  115 + }
  116 + $data = ServerInformation::query()->where( 'deleted', $deleted )->find( $id );
  117 + if ( !$data ) {
  118 + return $this->fail( '数据不存在!' );
  119 + }
  120 + return $data;
125 } 121 }
126 122
127 /** 123 /**
@@ -129,10 +125,10 @@ class ServerInformationLogic extends BaseLogic @@ -129,10 +125,10 @@ class ServerInformationLogic extends BaseLogic
129 * @param $ip 125 * @param $ip
130 * @return bool 126 * @return bool
131 */ 127 */
132 - public function checkIp($ip) 128 + public function checkIp( $ip )
133 { 129 {
134 - $usIp = ServerInformation::query()->where('ip', $ip)->first();  
135 - if ($usIp) { 130 + $usIp = ServerInformation::query()->where( 'ip', $ip )->first();
  131 + if ( $usIp ) {
136 return true; 132 return true;
137 } else { 133 } else {
138 return false; 134 return false;
@@ -146,15 +142,15 @@ class ServerInformationLogic extends BaseLogic @@ -146,15 +142,15 @@ class ServerInformationLogic extends BaseLogic
146 * @throws AsideGlobalException 142 * @throws AsideGlobalException
147 * @throws BsideGlobalException 143 * @throws BsideGlobalException
148 */ 144 */
149 - public function serverInfo(int $deleted = ServerInformation::DELETED_NORMAL) 145 + public function serverInfo( int $deleted = ServerInformation::DELETED_NORMAL )
150 { 146 {
151 - $id = \request()->input('id');  
152 - if (!$id) {  
153 - return $this->fail('参数错误'); 147 + $id = $this->param['id'] ?? 0;
  148 + if ( !$id ) {
  149 + return $this->fail( 'ID不能为空' );
154 } 150 }
155 - $data = ServerInformation::query()->where('deleted', $deleted)->find($id, ['type', 'ip', 'title', 'belong_to', 'sshpass', 'ports', 'create_at', 'update_at']);  
156 - if (!$data) {  
157 - return $this->fail('数据不存在!'); 151 + $data = ServerInformation::query()->where( 'deleted', $deleted )->find( $id, [ 'type', 'ip', 'title', 'belong_to', 'ports', 'created_at', 'updated_at' ] );
  152 + if ( !$data ) {
  153 + return $this->fail( '数据不存在!' );
158 } 154 }
159 return $data; 155 return $data;
160 } 156 }
@@ -165,32 +161,10 @@ class ServerInformationLogic extends BaseLogic @@ -165,32 +161,10 @@ class ServerInformationLogic extends BaseLogic
165 * @param array $original 原始数据 161 * @param array $original 原始数据
166 * @param array $revised 修改后数据 162 * @param array $revised 修改后数据
167 */ 163 */
168 - public function server_action_log(int $action = ServerInformationLog::ACTION_ADD, array $original = [], array $revised = [], $remarks = '') 164 + public function server_action_log( int $action = ServerInformationLog::ACTION_ADD, array $original = [], array $revised = [], $remarks = '' )
169 { 165 {
170 - // $action 1:添加 2:修改 3:删除 4:恢复  
171 - $actionArr = ServerInformationLog::actionArr();  
172 - $actionStr = $actionArr[$action];  
173 - $ip = request()->getClientIp();  
174 - $url = request()->getRequestUri();  
175 - $method = request()->getMethod();  
176 - $userId = $this->uid ?? 0;  
177 - $log = new ServerInformationLog();  
178 - $log->user_id = $userId;  
179 - $log->action = $actionStr;  
180 - $log->original = json_encode($original);  
181 - $log->revised = json_encode($revised);  
182 - $log->ip = $ip;  
183 - $log->url = $url;  
184 - $log->method = $method;  
185 - $log->remarks = $remarks;  
186 - DB::beginTransaction();  
187 - try {  
188 - $log->save();  
189 - DB::commit();  
190 - } catch (\Exception $e) {  
191 - DB::rollBack();  
192 - Log::error('服务器信息日志添加失败');  
193 - } 166 + $log = new ServerInformationLog();
  167 + $this->log( $log, $action, $original, $revised, $remarks );
194 } 168 }
195 169
196 /** 170 /**
@@ -198,14 +172,14 @@ class ServerInformationLogic extends BaseLogic @@ -198,14 +172,14 @@ class ServerInformationLogic extends BaseLogic
198 * @param $service 172 * @param $service
199 * @return void 173 * @return void
200 */ 174 */
201 - public function extracted(array $request, $service) 175 + public function extracted( array $request, $service, array $original = [] )
202 { 176 {
203 - $service->type = trim($request['type']); // 服务器类型  
204 - $service->ip = trim($request['ip']); // 服务器ip  
205 - $service->title = trim($request['title']); // 服务器标题  
206 - $service->belong_to = trim($request['belong_to']); // 服务器归属  
207 - $service->sshpass = trim($request['sshpass']); // ssh密码  
208 - $service->ports = trim($request['ports']); // ssh端口 177 + $service->type = trim( $request['type'] ) ?? $original['type']; // 服务器类型
  178 + $service->ip = trim( $request['ip'] ) ?? $original['ip']; // 服务器ip
  179 + $service->title = trim( $request['title'] ) ?? $original['title']; // 服务器标题
  180 + $service->belong_to = trim( $request['belong_to'] ) ?? $original['belong_to']; // 服务器归属
  181 + $service->sshpass = trim( $request['sshpass'] ) ?? $original['sshpass']; // ssh密码
  182 + $service->ports = trim( $request['ports'] ) ?? $original['ports']; // ssh端口
209 } 183 }
210 184
211 /** 185 /**
@@ -214,38 +188,50 @@ class ServerInformationLogic extends BaseLogic @@ -214,38 +188,50 @@ class ServerInformationLogic extends BaseLogic
214 * @throws AsideGlobalException 188 * @throws AsideGlobalException
215 * @throws BsideGlobalException 189 * @throws BsideGlobalException
216 */ 190 */
217 - public function get_batch_update($action = ServerInformationLog::ACTION_DELETE, $deleted = ServerInformation::DELETED_NORMAL) 191 + public function get_batch_update( $action = ServerInformationLog::ACTION_DELETE, $deleted = ServerInformation::DELETED_NORMAL )
218 { 192 {
219 - $id = request()->input('id');  
220 - if (!$id) {  
221 - return $this->fail('参数错误');  
222 - }  
223 - $ids = [];  
224 - if (!is_array($id)) {  
225 - $ids = explode(',', $id);  
226 - }  
227 - $ids = array_filter($ids, 'intval');  
228 - if (empty($ids)) {  
229 - return $this->fail('参数错误');  
230 - }  
231 - $data = ServerInformation::query()->whereIn('id', $ids)->where('deleted', $deleted)->get();  
232 - $restore_ids = $data->pluck('id')->toArray();  
233 - $actionArr = ServerInformationLog::actionArr();  
234 - $actionStr = $actionArr[$action];  
235 - if (empty($restore_ids)) {  
236 - $this->fail($actionStr . '服务器信息不存在!', Code::USER_ERROR); 193 + $ids = $this->getIds();
  194 + $data = ServerInformation::query()->whereIn( 'id', $ids )->where( 'deleted', $deleted )->get();
  195 + $restore_ids = $data->pluck( 'id' )->toArray();
  196 + $actionArr = ServerInformationLog::actionArr();
  197 + $actionStr = $actionArr[$action];
  198 + if ( empty( $restore_ids ) ) {
  199 + $this->fail( $actionStr . '服务器信息不存在!', Code::USER_ERROR );
237 } 200 }
238 $original = $data->toArray(); 201 $original = $data->toArray();
239 DB::beginTransaction(); 202 DB::beginTransaction();
240 try { 203 try {
241 $update = $deleted == ServerInformation::DELETED_NORMAL ? ServerInformation::DELETED_DELETE : ServerInformation::DELETED_NORMAL; 204 $update = $deleted == ServerInformation::DELETED_NORMAL ? ServerInformation::DELETED_DELETE : ServerInformation::DELETED_NORMAL;
242 - ServerInformation::query()->whereIn('id', $restore_ids)->update(['deleted' => $update]);  
243 - $this->server_action_log($action, $original, $original, $actionStr . '服务器信息 - ID : ' . implode(', ', $restore_ids)); 205 + ServerInformation::query()->whereIn( 'id', $restore_ids )->update( [ 'deleted' => $update ] );
  206 + $this->server_action_log( $action, $original, $original, $actionStr . '服务器信息 - ID : ' . implode( ', ', $restore_ids ) );
244 DB::commit(); 207 DB::commit();
245 return $this->success(); 208 return $this->success();
246 - } catch (\Exception $e) { 209 + } catch ( \Exception $e ) {
247 DB::rollBack(); 210 DB::rollBack();
248 - return $this->fail('服务器信息' . $actionStr . '失败', Code::USER_ERROR); 211 + return $this->fail( '服务器信息' . $actionStr . '失败', Code::USER_ERROR );
  212 + }
  213 + }
  214 +
  215 + /**
  216 + * 批量获取数据恢复
  217 + * @return array
  218 + * @throws AsideGlobalException
  219 + * @throws BsideGlobalException
  220 + */
  221 + public function getIds()
  222 + {
  223 + $id = $this->param['id'] ?? 0;
  224 + if ( !$id ) {
  225 + return $this->fail( '参数错误' );
  226 + }
  227 + $ids = [];
  228 + if ( !is_array( $id ) ) {
  229 + $ids = explode( ',', $id );
  230 + }
  231 + $ids = array_filter( $ids, 'intval' );
  232 + if ( empty( $ids ) ) {
  233 + return $this->fail( '参数错误' );
249 } 234 }
  235 + return $ids;
250 } 236 }
251 } 237 }
  1 +<?php
  2 +
  3 +namespace App\Http\Logic\Aside\Domain;
  4 +
  5 +
  6 +use App\Enums\Common\Code;
  7 +use App\Exceptions\AsideGlobalException;
  8 +use App\Exceptions\BsideGlobalException;
  9 +use App\Http\Logic\Aside\BaseLogic;
  10 +use App\Http\Logic\Aside\Devops\ServerInformationLogic;
  11 +use App\Models\Aside\Domain\DomainInfo;
  12 +use App\Models\Aside\Domain\DomainInfoLog;
  13 +use App\Models\Devops\ServerInformation;
  14 +use Illuminate\Database\Eloquent\Builder;
  15 +use Illuminate\Database\Eloquent\Collection;
  16 +use Illuminate\Database\Eloquent\Model;
  17 +use Illuminate\Support\Facades\DB;
  18 +
  19 +class DomainInfoLogic extends BaseLogic
  20 +{
  21 + /**
  22 + * @var array
  23 + */
  24 + private $param;
  25 +
  26 + public function __construct()
  27 + {
  28 + parent::__construct();
  29 +
  30 + $this->model = new ServerInformation();
  31 +
  32 + $this->param = $this->requestAll;
  33 +
  34 + }
  35 +
  36 + /**
  37 + * 添加数据
  38 + * @return array
  39 + * @throws AsideGlobalException
  40 + * @throws BsideGlobalException
  41 + */
  42 + public function create()
  43 + {
  44 + $request = $this->param ?? [];
  45 + if ($this->checkDomain($request['domain'])) {
  46 + return $this->fail('域名已存在!');
  47 + }
  48 + $domain = new DomainInfo();
  49 + $this->extracted($request, $domain);
  50 + DB::beginTransaction();
  51 + if ($domain->save()) {
  52 + $original = $domain->getOriginal();
  53 + $original['belong_to'] = $request['belong_to'];
  54 + $original['status'] = $request['status'];
  55 + // 添加日志
  56 + $this->domain_action_log(DomainInfoLog::ACTION_ADD, $original, $original, '添加域名信息成功 - ID : ' . $domain->id);
  57 + DB::commit();
  58 + return $this->success();
  59 + }
  60 + DB::rollBack();
  61 + return $this->fail('域名信息添加失败');
  62 +
  63 + }
  64 +
  65 + /**
  66 + * 修改数据
  67 + * @return array
  68 + * @throws AsideGlobalException
  69 + * @throws BsideGlobalException
  70 + */
  71 + public function update()
  72 + {
  73 + $domain = $this->getDomain();
  74 + $original = $domain->getOriginal();
  75 + $original['belong_to'] = $domain->BelongToStr($original['belong_to']);
  76 + $original['status'] = $domain->StatusToStr($original['status']);
  77 + $request = $this->param;
  78 + $this->extracted($request, $domain, $original);
  79 + // 检查ip是否存在
  80 + if ($domain->domain != $request['domain']) {
  81 + if ($this->checkDomain($request['domain'])) {
  82 + $this->fail('域名信息修改失败,域名已存在', Code::USER_ERROR);
  83 + }
  84 + }
  85 + DB::beginTransaction();
  86 + if ($domain->save()) {
  87 + $fields_array = $domain->FieldsArray();
  88 + $revised = $domain->getAttributes();
  89 + $diff = array_diff_assoc($original, $revised);
  90 + unset($diff['created_at']);
  91 + unset($diff['updated_at']);
  92 + unset($diff['deleted']);
  93 + $remarks = '';
  94 + if ($diff) {
  95 + $remarks .= '修改ID为 ' . $domain->id . ' 的服务器信息,修改内容为:';
  96 + foreach ($diff as $key => $value) {
  97 + $remarks .= $fields_array[$key] . ' 由 ' . $value . ' 修改为 ' . $revised[$key] . '; ';
  98 + }
  99 + } else {
  100 + $remarks .= '修改ID为 ' . $domain->id . ' 的域名信息,无修改';
  101 + }
  102 + // 添加日志
  103 + $this->domain_action_log(DomainInfoLog::ACTION_UPDATE, $original, $revised, $remarks);
  104 + DB::commit();
  105 + return $this->success();
  106 + }
  107 + DB::rollBack();
  108 + return $this->fail('域名信息修改失败');
  109 + }
  110 +
  111 + /**
  112 + * 根据ID获取数据
  113 + * @return array
  114 + * @throws AsideGlobalException
  115 + * @throws BsideGlobalException
  116 + */
  117 + public function getDomain(int $deleted = DomainInfo::DELETED_NORMAL)
  118 + {
  119 + $id = $this->param['id'] ?? 0;
  120 + if (!$id) {
  121 + return $this->fail('ID不能为空');
  122 + }
  123 + $data = DomainInfo::query()->where('deleted', $deleted)->find($id);
  124 + if (!$data) {
  125 + return $this->fail('数据不存在!');
  126 + }
  127 + return $data;
  128 + }
  129 +
  130 + /**
  131 + * 检查域名是否存在
  132 + * @param $domain
  133 + * @return bool
  134 + */
  135 + public function checkDomain($domain)
  136 + {
  137 + $usIp = DomainInfo::query()->where('domain', $domain)->first();
  138 + if ($usIp) {
  139 + return true;
  140 + } else {
  141 + return false;
  142 + }
  143 + }
  144 +
  145 + /**
  146 + * 详情
  147 + * @param int $deleted
  148 + * @return array|Builder|Collection|Model
  149 + * @throws AsideGlobalException
  150 + * @throws BsideGlobalException
  151 + */
  152 + public function domainInfo(int $deleted = DomainInfo::DELETED_NORMAL)
  153 + {
  154 + $id = $this->param['id'] ?? 0;
  155 + if (!$id) {
  156 + return $this->fail('ID不能为空');
  157 + }
  158 + $data = DomainInfo::query()->where('deleted', $deleted)->find($id, ['domain', 'belong_to', 'status', 'domain_start_time', 'domain_end_time', 'certificate_start_time', 'certificate_end_time', 'created_at', 'updated_at']);
  159 + if (!$data) {
  160 + return $this->fail('数据不存在!');
  161 + }
  162 + return $data;
  163 + }
  164 +
  165 + /**
  166 + * 服务器操作日志
  167 + * @param int $action 1:添加 2:修改 3:删除 4:搜索 5:详情 6:列表
  168 + * @param array $original 原始数据
  169 + * @param array $revised 修改后数据
  170 + */
  171 + public function domain_action_log(int $action = DomainInfoLog::ACTION_ADD, array $original = [], array $revised = [], $remarks = '')
  172 + {
  173 + $log = new DomainInfoLog();
  174 + $this->log($log, $action, $original, $revised, $remarks);
  175 + }
  176 +
  177 + /**
  178 + * @param array $request
  179 + * @param $domain
  180 + * @param array $original
  181 + * @return void
  182 + * @throws AsideGlobalException
  183 + * @throws BsideGlobalException
  184 + */
  185 + public function extracted( array $request, $domain, array $original = [])
  186 + {
  187 + $domain->domain = trim($request['domain']) ?? $original['domain'];
  188 + if (!$this->validateDomain($domain->domain)) {
  189 + $this->fail('域名格式错误');
  190 + }
  191 + $domain->belong_to = trim($request['belong_to']) ?? $original['belong_to']; // 域名归属 1 - 公司 2 - 客户
  192 + $domain->status = trim($request['status']) ?? $original['status']; // 域名状态 0 - 正常 1 - 关闭
  193 + $domain->domain_start_time = trim($request['domain_start_time']) ?? $original['domain_start_time']; // 域名开始时间
  194 + $domain->domain_end_time = trim($request['domain_end_time']) ?? $original['domain_end_time'];
  195 + $domain->certificate_start_time = trim($request['certificate_start_time']) ?? $original['certificate_start_time']; // 证书开始时间
  196 + $domain->certificate_end_time = trim($request['certificate_end_time']) ?? $original['certificate_end_time']; // 证书结束时间
  197 + }
  198 +
  199 + /**
  200 + * 批量获取数据删除
  201 + * @return array
  202 + * @throws AsideGlobalException
  203 + * @throws BsideGlobalException
  204 + */
  205 + public function get_batch_update($action = DomainInfoLog::ACTION_DELETE, $deleted = DomainInfo::DELETED_NORMAL)
  206 + {
  207 + $ids = (new ServerInformationLogic())->getIds();
  208 + $data = DomainInfo::query()->whereIn('id', $ids)->where('deleted', $deleted)->get();
  209 + $restore_ids = $data->pluck('id')->toArray();
  210 + $actionArr = DomainInfoLog::actionArr();
  211 + $actionStr = $actionArr[$action];
  212 + if (empty($restore_ids)) {
  213 + $this->fail($actionStr . '域名信息不存在!', Code::USER_ERROR);
  214 + }
  215 + $original = $data->toArray();
  216 + DB::beginTransaction();
  217 + try {
  218 + $update = $deleted == DomainInfo::DELETED_NORMAL ? DomainInfo::DELETED_DELETE : DomainInfo::DELETED_NORMAL;
  219 + DomainInfo::query()->whereIn('id', $restore_ids)->update(['deleted' => $update]);
  220 + $this->domain_action_log($action, $original, $original, $actionStr . '域名信息 - ID : ' . implode(', ', $restore_ids));
  221 + DB::commit();
  222 + return $this->success();
  223 + } catch (\Exception $e) {
  224 + DB::rollBack();
  225 + return $this->fail('域名信息' . $actionStr . '失败', Code::USER_ERROR);
  226 + }
  227 + }
  228 +
  229 + /**
  230 + * 证书到期时间
  231 + * @return array
  232 + */
  233 + public function getDomainCertificateTime($domain)
  234 + {
  235 + $domain = trim($domain);
  236 + $data = [];
  237 + $context = stream_context_create(['ssl' => ['capture_peer_cert' => true]]); // Notice: only 7.0.7+ supports this
  238 + $stream = stream_socket_client("ssl://$domain:443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
  239 + if ($stream) {
  240 + $params = stream_context_get_params($stream);
  241 + $peerCertificate = openssl_x509_parse($params['options']['ssl']['peer_certificate']);
  242 + if ($peerCertificate) {
  243 + $validFrom = date_create_from_format('U', $peerCertificate['validFrom_time_t']); // 有效期开始时间
  244 + $validTo = date_create_from_format('U', $peerCertificate['validTo_time_t']); // 有效期结束时间
  245 + $data['validFrom'] = $validFrom->format('Y-m-d H:i:s');
  246 + $data['validTo'] = $validTo->format('Y-m-d H:i:s');
  247 + }
  248 + }
  249 + return $data;
  250 + }
  251 +
  252 + /**
  253 + * 获取所有正常域名信息
  254 + * @return Builder[]|Collection
  255 + */
  256 + public function getAllDomain()
  257 + {
  258 + return DomainInfo::query()->where('status', 1)
  259 + ->where('deleted', DomainInfo::DELETED_NORMAL)
  260 + ->orderBy('updated_at', 'desc')
  261 + ->get();
  262 + }
  263 +
  264 + /**
  265 + * 域名到期时间
  266 + * @return array
  267 + */
  268 + public function getDomainTime($domain)
  269 + {
  270 + $conJson = file_get_contents("http://openai.waimaoq.com/v1/whois_api?domain={$domain}");
  271 + $conArr = json_decode($conJson, true);
  272 + $data = [];
  273 + if ($conArr['code'] == 200) {
  274 + $con = $conArr['text'];
  275 + $data['domain'] = $domain;
  276 + $data['validFrom'] = $con['creation_date'];
  277 + $data['validTo'] = $con['expiration_date'];
  278 + }
  279 + return $data;
  280 + }
  281 +
  282 + /**
  283 + * 验证给定的值是否是有效的域名。
  284 + *
  285 + * @param mixed $value
  286 + * @return bool
  287 + */
  288 + public function validateDomain($value)
  289 + {
  290 + // 从域中删除任何空间或路径。
  291 + $domain = preg_replace('/\s|\/.*$/', '', $value);
  292 + // 验证域是否至少包含一个句点。
  293 + if (strpos($domain, '.') === false) {
  294 + return false;
  295 + }
  296 + // 验证域是否以句点开始或结束。
  297 + if (strpos($domain, '.') === 0 || strrpos($domain, '.') === strlen($domain) - 1) {
  298 + return false;
  299 + }
  300 + // 验证域是否不包含无效字符。
  301 + if (!preg_match('/^[a-zA-Z0-9\-\.]+$/', $domain)) {
  302 + return false;
  303 + }
  304 + // 验证域是否具有有效的顶级域。
  305 + $tld = substr($domain, strrpos($domain, '.') + 1);
  306 + if (!in_array($tld, ['com', 'net', 'org'])) { // 如有必要,添加更多TLD。
  307 + return false;
  308 + }
  309 + return true;
  310 + }
  311 +
  312 + /**
  313 + * 根据域名更新证书到期时间
  314 + * @param $id
  315 + * @param $updata
  316 + * @return array
  317 + * @throws AsideGlobalException
  318 + * @throws BsideGlobalException
  319 + */
  320 + public function updateDomain($id, $updata)
  321 + {
  322 + $isRes = DomainInfo::query()->where('id', $id)->where('deleted', DomainInfo::DELETED_NORMAL)->update($updata);
  323 + if ($isRes) {
  324 + return $this->success();
  325 + } else {
  326 + return $this->fail('更新域名到期时间失败');
  327 + }
  328 + }
  329 +}
@@ -34,15 +34,12 @@ class CustomLogic extends BaseLogic @@ -34,15 +34,12 @@ class CustomLogic extends BaseLogic
34 */ 34 */
35 public function save($param) 35 public function save($param)
36 { 36 {
  37 + $param['html'] = '';
  38 +
37 $id = parent::save($param); 39 $id = parent::save($param);
38 40
39 $data = $this->getInfo($id['id']); 41 $data = $this->getInfo($id['id']);
40 42
41 - try {  
42 - RouteMap::setRoute($data['url'],RouteMap::SOURCE_CUSTOM,$data['id'],$this->user['project_id']);  
43 - }catch (\Throwable $e){  
44 -  
45 - }  
46 43
47 return $data; 44 return $data;
48 } 45 }
@@ -2,15 +2,20 @@ @@ -2,15 +2,20 @@
2 2
3 namespace App\Http\Logic\Bside\HomeCount; 3 namespace App\Http\Logic\Bside\HomeCount;
4 4
  5 +
5 use App\Http\Logic\Bside\BaseLogic; 6 use App\Http\Logic\Bside\BaseLogic;
  7 +use App\Models\EnterpriseService\EnterpriseService as EnterpriseServiceModel;
  8 +use App\Models\HomeCount\Count;
  9 +use App\Models\RankData\RankData as RankDataModel;
  10 +use Carbon\Carbon;
  11 +use Illuminate\Support\Facades\DB;
6 12
7 class CountLogic extends BaseLogic 13 class CountLogic extends BaseLogic
8 { 14 {
9 public function __construct() 15 public function __construct()
10 { 16 {
11 parent::__construct(); 17 parent::__construct();
12 -  
13 - $this->model = new Yes(); 18 + $this->model = new Count();
14 } 19 }
15 20
16 /** 21 /**
@@ -20,6 +25,166 @@ class CountLogic extends BaseLogic @@ -20,6 +25,166 @@ class CountLogic extends BaseLogic
20 * @time :2023/5/23 17:30 25 * @time :2023/5/23 17:30
21 */ 26 */
22 public function yesterday_count(){ 27 public function yesterday_count(){
23 - return $this->success(); 28 + $yesterday = Carbon::yesterday()->toDateString();
  29 + $param = [
  30 + 'date' => $yesterday,
  31 + 'project_id' => $this->user['project_id']
  32 + ];
  33 + $info = $this->model->read($param,['pv_num','ip_num','inquiry_num','date','compliance_day','service_day']);
  34 + if($info === false){
  35 + $info = [];
  36 + }
  37 + return $this->success($info);
  38 + }
  39 +
  40 + /**
  41 + * @name :(方案信息)scheme_info
  42 + * @author :lyh
  43 + * @method :post
  44 + * @time :2023/5/24 11:48
  45 + */
  46 + public function scheme_info(){
  47 + $data = [
  48 + 'company'=>$this->project['company'],
  49 + 'scheme'=>$this->project['deploy_build']['plan'],
  50 + 'service_duration'=>$this->project['deploy_build']['service_duration'],
  51 + ];
  52 + return $this->success($data);
  53 + }
  54 +
  55 + /**
  56 + * @name :(总访问量)total_count
  57 + * @author :lyh
  58 + * @method :post
  59 + * @time :2023/5/24 13:33
  60 + */
  61 + public function total_count($inquiry_num = ''){
  62 + $pv = DB::table('gl_customer_visit_item')->where(['domain'=>$this->project['deploy_build']['test_domain']])->count();
  63 + $ip = DB::table('gl_customer_visit')->where(['domain'=>$this->project['deploy_build']['test_domain']])->count();
  64 + $data = [
  65 + 'total_pv'=>$pv,
  66 + 'total_ip'=>$ip,
  67 + 'conversion_rate' => (isset($inquiry_num) && !empty($inquiry_num)) ? ($inquiry_num / $ip) * 100 : 0,
  68 + ];
  69 + return $this->success($data);
  70 + }
  71 +
  72 + /**
  73 + * @name :(前一天关键字排名统计)keyword_data
  74 + * @author :lyh
  75 + * @method :post
  76 + * @time :2023/5/24 14:03
  77 + */
  78 + public function keyword_data_count(){
  79 + $yesterday = Carbon::yesterday()->toDateString();
  80 + $rankDataModel = new RankDataModel();
  81 + $param = [
  82 + 'updated_date' => $yesterday,
  83 + 'project_id' => $this->user['project_id']
  84 + ];
  85 + $data = $rankDataModel->read($param,['first_num','first_page_num','first_three_pages_num','first_five_pages_num','first_ten_pages_num']);
  86 + if($data === false){
  87 + $data = [];
  88 + }
  89 + return $this->success($data);
  90 + }
  91 +
  92 + /**
  93 + * @name :(相关数据统计)with_data_count
  94 + * @author :lyh
  95 + * @method :post
  96 + * @time :2023/5/24 14:12
  97 + */
  98 + public function with_data_count(){
  99 + $product_count = DB::table('gl_product')->where(['project_id' => $this->user['project_id']])->count();
  100 + $news_count = DB::table('gl_news')->where(['project_id' => $this->user['project_id']])->count();
  101 + $page_count = DB::table('gl_web_template')->where(['project_id' => $this->user['project_id']])->count();
  102 + $data = [
  103 + 'product_count' => $product_count,
  104 + 'news_count' => $news_count,
  105 + 'page_count' => $page_count,
  106 + ];
  107 + return $this->success($data);
  108 + }
  109 +
  110 + /**
  111 + * @name :(30天数据统计)visit_data_count
  112 + * @author :lyh
  113 + * @method :post
  114 + * @time :2023/5/24 14:18
  115 + */
  116 + public function visit_data_count(){
  117 + $param = [
  118 + 'date' => ['between',[now()->subDays(30)->startOfDay()->toDateString(),now()->startOfDay()->toDateString()]],
  119 + 'project_id' => $this->user['project_id']
  120 + ];
  121 + $data = $this->model->list($param,'id',['id','pv_num','ip_num','date']);
  122 + return $this->success($data);
  123 + }
  124 +
  125 + /**
  126 + * @name :(询盘国家统计)inquiry_country_count
  127 + * @author :lyh
  128 + * @method :post
  129 + * @time :2023/5/24 14:58
  130 + */
  131 + public function inquiry_country_count(){
  132 + $data = DB::table('gl_inquiry_record')
  133 + ->select('ip_area', DB::raw('COUNT(ip_area) as count'))
  134 + ->groupBy('ip_area')->orderBy('count','desc')->limit(20)->get()->toArray();
  135 + $data = object_to_array($data);
  136 + $total = DB::table('gl_inquiry_record')->count();
  137 + foreach ($data as $k=>$v){
  138 + $data[$k]['proportion'] = ($v['count']/$total) * 100;
  139 + }
  140 + return $this->success($data);
  141 + }
  142 +
  143 + /**
  144 + * @name :(访问来源统计)referrer_count
  145 + * @author :lyh
  146 + * @method :post
  147 + * @time :2023/5/24 15:32
  148 + */
  149 + public function referrer_count(){
  150 + $data = DB::table('gl_customer_visit')
  151 + ->select('referrer_url', DB::raw('COUNT(*) as count'))->groupBy('referrer_url')
  152 + ->orderByDesc('count')->limit(8)->get()->toArray();
  153 + $total = DB::table('gl_customer_visit')->count();
  154 + $data = object_to_array($data);
  155 + foreach ($data as $k=>$v){
  156 + $data[$k]['proportion'] = ($v['count']/$total) * 100;
  157 + }
  158 + return $this->success($data);
  159 + }
  160 +
  161 + /**
  162 + * @name :(访问国家统计)access_country_count
  163 + * @author :lyh
  164 + * @method :post
  165 + * @time :2023/5/24 15:56
  166 + */
  167 + public function access_country_count(){
  168 + $data = DB::table('gl_customer_visit')
  169 + ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
  170 + ->groupBy('country')->orderBy('ip','desc')->limit(20)->get()->toArray();
  171 + $data = object_to_array($data);
  172 + foreach ($data as $k => $v){
  173 + $v['pv'] = (int)$v['pv'];
  174 + $data[$k] = $v;
  175 + }
  176 + return $this->success($data);
  177 + }
  178 +
  179 + /**
  180 + * @name :(售后服务中心)enterprise_service
  181 + * @author :lyh
  182 + * @method :post
  183 + * @time :2023/5/25 10:22
  184 + */
  185 + public function enterprise_service(){
  186 + $enterpriseServiceModel = new EnterpriseServiceModel();
  187 + $info = $enterpriseServiceModel->read(['status'=>0]);
  188 + return $this->success($info);
24 } 189 }
25 } 190 }
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 namespace App\Http\Logic\Bside; 3 namespace App\Http\Logic\Bside;
4 4
5 use App\Models\RouteMap; 5 use App\Models\RouteMap;
  6 +use App\Models\Template\BSetting;
6 use App\Models\Template\BTemplate; 7 use App\Models\Template\BTemplate;
7 8
8 /** 9 /**
@@ -82,6 +83,7 @@ class TemplateLogic extends BaseLogic @@ -82,6 +83,7 @@ class TemplateLogic extends BaseLogic
82 'project_id'=>$this->user['project_id'], 83 'project_id'=>$this->user['project_id'],
83 'data_source' => $source, 84 'data_source' => $source,
84 'data_source_id' => $source_id, 85 'data_source_id' => $source_id,
  86 + 'template_id' => BSetting::_get($this->user['project_id'])
85 ])->first(); 87 ])->first();
86 } 88 }
87 89
@@ -8,7 +8,10 @@ use \App\Helper\Common as CommonHelper; @@ -8,7 +8,10 @@ use \App\Helper\Common as CommonHelper;
8 use App\Exceptions\AsideGlobalException; 8 use App\Exceptions\AsideGlobalException;
9 use App\Exceptions\BsideGlobalException; 9 use App\Exceptions\BsideGlobalException;
10 use App\Helper\Arr; 10 use App\Helper\Arr;
  11 +use App\Models\Devops\ServerInformationLog;
11 use Illuminate\Support\Facades\Cache; 12 use Illuminate\Support\Facades\Cache;
  13 +use Illuminate\Support\Facades\DB;
  14 +use Illuminate\Support\Facades\Log;
12 use Illuminate\Support\Facades\Schema; 15 use Illuminate\Support\Facades\Schema;
13 16
14 /** 17 /**
@@ -29,7 +32,7 @@ class Logic @@ -29,7 +32,7 @@ class Logic
29 * @param array $data 32 * @param array $data
30 * @return array 33 * @return array
31 */ 34 */
32 - public function success(array $data = []) 35 + public function success($data = [])
33 { 36 {
34 return $data; 37 return $data;
35 } 38 }
@@ -393,4 +396,40 @@ class Logic @@ -393,4 +396,40 @@ class Logic
393 public static function instance(...$params){ 396 public static function instance(...$params){
394 return new static(...$params); 397 return new static(...$params);
395 } 398 }
  399 +
  400 + /**
  401 + * 添加日志
  402 + * @param $log
  403 + * @param int $action 1:添加 2:修改 3:删除 4:搜索 5:详情 6:列表
  404 + * @param array $original 原始数据
  405 + * @param array $revised 修改后数据
  406 + * @param string $remarks 备注
  407 + * @return bool
  408 + */
  409 + public function log($log, int $action = ServerInformationLog::ACTION_ADD, array $original = [], array $revised = [], string $remarks = ''): bool
  410 + {
  411 + // $action 1:添加 2:修改 3:删除 4:恢复
  412 + $actionArr = $log->actionArr();
  413 + $actionStr = $actionArr[$action];
  414 + $ip = request()->getClientIp();
  415 + $url = request()->getRequestUri();
  416 + $method = request()->getMethod();
  417 + $userId = $this->uid ?? 0;
  418 + $log->user_id = $userId;
  419 + $log->action = $actionStr;
  420 + $log->original = json_encode($original);
  421 + $log->revised = json_encode($revised);
  422 + $log->ip = $ip;
  423 + $log->url = $url;
  424 + $log->method = $method;
  425 + $log->remarks = $remarks;
  426 + DB::beginTransaction();
  427 + if($log->save()){
  428 + DB::commit();
  429 + return true;
  430 + }
  431 + DB::rollBack();
  432 + Log::error('日志添加失败');
  433 + return false;
  434 + }
396 } 435 }
  1 +<?php
  2 +
  3 +namespace App\Http\Requests\Aside\Domain;
  4 +
  5 +use App\Models\Aside\Domain\DomainInfo;
  6 +use Illuminate\Foundation\Http\FormRequest;
  7 +use Illuminate\Validation\Rule;
  8 +
  9 +class DomainInfoRequest extends FormRequest
  10 +{
  11 + /**
  12 + * Determine if the user is authorized to make this request.
  13 + *
  14 + * @return bool
  15 + */
  16 + public function authorize()
  17 + {
  18 + return true;
  19 + }
  20 +
  21 + /**
  22 + * Get the validation rules that apply to the request.
  23 + *
  24 + * @return array
  25 + */
  26 + public function rules()
  27 + {
  28 + $domain = new DomainInfo();
  29 + $status_tot_keys = array_keys($domain->StatusToArray());
  30 + $belong_to_keys = array_keys($domain->BelongToArray());
  31 + return [
  32 + 'domain' => 'required|max:200',
  33 + 'belong_to' => [
  34 + 'required',
  35 + Rule::in($belong_to_keys)
  36 + ],
  37 + 'status' => [
  38 + 'required',
  39 + Rule::in($status_tot_keys)
  40 + ]
  41 + ];
  42 + }
  43 +
  44 + public function messages()
  45 + {
  46 + return [
  47 + 'domain.required' => '域名不能为空',
  48 + 'domain.max' => '域名长度不能超过200个字符',
  49 + 'belong_to.required' => '域名所属不能为空',
  50 + 'belong_to.in' => '域名所属参数错误',
  51 + 'status.required' => '域名状态不能为空',
  52 + 'status.in' => '域名状态参数错误',
  53 + ];
  54 + }
  55 +
  56 +}
@@ -36,7 +36,7 @@ class CustomRequest extends FormRequest @@ -36,7 +36,7 @@ class CustomRequest extends FormRequest
36 'keywords' => ['required','max:200'], 36 'keywords' => ['required','max:200'],
37 'description' => ['required','max:250'], 37 'description' => ['required','max:250'],
38 // 'html' => ['required'], 38 // 'html' => ['required'],
39 - 'url' => ['required','max:200'], 39 + 'url' => ['required','max:200','url'],
40 'status' => ['required','in:0,1'], 40 'status' => ['required','in:0,1'],
41 ]; 41 ];
42 42
@@ -70,6 +70,7 @@ class CustomRequest extends FormRequest @@ -70,6 +70,7 @@ class CustomRequest extends FormRequest
70 70
71 'url.required' => '链接必须', 71 'url.required' => '链接必须',
72 'url.max' => '链接不能超过200个字符', 72 'url.max' => '链接不能超过200个字符',
  73 + 'url.url' => '链接不符合规则',
73 74
74 'status.required' => '状态选择错误', 75 'status.required' => '状态选择错误',
75 'status.in' => '状态必须是显示/隐藏' 76 'status.in' => '状态必须是显示/隐藏'
  1 +<?php
  2 +
  3 +namespace App\Models\Aside\Domain;
  4 +
  5 +use App\Models\Base;
  6 +
  7 +/**
  8 + * Class DomainInfo
  9 + * @package App\Models\Aside\Domain
  10 + * @Author YiYuan-LIn
  11 + * @Date: 2019/5/16
  12 + * 域名信息模型
  13 + */
  14 +class DomainInfo extends Base
  15 +{
  16 + protected $table = 'gl_domain_info';
  17 +
  18 + // 软删除 0:正常 1:删除
  19 + /** @var int 软删除 - 正常 */
  20 + const DELETED_NORMAL = 0;
  21 + /** @var int 软删除 - 删除 */
  22 + const DELETED_DELETE = 1;
  23 +
  24 + protected $hidden = [
  25 + 'created_at',
  26 + 'updated_at'
  27 + ];
  28 +
  29 + /**
  30 + * 字段信息
  31 + * @return array
  32 + */
  33 + public function FieldsArray()
  34 + {
  35 + return [
  36 + 'domain' => '域名',
  37 + 'belong_to' => '域名归属',
  38 + 'status' => '域名状态',
  39 + 'domain_start_time' => '域名开始时间',
  40 + 'domain_end_time' => '域名结束时间',
  41 + 'certificate_start_time' => '证书开始时间',
  42 + 'certificate_end_time' => '证书结束时间',
  43 + ];
  44 + }
  45 +
  46 + /**
  47 + * 域名归属信息
  48 + * @return array
  49 + */
  50 + public function BelongToArray()
  51 + {
  52 + return [
  53 + 1 => '公司',
  54 + 2 => '客户',
  55 + ];
  56 + }
  57 +
  58 + public function BelongToStr($num)
  59 + {
  60 + return array_flip($this->BelongToArray())[$num];
  61 + }
  62 +
  63 + public function BelongTo($num)
  64 + {
  65 + return $this->BelongToArray()[$num];
  66 + }
  67 +
  68 + /**
  69 + * 域名状态信息
  70 + * @return array
  71 + */
  72 + public function StatusToArray()
  73 + {
  74 + return [
  75 + 0 => '未使用',
  76 + 1 => '使用中',
  77 + ];
  78 + }
  79 +
  80 + public function StatusToStr($num)
  81 + {
  82 + return array_flip($this->StatusToArray())[$num];
  83 + }
  84 +
  85 + /**
  86 + * 返回域名状态
  87 + * @param $num
  88 + *
  89 + * @return string
  90 + */
  91 + public function StatusTo($num)
  92 + {
  93 + return $this->StatusToArray()[$num];
  94 + }
  95 +
  96 + /**
  97 + * 返回服务器归属
  98 + * @param $value
  99 + *
  100 + * @return string
  101 + */
  102 + public function getBelongToAttribute($value)
  103 + {
  104 + return $this->BelongTo($value);
  105 + }
  106 +
  107 + /**
  108 + * 返回服务器状态
  109 + * @param $value
  110 + *
  111 + * @return string
  112 + */
  113 + public function getStatusAttribute($value)
  114 + {
  115 + return $this->StatusTo($value);
  116 + }
  117 +}
  1 +<?php
  2 +
  3 +namespace App\Models\Aside\Domain;
  4 +
  5 +use Illuminate\Database\Eloquent\Model;
  6 +
  7 +class DomainInfoLog extends Model
  8 +{
  9 + protected $table = 'gl_domain_info_log';
  10 +
  11 + public function getOriginalAttribute($value)
  12 + {
  13 + return json_decode($value, true);
  14 + }
  15 +
  16 + public function getRevisedAttribute($value)
  17 + {
  18 + return json_decode($value, true);
  19 + }
  20 +
  21 + /** @var int 日志添加 */
  22 + const ACTION_ADD = 1;
  23 + /** @var int 日志修改 */
  24 + const ACTION_UPDATE = 2;
  25 + /** @var int 日志删除 */
  26 + const ACTION_DELETE = 3;
  27 + /** @var int 日志恢复 */
  28 + const ACTION_RECOVER = 4;
  29 +
  30 +
  31 + /**
  32 + * @return string[]
  33 + */
  34 + public static function actionArr()
  35 + {
  36 + return [
  37 + 1 => '添加',
  38 + 2 => '修改',
  39 + 3 => '删除',
  40 + 4 => '恢复',
  41 + ];
  42 + }
  43 +}
@@ -8,8 +8,6 @@ class ServerInformation extends Model @@ -8,8 +8,6 @@ class ServerInformation extends Model
8 { 8 {
9 9
10 protected $table = 'gl_server_information'; 10 protected $table = 'gl_server_information';
11 - const CREATED_AT = 'create_at';  
12 - const UPDATED_AT = 'update_at';  
13 11
14 // 软删除 0:正常 1:删除 12 // 软删除 0:正常 1:删除
15 const DELETED_NORMAL = 0; 13 const DELETED_NORMAL = 0;
@@ -44,6 +42,11 @@ class ServerInformation extends Model @@ -44,6 +42,11 @@ class ServerInformation extends Model
44 ]; 42 ];
45 } 43 }
46 44
  45 + public function ServiceStr($num)
  46 + {
  47 + return array_flip($this->ServiceArray())[$num];
  48 + }
  49 +
47 /** 50 /**
48 * 字段信息 51 * 字段信息
49 * @return array 52 * @return array
@@ -73,6 +76,11 @@ class ServerInformation extends Model @@ -73,6 +76,11 @@ class ServerInformation extends Model
73 ]; 76 ];
74 } 77 }
75 78
  79 + public function BelongToStr($num)
  80 + {
  81 + return array_flip($this->BelongToArray())[$num];
  82 + }
  83 +
76 public function BelongTo($num) 84 public function BelongTo($num)
77 { 85 {
78 return $this->BelongToArray()[$num]; 86 return $this->BelongToArray()[$num];
@@ -7,8 +7,6 @@ use Illuminate\Database\Eloquent\Model; @@ -7,8 +7,6 @@ use Illuminate\Database\Eloquent\Model;
7 class ServerInformationLog extends Model 7 class ServerInformationLog extends Model
8 { 8 {
9 protected $table = 'gl_server_information_log'; 9 protected $table = 'gl_server_information_log';
10 - const CREATED_AT = 'create_at';  
11 - const UPDATED_AT = 'update_at';  
12 10
13 public function getOriginalAttribute($value) 11 public function getOriginalAttribute($value)
14 { 12 {
  1 +<?php
  2 +
  3 +namespace App\Models\EnterpriseService;
  4 +
  5 +use App\Models\Base;
  6 +
  7 +class EnterpriseService extends Base
  8 +{
  9 + protected $table = 'gl_enterprise_service';
  10 +}
@@ -4,7 +4,7 @@ namespace App\Models\HomeCount; @@ -4,7 +4,7 @@ namespace App\Models\HomeCount;
4 4
5 use App\Models\Base; 5 use App\Models\Base;
6 6
7 -class YesterdayCount extends Base 7 +class Count extends Base
8 { 8 {
9 - protected $table = 'gl_yesterday_count'; 9 + protected $table = 'gl_count';
10 } 10 }
@@ -6,9 +6,11 @@ use App\Models\Base; @@ -6,9 +6,11 @@ use App\Models\Base;
6 6
7 class WebSetting extends Base 7 class WebSetting extends Base
8 { 8 {
  9 + //锚文本常量配置在settingTextModel中
9 protected $table = 'gl_web_setting'; 10 protected $table = 'gl_web_setting';
10 11
11 //连接数据库 12 //连接数据库
12 // protected $connection = 'custom_mysql'; 13 // protected $connection = 'custom_mysql';
13 14
  15 +
14 } 16 }
@@ -116,6 +116,19 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w @@ -116,6 +116,19 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w
116 Route::post('/save_follow', [Aside\Task\TaskController::class, 'save_follow'])->name('admin.task_save_follow'); 116 Route::post('/save_follow', [Aside\Task\TaskController::class, 'save_follow'])->name('admin.task_save_follow');
117 }); 117 });
118 118
  119 + // 域名
  120 + Route::prefix('domain')->group(function () {
  121 + Route::get('/', [Aside\Domain\DomainInfoController::class, 'lists'])->name('admin.domain'); // 列表 | 搜索
  122 + Route::get('/info', [Aside\Domain\DomainInfoController::class, 'info'])->name('admin.domain_info'); // 详情
  123 + Route::get('/delete_info', [Aside\Domain\DomainInfoController::class, 'getDeleteDomainInfo'])->name('admin.domain_delete_info'); // 删除信息
  124 + Route::post('/add', [Aside\Domain\DomainInfoController::class, 'add'])->name('admin.domain_save'); // 添加
  125 + Route::post('/edit', [Aside\Domain\DomainInfoController::class, 'edit'])->name('admin.domain_edit'); // 编辑
  126 + Route::any('/delete', [Aside\Domain\DomainInfoController::class, 'delete'])->name('admin.domain_delete'); // 删除
  127 + Route::get('/delete_list', [Aside\Domain\DomainInfoController::class, 'delete_list'])->name('admin.domain_delete_list'); // 删除列表
  128 + Route::any('/restore', [Aside\Domain\DomainInfoController::class, 'restore'])->name('admin.domain_restore'); // 恢复
  129 + Route::get('/log', [Aside\Domain\DomainInfoLogController::class, 'lists'])->name('admin.domain_log_lists'); // 日志
  130 + });
  131 +
119 //运维 132 //运维
120 Route::prefix('devops')->group(function () { 133 Route::prefix('devops')->group(function () {
121 //服务器配置 134 //服务器配置
@@ -127,7 +140,7 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w @@ -127,7 +140,7 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w
127 140
128 // 服务器添加|修改|删除 141 // 服务器添加|修改|删除
129 Route::prefix('server')->group(function () { 142 Route::prefix('server')->group(function () {
130 - Route::get('/', [Aside\Devops\ServerInformationController::class, 'lists'])->name('admin.devops.bt'); // 列表 143 + Route::get('/', [Aside\Devops\ServerInformationController::class, 'lists'])->name('admin.devops.bt'); // 列表 | 搜索
131 Route::get('/info', [Aside\Devops\ServerInformationController::class, 'getServerInfo'])->name('admin.devops.bt_info'); // 获取信息 144 Route::get('/info', [Aside\Devops\ServerInformationController::class, 'getServerInfo'])->name('admin.devops.bt_info'); // 获取信息
132 Route::get('/delete_info', [Aside\Devops\ServerInformationController::class, 'getDeleteServerInfo'])->name('admin.devops.bt_delete_info'); // 删除信息 145 Route::get('/delete_info', [Aside\Devops\ServerInformationController::class, 'getDeleteServerInfo'])->name('admin.devops.bt_delete_info'); // 删除信息
133 Route::post('/add', [Aside\Devops\ServerInformationController::class, 'add'])->name('admin.devops.bt_add'); // 添加 146 Route::post('/add', [Aside\Devops\ServerInformationController::class, 'add'])->name('admin.devops.bt_add'); // 添加
@@ -135,10 +148,8 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w @@ -135,10 +148,8 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w
135 Route::get('/delete', [Aside\Devops\ServerInformationController::class, 'delete'])->name('admin.devops.bt_delete'); // 删除 148 Route::get('/delete', [Aside\Devops\ServerInformationController::class, 'delete'])->name('admin.devops.bt_delete'); // 删除
136 Route::get('/delete_list', [Aside\Devops\ServerInformationController::class, 'delete_list'])->name('admin.devops.bt_delete_list'); // 删除列表 149 Route::get('/delete_list', [Aside\Devops\ServerInformationController::class, 'delete_list'])->name('admin.devops.bt_delete_list'); // 删除列表
137 Route::get('/restore', [Aside\Devops\ServerInformationController::class, 'restore'])->name('admin.devops.bt_restore'); //恢复数据 150 Route::get('/restore', [Aside\Devops\ServerInformationController::class, 'restore'])->name('admin.devops.bt_restore'); //恢复数据
138 - Route::get('/search', [Aside\Devops\ServerInformationController::class, 'search'])->name('admin.devops.bt_search'); //搜索  
139 Route::get('/log', [Aside\Devops\ServerInformationLogController::class, 'lists'])->name('admin.devops.bt_log_lists'); //日志列表 151 Route::get('/log', [Aside\Devops\ServerInformationLogController::class, 'lists'])->name('admin.devops.bt_log_lists'); //日志列表
140 }); 152 });
141 -  
142 }); 153 });
143 154
144 // 自定义页面 模板,头部底部 155 // 自定义页面 模板,头部底部
@@ -262,12 +262,19 @@ Route::middleware(['bloginauth','accesstoken'])->group(function () { @@ -262,12 +262,19 @@ Route::middleware(['bloginauth','accesstoken'])->group(function () {
262 Route::any('/get_google_rank', [\App\Http\Controllers\Bside\RankDataController::class, 'get_google_rank'])->name('rank_data_get_google_rank'); 262 Route::any('/get_google_rank', [\App\Http\Controllers\Bside\RankDataController::class, 'get_google_rank'])->name('rank_data_get_google_rank');
263 }); 263 });
264 264
  265 + //首页统计数据
  266 + Route::prefix('home')->group(function () {
  267 + Route::any('/count', [\App\Http\Controllers\Bside\HomeCount\CountController::class, 'count'])->name('home_count');
  268 + Route::any('/yesterday', [\App\Http\Controllers\Bside\HomeCount\CountController::class, 'yesterday'])->name('home_yesterday');
  269 + });
  270 +
265 //访问数据 271 //访问数据
266 Route::prefix('visit')->group(function () { 272 Route::prefix('visit')->group(function () {
267 Route::any('/', [\App\Http\Controllers\Bside\VisitController::class, 'index'])->name('visit_list'); 273 Route::any('/', [\App\Http\Controllers\Bside\VisitController::class, 'index'])->name('visit_list');
268 Route::any('/item', [\App\Http\Controllers\Bside\VisitController::class, 'item'])->name('visit_item'); 274 Route::any('/item', [\App\Http\Controllers\Bside\VisitController::class, 'item'])->name('visit_item');
269 }); 275 });
270 276
  277 +
271 }); 278 });
272 //无需登录验证的路由组 279 //无需登录验证的路由组
273 Route::group([], function () { 280 Route::group([], function () {