Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
11 个修改的文件
包含
388 行增加
和
180 行删除
| @@ -63,13 +63,18 @@ class TemplateLog extends Command | @@ -63,13 +63,18 @@ class TemplateLog extends Command | ||
| 63 | * @time :2024/7/10 14:48 | 63 | * @time :2024/7/10 14:48 |
| 64 | */ | 64 | */ |
| 65 | public function deleteTemplate(){ | 65 | public function deleteTemplate(){ |
| 66 | - | ||
| 67 | - $date = date('Y-m-d H:i:s', strtotime('-60 days')); | 66 | + $date = date('Y-m-d H:i:s', strtotime('-30 days')); |
| 68 | $templateLogModel = new BTemplateLog(); | 67 | $templateLogModel = new BTemplateLog(); |
| 69 | $templateLogModel->del(['created_at'=>['<=',$date],'source'=>['!=',1]]); | 68 | $templateLogModel->del(['created_at'=>['<=',$date],'source'=>['!=',1]]); |
| 70 | - //首页保存最新的20条记录 | ||
| 71 | - $latestIds = $templateLogModel->where(['source'=>1,'is_custom'=>0])->orderBy('created_at', 'desc')->take(20)->pluck('id'); // 仅提取ID字段 | ||
| 72 | - return $templateLogModel->del(['id'=>['not in',$latestIds],'source'=>1,'is_custom'=>0,'is_list'=>0]); | 69 | + //查询最近20天是否有装修记录,首页保存最新的20条记录 |
| 70 | + $counts = $templateLogModel->counts(['source'=>1,'source_id'=>0,'is_custom'=>0,'created_at'=>['>=',$date]]); | ||
| 71 | + if($counts == 0){ | ||
| 72 | + $latestIds = $templateLogModel->where(['source'=>1,'is_custom'=>0])->orderBy('created_at', 'desc')->take(20)->pluck('id'); // 仅提取ID字段 | ||
| 73 | + $templateLogModel->del(['id'=>['not in',$latestIds],'source'=>1,'is_custom'=>0,'is_list'=>0]); | ||
| 74 | + }else{ | ||
| 75 | + $templateLogModel->del(['created_at'=>['<=',$date],'source'=>1]); | ||
| 76 | + } | ||
| 77 | + return true; | ||
| 73 | } | 78 | } |
| 74 | 79 | ||
| 75 | /** | 80 | /** |
| @@ -102,10 +102,10 @@ class DomainInfo extends Command | @@ -102,10 +102,10 @@ class DomainInfo extends Command | ||
| 102 | $domain_array = parse_url($v['domain']); | 102 | $domain_array = parse_url($v['domain']); |
| 103 | $host = $domain_array['host'] ?? $domain_array['path']; | 103 | $host = $domain_array['host'] ?? $domain_array['path']; |
| 104 | $host_array = explode('.', $host); | 104 | $host_array = explode('.', $host); |
| 105 | - if (count($host_array) <= 2) { | ||
| 106 | - array_unshift($host_array, 'm'); | ||
| 107 | - } else { | 105 | + if($host_array[0] == 'www'){ |
| 108 | $host_array[0] = 'm'; | 106 | $host_array[0] = 'm'; |
| 107 | + }else{ | ||
| 108 | + array_unshift($host_array,'m'); | ||
| 109 | } | 109 | } |
| 110 | $amp_domain = implode('.', $host_array); | 110 | $amp_domain = implode('.', $host_array); |
| 111 | 111 | ||
| @@ -192,10 +192,10 @@ class DomainInfo extends Command | @@ -192,10 +192,10 @@ class DomainInfo extends Command | ||
| 192 | $domain_array = parse_url($v['domain']); | 192 | $domain_array = parse_url($v['domain']); |
| 193 | $host = $domain_array['host'] ?? $domain_array['path']; | 193 | $host = $domain_array['host'] ?? $domain_array['path']; |
| 194 | $host_array = explode('.', $host); | 194 | $host_array = explode('.', $host); |
| 195 | - if (count($host_array) <= 2) { | ||
| 196 | - array_unshift($host_array, 'm'); | ||
| 197 | - } else { | 195 | + if($host_array[0] == 'www'){ |
| 198 | $host_array[0] = 'm'; | 196 | $host_array[0] = 'm'; |
| 197 | + }else{ | ||
| 198 | + array_unshift($host_array,'m'); | ||
| 199 | } | 199 | } |
| 200 | $amp_domain = implode('.', $host_array); | 200 | $amp_domain = implode('.', $host_array); |
| 201 | 201 |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :CreateProject.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/1/6 10:34 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Console\Commands\Project; | ||
| 11 | + | ||
| 12 | +use App\Helper\Arr; | ||
| 13 | +use App\Models\Channel\Channel; | ||
| 14 | +use App\Models\Com\UpdateLog; | ||
| 15 | +use App\Models\Com\UpdateVisit; | ||
| 16 | +use App\Models\Devops\Servers; | ||
| 17 | +use App\Models\Devops\ServersIp; | ||
| 18 | +use App\Models\Manage\Mobile; | ||
| 19 | +use App\Models\Project\After; | ||
| 20 | +use App\Models\Project\DeployBuild; | ||
| 21 | +use App\Models\Project\DeployOptimize; | ||
| 22 | +use App\Models\Project\Payment; | ||
| 23 | +use App\Models\Project\Project; | ||
| 24 | +use App\Models\User\User as UserModel; | ||
| 25 | +use App\Services\ProjectServer; | ||
| 26 | +use Hashids\Hashids; | ||
| 27 | +use Illuminate\Console\Command; | ||
| 28 | +use Illuminate\Support\Facades\DB; | ||
| 29 | + | ||
| 30 | +class CreateProject extends Command | ||
| 31 | +{ | ||
| 32 | + protected $signature = 'create_project'; | ||
| 33 | + protected $description = '创建项目'; | ||
| 34 | + | ||
| 35 | + public function handle(){ | ||
| 36 | + return $this->sync(); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public function sync($is_update = 0){ | ||
| 40 | + $title = date('Ymd') . '-广东威美建材科技有限公司'; | ||
| 41 | + $data = [ | ||
| 42 | + 'project'=>[ | ||
| 43 | + 'title' => $title, | ||
| 44 | + 'company' => '广东威美建材科技有限公司', | ||
| 45 | + 'lead_name' => '蔡伟文', | ||
| 46 | + 'mobile' => '13929953235', | ||
| 47 | + 'mysql_id'=>Project::MYSQL_ID, | ||
| 48 | + 'serve_id'=>9, | ||
| 49 | + 'qq' => '', | ||
| 50 | + 'channel' => '{"user_id": "53", "zone_id": "4", "channel_id": "4"}', | ||
| 51 | + 'requirement' => '', | ||
| 52 | + 'cooperate_date' => '2019-04-01', | ||
| 53 | + 'from_order_id' => '', | ||
| 54 | + 'type' => $is_update, | ||
| 55 | + 'is_upgrade'=>$is_update, | ||
| 56 | + ], | ||
| 57 | + 'deploy_build' => [ | ||
| 58 | + 'service_duration' => 0, | ||
| 59 | + 'plan' => $this->versionData('标准版'), | ||
| 60 | + 'login_mobile'=>'13929953235' | ||
| 61 | + ], | ||
| 62 | + 'deploy_optimize' => [ | ||
| 63 | +// 'api_no' => 0 | ||
| 64 | + ], | ||
| 65 | + 'project_after' => [], | ||
| 66 | + 'payment' => [ | ||
| 67 | + 'amount' => 0, | ||
| 68 | + 'contract'=>[], | ||
| 69 | + 'bill'=>[] | ||
| 70 | + ], | ||
| 71 | + ]; | ||
| 72 | + DB::beginTransaction(); | ||
| 73 | + try { | ||
| 74 | + $id = $this->saveProject($data['project']); | ||
| 75 | + $this->setPostId($data['deploy_build']['plan'],$id); | ||
| 76 | + $this->savePayment($data['payment'],$id); | ||
| 77 | + $this->saveDeployBuild($data['deploy_build'],$id); | ||
| 78 | + $this->saveDeployOptimize($data['deploy_optimize'],$id); | ||
| 79 | + $this->saveAfter($data['project_after'],$id); | ||
| 80 | + $serversIpModel = new ServersIp(); | ||
| 81 | + $serversModel = new Servers(); | ||
| 82 | + $serversIpModel->where(['id'=>9])->increment('total',1); | ||
| 83 | + $serversModel->where(['id'=>7])->increment('being_number',1); | ||
| 84 | + if($is_update == 1){ | ||
| 85 | + //4.0或5.0更新到6.0 | ||
| 86 | + //初始化数据库 | ||
| 87 | + $this->initializationMysql($id); | ||
| 88 | + //初始账号 | ||
| 89 | + $this->createUser($data['project']['mobile'],$id,$data['project']['lead_name']); | ||
| 90 | + } | ||
| 91 | + DB::commit(); | ||
| 92 | + }catch (\Exception $e){ | ||
| 93 | + DB::rollBack(); | ||
| 94 | + throw new \Exception($e->getMessage()); | ||
| 95 | + } | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + /** | ||
| 99 | + * @remark :获取版本 | ||
| 100 | + * @name :versionData | ||
| 101 | + * @author :lyh | ||
| 102 | + * @method :post | ||
| 103 | + * @time :2023/8/9 14:46 | ||
| 104 | + */ | ||
| 105 | + public function versionData($param){ | ||
| 106 | + $data = Project::planMap(); | ||
| 107 | + $data = array_flip($data); | ||
| 108 | + if(isset($data[$param])){ | ||
| 109 | + return $data[$param]; | ||
| 110 | + }else{ | ||
| 111 | + return 1; | ||
| 112 | + } | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + /** | ||
| 116 | + * @remark :保存项目 | ||
| 117 | + * @name :saveProject | ||
| 118 | + * @author :lyh | ||
| 119 | + * @method :post | ||
| 120 | + * @time :2023/8/30 15:53 | ||
| 121 | + */ | ||
| 122 | + public function saveProject($param){ | ||
| 123 | + $projectModel = new Project(); | ||
| 124 | + return $projectModel->addReturnId($param); | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + /** | ||
| 128 | + * @remark :设置post_id | ||
| 129 | + * @name :setPostId | ||
| 130 | + * @author :lyh | ||
| 131 | + * @method :post | ||
| 132 | + * @time :2023/8/9 14:47 | ||
| 133 | + */ | ||
| 134 | + public function setPostId($plan,$id){ | ||
| 135 | + $length = strlen((string)$id); // 获取变量的位数 | ||
| 136 | + $paddingLength = Project::TYPE_FIVE - $length; // 计算填充前面的 0 的位数 | ||
| 137 | + $zeros = str_repeat("0", $paddingLength); | ||
| 138 | + $number = Project::TYPE_SIX.$plan.$zeros.$id; | ||
| 139 | + $projectModel = new Project(); | ||
| 140 | + $projectModel->edit(['post_id'=>$number],['id'=>$id]); | ||
| 141 | + return true; | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + /** | ||
| 145 | + * 保存优化部署 | ||
| 146 | + * @author zbj | ||
| 147 | + * @date 2023/4/26 | ||
| 148 | + */ | ||
| 149 | + protected function saveAfter($param,$id){ | ||
| 150 | + $param['project_id'] = $id; | ||
| 151 | + //查询数据是否存在 | ||
| 152 | + $afterModel = new After(); | ||
| 153 | + $info = $afterModel->read(['project_id'=>$id]); | ||
| 154 | + if($info !== false){ | ||
| 155 | + $afterModel->edit($param,['id'=>$info['id']]); | ||
| 156 | + }else{ | ||
| 157 | + $afterModel->add($param); | ||
| 158 | + } | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + /** | ||
| 162 | + * @remark :保存付款续费 | ||
| 163 | + * @name :savePayment | ||
| 164 | + * @author :lyh | ||
| 165 | + * @method :post | ||
| 166 | + * @time :2023/8/29 16:19 | ||
| 167 | + */ | ||
| 168 | + protected function savePayment($param,$id){ | ||
| 169 | + $param['project_id'] = $id; | ||
| 170 | + $paymentModel= new Payment(); | ||
| 171 | + $param['contract'] = Arr::a2s($param['contract']); | ||
| 172 | + $param['bill'] = Arr::a2s($param['bill']); | ||
| 173 | + if(!isset($param['renewal_record'])){ | ||
| 174 | + $param['renewal_record'] = Arr::a2s([["amount"=> null, "remark"=> null, "expire_at"=> null]]); | ||
| 175 | + } | ||
| 176 | + $info = $paymentModel->read(['project_id'=>$id]); | ||
| 177 | + if($info !== false){ | ||
| 178 | + $paymentModel->edit($param,['id'=>$info['id']]); | ||
| 179 | + }else{ | ||
| 180 | + $paymentModel->add($param); | ||
| 181 | + } | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + /** | ||
| 185 | + * @remark :保存建站部署 | ||
| 186 | + * @name :saveDeployBuild | ||
| 187 | + * @author :lyh | ||
| 188 | + * @method :post | ||
| 189 | + * @time :2023/8/29 16:19 | ||
| 190 | + */ | ||
| 191 | + protected function saveDeployBuild($param,$id){ | ||
| 192 | + $param['project_id'] = $id; | ||
| 193 | + $hashids = new Hashids('test_domain', 5, 'abcdefghjkmnpqrstuvwxyz1234567890'); | ||
| 194 | + $code = $hashids->encode($id); | ||
| 195 | + $param['test_domain'] = 'https://v6-' . $code . '.globalso.site/'; | ||
| 196 | + $deployBuildModel = new DeployBuild(); | ||
| 197 | + $info = $deployBuildModel->read(['project_id'=>$id]); | ||
| 198 | + if($info !== false){ | ||
| 199 | + $deployBuildModel->edit($param,['id'=>$info['id']]); | ||
| 200 | + }else{ | ||
| 201 | + $deployBuildModel->add($param); | ||
| 202 | + } | ||
| 203 | + } | ||
| 204 | + | ||
| 205 | + /** | ||
| 206 | + * @remark :保存优化信息 | ||
| 207 | + * @name :saveDeployOptimize | ||
| 208 | + * @author :lyh | ||
| 209 | + * @method :post | ||
| 210 | + * @time :2023/8/30 16:11 | ||
| 211 | + */ | ||
| 212 | + protected function saveDeployOptimize($param,$id){ | ||
| 213 | + $param['project_id'] = $id; | ||
| 214 | + $deployOptimizeModel = new DeployOptimize(); | ||
| 215 | + $info = $deployOptimizeModel->read(['project_id'=>$id]); | ||
| 216 | + if($info !== false){ | ||
| 217 | + //存在就不处理了 | ||
| 218 | +// $deployOptimizeModel->edit($param,['id'=>$info['id']]); | ||
| 219 | + }else{ | ||
| 220 | + $deployOptimizeModel->add($param); | ||
| 221 | + } | ||
| 222 | + } | ||
| 223 | + /** | ||
| 224 | + * 初始化数据库 | ||
| 225 | + * @param $project_id | ||
| 226 | + * @author Akun | ||
| 227 | + * @date 2023/09/19 15:12 | ||
| 228 | + */ | ||
| 229 | + public function initializationMysql($project_id){ | ||
| 230 | + //切换数据库配置 | ||
| 231 | + $project = ProjectServer::useProject($project_id); | ||
| 232 | + //创建数据库 | ||
| 233 | + ProjectServer::createDatabase($project); | ||
| 234 | + //创建表 | ||
| 235 | + ProjectServer::initTable(); | ||
| 236 | + //初始数据 | ||
| 237 | + ProjectServer::saveInitParam($project_id); | ||
| 238 | + } | ||
| 239 | + | ||
| 240 | + /** | ||
| 241 | + * 创建用户 | ||
| 242 | + * @param $mobile | ||
| 243 | + * @param $project_id | ||
| 244 | + * @param $lead_name | ||
| 245 | + * @author Akun | ||
| 246 | + * @date 2023/09/19 15:12 | ||
| 247 | + */ | ||
| 248 | + public function createUser($mobile,$project_id,$lead_name){ | ||
| 249 | + $userModel = new UserModel(); | ||
| 250 | + //查看当前项目是否存在号码库中 | ||
| 251 | + $mobileModel = new Mobile(); | ||
| 252 | + $mobileInfo = $mobileModel->read(['mobile'=>$mobile]); | ||
| 253 | + if($mobileInfo === false){ | ||
| 254 | + //查看当前用户是否存在 | ||
| 255 | + $info = $userModel->read(['mobile'=>$mobile,'project_id'=>$project_id]); | ||
| 256 | + if($info === false){ | ||
| 257 | + $data = [ | ||
| 258 | + 'mobile'=>$mobile, | ||
| 259 | + 'password'=>base64_encode(md5('123456')), | ||
| 260 | + 'project_id'=>$project_id, | ||
| 261 | + 'name'=>$lead_name, | ||
| 262 | + 'type'=>UserModel::TYPE_ONE | ||
| 263 | + ]; | ||
| 264 | + $userModel->add($data); | ||
| 265 | + } | ||
| 266 | + } | ||
| 267 | + return true; | ||
| 268 | + } | ||
| 269 | +} |
| @@ -126,65 +126,6 @@ class Temp extends Command | @@ -126,65 +126,6 @@ class Temp extends Command | ||
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | /** | 128 | /** |
| 129 | - * 创建指定服务器所有项目主站生成任务 | ||
| 130 | - * @author Akun | ||
| 131 | - * @date 2024/12/19 17:54 | ||
| 132 | - */ | ||
| 133 | - public function create_server_update_page() | ||
| 134 | - { | ||
| 135 | - $server_id = 15; | ||
| 136 | - | ||
| 137 | - $server_ip_model = new ServersIp(); | ||
| 138 | - | ||
| 139 | - $server_ip_ids = $server_ip_model->where('servers_id', $server_id)->get()->pluck('id')->toArray(); | ||
| 140 | - | ||
| 141 | - $project_list = Project::select(['id', 'serve_id'])->whereIn('serve_id', $server_ip_ids)->get(); | ||
| 142 | - | ||
| 143 | - $domain_model = new DomainInfo(); | ||
| 144 | - $notify_model = new Notify(); | ||
| 145 | - | ||
| 146 | - foreach ($project_list as $value) { | ||
| 147 | - $project_id = $value->id; | ||
| 148 | - | ||
| 149 | - $domain_info = $domain_model->read(['project_id' => $project_id, 'status' => 1], ['id', 'domain']); | ||
| 150 | - if (!$domain_info) { | ||
| 151 | - //过滤未绑定正式域名的项目 | ||
| 152 | - continue; | ||
| 153 | - } | ||
| 154 | - $domain = $domain_info['domain']; | ||
| 155 | - | ||
| 156 | - //获取项目所在服务器 | ||
| 157 | - $serve_ip_info = $server_ip_model->read(['id' => $value->serve_id], ['domain', 'ip']); | ||
| 158 | - if (!$serve_ip_info) { | ||
| 159 | - $this->output('项目id:' . $project_id . ' | 未查询到服务器数据'); | ||
| 160 | - continue; | ||
| 161 | - } | ||
| 162 | - | ||
| 163 | - if (!check_domain_record($domain, $serve_ip_info)) { | ||
| 164 | - $this->output('项目id:' . $project_id . ', domain:' . $domain . ' | 未解析到目标服务器'); | ||
| 165 | - continue; | ||
| 166 | - } | ||
| 167 | - | ||
| 168 | - $data = [ | ||
| 169 | - 'project_id' => $project_id, | ||
| 170 | - 'type' => 1, | ||
| 171 | - 'route' => 1, | ||
| 172 | - 'server_id' => $server_id, | ||
| 173 | - 'status' => ['!=', Notify::STATUS_FINISH_SITEMAP] | ||
| 174 | - ]; | ||
| 175 | - $notify = $notify_model->read($data, ['id']); | ||
| 176 | - | ||
| 177 | - if (!$notify) { | ||
| 178 | - $data['data'] = Arr::a2s(['domain' => $domain, 'url' => null, 'language' => []]); | ||
| 179 | - $data['status'] = Notify::STATUS_INIT; | ||
| 180 | - $notify_model->add($data); | ||
| 181 | - | ||
| 182 | - $this->output('项目id:' . $project_id . ' | success'); | ||
| 183 | - } | ||
| 184 | - } | ||
| 185 | - } | ||
| 186 | - | ||
| 187 | - /** | ||
| 188 | * 判断指定服务器项目是否正常访问 | 129 | * 判断指定服务器项目是否正常访问 |
| 189 | * @author Akun | 130 | * @author Akun |
| 190 | * @date 2024/12/11 10:15 | 131 | * @date 2024/12/11 10:15 |
| @@ -272,6 +213,7 @@ class Temp extends Command | @@ -272,6 +213,7 @@ class Temp extends Command | ||
| 272 | public function get_all_projects_by_server() | 213 | public function get_all_projects_by_server() |
| 273 | { | 214 | { |
| 274 | $server_id = 1; | 215 | $server_id = 1; |
| 216 | + $server_name = '240云服务器'; | ||
| 275 | 217 | ||
| 276 | $server_ip_model = new ServersIp(); | 218 | $server_ip_model = new ServersIp(); |
| 277 | 219 | ||
| @@ -297,7 +239,7 @@ class Temp extends Command | @@ -297,7 +239,7 @@ class Temp extends Command | ||
| 297 | } | 239 | } |
| 298 | $map = ['项目id', '名称', '域名']; | 240 | $map = ['项目id', '名称', '域名']; |
| 299 | if ($data) { | 241 | if ($data) { |
| 300 | - $table = new BatchExportService("240云服务器项目"); | 242 | + $table = new BatchExportService($server_name . '项目'); |
| 301 | $file = $table->head($map)->data($data)->save(); | 243 | $file = $table->head($map)->data($data)->save(); |
| 302 | if (!$file) { | 244 | if (!$file) { |
| 303 | $this->output('文件生成失败,请重试'); | 245 | $this->output('文件生成失败,请重试'); |
| @@ -371,6 +313,7 @@ class Temp extends Command | @@ -371,6 +313,7 @@ class Temp extends Command | ||
| 371 | public function check_no_server_projects() | 313 | public function check_no_server_projects() |
| 372 | { | 314 | { |
| 373 | $server_id = 15; | 315 | $server_id = 15; |
| 316 | + $server_name = '美服1'; | ||
| 374 | 317 | ||
| 375 | $server_ip_model = new ServersIp(); | 318 | $server_ip_model = new ServersIp(); |
| 376 | 319 | ||
| @@ -403,7 +346,7 @@ class Temp extends Command | @@ -403,7 +346,7 @@ class Temp extends Command | ||
| 403 | } | 346 | } |
| 404 | $map = ['项目id', '名称', '域名', 'IP', '服务器ID',]; | 347 | $map = ['项目id', '名称', '域名', 'IP', '服务器ID',]; |
| 405 | if ($data) { | 348 | if ($data) { |
| 406 | - $table = new BatchExportService("美服2项目解析未在当前服务器项目"); | 349 | + $table = new BatchExportService($server_name . '解析未在当前服务器项目'); |
| 407 | $file = $table->head($map)->data($data)->save(); | 350 | $file = $table->head($map)->data($data)->save(); |
| 408 | if (!$file) { | 351 | if (!$file) { |
| 409 | $this->output('文件生成失败,请重试'); | 352 | $this->output('文件生成失败,请重试'); |
| @@ -416,6 +359,65 @@ class Temp extends Command | @@ -416,6 +359,65 @@ class Temp extends Command | ||
| 416 | } | 359 | } |
| 417 | 360 | ||
| 418 | /** | 361 | /** |
| 362 | + * 创建指定服务器所有项目主站生成任务 | ||
| 363 | + * @author Akun | ||
| 364 | + * @date 2024/12/19 17:54 | ||
| 365 | + */ | ||
| 366 | + public function create_server_update_page() | ||
| 367 | + { | ||
| 368 | + $server_id = 15; | ||
| 369 | + | ||
| 370 | + $server_ip_model = new ServersIp(); | ||
| 371 | + | ||
| 372 | + $server_ip_ids = $server_ip_model->where('servers_id', $server_id)->get()->pluck('id')->toArray(); | ||
| 373 | + | ||
| 374 | + $project_list = Project::select(['id', 'serve_id'])->whereIn('serve_id', $server_ip_ids)->get(); | ||
| 375 | + | ||
| 376 | + $domain_model = new DomainInfo(); | ||
| 377 | + $notify_model = new Notify(); | ||
| 378 | + | ||
| 379 | + foreach ($project_list as $value) { | ||
| 380 | + $project_id = $value->id; | ||
| 381 | + | ||
| 382 | + $domain_info = $domain_model->read(['project_id' => $project_id, 'status' => 1], ['id', 'domain']); | ||
| 383 | + if (!$domain_info) { | ||
| 384 | + //过滤未绑定正式域名的项目 | ||
| 385 | + continue; | ||
| 386 | + } | ||
| 387 | + $domain = $domain_info['domain']; | ||
| 388 | + | ||
| 389 | + //获取项目所在服务器 | ||
| 390 | + $serve_ip_info = $server_ip_model->read(['id' => $value->serve_id], ['domain', 'ip']); | ||
| 391 | + if (!$serve_ip_info) { | ||
| 392 | + $this->output('项目id:' . $project_id . ' | 未查询到服务器数据'); | ||
| 393 | + continue; | ||
| 394 | + } | ||
| 395 | + | ||
| 396 | + if (!check_domain_record($domain, $serve_ip_info)) { | ||
| 397 | + $this->output('项目id:' . $project_id . ', domain:' . $domain . ' | 未解析到目标服务器'); | ||
| 398 | + continue; | ||
| 399 | + } | ||
| 400 | + | ||
| 401 | + $data = [ | ||
| 402 | + 'project_id' => $project_id, | ||
| 403 | + 'type' => 1, | ||
| 404 | + 'route' => 1, | ||
| 405 | + 'server_id' => $server_id, | ||
| 406 | + 'status' => ['!=', Notify::STATUS_FINISH_SITEMAP] | ||
| 407 | + ]; | ||
| 408 | + $notify = $notify_model->read($data, ['id']); | ||
| 409 | + | ||
| 410 | + if (!$notify) { | ||
| 411 | + $data['data'] = Arr::a2s(['domain' => $domain, 'url' => null, 'language' => []]); | ||
| 412 | + $data['status'] = Notify::STATUS_INIT; | ||
| 413 | + $notify_model->add($data); | ||
| 414 | + | ||
| 415 | + $this->output('项目id:' . $project_id . ' | success'); | ||
| 416 | + } | ||
| 417 | + } | ||
| 418 | + } | ||
| 419 | + | ||
| 420 | + /** | ||
| 419 | * 创建所有amp站页面生成任务 | 421 | * 创建所有amp站页面生成任务 |
| 420 | * @author Akun | 422 | * @author Akun |
| 421 | * @date 2024/09/26 10:48 | 423 | * @date 2024/09/26 10:48 |
| @@ -435,10 +437,10 @@ class Temp extends Command | @@ -435,10 +437,10 @@ class Temp extends Command | ||
| 435 | $domain_array = parse_url($domain); | 437 | $domain_array = parse_url($domain); |
| 436 | $host = $domain_array['host'] ?? $domain_array['path']; | 438 | $host = $domain_array['host'] ?? $domain_array['path']; |
| 437 | $host_array = explode('.', $host); | 439 | $host_array = explode('.', $host); |
| 438 | - if (count($host_array) <= 2) { | ||
| 439 | - array_unshift($host_array, 'm'); | ||
| 440 | - } else { | 440 | + if ($host_array[0] == 'www') { |
| 441 | $host_array[0] = 'm'; | 441 | $host_array[0] = 'm'; |
| 442 | + } else { | ||
| 443 | + array_unshift($host_array, 'm'); | ||
| 442 | } | 444 | } |
| 443 | $amp_domain = implode('.', $host_array); | 445 | $amp_domain = implode('.', $host_array); |
| 444 | 446 |
| @@ -93,7 +93,7 @@ class OptimizationReportController extends BaseController | @@ -93,7 +93,7 @@ class OptimizationReportController extends BaseController | ||
| 93 | 'data' => array_values($indexed_pages['data'] ?? []), | 93 | 'data' => array_values($indexed_pages['data'] ?? []), |
| 94 | ]; | 94 | ]; |
| 95 | //月统计报告 | 95 | //月统计报告 |
| 96 | - $data['month_count'] = $this->currentMonthCount($domain_info['domain'],$this->param['project_id']); | 96 | + $data['month_count'] = $this->currentMonthCount($this->param['project_id']); |
| 97 | //测速 | 97 | //测速 |
| 98 | $speed = Speed::where('project_id', $this->param['project_id'])->first(); | 98 | $speed = Speed::where('project_id', $this->param['project_id'])->first(); |
| 99 | $data['speed'] = $speed['data'] ?? []; | 99 | $data['speed'] = $speed['data'] ?? []; |
| @@ -110,107 +110,30 @@ class OptimizationReportController extends BaseController | @@ -110,107 +110,30 @@ class OptimizationReportController extends BaseController | ||
| 110 | * @method :post | 110 | * @method :post |
| 111 | * @time :2023/7/3 9:55 | 111 | * @time :2023/7/3 9:55 |
| 112 | */ | 112 | */ |
| 113 | - public function currentMonthCount($domain,$project_id){ | ||
| 114 | - // 获取当前月的开始时间 | ||
| 115 | - $startTime = date('Y-m-01', strtotime($this->param['date'])); | ||
| 116 | - // 获取当前月的结束时间 | ||
| 117 | - $endTime = date('Y-m-t', strtotime($this->param['date'])); | 113 | + public function currentMonthCount($project_id){ |
| 118 | $arr = []; | 114 | $arr = []; |
| 119 | - $arr = $this->inquiryCount($arr,$startTime,$endTime,$domain,$project_id); | ||
| 120 | - $arr = $this->flowCount($arr,$startTime,$endTime,$project_id); | ||
| 121 | - $arr = $this->sourceCount($arr,$startTime,$endTime,$domain); | ||
| 122 | - $arr['month'] = date('Y-m',time()); | ||
| 123 | - return $arr; | ||
| 124 | - } | ||
| 125 | - | ||
| 126 | - /** | ||
| 127 | - * @param $domain | ||
| 128 | - * @param $project_id | ||
| 129 | - * @remark :询盘按月统计 | ||
| 130 | - * @name :inquiryCount | ||
| 131 | - * @author :lyh | ||
| 132 | - * @method :post | ||
| 133 | - * @time :2023/6/30 14:29 | ||
| 134 | - */ | ||
| 135 | - public function inquiryCount(&$arr, &$startTime, $project_id){ | ||
| 136 | - $month = date('Y-m',strtotime($startTime)); | 115 | + $date = date('Y-m', strtotime($this->param['date'])); |
| 137 | $monthCountModel = new MonthCount(); | 116 | $monthCountModel = new MonthCount(); |
| 138 | - $info = $monthCountModel->read(['project_id'=>$project_id,'month'=>$month]); | ||
| 139 | - if($info !== false){ | ||
| 140 | - $arr['country'] = $info['country']; | ||
| 141 | - $arr['total'] = $info['total']; | ||
| 142 | - $arr['month_total'] = $info['month_total']; | ||
| 143 | - } | ||
| 144 | - return $arr; | ||
| 145 | - } | ||
| 146 | - | ||
| 147 | - /** | ||
| 148 | - * @remark :流量统计 | ||
| 149 | - * @name :flowCount | ||
| 150 | - * @author :lyh | ||
| 151 | - * @method :post | ||
| 152 | - * @time :2023/6/30 14:31 | ||
| 153 | - */ | ||
| 154 | - public function flowCount(&$arr,&$startTime,&$endTime,$project_id){ | ||
| 155 | - $pv_ip = DB::table('gl_count') | ||
| 156 | - ->where(['project_id'=>$project_id]) | ||
| 157 | - ->whereBetween('date', [$startTime,$endTime]) | ||
| 158 | - ->select(DB::raw('SUM(pv_num) as pv_num'), DB::raw('SUM(ip_num) as ip_num')) | ||
| 159 | - ->orderBy('id','desc') | ||
| 160 | - ->first(); | ||
| 161 | - $arr['pv'] = $pv_ip->pv_num; | ||
| 162 | - $arr['ip'] = $pv_ip->ip_num; | ||
| 163 | - $arr['rate'] = 0; | ||
| 164 | - if($arr['ip'] != 0){ | ||
| 165 | - $arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 100,2); | 117 | + $month_info = $monthCountModel->read(['project_id'=>$project_id,'month'=>$date]); |
| 118 | + if($month_info !== false){ | ||
| 119 | + $arr['country'] = $month_info['country']; | ||
| 120 | + $arr['total'] = $month_info['total']; | ||
| 121 | + $arr['month_total'] = $month_info['month_total']; | ||
| 122 | + $arr['pv'] = $month_info['pv']; | ||
| 123 | + $arr['ip'] = $month_info['ip']; | ||
| 124 | + $arr['rate'] = 0; | ||
| 125 | + if($arr['ip'] != 0){ | ||
| 126 | + $arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 100,2); | ||
| 127 | + } | ||
| 128 | + $arr['source'] = json_decode($month_info['source'],true); | ||
| 129 | + $arr['source_country'] = json_decode($month_info['source_country'],true); | ||
| 130 | + $arr['referrer_url'] = json_decode($month_info['referrer_url'],true); | ||
| 131 | + $arr['referrer_port'] = json_decode($month_info['referrer_port'],true); | ||
| 166 | } | 132 | } |
| 133 | + $arr['month'] = date('Y-m',time()); | ||
| 167 | return $arr; | 134 | return $arr; |
| 168 | } | 135 | } |
| 169 | 136 | ||
| 170 | - /** | ||
| 171 | - * @remark :来源访问前8 | ||
| 172 | - * @name :sourceCount | ||
| 173 | - * @author :lyh | ||
| 174 | - * @method :post | ||
| 175 | - * @time :2023/6/30 16:14 | ||
| 176 | - */ | ||
| 177 | - public function sourceCount(&$arr,$startTime,$endTime,$domain){ | ||
| 178 | - //访问来源前10 | ||
| 179 | - $source = DB::connection('custom_mysql')->table('gl_customer_visit') | ||
| 180 | - ->select('referrer_url', DB::raw('COUNT(*) as count')) | ||
| 181 | - ->groupBy('referrer_url') | ||
| 182 | - ->where('referrer_url','!=','') | ||
| 183 | - ->whereBetween('updated_date', [$startTime,$endTime]) | ||
| 184 | - ->orderByDesc('count')->limit(10)->get()->toArray(); | ||
| 185 | - $arr['source'] = $source; | ||
| 186 | - //访问国家前15 | ||
| 187 | - $query = DB::connection('custom_mysql')->table('gl_customer_visit') | ||
| 188 | - ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv')) | ||
| 189 | - ->groupBy('country'); | ||
| 190 | - | ||
| 191 | - $query->where('country','<>','中国'); | ||
| 192 | - | ||
| 193 | - $source_country = $query->whereBetween('updated_date', [$startTime,$endTime]) | ||
| 194 | - ->orderBy('ip','desc')->limit(15)->get()->toArray(); | ||
| 195 | - $arr['source_country'] = $source_country; | ||
| 196 | - //受访界面前15 | ||
| 197 | - $referrer_url = DB::connection('custom_mysql')->table('gl_customer_visit') | ||
| 198 | - ->select('url',DB::raw('COUNT(*) as num')) | ||
| 199 | - ->orderBy('num','desc') | ||
| 200 | - ->whereBetween('updated_date', [$startTime,$endTime]) | ||
| 201 | - ->groupBy('url') | ||
| 202 | - ->limit(15)->get()->toArray(); | ||
| 203 | - $arr['referrer_url'] = $referrer_url; | ||
| 204 | - //访问断后 | ||
| 205 | - $referrer_port = DB::connection('custom_mysql')->table('gl_customer_visit') | ||
| 206 | - ->select('device_port',DB::raw('COUNT(*) as num')) | ||
| 207 | - ->orderBy('num','desc') | ||
| 208 | - ->whereBetween('updated_date', [$startTime,$endTime]) | ||
| 209 | - ->groupBy('device_port') | ||
| 210 | - ->limit(15)->get()->toArray(); | ||
| 211 | - $arr['referrer_port'] = $referrer_port; | ||
| 212 | - return $arr; | ||
| 213 | - } | ||
| 214 | 137 | ||
| 215 | public function getApiList($projectInfo,$export = false) | 138 | public function getApiList($projectInfo,$export = false) |
| 216 | { | 139 | { |
| @@ -61,13 +61,18 @@ class CNoticeController extends BaseController | @@ -61,13 +61,18 @@ class CNoticeController extends BaseController | ||
| 61 | ],[ | 61 | ],[ |
| 62 | 'language.required' => 'language不能为空', | 62 | 'language.required' => 'language不能为空', |
| 63 | ]); | 63 | ]); |
| 64 | + $project_id_arr = explode(',',env('PROJECT_ID')) ?? []; | ||
| 65 | + if(in_array($this->user['project_id'],$project_id_arr)){ | ||
| 66 | + $this->response('success'); | ||
| 67 | + } | ||
| 64 | $lang_num = count($this->param['language']); | 68 | $lang_num = count($this->param['language']); |
| 65 | $keyword_num = (new Keyword())->counts(['route'=>['!=',null]]); | 69 | $keyword_num = (new Keyword())->counts(['route'=>['!=',null]]); |
| 66 | $data_num = $this->productNum() + $this->CustomNum() + $this->newsNum() + $this->blogNum(); | 70 | $data_num = $this->productNum() + $this->CustomNum() + $this->newsNum() + $this->blogNum(); |
| 67 | $number = $keyword_num * 18 + $lang_num * $data_num; | 71 | $number = $keyword_num * 18 + $lang_num * $data_num; |
| 68 | - if($number >= 45000){ | ||
| 69 | - $this->response('success',Code::SUCCESS,['msg'=>'翻译数量过多, 大概页面数量:'.$number.', 磁盘空间占用可能会超过40G,请谨慎使用!']); | 72 | + if($number >= 450000){ |
| 73 | + $this->response('success',Code::SUCCESS,['msg'=>'翻译数量过多, 大概页面数量:'.$number.', 磁盘空间占用可能会超过40G,请联系管理员操作!']); | ||
| 70 | } | 74 | } |
| 75 | + //? Copyright - 2010-2024 : All Rights Reserved.© Copyright - 2010-2024 : All Rights Reserved. | ||
| 71 | $this->response('success'); | 76 | $this->response('success'); |
| 72 | } | 77 | } |
| 73 | 78 |
| @@ -88,7 +88,6 @@ class MonthReportController extends BaseController | @@ -88,7 +88,6 @@ class MonthReportController extends BaseController | ||
| 88 | ])->count(); | 88 | ])->count(); |
| 89 | $info['service_duration'] = $this->user['service_duration'];//服务天数 | 89 | $info['service_duration'] = $this->user['service_duration'];//服务天数 |
| 90 | $info['ip_total'] = (new Visit())->count();//ip总数 | 90 | $info['ip_total'] = (new Visit())->count();//ip总数 |
| 91 | - | ||
| 92 | $info['remain_day'] = $this->user['remain_day'];//剩余服务天数 | 91 | $info['remain_day'] = $this->user['remain_day'];//剩余服务天数 |
| 93 | $info['speed'] = round((0.3 + mt_rand()/mt_getrandmax() * (1-0.3)),2); | 92 | $info['speed'] = round((0.3 + mt_rand()/mt_getrandmax() * (1-0.3)),2); |
| 94 | $info['month_total'] = (int)$info['month_total']; | 93 | $info['month_total'] = (int)$info['month_total']; |
| @@ -80,7 +80,7 @@ class BaseController extends Controller | @@ -80,7 +80,7 @@ class BaseController extends Controller | ||
| 80 | case "order": | 80 | case "order": |
| 81 | $this->order = $v; | 81 | $this->order = $v; |
| 82 | break; | 82 | break; |
| 83 | - case "order": | 83 | + case "order_type": |
| 84 | $this->order_type = $v; | 84 | $this->order_type = $v; |
| 85 | break; | 85 | break; |
| 86 | case 'page': | 86 | case 'page': |
| @@ -12,6 +12,7 @@ use App\Http\Logic\Bside\Product\ProductLogic; | @@ -12,6 +12,7 @@ use App\Http\Logic\Bside\Product\ProductLogic; | ||
| 12 | use App\Http\Requests\Bside\Product\ProductRequest; | 12 | use App\Http\Requests\Bside\Product\ProductRequest; |
| 13 | use App\Models\Product\Category; | 13 | use App\Models\Product\Category; |
| 14 | use App\Models\Product\CategoryRelated; | 14 | use App\Models\Product\CategoryRelated; |
| 15 | +use App\Models\Product\Detail; | ||
| 15 | use App\Models\Product\Extend; | 16 | use App\Models\Product\Extend; |
| 16 | use App\Models\Product\ExtendInfo; | 17 | use App\Models\Product\ExtendInfo; |
| 17 | use App\Models\Product\Keyword; | 18 | use App\Models\Product\Keyword; |
| @@ -68,13 +69,12 @@ class ProductController extends BaseController | @@ -68,13 +69,12 @@ class ProductController extends BaseController | ||
| 68 | $v = $this->getHandleFileImage($v); | 69 | $v = $this->getHandleFileImage($v); |
| 69 | $lists['list'][$k] = $v; | 70 | $lists['list'][$k] = $v; |
| 70 | } | 71 | } |
| 72 | + $lists['order_type'] = $this->order_type; | ||
| 73 | + $lists['order'] = $this->order; | ||
| 71 | } | 74 | } |
| 72 | $this->response('success',Code::SUCCESS,$lists); | 75 | $this->response('success',Code::SUCCESS,$lists); |
| 73 | } | 76 | } |
| 74 | 77 | ||
| 75 | - public function setOrderBy(){ | ||
| 76 | - | ||
| 77 | - } | ||
| 78 | /** | 78 | /** |
| 79 | * @remark :列表 | 79 | * @remark :列表 |
| 80 | * @name :index | 80 | * @name :index |
| @@ -679,7 +679,11 @@ class ProductController extends BaseController | @@ -679,7 +679,11 @@ class ProductController extends BaseController | ||
| 679 | $new_content = htmlentities($contents); | 679 | $new_content = htmlentities($contents); |
| 680 | } | 680 | } |
| 681 | if (!empty($new_content)){ | 681 | if (!empty($new_content)){ |
| 682 | - $productInfo['content'] = $new_content . $productInfo['content']; | 682 | + $detailModel = new Detail(); |
| 683 | + $detailInfo = $detailModel->read(['column_id'=>1]); | ||
| 684 | + if($detailInfo !== false && !empty($detailInfo['content'])){ | ||
| 685 | + $productInfo['content'] = $new_content . $detailInfo['content']['content']; | ||
| 686 | + } | ||
| 683 | } | 687 | } |
| 684 | $this->response('success',Code::SUCCESS,$productInfo); | 688 | $this->response('success',Code::SUCCESS,$productInfo); |
| 685 | } | 689 | } |
| @@ -263,6 +263,7 @@ class UserLoginLogic | @@ -263,6 +263,7 @@ class UserLoginLogic | ||
| 263 | $info['upload_config'] = $project['upload_config']; | 263 | $info['upload_config'] = $project['upload_config']; |
| 264 | $info['main_lang_id'] = $project['main_lang_id']; | 264 | $info['main_lang_id'] = $project['main_lang_id']; |
| 265 | $info['image_max'] = $project['image_max']; | 265 | $info['image_max'] = $project['image_max']; |
| 266 | + $info['is_del_inquiry'] = $project['is_del_inquiry'] ?? 0; | ||
| 266 | $info['uptime_type'] = $this->getHistory($project); | 267 | $info['uptime_type'] = $this->getHistory($project); |
| 267 | $info['uptime'] = $project['uptime']; | 268 | $info['uptime'] = $project['uptime']; |
| 268 | $info['is_update_language'] = $project['is_update_language']; | 269 | $info['is_update_language'] = $project['is_update_language']; |
| @@ -31,7 +31,7 @@ class TextMail extends Mailable | @@ -31,7 +31,7 @@ class TextMail extends Mailable | ||
| 31 | */ | 31 | */ |
| 32 | public function build() | 32 | public function build() |
| 33 | { | 33 | { |
| 34 | - return $this->subject($this->subject)->view('mail.text', ['text' => $this->text]); | 34 | + return $this->subject($this->subject)->text('mail.text', ['text' => $this->text])->view('mail.html', ['text' => $this->text]); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | } | 37 | } |
-
请 注册 或 登录 后发表评论